// JavaScript Document

 function DefaultcheckEmail()
    {

    if (document.getElementById('txtemail').value != "")
    {
    var valEmail = document.getElementById('txtemail').value;

    valEmail = valEmail.match(/(\w+)@(.+)\.(\w+)$/);
    if (valEmail !=null)
    {
    if ((valEmail[3].length==2) || (valEmail[3].length==3) || (valEmail[3].length==4))
    return true;
    }

    }

    document.getElementById('txtemail').focus();
    return false;
    }
    function DefaultcheckFriendEmail()
    {

    if (document.getElementById('txtfriendemail').value != "")
    {
    var valEmail = document.getElementById('txtfriendemail').value;

    valEmail = valEmail.match(/(\w+)@(.+)\.(\w+)$/);
    if (valEmail !=null)
    {
    if ((valEmail[3].length==2) || (valEmail[3].length==3) || (valEmail[3].length==4))
    return true;
    }

    }

    document.getElementById('txtfriendemail').focus();
    return false;
    }

    function DoTrim(strComp)
    {
    ltrim = /^\s+/
    rtrim = /\s+$/
    strComp = strComp.replace(ltrim,'');
    strComp = strComp.replace(rtrim,'');
    return strComp;
    }
    function Defaultvalidatetell()
    {
    var fields="";

    if (DoTrim(document.getElementById('txtfriendname').value).length ==0)
    {
    fields = fields + "\n-- Your Friend Name";
    document.getElementById('txtfriendname').value="";
    }

    if (DoTrim(document.getElementById('txtfriendemail').value).length ==0)
    {
    fields = fields + "\n-- Your Friend Email";
    document.getElementById('txtfriendemail').value="";
    }

    if (DoTrim(document.getElementById('txtname').value).length ==0)
    {
    fields = fields + "\n-- Your Name";
    document.getElementById('txtname').value="";
    }

    if (DoTrim(document.getElementById('txtemail').value).length ==0)
    {
    fields = fields + "\n-- Your Email";
    document.getElementById('txtemail').value="";
    }

    if (DoTrim(document.getElementById('txtmsg').value).length ==0)
    {
    fields = fields + "\n-- Message";
    document.getElementById('txtmsg').value="";
    }

    if(fields !="")
    {
    fields = "Please fill in the following details\n--------------------------------------\n"+fields;
    alert(fields);
    return false;
    }
    else
    {
    if(DefaultcheckFriendEmail())
    {
    if(DefaultcheckEmail())
    {
    return true;
    }
    else
    {
    alert("Enter valid your email address");
    return false;
    }

    }
    else
    {
    alert("Enter valid friend email address");
    return false;
    }

    }

    }

function ValidateSearch()
		{
			if (Dotrim(document.getElementById('Header1_txtSearch').value).length == 0 )
			{
				alert("Enter search keyword!");
				return false;
			}
			else
			{
				PostData();
			}
		}
		function Dotrim(strComp)
		{
			ltrim = /^\s+/
			rtrim = /\s+$/
			strComp = strComp.replace(ltrim,'');
			strComp = strComp.replace(rtrim,'');
			return strComp;
		}
		
		function DefaultSubmitSearch(e)
		{
			var key = e.which||e.keyCode;
			if(key==13)
			{
				if(ValidateSearch()==true)
				{
					PostData();	
				}
				if(e.preventDefault)
				{
					e.preventDefault();
				}
				else
				{
					e.returnValue=false;
					e.cancel=true;
					return false;
				}
			}
		}
		
		function PostData()
		{
			__doPostBack('Header1$lnkSearch','');	
			return true;
		}

/*----------------------------------------------------------------------*/



function validateUnsub()
{
	if(document.form1.txtEmail.value!= "")
	{
		var valEmail = document.form1.txtEmail.value;
			valEmail = valEmail.match(/(\w+)@(.+)\.(\w+)$/);
			if (valEmail !=null)
			{
		
				if ((valEmail[3].length==2) || (valEmail[3].length==3) || (valEmail[3].length==4))
				return true;
			}
			else
			{
				alert("Invalid Email Address")
				document.form1.txtEmail.value = "";
				document.form1.txtEmail.focus();
				return false;
			}
	}
	else
	{
		alert("Please enter the Email Address.")
		return false;
	}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

<!--...........................................................................................-->
function LeftcheckEmail()
    {

		if (document.getElementById('left_txtemail').value != "")
		{
			var valEmail = document.getElementById('left_txtemail').value;
			valEmail = valEmail.match(/(\w+)@(.+)\.(\w+)$/);
			if (valEmail !=null)
			{
			if ((valEmail[3].length==2) || (valEmail[3].length==3) || (valEmail[3].length==4))
			return true;
			}

   		 }
   		 document.getElementById('left_txtemail').focus();
   		 return false;
    }
    function LeftcheckFriendEmail()
    {

		if (document.getElementById('left_txtfriendemail').value != "")
		{
			var valEmail = document.getElementById('left_txtfriendemail').value;
			valEmail = valEmail.match(/(\w+)@(.+)\.(\w+)$/);
			if (valEmail !=null)
			{
				if ((valEmail[3].length==2) || (valEmail[3].length==3) || (valEmail[3].length==4))
				return true;
			}
	
		}

		document.getElementById('left_txtfriendemail').focus();
		return false;
    }

    function DoTrim(strComp)
    {
		ltrim = /^\s+/
		rtrim = /\s+$/
		strComp = strComp.replace(ltrim,'');
		strComp = strComp.replace(rtrim,'');
		return strComp;
    }
    function Leftvalidatetell()
    {
    	var fields="";
		if (DoTrim(document.getElementById('left_txtfriendname').value).length ==0)
		{
		fields = fields + "\n-- Your Friend Name";
		document.getElementById('left_txtfriendname').value="";
		}

		if (DoTrim(document.getElementById('left_txtfriendemail').value).length ==0)
		{
		fields = fields + "\n-- Your Friend Email";
		document.getElementById('left_txtfriendemail').value="";
		}

		if (DoTrim(document.getElementById('left_txtname').value).length ==0)
		{
		fields = fields + "\n-- Your Name";
		document.getElementById('left_txtname').value="";
		}
	
		if (DoTrim(document.getElementById('left_txtemail').value).length ==0)
		{
		fields = fields + "\n-- Your Email";
		document.getElementById('left_txtemail').value="";
		}
	
		if (DoTrim(document.getElementById('left_txtmsg').value).length ==0)
		{
		fields = fields + "\n-- Message";
		document.getElementById('left_txtmsg').value="";
		}
	
		if(fields !="")
		{
		fields = "Please fill in the following details\n--------------------------------------\n"+fields;
		alert(fields);
		return false;
		}
		else
		{
		if(LeftcheckFriendEmail())
		{
		if(LeftcheckEmail())
		{
		return true;
		}
		else
		{
		alert("Enter valid your email address");
		return false;
		}

		}
		else
		{
		alert("Enter valid friend email address");
		return false;
		}
	
		}

    }
	<!--========================================================================-->
	
	function SubscribeCheckValue()
		{
			var fields;
			fields = "";
			if (DoTrim(document.getElementById('txtFName').value).length == 0 )
			{
				fields = "\n- First Name";
				document.getElementById('txtFName').focus();
			}
			if (DoTrim(document.getElementById('txtLName').value).length == 0 )
			{
				fields = fields + "\n- Last Name";
				document.getElementById('txtLName').focus();
			}
			if (DoTrim(document.getElementById('txtEmail').value).length == 0 )
			{
				fields = fields + "\n- Email";
				document.getElementById('txtEmail').focus();
			}
			else
			{	
					var re = new RegExp();
					re = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
					var sinput ;
					sinput= "" ;
					sinput = DoTrim(document.getElementById('txtEmail').value);
					if (!re.test(sinput))
					{
						fields = fields + "\n-- Invalid Email Address --";
					}	
			}
			if (document.getElementById('State').value== '0' )
			{
				fields = fields + "\n- State";
				//document.getElementById('State').focus();
			}
			if(fields !="")
			{
				fields = "Please fill in the following details:\n--------------------------------"+fields;
				alert(fields);
				return false;
			}
			else
			{
				return true;		
			}
		}
		
		function SubscribecheckEmail()
		{		
			if (document.getElementById('txtEmail').value != "")
			{
				var valEmail = document.getElementById('txtEmail').value;
				valEmail = valEmail.match(/(\w+)@(.+)\.(\w+)$/);
				if (valEmail !=null)
				{
					if ((valEmail[3].length==2) || (valEmail[3].length==3) || (valEmail[3].length==4))
					return true;
				}
				else
				{
					return false;
				}
			}
		}

// commercial solar renewable energy JS
	function ValidateCSRE()
	{
		var fields;
		fields = "";
		
		if (Dotrim(document.getElementById('txtName').value).length == 0 )
		{
			fields = fields + "\n-- Your Name --";
		}
		
		if (Dotrim(document.getElementById('txtPhone').value).length == 0 )
		{
			fields = fields + "\n-- Phone Number --";
		}
		if (Dotrim(document.getElementById('txtEmail').value).length == 0)
		{
			fields = fields + "\n-- eMail Address --";
		}
		else
		{
			var re = new RegExp();
			re = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
			var sinput ;
			sinput= "" ;
			sinput = Dotrim(document.getElementById('txtEmail').value);
			if (!re.test(sinput))
			{
				fields = fields + "\n-- Invalid Email Address --";
			}
		}
		if (Dotrim(document.getElementById('txtBestTime').value).length == 0)
		{
			fields = fields + "\n-- Best time to reach you? --";
		}
		if(fields !="")
		{
		
			fields = "Please fill in the following details:\n--------------------------------\n"+fields;
			alert(fields);
			return false;
		}
		else
		{
			return true;
		}
	}


