var regEmail = /^([a-zA-Z0-9])+([\.a-zA-Z0-9_-])*@([a-zA-Z0-9])+(\.[a-zA-Z0-9_-]+)+$/

function getState(value)
{
	if (value=="United States"){
		document.getElementById("USState").disabled="";
	}else{
		document.getElementById("USState").disabled="disabled";
		document.getElementById("USState").selectedIndex=0;
	}
}

function validateProjectBrief1(){
	var compName = escape(document.getElementById("CompName").value)
	var contactPerson = escape(document.getElementById("Name").value)
	var website = escape(document.getElementById("Website").value)
	var email = escape(document.getElementById("Email").value)
	var timezone = escape(document.getElementById("TimeZone").value)
	var username = escape(document.getElementById("Username").value)
	var pwd = escape(document.getElementById("Password").value)
	var pwd2 = escape(document.getElementById("Password2").value)
	
	if (compName == "") {
		alert("Please enter your company name.");
		return false;
	}
	
	else if (contactPerson == ""){
		alert("Please enter a contact person.");
		return false;
	}
	
	else if (email == ""){
		alert("Please enter your email address.");
		return false;
	}
	
	else if (website == ""){
		alert("Please enter your website.");
		return false;
	}
	
	else if (timezone == "none"){
		alert("Please select your timezone.");
		return false;
	}

	else if (username == ""){
		alert("Please enter a username.");
		return false;
	}
	
	else if (pwd == ""){
		alert("Please enter a password.");
		return false;
	}
	
	else if (pwd2 == ""){
		alert("Please re-enter your password.");
		return false;
	}
	
	else if (pwd != pwd2){
		alert("Passwords do not match.");
		return false;
	}
 
	else if (email.search(regEmail)==-1){
		alert("Please enter a valid email address.");
		return false;
	}
	
	return true;
}
 
function displayOther(val, element){
	if (val == "Other"){
		if (element=="JobProfileName"){
			document.getElementById("box_OtherJobProfile").style.display="";
			document.getElementById("OtherJobProfile").focus();
		}
		else if (element=="WorkingHours"){
			document.getElementById("box_OtherWorkingHours").style.display="";
			document.getElementById("OtherWorkingHours").focus();
		}
	}else{
		if (element=="JobProfileName"){
			document.getElementById("box_OtherJobProfile").style.display="none";
		}
		else if (element=="WorkingHours"){
			document.getElementById("box_OtherWorkingHours").style.display="none";
		}
	}
}

function populateOther(val, dbVal, element){
	if (element=="JobProfileName"){
		for (var i=0;i<document.getElementById("JobProfileName").options.length;i++){
			//alert(document.getElementById("JobProfileName").options[i].value + "===" + dbVal)
			if (document.getElementById("JobProfileName").options[i].value==dbVal){
				document.getElementById("JobProfileName").selectedIndex = i;
				document.getElementById("box_OtherJobProfile").style.display="none";
				document.getElementById("OtherJobProfile").value=""; 
				break;
			}else{
				document.getElementById("JobProfileName").selectedIndex = 15;
				document.getElementById("box_OtherJobProfile").style.display="";
				document.getElementById("OtherJobProfile").value=dbVal; 
			}
		}
	}
	else if (element=="WorkingHours"){
		for (var i=0;i<document.getElementById("WorkingHours").options.length;i++){
			if (document.getElementById("WorkingHours").options[i].value==dbVal){
				document.getElementById("WorkingHours").selectedIndex = i;
				document.getElementById("OtherWorkingHours").value=""; 
				document.getElementById("box_OtherWorkingHours").style.display="none";
				break;
			}else{
				document.getElementById("WorkingHours").selectedIndex = 2;
				document.getElementById("box_OtherWorkingHours").style.display="";
				document.getElementById("OtherWorkingHours").value=dbVal; 
			}
		}
	}	
}

function CheckFormCallBack(){
	var conName = escape(document.getElementById("ConName").value)
	var conEmail = escape(document.getElementById("ConEmail").value)
	var ConCompany = escape(document.getElementById("ConCompany").value)
	var timezone = escape(document.getElementById("TimeZone").value)
	
	if (conName == "") {
		alert("Please enter your name.");
		document.getElementById("ConName").focus();
		return false;
	}
	
	else if (conEmail == ""){
		alert("Please enter your email address.");
		document.getElementById("ConEmail").focus();
		return false;
	}
	
	else if (conEmail.search(regEmail)==-1){
		alert("Please enter a valid email address.");
		document.getElementById("ConEmail").focus();
		return false;
	}
	
	else if (ConCompany == ""){
		alert("Please enter your company name.");
		document.getElementById("ConCompany").focus();
		return false;
	}
	
	else if (timezone == "none"){
		alert("Please select your timezone.");
		document.getElementById("TimeZone").focus();
		return false;
	}
	
	return true;
}

function CheckFormEmail(){
	var conName = escape(document.getElementById("ConEmailName").value)
	var conEmail = escape(document.getElementById("ConEmailEmail").value)
	var conMessage = escape(document.getElementById("ConEmailMessage").value)
	
	if (conName == "") {
		alert("Please enter your name.");
		document.getElementById("ConEmailName").focus();
		return false;
	}
	
	else if (conEmail == ""){
		alert("Please enter your email address.");
		document.getElementById("ConEmailEmail").focus();
		return false;
	}
	
	else if (conEmail.search(regEmail)==-1){
		alert("Please enter a valid email address.");
		document.getElementById("ConEmailEmail").focus();
		return false;
	}
	
	
	else if (conMessage.length < 5){
		alert("Please enter your message.");
		document.getElementById("ConEmailMessage").focus();
		return false;
	}
	
	return true;
}

/********* EXPANDING FLASH *********/
