if (typeof mayaFish.modules.siteCreator == "undefined")
	mayaFish.modules.siteCreator = {
		"closePopup": null,
		"submit": function (form) {
			try
			{
				if (window.top != window)
				{
					if (typeof window.top.mayaFish == 'undefined')
						window.top.mayaFish = { "modules": { } };
					window.top.mayaFish.modules.siteCreator =
						window.mayaFish.modules.siteCreator;
				}
				var n = navigator.userAgent.toLowerCase(),
					isChrome = (n.indexOf('webkit/') > -1) && (n.indexOf('chrome/') > -1);
				if (false && isChrome)
				{
					var sizes = mayaFish.windowSize(),
						win = window.open('', 'siteCreatorTarget',
							'location=no,menubar=no,resiable=no,status=no,toolbar=no,height=500,width=850' +
							',top=' + parseInt((sizes.height - 500) / 2, 10) +
							',left=' + parseInt((sizes.width - 850) / 2, 10));
					if (!!win.focus) win.focus();
					mayaFish.modules.siteCreator.closePopup = null;
				}
				else
				{
					if (!mayaFish.$id("siteCreatorTarget", true))
						mayaFish.modules.siteCreator.closePopup =
							mayaFish.ui.preview("<iframe style='width:850px;height:500px;border:0px none;box-shadow:4px 4px 16px #000000;" +
								"-moz-box-shadow:4px 4px 16px #000000;-webkit-box-shadow:4px 4px 16px #000000;'" +
								"id='siteCreatorTarget' name='siteCreatorTarget' frameborder='0' src=''></iframe>", true, '#000000');
				}
				form.setAttribute("target", form.target = "siteCreatorTarget");
			}
			catch (e)
			{
				mayaFish.debug(e);
				mayaFish.modules.siteCreator.closePopup = null;
				form.setAttribute("action", form.action = location.href);
				form.setAttribute("target", form.target = "_blank");
			}
			return true;
		},
        "domainChange": function (input, postfix, onEmpty) {
            var sample = input.parentNode;
			while (!!sample && !(/sample/.test(sample.className)))
				sample = sample.nextSibling;
			if (!!sample) {
                sample = sample.firstChild;
                while (!!sample && !(/label/.test(sample.className)))
                    sample = sample.nextSibling;
                if (!!sample)
                    sample.innerHTML = ( input.value ||
                        ( "<i>" + onEmpty + "</i>")) + postfix;
			}
            
            return true;
        },
		"check": function (input) {
			var errorInfo = input;
			while (!!errorInfo && !(/errorInfo/.test(errorInfo.className)))
				errorInfo = errorInfo.previousSibling;
			if (!!errorInfo) {
				errorInfo.title = mayaFish.translations('siteCreator', 'Checking');
				mayaFish.removeClass(errorInfo, 'invalid');
				mayaFish.removeClass(errorInfo, 'valid');
				mayaFish.addClass(errorInfo, 'checking');
			}
			mayaFish.jsonRpc.call({
				'method': 'siteCreatorModel::checkInitial',
				'params': {
					"name": "" + input.name,
					"value": "" + input.value
				},
				'onSuccess': function (result) {
					if (result.valid) {
						if (!!errorInfo) {
							errorInfo.title = '';
							mayaFish.removeClass(errorInfo, 'checking');
							mayaFish.addClass(errorInfo, 'valid');
							try {
								mayaFish.ui.toolTip(input, '');
							} catch (e) {
								mayaFish.debug(e);
							}
						}
					} else {
						if (!!errorInfo) {
							errorInfo.title = '';
							mayaFish.removeClass(errorInfo, 'checking');
							mayaFish.addClass(errorInfo, 'invalid');
							try {
								mayaFish.ui.toolTip(input, mayaFish.translations('siteCreator', 'Error ' + result.error), ['below']);
							} catch (e) {
								mayaFish.debug(e);
								errorInfo.title = mayaFish.translations('siteCreator', 'Error ' + result.error);
							}
						} else {
							mayaFish.ui.alert(mayaFish.translations('siteCreator', 'Error ' + result.error),
								mayaFish.translations('common', 'Error'), null, null, mayaFish.ui.icons.ERROR);
						}
					}
				}
			});
			return false;
		}
	};

