// JavaScript Document
function checkForm(signupform) {
  var email = signupform.email.value;
    if(!email.match(/\w+((-\w+)|(\.\w+))*@\w+((\.|-)\w+)*\.\w+$/
    )){
        alert('Please enter the valid email address');
		signupform.email.focus();
        return false;
    }
    var password = trim(signupform.password.value);
    if (password == '')
    {
        alert('Please enter password');
		signupform.password.focus();
        return false;
    }
    ;
    var companyName = trim(signupform.companyName.value);
    if (companyName == '')
    {
        alert('Please enter company name');
		signupform.companyName.focus();
        return false;
    }
    ;
    var companyType = trim(signupform.companyType.value);
    if (companyType == 0)
    {
        alert('Please Select company type');
		signupform.companyType.focus();
        return false;
    }
    ;
   var coAddress1 = trim(signupform.coAddress1.value);
    var coAddress2 = trim(signupform.coAddress2.value);
    if (coAddress1 == '')
    {
        alert('Please enter company Address1');
		signupform.coAddress1.focus();
        return false;
    }
    ;
    var coCity = trim(signupform.coCity.value);
    if (coCity == '')
    {
        alert('Please enter company City');
		signupform.coCity.focus();
        return false;
    }
    ;
    var coCountry = trim(signupform.coCountry.value);
    if (coCountry == 0)
    {
        alert('Please select company country');
		signupform.coCountry.focus();
        return false;
    }
    ;
    var coState = trim(signupform.coState.value);
    if (coState == 0)
    {
        alert('Please select company state');
		signupform.coState.focus();
        return false;
    }
    ;
    var coZip = trim(signupform.coZip.value);
    if (coZip == '')
    {
        alert('Please enter company zip/postal code');
		signupform.coZip.focus();
        return false;
    }
    ;
    var coTelephone = trim(signupform.coTelephone.value);
    if (coTelephone == '')
    {
        alert('Please enter company Telephone');
		signupform.coTelephone.focus();
        return false;
    }
    ;
    var firstName = trim(signupform.firstName.value);
    if (firstName == '')
    {
        alert('Please enter firstName');
		signupform.firstName.focus();
        return false;
    }
    ;
    var address1= trim(signupform.address1.value);
	if (address1 == '')
		{
			alert('Pleae enter Contact Address1');
			signupform.address1.focus();
			return false;
		}
	;
	 var city= trim(signupform.city.value);
	if (city == '')
		{
			alert('Pleae enter Contact City');
			signupform.city.focus();
			return false;
		}
	;
	var country= trim(signupform.country.value);
	if (country == 0)
		{
			alert('Pleae enter Contact Country');
			signupform.country.focus();
			return false;
		}
	;
	var state= trim(signupform.state.value);
	if (state == 0)
		{
			alert('Pleae enter Contact State');
			signupform.state.focus();
			return false;
		}
	;
	var zip= trim(signupform.zip.value);
	if (zip == '')
		{
			alert('Pleae enter Contact Zip/Postal Code');
			signupform.zip.focus();
			return false;
		}
	;
	var telephone= trim(signupform.telephone.value);
	if (telephone == '')
		{
			alert('Pleae enter Contact Telephone');
			signupform.telephone.focus();
			return false;
		}
	;
	var bAddress1= trim(signupform.bAddress1.value);
	if (bAddress1 == '')
		{
			alert('Pleae enter Billing Address');
			signupform.bAddress1.focus();
			return false;
		}
	;
	var bCity= trim(signupform.bCity.value);
	if (bCity == '')
		{
			alert('Pleae enter Billing City');
			signupform.bCity.focus();
			return false;
		}
	;
	var bCountry= trim(signupform.bCountry.value);
	if (bCountry == '')
		{
			alert('Pleae enter Billing Country');
			signupform.bCountry.focus();
			return false;
		}
	;
	var bState= trim(signupform.bState.value);
	if (bState == '')
		{
			alert('Pleae enter Billing State');
			signupform.bState.focus();
			return false;
		}
	;
	var bZip= trim(signupform.bZip.value);
	if (bZip == '')
		{
			alert('Pleae enter Billing Zip/Postal Code');
			signupform.bZip.focus();
			return false;
		}
	;
	var bTelephone= trim(signupform.bTelephone.value);
	if (bTelephone == '')
		{
			alert('Pleae enter Billing Telephone');
			signupform.bTelephone.focus();
			return false;
		}
	;
	if ((signupform.paymentoption[0].checked==false) &&  (signupform.paymentoption[1].checked==false))
    {
        alert('Please choose payment option ');
        return false;
    }
	;
	var textfield= trim(signupform.textfield.value);
	if ((signupform.paymentoption[1].checked==true) && (textfield =="")){
			alert('Please fill Date, Time and Contact number for our Customer Care member to reach you');
			signupform.textfield.focus();
			return false;
	}
	;
		
	
    var checkboxAgreement = signupform.checkboxAgreement.checked;
    if (!checkboxAgreement)
    {
        alert('Please agree to terms and service ');
        return false;
    }
	return true;
}

function trim(str) {
    return str.replace(/^\s*|\s*$/g, "");
}

function clearform() {
	var raman = "A brief description about your company";
	if (document.getElementById("profile").value == raman) 
		{
			document.getElementById("profile").value="";
		}
		return true;
}

function populatedata()
{
	var raman1=document.getElementById("coAddress1").value;
	if(raman1!="")
	{
	document.getElementById("address1").value=document.getElementById("coAddress1").value;
	document.getElementById("address2").value=document.getElementById("coAddress2").value;
	document.getElementById("city").value=document.getElementById("coCity").value;
	document.getElementById("country").selectedIndex=document.getElementById("coCountry").selectedIndex;
	document.getElementById("state").selectedIndex=document.getElementById("coState").selectedIndex;
	document.getElementById("zip").value=document.getElementById("coZip").value;
	}
	else
	{
		alert("Please fill the company address first");
		document.getElementById("checkboxContact").checked=false;
	}
}


function unpopulate()
{
	document.getElementById("address1").value="";
	document.getElementById("address2").value="";
	document.getElementById("city").value="";
	document.getElementById("country").value="";
	document.getElementById("state").value="";
	document.getElementById("zip").value="";
}

function bpopulatedata() {
	var raman2=document.getElementById("address1").value
	if(raman2!="") {
		document.getElementById("bFirstName").value=document.getElementById("firstName").value;
		document.getElementById("bLastName").value=document.getElementById("lastName").value;
		document.getElementById("bAddress1").value=document.getElementById("address1").value;
		document.getElementById("bAddress2").value=document.getElementById("address2").value;
		document.getElementById("bCity").value=document.getElementById("city").value;
		document.getElementById("bCountry").selectedIndex=document.getElementById("country").selectedIndex;
		document.getElementById("bState").selectedIndex=document.getElementById("state").selectedIndex;
		document.getElementById("bZip").value=document.getElementById("zip").value;
		document.getElementById("bTelephone").value=document.getElementById("telephone").value;
	}
	else
	{
		alert("Please fill the contact address first");
		document.getElementById("checkboxBilling").checked=false;
	}
}

function bunpopulate()
{
		document.getElementById("bFirstName").value="";
		document.getElementById("bLastName").value="";
		document.getElementById("bAddress1").value="";
		document.getElementById("bAddress2").value="";
		document.getElementById("bCity").value="";
		document.getElementById("bCountry").selectedIndex="";
		document.getElementById("bState").selectedIndex="";
		document.getElementById("bZip").value="";
		document.getElementById("bTelephone").value="";
}
