	// global main wrapper variable
	var gWRAPPER="wrapper";
	var confirm_last_result=false;
	var dlg=null;
	var lang_path='';
	var my_after_hide=function() {};
	var BOXY_CLOSE = '<input onclick="dlg.hide();" value="סגירה" style="font-size: 11px; padding: 0; width: auto; text-align: center; font-family: Arial; margin-left: auto; margin-right: auto; font-weight: 400; color: #000000;" type="button" /><br />';

	function showDialog(txt, myTitle)
		{
		document.getElementById('nowhere').focus();
		dlg = new Boxy('<div id="boxy_content">'+txt+'</div>'+BOXY_CLOSE, { afterHide:my_after_hide,modal:true,center:true,draggable:false,title:myTitle,closeText:'X'});
		dlg.show();
		}

	function showConfirmDialog(txt, myTitle)
		{
		document.getElementById('nowhere').focus();
		var dlg = Boxy.confirm('<div id="boxy_content">'+txt+'</div>'+BOXY_CLOSE, function() { confirm_last_result=true; }, { modal:true,center:true,draggable:false,title:myTitle,closeText:'X'});
		}

	function centering(div)
		{
		var winH = $(window).height();
		var winW = $(window).width();
		var centerDiv = $('#' + div);
		var val = parseInt(winH/2-centerDiv.height()/2);

		if (val<0) { val=0; }

		centerDiv.css('position', 'absolute');
		centerDiv.css('top', val+'px');
		centerDiv.css('left', winW/2-centerDiv.width()/2);
		}

	function recenter()
		{
		centering(gWRAPPER);
		}

	function focus_login()
		{
		$('#login_container').effect("bounce", {direction:'down'}, 300, function() { $('#__email').focus(); } );
		}

	function is_valid_email(txt)
		{
		var regexptrn = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;

		if (regexptrn.test(txt) == false)
			{
			return false;
			}
		else
			{
			return true;
			}
		}

	function submit_login(_caller)
		{
		var ret=true;

		$('#logon_form INPUT[class=required]').each(function() {
			this.value = $.trim(this.value);

			if (this.value.length<3)
				{
				$(this).animate( { backgroundColor: "#EEDDDD" }, 200);
				$(this).animate( { backgroundColor: "#ffffff" }, 200, function() { this.focus() });
				ret=false;
				return false;
				}
			else
				{
				if (this.id=='__email' && !is_valid_email(this.value))
					{
					$(this).animate( { backgroundColor: "#EEDDDD" }, 200);
					$(this).animate( { backgroundColor: "#ffffff" }, 200, function() { this.focus() });
					ret=false;
					return false;
					}
				}
			});

		if (_caller==1)
			{
			return ret;
			}
		else
			{
			if (ret) document.getElementById('logon_form').submit();
			}
		}

	function logout()
		{
		document.getElementById('innerframe').src='/index.rtx?logout';
		}

	function go_reg(_caller)
		{
		$('#rightside').load(LANG_PATH + 'reg_header.rtx', function() { $('#main').fadeOut(); } );
		$('#leftside').load(LANG_PATH + 'reg.rtx', function() { $('#main').fadeIn(); recenter(); $('#__email').focus() });
		}

	function go_forgot(_caller)
		{
		$('#rightside').html('<img alt="" src="images/forgot.png" id="welcome" /><br /><p>שכחת את הסיסמא? אל דאגה, באמצעות דף זה ניתן לקבוע מחדש את הסיסמא לחשבון בקלות ובמהירות.</p>');
		$('#leftside').load(LANG_PATH + 'forgot.rtx', function() { $('#main').fadeIn(); recenter(); });
		}

	function go_forgot_link(id, email, _code)
		{
		$('#rightside').html('<img alt="" src="images/forgot.png" id="welcome" /><br /><p>שכחת את הסיסמא? אל דאגה, באמצעות דף זה ניתן לקבוע מחדש את הסיסמא לחשבון בקלות ובמהירות.</p>');
		$('#leftside').load(LANG_PATH + 'forgot.rtx?', function() {
			$('#main').fadeIn();
			recenter();

			$('#forgot_form2').show();
			$('#step2_msg').html('<br />קוד איפוס אומת בהצלחה, יש להקיש סיסמא חדשה');

			$('#forgot_form3').show('slow', function() {
				document.getElementById('step3_id').value=id;

				document.getElementById('__email').value=email;
				document.getElementById('__email').disabled=1;

				document.getElementById('__reset_code').value=_code;
				document.getElementById('step3_reset_code').value=_code;

				document.getElementById('forgot_form1').disabled=1;
				document.getElementById('forgot_form2').disabled=1;

				document.getElementById('__password').focus();
				});
			});
		}

	function checkEmail(email)
		{
		if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email))
			{
			return true;
			}
		else
			{
			return false;
			}
		}

	function load_module(mod, _caller)
		{
		// set all DIVs back to regular class
		$('#menu_container DIV').each(function() { this.className='menu_item'; } );

		if (_caller)
			{
			// then chosen one to with '_chosen'
			_caller.className='menu_item_chosen';
			}

		// now load module
		$('#leftside').load(LANG_PATH + 'modules/'+mod+'.rtx', function() { recenter(); } );
		}

	function dispatchModule()
		{
		var h = location.href;

		if (h.indexOf('#')!=-1)
			{
			var anchor = location.href.split('#');

			if (anchor[1].length>2 && anchor[1]!='undefined')
				{
				load_module(anchor[1]);
				}
			else
				{
				$('#leftside').load(LANG_PATH + 'welcome.rtx', function() { recenter(); } );
				}
			}
		else
			{
			$('#leftside').load(LANG_PATH + 'welcome.rtx', function() { recenter(); });
			}
		}