// <![CDATA[

/* Functions to perform login - Appear on the header. */

	function showLogin() {

		if ((getJScookie("userId") != '') && (getJScookie("userPassword") != '')) {
			displayError('You are already logged in. You must log out first.');	
		} else {
			$.blockUI( { message: $('#LoginMessage') , css: {height: '130px', width: '200px', border: '0px solid #a00', backgroundColor: '#000'  }} );
		}
	}

	function doLogin() {

		var sEmailId = "";
		var sPassword="";

		var st1 = "";
		var st2 = "";

		st1 = getJScookie("userId");
		st2 = getJScookie("userPassword");


		if ((st1 != '') && (st2 != '')) {
			displayError('You are already logged in. You must log out first.');	
		} else {

			// Get values		
			sEmailId = loginScreen.elements["emailtxt"].value;
			sPassword = loginScreen.elements["passwordtxt"].value;


			// If value is null
			if ((sEmailId=='') || (sPassword=='')){
				displayError('Email address and password must be entered.');
			} else {
				if (getJScookie("userId") == sEmailId)  {
					displayError('You are already logged in.');			
				} else {
					setJScookie ("userId", sEmailId);
					setJScookie ("userPassword", sPassword);

					parent.location.href='/includes/inc_login.asp';
				
				}
			}
		}
	}

	
	function doSendPassword() {
		document.frmforgotpass.action = '/includes/sendpassword.asp';
		document.frmforgotpass.submit();
	}


	function dogetPassword() {
		$.unblockUI();
		$.blockUI( { message: $('#ForgotPassword') , css: {height: '130px', width: '200px', border: '0px solid #a00', backgroundColor: '#000'  }} );
		
	}
	

	function donewuser() {
		parent.location.href='/includes/join.asp';
	}


	function returnHandler(e) {
		var characterCode 
		if (e && e.which) {
			e = e;
			characterCode = e.which;
		} else {
			e = event;
			characterCode = e.keyCode;
		}
		if (characterCode == 13) {
			if (document.getElementById('LoginMessage').style.display != 'block') {
				callSearchEngine();
			} else {
				doLogin();
			}

			return false;
		} else {
			return true;
		}
	}

	function callSearchEngine() {

		sSearchBox = frmSearchBox.elements["searchbox"].value;

		if (typeof(frmSearchBox.elements["chblocal"]) == "undefined") {
			sLocal = "false"			
		} else {

			sLocal = frmSearchBox.elements["chblocal"].value;
			if (sLocal == "on") {
				sLocal = "true"
			} else {
				sLocal = "false"			
			}
		}



		//alert('::' + sSearchBox + '::');
		if ('::' + sSearchBox + '::'=='::::') {
			displayMessage('Error','You must enter text in the search bar.');	
		} else {	
			sURL = '/includes/searchEngine.asp?local=' + sLocal + '&serQuery=' + sSearchBox + '&pagecnt=1'
			parent.location.href=sURL;
		}
	}

// ]]>