<!--
// Constants

//alert("in the /script/");

var pEmail='Please enter your Email Address here.  It will become your logon id.';
var pUsername='Please enter your Username. (must be 1 or more characters)\n';
var pPassword='Please enter your Password. (must be 4 or more characters)\n';
var pReset='Please Press Reset to clear the screen.\n';
var pLogin='Press Login when you have entered your Email and Password form.';

// Error Messages
var errUsername='Please enter your Username.\n';
var errPassword='Please enter your password.\n';
var errEmail='Please enter your Email address in the format: EmailId@Isp.Domain.\n';

// whitespace characters
var cWhitespace = " \t\n\r";

// constants
var sNewClient = "NewClient";
var sLogin = "Login";


function InitForm() {

	var obj = document.forms["frmLogin"];
	
	//alert(sEmail);
	//alert(obj.action);
	
	obj.inpLoginEmail.value = sEmail;
	obj.inpLoginEmail.focus();
	
	//document.forms.frmLogin.inpEmail.focus();
}

function EditAndSubmitForm(obj, btnPressed){

	var bPassedEdits='true';
	var sErrMsg='';

	if (!isEmail(obj.inpLoginEmail.value)){
		sErrMsg += errEmail;
		bPassedEdits=false;
		objFocusObject = obj.inpLoginEmail;
	}

	if (!isPassword(obj.inpLoginPassword.value)){
		sErrMsg += errPassword;
		if (bPassedEdits){
			bPassedEdits=false;
			objFocusObject = obj.inpLoginPassword;
		}
	}

	if (bPassedEdits) {
		if (btnPressed == sNewClient){
			document.forms["frmLogin"].action = "Register.asp";
		}
		else{
			document.forms["frmLogin"].inpAction.value = "FindParty";
		}

		document.forms["frmLogin"].submit();

	}
	else {
		alert (sErrMsg);
		objFocusObject.focus();
	}
}


// Returns true if string sStr is empty or 
// whitespace characters only.

function isWhitespace (sStr){

	var i;
	var cChar;

    if (isEmpty(sStr)) return true;

    // Search through string's characters one by one
    // until we find a non-whitespace character.
    // When we do, return false; if we don't, return true.

    for (i = 0; i < sStr.length; i++)
    {   
        // Check that current character isn't whitespace.
        cChar = sStr.charAt(i);

        if (cWhitespace.indexOf(cChar) == -1) return false;
    }

    // All characters are whitespace.
    return true;
}

// Check whether string sStr is empty.

function isEmpty(sStr){
	return ((sStr == null) || (sStr.length == 0))
}

// Display prompt string sPrompt in status bar.
function Prompt (sPrompt){
   window.status = sPrompt;
}
// Password must be at least 5 characters long.

function isLoginId (sStr) {
   
    if (isWhitespace(sStr)) return false;
    
	if (sStr.length<1) return false;

	return true;
}

// Password must be at least 5 characters long.


function isEmail (sStr) {
   
    // is sStr whitespace?
    if (isWhitespace(sStr)) return false;
    
    // there must be >= 1 character before @, so look at character position 1 (i.e. second character)
    var i = 1;
    var iLength = sStr.length;

    // look for @
    while ((i < iLength) && (sStr.charAt(i) != "@")){
		i++;
    }

    if ((i >= iLength) || (sStr.charAt(i) != "@")) return false;
    else i += 2;

    // look for .
    while ((i < iLength) && (sStr.charAt(i) != ".")){
		i++
    }

    // there must be at least one character after the .
    if ((i >= iLength - 1) || (sStr.charAt(i) != "."))
		return false;
    else
		return true;
}

function isPassword (sStr) {
   
    if (isWhitespace(sStr)) return false;
    
	if (sStr.length<3) return false;

	return true;
}

// Returns true if string sStr is empty or 
// whitespace characters only.

function isWhitespace (sStr){

	var i;
	var cChar;

    if (isEmpty(sStr)) return true;

    // Search through string's characters one by one
    // until we find a non-whitespace character.
    // When we do, return false; if we don't, return true.

    for (i = 0; i < sStr.length; i++)
    {   
        // Check that current character isn't whitespace.
        cChar = sStr.charAt(i);

        if (cWhitespace.indexOf(cChar) == -1) return false;
    }

    // All characters are whitespace.
    return true;
}

// Check whether string sStr is empty.

function isEmpty(sStr){
	return ((sStr == null) || (sStr.length == 0))
}

// Display prompt string sPrompt in status bar.
function Prompt (sPrompt){
   window.status = sPrompt;
}

//-->


