// JavaScript Document

function trim(str){
while (str.charAt(0)  == " "){
// remove leading spaces
str = str.substring(1);
}
while (str.charAt(str.length - 1) == " "){
// remove trailing spaces
str = str.substring(0,str.length - 1);
}
return str;
}

function isValid(email) {
	len= email.length;
	posAt= email.indexOf("@");
	posDot= email.lastIndexOf(".");
	if ((len >= 5) && (posAt+1 < posDot) && (posAt+1 > 1) && (posDot+1 < len))
	   return true;
	else
	   {
	    return false;
	}
}
function isValid1(reference_email) {
	len= reference_email.length;
	posAt= reference_email.indexOf("@");
	posDot= reference_email.lastIndexOf(".");
	if ((len >= 5) && (posAt+1 < posDot) && (posAt+1 > 1) && (posDot+1 < len))
	   return true;
	else
	   {
	    return false;
	}
}
var radio_selection="";
function frmCheck(){
	//setDesc();
	//validateRadioBox(field, field2, msg);
//	radioButtons()
	var val=""
	var additionalComments;
	var val1=""
	var Statebool=1;
	var hyphen="-"
	f=document.LandingPage;
	j=document.LandingPage.length;
	for (var k=0; k<j;k++)
	{
		cntr=0;
		elem=f.elements[k];
				
			if(elem.name=="country")
			{
				if(elem.value=="")
				{
					alert("Please select country");
					cntr=1;
					elem.focus();
				}
			/*	else
				{
					if ((elem.value=="United States") || (elem.value=="Canada"))
						{
							if (document.LandingPage.state.value=="") 
							{
								alert("Please select a relevant state or province");
								cntr=1;
								document.LandingPage.state.focus();
							}
						}
					else 
						{
							document.LandingPage.state.value="";
						}	
				} */
			}
			

			if((elem.name=="first_name") && (trim(elem.value)==""))
			{
				alert("Please enter first name");
				cntr=1;
				elem.focus();
			}
			if((elem.name=="last_name") && (trim(elem.value)==""))
			{
				alert("Please enter last name");
				cntr=1;
				elem.focus();
			}
			if((elem.name=="company") && (trim(elem.value)==""))
			{
				alert("Please enter company");
				cntr=1;
				elem.focus();
			}
			if((elem.name=="title") && (trim(elem.value)==""))
			{
				alert("Please enter title");
				cntr=1;
				elem.focus();
			}
			if((elem.name=="phone") && (trim(elem.value)==""))
			{
				alert("Please enter telephone");
				cntr=1;
				elem.focus();
			}

			if((elem.name=="city") && (trim(elem.value)==""))
			{
				alert("Please enter your city or town");
				cntr=1;
				elem.focus();
			}
		
						
			if((elem.name=="email")&&(elem.value!=""))
			{
			if (!(isValid(elem.value)))
			{
				alert("Incorrect email format");
				cntr=1;
				elem.focus();
			}
			}
			if((elem.name=="email") && (trim(elem.value)==""))
			{
				alert("Please enter email");
				cntr=1;
				elem.focus();
			}
			/*
			if((elem.name=="street") && (trim(elem.value)==""))
			{
				alert("Please enter End User's street address");
				cntr=1;
				elem.focus();
			}
			
			if((elem.name=="zip") && (trim(elem.value)==""))
			{
				alert("Please enter End User's postal code");
				cntr=1;
				elem.focus();
			}*/
			
			/*
			if (elem.name=="00N30000000ixKY")
			{	
				elem.value=getCookie("utm_source");
			}
			if (elem.name=="00N30000000ixKX")
			{
				elem.value=getCookie("utm_medium");
			}
			if (elem.name=="00N30000000ixKZ")
			{
				elem.value=getCookie("utm_term");
			}
			*/
			
			if (cntr==1) 
			{
				break;
			}
	}
if (cntr==1) return false;
return true;
}

/*function getCookie(name)
{
    var dc = document.cookie;
	var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1)
    {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    }
    else
    {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1)
    {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
	
}*/

/* Copyright ©2007 Nowspeed, Inc.*/
