$(document).ready(function() { 
	if($.cookie("USER_STATUS") == 'A'){
		if($.cookie("AXAUserRole") == 'C'){
			$("div.loginBox").html('<h3 style="text-align: center;">Welcome ' + $.cookie('USER_DISPLAYNAME').replace("\+"," ") + '</h3><br><form style="text-align: center;" action="https://uls.axa-equitable.com/uls/jsp/logoff.jsp" method="post" id="logOutForm" name="logOutForm"><input type="submit" src="/images/btn_search.gif" value="Log out" class="btn submitBut" /></form>');
		} else {
			$("div.loginBox").html('<h3 style="text-align: center;">Welcome ' + $.cookie('USER_DISPLAYNAME').replace("\+"," ") + '</h3><form style="text-align: center;" action="https://uls.axa-equitable.com/uls/jsp/logoff.jsp" method="post" id="logOutForm" name="logOutForm"><input type="submit" src="/images/btn_search.gif" value="Log out" class="btn submitBut" /></form>');
		}
	}
});



function checkSearchInput(searchform) {

	var errorMsg = "";
	var result = true;
	var zipnumbers = "1234567890";
	var hyphencount=0;
	var zip_length ="";
	var zipstr = "";

	if(searchform.zip.value != null && searchform.zip.value != ""){

	   	zipstr = searchform.zip.value;	   	
		zip_length = zipstr.length;

		if ( (zip_length != 5) ) {
			errorMsg = "This is an invalid US zip code.";
			searchform.zip.value = "";
			searchform.zip.focus();
			result = false;
		}

		for (var str_pos=0;str_pos < zipstr.length; ++str_pos) {
			var c = zipstr.charAt(str_pos);
			// Not a number
			if (c == "-") { 
			   ++hyphencount; 
			   continue;
			} 
			if (zipnumbers.indexOf(c) == -1) {
				errorMsg = "Zip Code should only contain numbers.";
				searchform.zip.value = "";
				searchform.zip.focus();
				result = false;
			}
		}
	} else if ((searchform.city.value !=null  && searchform.city.value != "") || 
	           (searchform.state.value !=null  && searchform.state.value != "")) {		

		if(searchform.city.value == null  || searchform.city.value == ""){
			errorMsg = "City is a required field.";
			result = false;
		}
		
		if(searchform.state.value == null  || searchform.state.value == ""){
					errorMsg = "State is a required field.";
					result = false;
		}
	
	} else if ((searchform.firstName.value == null  || searchform.firstName.value == "") &&
	           (searchform.lastName.value == null  || searchform.lastName.value == "")) {

		errorMsg = "Enter city and state OR" +"\n" +"Enter zip code OR" +"\n" + "Enter firstname or lastname.";
		result = false;
	} else {
	
	}
	

	if(result == false){
		alert(errorMsg);
		return false;
	} else{
		return true;
	}

}


