function textValidate(incomingString, defaultValue)
{
  if(trimSpace(incomingString).length == 0 || incomingString.search(/[^a-zA-Z ]/g) != -1 || incomingString==defaultValue)
  {
    return false;
  }
  else
    return true;
}

function trimSpace(x)
{
  var emptySpace = / /g;
  var trimAfter = x.replace(emptySpace,"");
  return(trimAfter);
}

function alphanumeric(incomingString, defaultValue)
{
  if(trimSpace(incomingString).length == 0 || incomingString.search(/[^0-9a-zA-Z]/g) != -1 || incomingString==defaultValue)
  {
    return false;
  }
  else
    return true;
}
function numberValidate(incomingString, defaultValue)
{
  if(trimSpace(incomingString).length == 0 || incomingString.search(/[^0-9\.]/g) != -1 || incomingString==defaultValue || parseInt(incomingString, 10) <= 0 )
  {
    return false;
  }
  else
    return true;
}
function numberValidate2(incomingString)
{
  if(trimSpace(incomingString).length == 0 || incomingString.search(/[^0-9\.]/g) != -1 || parseInt(incomingString, 10) < 0 )
  {
    return false;
  }
  else
    return true;
}
function emailValidate(incomingString, defaultValue)
{
  if(trimSpace(incomingString).length == 0 || incomingString.search(/[\_\-\d]*[A-Za-z]+[\w\_\-]*[\@][\d]*[A-Za-z]+[\w\-]*[\.][A-Za-z]+/g) == -1 || incomingString==defaultValue)
  {
    return false;
  }
  else
    return true;
}
function zipenable() {
          if(!(document.Space_form.City.options[document.Space_form.City.selectedIndex].text=="USA") && (document.Space_form.City.options[document.Space_form.City.selectedIndex].text!="United Kingdom"))
          {
            document.Space_form.Zip_Code.disabled=true;
          }
          else
          {
            document.Space_form.Zip_Code.disabled=false;
          }
		  return true;
}

var flagCoun;
showCounCode.flagCoun = 1;
function showCounCode()
{
		 if(numberValidate(document.Space_form.Office_Country_Code.value, 'Country'))
		 {
//			 	alert("Presssss "+showCounCode.flagCoun);
			 	if(showCounCode.flagCoun == 1)
				{
				document.Space_form.Home_Country_Code.value=document.Space_form.Office_Country_Code.value;
				showCounCode.flagCoun++;
				}
		 }
}
showCounCode1.flagCoun = 1;
function showCounCode1()
{
		 if(numberValidate(document.Space_form.Office_Area_Code.value, 'Area Code'))
		 {
//			 	alert("Presssss "+showCounCode.flagCoun);
			 	if(showCounCode1.flagCoun == 1)
				{
				document.Space_form.Home_Area_Code.value=document.Space_form.Office_Area_Code.value;
				showCounCode1.flagCoun++;
				}
		 }
}
showCounCode2.flagCoun = 1;
function showCounCode2()
{
		 if(numberValidate(document.Space_form.Office_Phone.value, 'Area Code'))
		 {
//			 	alert("Presssss "+showCounCode.flagCoun);
			 	if(showCounCode2.flagCoun == 1)
				{
				document.Space_form.Home_Phone.value=document.Space_form.Office_Phone.value;
				showCounCode2.flagCoun++;
				}
		 }
}
function validateForm1()
{
  if(document.Space_form.Name.value=='Name' || document.Space_form.Name.value=="")
	{
		alert("Please Enter Your Name");
		document.Space_form.Name.focus();
		document.Space_form.Name.select();
		return false;
	}
if(document.Space_form.Email_Id.value=='E-Mail Address' || trimSpace(document.Space_form.Email_Id.value)=="")
	{
		alert("Please Enter Your Email Id");
		document.Space_form.Email_Id.focus();
		document.Space_form.Email_Id.select();
		return false;
	}
if(!emailValidate(document.Space_form.Email_Id.value,'E-Mail Address'))
	{
		alert("Please Enter the Correct Email Id");
		document.Space_form.Email_Id.focus();
		document.Space_form.Email_Id.select();
		return false;
	}
if(document.Space_form.Office_Phone.value=='Phone' || trimSpace(document.Space_form.Office_Phone.value)=="")
	{
		alert("Please Enter Your Phone Number");
		document.Space_form.Office_Phone.focus();
		document.Space_form.Office_Phone.select();
		return false;
	}
if(!numberValidate(document.Space_form.Office_Phone.value, 'Phone'))
	{
		alert("Please Enter Numbers Only");
		document.Space_form.Office_Phone.focus();
		document.Space_form.Office_Phone.select();
		return false;
	}
if(document.Space_form.birth_year.options[document.Space_form.birth_year.selectedIndex].value == "-1")
	{
		alert("Please select your year of birth");
		document.Space_form.birth_year.focus();
		return false;
	}
if(document.Space_form.birth_month.options[document.Space_form.birth_month.selectedIndex].value == "-1")
	{
		alert("Please select your month of birth");
		document.Space_form.birth_month.focus();
		return false;
	}
if(document.Space_form.birth_date.options[document.Space_form.birth_date.selectedIndex].value == "-1")
	{
		alert("Please select your date of birth");
		document.Space_form.birth_date.focus();
		return false;
	}
    if(document.Space_form.School.value=='School' || document.Space_form.School.value=="")
	{
		alert("Please Enter Your School Name");
		document.Space_form.School.focus();
		document.Space_form.School.select();
		return false;
	}
	document.Space_form.phone2.value=document.Space_form.Office_Phone.value;
	document.Space_form.DOB.value =
    document.Space_form.birth_year.value + "-"+
    document.Space_form.birth_month.value + "-"+
    document.Space_form.birth_date.value;
	return true;
}
