
function formValidationLogin(objForm) {
    with (objForm) {
        if ( !checkEmpty( Client_UserID, "Please enter a UserID" ) ) {UserID.focus(); return false;}
        if ( !checkEmpty( Client_Password, "Please enter a Password" ) ) {Password.focus(); return false;}
		if ( SelectedValue(loginAs) == "candidate" ) {
			var strURL;
			strURL = "https://www.careeringahead.com.au/survey/login/login.asp?UserID="+Client_UserID.value+"&Password="+Client_Password.value;
			window.open(strURL, 'Careeringahead', 'width=900, height=700, toolbar=no, location=no, status=no, menubar=no, scrollbars=yes, resizable=yes');
			return false;
		}
		return true;
    }
		
}

function SelectedValue(objToCheck)
{
    var selectedIndex = -1;
    var i = 0;
    
    for (i=0; i<objToCheck.length; i++)
    {
        if (objToCheck[i].checked)
        {
			return(objToCheck[i].value);
            break;
        }
    }
}



function formValidationSearch(objForm) {
	with (objForm) {
			if ( !checkEmpty( Search, "Please enter a Keyword to search." ) ) {Search.focus(); return false;}        
			
			setKeywords(Search);
	}			
}

function checkEmpty(objToCheck, strMessage) {
	with (objToCheck) {
			if ( value == null || value == "" ) {
					alert(strMessage); return false;
			} else {return true;}
	}
}

function setKeywords(obj)
	{
	   var tempstr = obj.value;
		 if ( tempstr.indexOf(" ") != -1 )
		 {
		 //alert("found space ");
				f1.key1.value = tempstr.substring(0,tempstr.indexOf(" "));
				tempstr = tempstr.substring(tempstr.indexOf(" ")+1);	
				//alert("f1.key1.value"+f1.key1.value);				
				if ( tempstr.indexOf(" ") != -1 )
		 		{
					f1.key2.value = tempstr.substring(0,tempstr.indexOf(" "));
					tempstr = tempstr.substring(tempstr.indexOf(" ")+1);
					//alert("f1.key2.value"+f1.key2.value);	
					if ( tempstr.indexOf(" ") != -1 )
					{
						f1.key3.value = tempstr.substring(0,tempstr.indexOf(" "));
						f1.key4.value = tempstr.substring(tempstr.indexOf(" ")+1);	
						//alert("f1.key3.value"+f1.key3.value);	
					}	else
					 {
					 f1.key3.value = tempstr;
					 }
				}else
			 {
			 f1.key2.value = tempstr;
			 }		 
		 }else
		 {
		 f1.key1.value = tempstr;
		 //alert(f1.key1.value);
		 }
		 return true;			
	}