/*
	File:		LoginBox_v6.js
	Purpose:	Submits Login from Inline login box
	Author:		Ajai
	Created:	06 Jan 2005
	Modified:	Ajai			06 Jan 2005	Added new function capsDetect to display Caps Warning.
				Alex Moses		22 Mar 2006	v6: Added submitRegistrationNoCC()
				
*/

	function SubmitForm(pstrOriginalURL)
	{
	
		// Variables
		var strProtocol
		
		strProtocol = 'https://';
		//strProtocol = 'http://';
	
		//validate inputs
		if(document.frmLogin.inpUsername.value.length < 1)
		{
			alert("Please enter your username.");
		}
		else if(document.frmLogin.inpPassword.value.length < 1)
		{
			alert("Please enter your password.");
		}		
		else
		{	
			document.frmLogin.action = strProtocol + document.frmHost.inpHost.value + "/Security/Login/ServeLoginKS3ICT.asp";
			document.frmLogin.submit();
		}
	}
	
	function SubmitPassedForm(pstrFormName)
	{
	
		// Variables
		var strProtocol
		
		strProtocol = 'https://'
		//strProtocol = 'http://'
	
		//validate inputs
		if(document.forms[pstrFormName].inpUsername.value.length < 1)
		{
			alert("Please enter your username.");
		}
		else if(document.forms[pstrFormName].inpPassword.value.length < 1)
		{
			alert("Please enter your password.");
		}		
		else
		{	
			document.forms[pstrFormName].action = strProtocol + document.frmHost.inpHost.value + "/Security/Login/ServeLogin.asp";
			document.forms[pstrFormName].submit();
		}
	}
	
	function SubmitPassedFormByProtocol(pstrFormName, pbSSL)
	{
		
		// Variables
		var strProtocol	
		
		// Validate Inputs
		if(document.forms[pstrFormName].inpUsername.value.length < 1)
		{
			alert("Please enter your username.");
		}
		else if(document.forms[pstrFormName].inpPassword.value.length < 1)
		{
			alert("Please enter your password.");
		}		
		else
		{	
			if(pbSSL == 'True')
			{
				strProtocol = 'https://'
			}
			else
			{
				strProtocol = 'http://'
			}
			document.forms[pstrFormName].action = strProtocol + document.frmHost.inpHost.value + "/Security/Login/ServeLoginKS3ICT.asp";
			document.forms[pstrFormName].submit();	
		}
	}
	
	function submitRegistrationType(pstrFormName)
	{
		var strEMail = document.forms[pstrFormName].inpEmail.value;
		var strConfirmEMail=document.forms[pstrFormName].inpConfirmEmail.value;
		var bResult = true;
		var strMessage = '';
	
		if (strEMail.length == '0' || checkEmail(strEMail) == false )
			{
			strMessage = strMessage + 'You must enter a valid email address in the Email Address field\n';
			bResult = false;		
			}
		if (strConfirmEMail.length == '0' || checkEmail(strConfirmEMail) == false )
			{
			strMessage = strMessage +'You must enter a valid email address in the Confirm Email Address field\n';
			bResult = false;
			} 
		if (strConfirmEMail != strEMail)
			{
			strMessage = strMessage +'Email Address and Confirm Email Address fields should be the same\n';
			bResult = false;
			}
		if(!bResult)
			{
			alert('The following errors have been found. Please correct and continue.\n\n' + strMessage );		
			}	 		
		else
			{
			document.forms[pstrFormName].action = '/ContactUs/RegistrationType.asp';
			document.forms[pstrFormName].submit();
			}
	}	

	
	function submitRegistrationNoCC(pstrFormName, pstrAction)
	{
		// register when CC Payment switched off
		document.forms[pstrFormName].inpAction.value = pstrAction;
		document.forms[pstrFormName].action = '../ContactUs/Register.asp';
		document.forms[pstrFormName].submit();
	}	

	
	var mbCapsWarning=false;
	var mbIE3 = ( navigator.appName != "Netscape" && navigator.appVersion.substring(0,3) < 4 );
	var mbIE55 = (navigator.appVersion.indexOf("MSIE 5.5") > 0);

	function capsDetect(poInput, e, poObject ) 
	{	
		if(!mbIE3) {		
			if( !e ) { e = window.event; } 
			//what (case sensitive in good browsers) key was pressed
			var theKey = e.which ? e.which : ( e.keyCode ? e.keyCode : ( e.charCode ? e.charCode : 0 ) );
			//was the shift key was pressed
			var theShift = e.shiftKey || ( e.modifiers && ( e.modifiers & 4 ) ); //bitWise AND
			//if upper case, check if shift is not pressed. if lower case, check if shift is pressed
			
			if(!mbCapsWarning && ((theKey > 64 && theKey < 91 && !theShift ) || ( theKey > 96 && theKey < 123 && theShift ))) {		
				poObject.style.display='inline';
				mbCapsWarning=true;			
			}
			else {
				poObject.style.display='none';
				mbCapsWarning=false;
			}		
		}
		mbCapsWarning=false;
	}