
	function gup( name )
		{
		  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
		  var regexS = "[\\?&]"+name+"=([^&#]*)";
		  var regex = new RegExp( regexS );
		  var results = regex.exec( window.location.href );
		  if( results == null )
		    return "";
		  else
		    return results[1];
		}


	function ValidateInput( szDomain )
	{
		
		with( document.Login )
		{
			
			if( isWhitespace( username.value ) )
			{
				alert( "Your id cannot be blank. Please enter your id" );
				j_username.focus();
				return false;
			}
			
			else if ( !isEmailEx( username.value+"@"+domainname.value ))
			{
				alert( "Your id can contain only the following characters : \na-z, A-Z, 0-9,!,#,$,%,^,&,*,-,(,),_ and |" );
				j_username.focus();
				return false;
			}

			if( isWhitespace( j_password.value ) )
			{
				alert( "Your password cannot be blank. Please enter your password" );
				j_password.focus();
				return false;
			}
			else if( j_password.value.indexOf( " " ) != -1 )
			{
				alert( "Your password cannot contain spaces in it.Please re-enter your password" );
				j_password.focus();
				return false;
			}
			
		}

		return true;
	}
	
	
	function ErrorMessage(szCode)
	{
		var errorString = "";
		if(lcode.style.display == "none" && szCode != "")
		lcode.style.display = "";
		 
		if(szCode == "791117731136")
		{
			document.getElementById("lcode").innerHTML = "We are unable to access your account. You have either logged out of your account or your session has timed out. Please login again to access your account.";		
		}
		else if(szCode == "1")
		{
			document.getElementById("lcode").innerHTML = "The username or password you entered is incorrect.";
			
		}
		else if(szCode == "2")
		{
			document.getElementById("lcode").innerHTML = "You have logged out successfully.";
			
		}
		
		else if(szCode == "4")
		{
			document.getElementById("lcode").innerHTML = "Sorry. User id and password could not be verified. Please re-enter your user id and password.";
		}
		else if(szCode == "35")
		{
			document.getElementById("lcode").innerHTML = "The password was successfully changed on the site servers.The changes could take about 30 minutes to reflect on all the servers.";
		}
		else if(szCode == "52")
		{
			document.getElementById("lcode").innerHTML = "This domain does not exist.";
		}
		else if(szCode == "27")
		{
			document.getElementById("lcode").innerHTML = "Your account has been disabled. Please contact your domain administrator for more information.";
		}
		else if(szCode == "12")
		{
			document.getElementById("lcode").innerHTML = "An error has occurred in your mail box. You will have to login again to reuse your mailbox. Please logout from your account and then login again.";
		}
		else
		{
			lcode.style.display = "none";
		}		
	}
	
	function callbackFunction(loader)
	{
		var ret = true;
		//if xml object returned from MCSIFUGetWebMailLocation webservice is null then give error on Login page.
		if( loader.xmlDoc.responseXML != null )
		{
			OutputString=loader.doSerialization();
		}
		else
		{
			error = "Exception occured while getting webmailocation for user.";
			ret = false;
			return ret;
		}
		
		if (window.DOMParser)
		{
			parser=new DOMParser();
			xmlDoc=parser.parseFromString(OutputString,"text/xml");
		}
		else // Internet Explorer
		{
			xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
			xmlDoc.async="false";
			xmlDoc.loadXML(OutputString);
		}
		
		var server = "";
		if( xmlDoc.getElementsByTagName("server")[0] != null &&  xmlDoc.getElementsByTagName("server")[0].childNodes[0] != null )
		{
			server=xmlDoc.getElementsByTagName("server")[0].childNodes[0].nodeValue;
		}
		
		var webmailhost = "";
		if( xmlDoc.getElementsByTagName("webmailhost")[0] != null && xmlDoc.getElementsByTagName("webmailhost")[0].childNodes[0] != null )
		{
			webmailhost=xmlDoc.getElementsByTagName("webmailhost")[0].childNodes[0].nodeValue;
		}
		
		var webmailprotocol = "http";
		if( xmlDoc.getElementsByTagName("webmailprotocol")[0] != null && xmlDoc.getElementsByTagName("webmailprotocol")[0].childNodes[0] != null )
		{
			webmailprotocol=xmlDoc.getElementsByTagName("webmailprotocol")[0].childNodes[0].nodeValue;
		}
		
		var error = "";
		if( xmlDoc.getElementsByTagName("error")[0] != null && xmlDoc.getElementsByTagName("error")[0].childNodes[0] != null )
		{
			error=xmlDoc.getElementsByTagName("error")[0].childNodes[0].nodeValue;
		}
		
		//here getting domain value from domain (if domain name entered on login page)/ domainname (if domain name alredy set in login page) field.
		var domainvalue= "";
		if( document.Login.domainname.value == "" )
		{
			domainvalue= document.Login.domain.value;
		}
		else
		{
			domainvalue= document.Login.domainname.value;
		}
		
		if ( error != '' )
		{
			alert(error);
			ret = false;
			
		}else if( server == 'xd' )
		{
			document.Login.passwd.value=document.Login.j_password.value;
			document.Login.name.value=document.Login.username.value;
			
			document.Login.action = webmailprotocol+"://"+webmailhost+"/servlet/Login?domain="+domainvalue;
		}
		else
		{
			document.Login.j_username.value=document.Login.username.value+"@"+domainvalue;
			document.Login.action = "j_security_check"
		}
		return ret;
	}
	
	function validateXDXFUser()
	{
		//here getting domain value from domain (if domain name entered on login page)/ domainname (if domain name alredy set in login page) field.
		
		var domainvalue= "";
		if( document.Login.domainname.value == "" )
		{
			domainvalue= document.Login.domain.value;
		}
		else
		{
			domainvalue= document.Login.domainname.value;
		}
		
		var loader = dhtmlxAjax.postSync("/ueiws/servlet/MCSIFUGetUserWebmailLocation","userid="+document.Login.username.value+"@"+domainvalue);
		
		return callbackFunction(loader);
	}

