function isexplorer(){
	if(navigator.appName.indexOf('Microsoft')!=-1)
		return true;
	else
		return false;
	}


function valuecity(){
	var elementmaincity = document.getElementById("fill_category_city");
	var elementcityb = document.getElementById("fill_category_cityb");
	var elementcity2 = document.getElementById("fill_category_city2");
	var citymainvalue;
	var citybvalue;
	var city2value;	
	if(isexplorer()){
		citymainvalue = elementmaincity.childNodes[0].value;
		citybvalue = elementcityb.childNodes[0].value;
		city2value = elementcity2.childNodes[0].value;		
		}
	else{
		citymainvalue = elementmaincity.childNodes[1].value;
		citybvalue = elementcityb.childNodes[1].value;
		city2value = elementcity2.childNodes[1].value;
		}	
	if(citybvalue == '') citybvalue = 0;
	if(city2value == '') city2value = 0;
	//alert("Main city: " + citymainvalue);
	//alert("City2: " + city2value);
	//alert("Cityb: " + citybvalue);	
	document.finquiry.hidcitymainval.value = citymainvalue;
	document.finquiry.hidcity2val.value = city2value;
	document.finquiry.hidcitybval.value = citybvalue;
}


function formValidation(thisform)
{ 	

	//alert(document.getElementById("selectcity"));
with (thisform)
	{
		 
		 if (emptyvalidation(firstname,"Woops! You forgot to fill in your First Name")==false) 
				{
					firstname.focus();
					return false;
				}
		if (emptyvalidation(lastname,"Woops! You forgot to fill in your Last Name")==false) 
				{
					lastname.focus();
					return false;
				}
		if (emptyvalidation(email,"Woops! You forgot to fill in your Email Address")==false) 
			   {
		 	 email.focus();
			  return false;
			   }
			   
		 if(emailvalidation(email)==false)
			{
				alert("Woops! You forgot to enter a valid Email Address");
				email.select();
				email.focus();
				return false;			
			} 
		if (emptyvalidation(country,"Woops! You forgot to select in your Country")==false) 
				{
					country.focus();
					return false;
				}
				
			 if (emptyvalidation(state,"Woops! You forgot to select in your State/Province")==false) 
			   {
				state.focus();
				return false;
			   }
			   
		if (emptyvalidation(city,"Woops! You forgot to select in your City")==false) 
			   {
		 	 city.focus();
			  return false;
			   }
				 

		if (emptyvalidation(pcode,"Woops! You forgot to fill in your Postal Code ")==false) 
				{
					pcode.focus();
					return false;
				}
		   
		
			//thisform.hidSubmit.value="proceedSubmit";
		    //thisform.hidBcc.value="webleads@techwyse.com";
		//valuecity();
		thisform.submit();			
		
	} 
	return true;
}
function emailvalidation(thisform) {

   var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
   var address = thisform.value;
   var email = address.split(',');
   
   for (var i = 0; i < email.length; i++) {
   if(reg.test(email[i]) == false) {
     // alert('Invalid Email Address');
      return false;
   }
   else
   {
    }
   }
}

function echeck(str)
{ 
	var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Invalid Email Address")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Woops! You have entered an invalid Email Address")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Woops! You have entered an invalid Email Address")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Woops! You have entered an invalid Email Address")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Woops! You have entered an invalid Email Address")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Woops! You have entered an invalid Email Address")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Woops! You have entered an invalid Email Address")
		    return false
		 }

 		 return true					
	}	