// JavaScript Document

<!--
	var textCache = "Email Address";

	function MM_swapImgRestore() 
	{ 
		// v3.0

  		var i, x, a = document.MM_sr; 

		for(i = 0; a && i < a.length && (x = a[i]) && x.oSrc; i++)
			x.src = x.oSrc;
	}

	function MM_preloadImages() 
	{
		// v3.0

		var d = document; 

		if(d.images)
		{ 
			if(!d.MM_p) 
				d.MM_p = new Array();

			var i, j = d.MM_p.length, a = MM_preloadImages.arguments; 

			for(i = 0; i < a.length; i++)
			{
				if (a[i].indexOf("#") != 0)
				{ 
					d.MM_p[j] = new Image; 
					d.MM_p[j++].src = a[i];
				}
			}
		}
	}

	function MM_findObj(n, d) 
	{ 
		// v4.01

		var p, i, x;  

		if(!d) 
			d = document; 

		if((p = n.indexOf("?")) > 0 && parent.frames.length) 
		{
			d = parent.frames[n.substring(p+1)].document; 
			n = n.substring(0, p);
		}

		if(!(x = d[n]) && d.all) 
			x = d.all[n]; 

		for(i = 0; !x && i < d.forms.length; i++) 
			x = d.forms[i][n];

  		for(i = 0; !x && d.layers && i < d.layers.length; i++) 
			x = MM_findObj(n, d.layers[i].document);

  		if(!x && d.getElementById) 
			x = d.getElementById(n); 

		return x;
	}

	function MM_swapImage() 
	{ 
		// v3.0

  		var i, j = 0, x, a = MM_swapImage.arguments; 
		document.MM_sr=new Array; 

		for(i = 0; i < (a.length - 2); i += 3)
		{
   			if ((x = MM_findObj(a[i])) != null)
			{
				document.MM_sr[j++] = x; 

				if(!x.oSrc) 
					x.oSrc = x.src; x.src = a[i + 2];
			}
		}
	}

	function clearTextbox()
	{
		document.getElementById("txtEmail").value = "";
	}

	function refreshTextbox()
	{
		document.getElementById("txtEmail").value = textCache;
	}

	function checkLength(evt)
	{
		var emailAddress = "" + document.getElementById("txtEmail").value;

		if(emailAddress.length > 50)
		{
			document.getElementById("txtEmail").value = emailAddress.substring(0, emailAddress.length - 5);
			return false;
		}

                var keyCode = null;

                if(evt.which)
                    keyCode = evt.which;
                else if(evt.keyCode)
                    keyCode = evt.keyCode;
                    
                if(keyCode == 13)
                {
                    registerEmail();
                    return false;
                }

		return true;
	}

	function registerEmail()
	{
		var errorCode = 0;
		var count = 0;

		var emailAddress = "" + document.getElementById("txtEmail").value;

		for(loop = 0; loop < emailAddress.length - 1; loop++)
			if(emailAddress.substring(loop, loop+1) == "@")
				count++;

		if(count == 0)
			errorCode = 1;

		count = 0;

		for(loop = 0; loop < emailAddress.length - 1; loop++)
			if(emailAddress.substring(loop, loop+1) == ".")
				count++;

		if(count == 0)
			errorCode = 1;

		showPopup();

		if(errorCode == 0)
			sendRequest();
		else
			document.getElementById("divPopup").innerHTML = "<table width=\"100%\" style=\"horizontal-align: center;\"><tr><td colspan=\"100%\">&nbsp;</td></tr><tr><td>&nbsp;</td><td align=\"center\"><table style=\"horizontal-align: center;\"><tr><td align=\"center\"><font size=\"4\" color=\"white\">Incorrect email address provided</font></td></tr><tr><td>&nbsp;</td></tr><tr><td align=\"center\"><a style=\"cursor: pointer;\" onclick=\"hidePopup()\"><font color=\"white\" size=\"3\">OK</font></a>&nbsp;&nbsp;</td></tr></table></td><td>&nbsp;</td></tr><tr><td colspan=\"100%\">&nbsp;</td></tr></table>";
	}

	function sendRequest()
	{
		document.getElementById("divPopup").innerHTML = "";

		var rspText = "";

		try
		{
			var objHTTP = new ActiveXObject("MSXML2.XMLHTTP");
			objHTTP.open("GET", "addEmail.asp?txtEmail=" + document.getElementById("txtEmail").value, false);
			objHTTP.send();

			rspText = objHTTP.responseText;
		}
		catch(exp)
		{
			rspText = "There may be a compatibility issue with your browser, sorry for the inconvenience. Please upgrade your browser.";
		}

		document.getElementById("divPopup").innerHTML = "<table width=\"100%\" style=\"horizontal-align: center;\"><tr><td colspan=\"100%\">&nbsp;</td></tr><tr><td>&nbsp;</td><td align=\"center\"><table style=\"horizontal-align: center;\"><tr><td align=\"center\"><font size=\"4\" color=\"white\">" + rspText + "</font></td></tr><tr><td>&nbsp;</td></tr><tr><td align=\"center\"><a style=\"cursor: pointer;\" onclick=\"hidePopup()\"><font color=\"white\" size=\"3\">OK</font></a>&nbsp;&nbsp;</td></tr></table></td><td>&nbsp;</td></tr><tr><td colspan=\"100%\">&nbsp;</td></tr></table>";
	}

	function showPopup()
	{
		$('#divPopup').fadeIn('fast');
		$('#divPopup').animate({"width" : "550px", "height" : "109px", "top": "50%", "left" : "23%"}, 250);
		document.getElementById("divPopup").innerHTML = "<table width=\"100%\" style=\"horizontal-align: center;\"><tr><td colspan=\"100%\">&nbsp;</td></tr><tr><td>&nbsp;</td><td align=\"center\"><table style=\"horizontal-align: center;\"><tr><td align=\"center\"><font size=\"4\" color=\"white\">Please wait..</font></td></tr><tr><td>&nbsp;</td></tr></table></td><td>&nbsp;</td></tr><tr><td colspan=\"100%\">&nbsp;</td></tr></table>";
	}

	function hidePopup()
	{
		document.getElementById("divPopup").innerHTML = "";
		$('#divPopup').animate({"width" : "0px", "height" : "0px", "top": "50%", "left" : "50%"}, 250);
		$('#divPopup').fadeOut('fast');
	}

	function showCategory(index)
	{
		if(index == 0)
		{
			document.getElementById("divOffline").style.display = "none";
			document.getElementById("divPrint").style.display = "none";
			$('#divOnline').fadeIn('slow');
		}
		else if(index == 1)
		{
			document.getElementById("divOnline").style.display = "none";
			document.getElementById("divPrint").style.display = "none";
			$('#divOffline').fadeIn('slow');
		}
		else if(index == 2)
		{
			document.getElementById("divOnline").style.display = "none";
			document.getElementById("divOffline").style.display = "none";
			$('#divPrint').fadeIn('slow');
		}
	}
//-->
