///For TRIM White Spaces////////////////////////
  function trim(str) 
       { 
	    return str.replace(/^\s*|\s*$/g,"");
      }
	  
///////////Email
function isAValidEmail( emailField )
{ 
   // var emailregex=/^[\w]+\+?\w*@[\w]+\.[\w.]+\w$/; 
   var emailregex=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
    var match=emailField.match( emailregex ); 
    if ( !match ) 
    { 
       return false; 
    }
    else
    {
       return true; 
    }
}

function isPhoneNumber(s) 
{

     // Check for correct phone number
	 var validPhoneDigits = '0123456789()-+';
	 var phoneLength = s.length;
	 
	for(var i=0; i < phoneLength; i++)
	 {
	   if(validPhoneDigits.indexOf(s.substr(i,1)) == '-1')
		{
		  var returnvar = false;
		  break;
		}
		else
		{
		  var returnvar = true;
		} 
		
	 }
	 return returnvar;
}
	  
 
function FunLocation(val)
{
	window.location=val;
}

function CheckValidation()
{
	if(trim(document.theform.average_consumption.value)=="")
		 {
			alert("Please enter the required field.");
			document.getElementById("average_consumption_id").style.backgroundColor="#FFD9D9";
			document.theform.average_consumption.focus();
			return false;
		 }
	else
		 {
		 	document.getElementById("average_consumption_id").style.backgroundColor="#D0ECBD";	
		}
		 
	if(trim(document.theform.electric_service.value)=="")
		 {
			alert("Please enter the required field.");
			document.getElementById("electric_service_id").style.backgroundColor="#FFD9D9";
			document.theform.electric_service.focus();
			return false;
		 }
	else
		 {
		 	document.getElementById("electric_service_id").style.backgroundColor="#D0ECBD";	
		}		 
		 
	if(trim(document.theform.name.value)=="")
		 {
			alert("Please enter the required field.");
			document.getElementById("name_id").style.backgroundColor="#FFD9D9";
			document.theform.name.focus();
			return false;
		 }
	else
		 {
		 	document.getElementById("name_id").style.backgroundColor="#D0ECBD";	
		}		 
	if(trim(document.theform.address.value)=="")
		 {
			alert("Please enter the required field.");
			document.getElementById("address_id").style.backgroundColor="#FFD9D9";
			document.theform.address.focus();
			return false;
		 }
	else
		 {
		 	document.getElementById("address_id").style.backgroundColor="#D0ECBD";	
		}
			
	if(trim(document.theform.city.value)=="")
		 {
			alert("Please enter the required field.");
			document.getElementById("city_id").style.backgroundColor="#FFD9D9";
			document.theform.city.focus();
			return false;
		 }
	else
		 {
		 	document.getElementById("city_id").style.backgroundColor="#D0ECBD";	
		}		 
	if(trim(document.theform.state.value)=="")
		 {
			alert("Please enter the required field.");
			document.getElementById("state_id").style.backgroundColor="#FFD9D9";
			document.theform.state.focus();
			return false;
		 }
	else
		 {
		 	document.getElementById("state_id").style.backgroundColor="#D0ECBD";	
		}		 
	if(trim(document.theform.zip.value)=="")
		 {
			alert("Please enter the required field.");
			document.getElementById("zip_id").style.backgroundColor="#FFD9D9";
			document.theform.zip.focus();
			return false;
		 }
	else
		 {
		 	document.getElementById("zip_id").style.backgroundColor="#D0ECBD";	
		}		 
	if(isNaN(document.theform.zip.value))
		 {
			alert("Please enter valid zip code.");
			document.getElementById("zip_id").style.backgroundColor="#FFD9D9";
			document.theform.zip.focus();
			return false;
		 }
	else
		 {
		 	document.getElementById("zip_id").style.backgroundColor="#D0ECBD";	
		}		 
	if(trim(document.theform.phone.value)=="")
		 {
			alert("Please enter the required field.");
			document.getElementById("phone_id").style.backgroundColor="#FFD9D9";
			document.theform.phone.focus();
			return false;
		 }
	else
		 {
		 	document.getElementById("phone_id").style.backgroundColor="#D0ECBD";	
		}		 
		 
	if(trim(document.theform.email.value)=="")
		 {
			alert("Please enter the required field.");
			document.getElementById("email_id").style.backgroundColor="#FFD9D9";
			document.theform.email.focus();
			return false;
		 }
	else
		 {
		 	document.getElementById("email_id").style.backgroundColor="#D0ECBD";	
		}		 
	if(!isAValidEmail(document.theform.email.value))
		{
		    alert("Please enter valid e-mail address.");
			document.getElementById("email_id").style.backgroundColor="#FFD9D9";
			document.theform.email.focus();
			return false; 	
	    }
	else
		 {
		 	document.getElementById("email_id").style.backgroundColor="#D0ECBD";	
		}		
}

function ShowBox(val)
{
	if(val == 'Other')
	  {
			document.getElementById("others").style.display = "";
			document.getElementById("textbox_id").value        = 1;
	  }
	  else
	   {
			document.getElementById("others").style.display = "none"; 
			document.getElementById("textbox_id").value        = 0;
	   }
}

function ShowTextbox(valu)
{
	if(valu == 'other_occupation')
	  {
			document.getElementById("occupation_other").style.display = "";
			document.getElementById("textbox_id1").value        = 1;
	  }
	  else
	   {
			document.getElementById("occupation_other").style.display = "none";   
			document.getElementById("textbox_id1").value        = 0;
	   }	
}

function ShowText(val)
{
	if(val == 'voltage_Other')
	  {
			document.getElementById("voltage_text").style.display = "";
			document.getElementById("textbox_id2").value        = 1;
	  }
	  else
	   {
			document.getElementById("voltage_text").style.display = "none"; 
			document.getElementById("textbox_id2").value        = 0;
	   }
  
}

function CheckValidation2()
{
	if(trim(document.theform.average_consumption.value)=="")
		 {
			alert("Please enter the required field.");
			document.getElementById("average_consumption_id").style.backgroundColor="#FFD9D9";
			document.theform.average_consumption.focus();
			return false;
		 }
	else{
		 	document.getElementById("average_consumption_id").style.backgroundColor="#D0ECBD";	
		}		 
	if(trim(document.theform.location_zip.value)=="")
		 {
			alert("Please enter the required field.");
			document.getElementById("location_zip_id").style.backgroundColor="#FFD9D9";
			document.theform.location_zip.focus();
			return false;
		 }
	else{
		 	document.getElementById("location_zip_id").style.backgroundColor="#D0ECBD";	
		}		 
	if(trim(document.theform.location_attitude.value)=="")
		 {
			alert("Please enter the required field.");
			document.getElementById("location_attitude_id").style.backgroundColor="#FFD9D9";
			document.theform.location_attitude.focus();
			return false;
		 }
	else{
		 	document.getElementById("location_attitude_id").style.backgroundColor="#D0ECBD";	
		}		 
	if(trim(document.theform.electric_provider.value)=="")
		 {
			alert("Please enter the required field.");
			document.getElementById("electric_provider_id").style.backgroundColor="#FFD9D9";
			document.theform.electric_provider.focus();
			return false;
		 }
	else{
		 	document.getElementById("electric_provider_id").style.backgroundColor="#D0ECBD";	
		}		 
		
	if(document.theform.textbox.value ==1 && trim(document.theform.building_type1.value)=="")
		 {
			alert("Please enter the required field.");
			document.getElementById("building_type1_id").style.backgroundColor="#FFD9D9";
			document.theform.building_type1.focus();
			return false;
		 }
	else{
		 	document.getElementById("building_type1_id").style.backgroundColor="#D0ECBD";	
		}		 
	
	if(trim(document.theform.name.value)=="")
		 {
			alert("Please enter the required field.");
			document.getElementById("name_id").style.backgroundColor="#FFD9D9";
			document.theform.name.focus();
			return false;
		 }
	else{
		 	document.getElementById("name_id").style.backgroundColor="#D0ECBD";	
		}		 
	if(trim(document.theform.company.value)=="")
		 {
			alert("Please enter the required field.");
			document.getElementById("company_id").style.backgroundColor="#FFD9D9";
			document.theform.company.focus();
			return false;
		 }
	else{
		 	document.getElementById("company_id").style.backgroundColor="#D0ECBD";	
		}			 
	
	if(document.theform.textbox1.value == 1 && (trim(document.theform.occupation1.value)==""))
		 {
			alert("Please enter the required field.");
			document.getElementById("occupation1_id").style.backgroundColor="#FFD9D9";
			document.theform.occupation1.focus();
			return false;
		 }		 
	else{
		 	document.getElementById("occupation1_id").style.backgroundColor="#D0ECBD";	
		}	
	if(trim(document.theform.address.value)=="")
		 {
			alert("Please enter the required field.");
			document.getElementById("address_id").style.backgroundColor="#FFD9D9";
			document.theform.address.focus();
			return false;
		 }
	else{
		 	document.getElementById("address_id").style.backgroundColor="#D0ECBD";	
		}		 
	if(trim(document.theform.city.value)=="")
		 {
			alert("Please enter the required field.");
			document.getElementById("city_id").style.backgroundColor="#FFD9D9";
			document.theform.city.focus();
			return false;
		 }
	else{
		 	document.getElementById("city_id").style.backgroundColor="#D0ECBD";	
		}		 
	if(trim(document.theform.state.value)=="")
		 {
			alert("Please enter the required field.");
			document.getElementById("state_id").style.backgroundColor="#FFD9D9";
			document.theform.state.focus();
			return false;
		 }
	else{
		 	document.getElementById("state_id").style.backgroundColor="#D0ECBD";	
		}		 
	if(trim(document.theform.zip.value)=="")
		 {
			alert("Please enter the required field.");
			document.getElementById("zip_id").style.backgroundColor="#FFD9D9";
			document.theform.zip.focus();
			return false;
		 }
	else{
		 	document.getElementById("zip_id").style.backgroundColor="#D0ECBD";	
		}		 
	if(isNaN(document.theform.zip.value))
		 {
			alert("Please enter valid zip code.");
			document.getElementById("zip_id").style.backgroundColor="#FFD9D9";
			document.theform.zip.focus();
			return false;
		 }
	else{
		 	document.getElementById("zip_id").style.backgroundColor="#D0ECBD";	
		}		 
	if(trim(document.theform.phone.value)=="")
		 {
			alert("Please enter the required field.");
			document.getElementById("phone_id").style.backgroundColor="#FFD9D9";
			document.theform.phone.focus();
			return false;
		 }
	else{
		 	document.getElementById("phone_id").style.backgroundColor="#D0ECBD";	
		}		 
	if(trim(document.theform.email.value)=="")
		 {
			alert("Please enter the required field.");
			document.getElementById("email_id").style.backgroundColor="#FFD9D9";
			document.theform.email.focus();
			return false;
		 }
	else{
		 	document.getElementById("email_id").style.backgroundColor="#D0ECBD";	
		}		 
	if(!isAValidEmail(document.theform.email.value))
		{
		    alert("Please enter valid e-mail address.");
			document.getElementById("email_id").style.backgroundColor="#FFD9D9";
			document.theform.email.focus();
			return false; 	
	    }
	else{
		 	document.getElementById("email_id").style.backgroundColor="#D0ECBD";	
		}			
	
}

function CheckValidation3()
{
	
	if(trim(document.theform.average_consumption.value)=="")
		 {
			alert("Please enter the required field.");
			document.getElementById("average_consumption_id").style.backgroundColor="#FFD9D9";
			document.theform.average_consumption.focus();
			return false;
		 }
	else{
		 	document.getElementById("average_consumption_id").style.backgroundColor="#D0ECBD";	
		}		 
	if(trim(document.theform.location_zip.value)=="")
		 {
			alert("Please enter the required field.");
			document.getElementById("location_zip_id").style.backgroundColor="#FFD9D9";
			document.theform.location_zip.focus();
			return false;
		 }
	else{
		 	document.getElementById("location_zip_id").style.backgroundColor="#D0ECBD";	
		}
	if(trim(document.theform.roof_size.value)=="")
		 {
			alert("Please enter the required field.");
			document.getElementById("roof_size_id").style.backgroundColor="#FFD9D9";
			document.theform.roof_size.focus();
			return false;
		 }
	else{
		 	document.getElementById("roof_size_id").style.backgroundColor="#D0ECBD";	
		}		
	if(trim(document.theform.roof_height.value)=="")
		 {
			alert("Please enter the required field.");
			document.getElementById("roof_height_id").style.backgroundColor="#FFD9D9";
			document.theform.roof_height.focus();
			return false;
		 }
	else{
		 	document.getElementById("roof_height_id").style.backgroundColor="#D0ECBD";	
		}		
	if(trim(document.theform.electric_provider.value)=="")
		 {
			alert("Please enter the required field.");
			document.getElementById("electric_provider_id").style.backgroundColor="#FFD9D9";
			document.theform.electric_provider.focus();
			return false;
		 }
	else{
		 	document.getElementById("electric_provider_id").style.backgroundColor="#D0ECBD";	
		}	
		
		
	if(document.theform.textbox2.value ==1 && trim(document.theform.voltage1.value)=="")
		 {
			alert("Please enter the required field.");
			document.getElementById("voltage1_id").style.backgroundColor="#FFD9D9";
			document.theform.voltage1.focus();
			return false;
		 }
	else{
		 	document.getElementById("voltage1_id").style.backgroundColor="#D0ECBD";	
		}		
		
	if(document.theform.textbox.value ==1 && trim(document.theform.composition_roof1.value)=="")
		 {
			alert("Please enter the required field.");
			document.getElementById("composition_roof1_id").style.backgroundColor="#FFD9D9";
			document.theform.composition_roof1.focus();
			return false;
		 }
	else{
		 	document.getElementById("composition_roof1_id").style.backgroundColor="#D0ECBD";	
		}		 
	
	if(trim(document.theform.name.value)=="")
		 {
			alert("Please enter the required field.");
			document.getElementById("name_id").style.backgroundColor="#FFD9D9";
			document.theform.name.focus();
			return false;
		 }
	else{
		 	document.getElementById("name_id").style.backgroundColor="#D0ECBD";	
		}		 
	if(trim(document.theform.company.value)=="")
		 {
			alert("Please enter the required field.");
			document.getElementById("company_id").style.backgroundColor="#FFD9D9";
			document.theform.company.focus();
			return false;
		 }
	else{
		 	document.getElementById("company_id").style.backgroundColor="#D0ECBD";	
		}			 
	
	if(document.theform.textbox1.value == 1 && (trim(document.theform.occupation1.value)==""))
		 {
			alert("Please enter the required field.");
			document.getElementById("occupation1_id").style.backgroundColor="#FFD9D9";
			document.theform.occupation1.focus();
			return false;
		 }		 
	else{
		 	document.getElementById("occupation1_id").style.backgroundColor="#D0ECBD";	
		}	
	if(trim(document.theform.address.value)=="")
		 {
			alert("Please enter the required field.");
			document.getElementById("address_id").style.backgroundColor="#FFD9D9";
			document.theform.address.focus();
			return false;
		 }
	else{
		 	document.getElementById("address_id").style.backgroundColor="#D0ECBD";	
		}		 
	if(trim(document.theform.city.value)=="")
		 {
			alert("Please enter the required field.");
			document.getElementById("city_id").style.backgroundColor="#FFD9D9";
			document.theform.city.focus();
			return false;
		 }
	else{
		 	document.getElementById("city_id").style.backgroundColor="#D0ECBD";	
		}		 
	if(trim(document.theform.state.value)=="")
		 {
			alert("Please enter the required field.");
			document.getElementById("state_id").style.backgroundColor="#FFD9D9";
			document.theform.state.focus();
			return false;
		 }
	else{
		 	document.getElementById("state_id").style.backgroundColor="#D0ECBD";	
		}		 
	if(trim(document.theform.zip.value)=="")
		 {
			alert("Please enter the required field.");
			document.getElementById("zip_id").style.backgroundColor="#FFD9D9";
			document.theform.zip.focus();
			return false;
		 }
	else{
		 	document.getElementById("zip_id").style.backgroundColor="#D0ECBD";	
		}		 
	if(isNaN(document.theform.zip.value))
		 {
			alert("Please enter valid zip code.");
			document.getElementById("zip_id").style.backgroundColor="#FFD9D9";
			document.theform.zip.focus();
			return false;
		 }
	else{
		 	document.getElementById("zip_id").style.backgroundColor="#D0ECBD";	
		}		 
	if(trim(document.theform.phone.value)=="")
		 {
			alert("Please enter the required field.");
			document.getElementById("phone_id").style.backgroundColor="#FFD9D9";
			document.theform.phone.focus();
			return false;
		 }
	else{
		 	document.getElementById("phone_id").style.backgroundColor="#D0ECBD";	
		}		 
	if(trim(document.theform.email.value)=="")
		 {
			alert("Please enter the required field.");
			document.getElementById("email_id").style.backgroundColor="#FFD9D9";
			document.theform.email.focus();
			return false;
		 }
	else{
		 	document.getElementById("email_id").style.backgroundColor="#D0ECBD";	
		}		 
	if(!isAValidEmail(document.theform.email.value))
		{
		    alert("Please enter valid e-mail address.");
			document.getElementById("email_id").style.backgroundColor="#FFD9D9";
			document.theform.email.focus();
			return false; 	
	    }
	else{
		 	document.getElementById("email_id").style.backgroundColor="#D0ECBD";	
		}			
	
  	
}