// Texas GOP JavaScript Document

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_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_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_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 mytrim(val)
{
		val1 = "";
		val2="";
		ctrr = 0;
		lngth = val.length;
		for (i=0; i<lngth; i++)
		{
		if (val.charCodeAt(i) != 32)
		{
		for(j=i;j<lngth;j++)
		{
		if (val.charCodeAt(j) != 13 && val.charCodeAt(j) != 10 )
			{
			val1 += val.charAt(j);
			}
		}
		break;
		}
		}
		if (val1 != "")
		{
		lngth = val1.length
		ctrr=lngth;
		for (k=0; k<lngth; k++)
		{
		ctrr=ctrr-1;
		if (val1.charCodeAt(ctrr) != 32)
		{
		for(l=0;l<lngth-k;l++)
		{
		val2 += val1.charAt(l);
		}
		val1=val2;
		break;
		}
		}
		}
		return val1;
}
function chkemail(email)
{
	var emailvalid=true;

		if (email.value.length < 5)
		{
			emailvalid=false;
		}
		else
		{

			var flag = "false";
			var flag1 = "false";
			var flag2="true";
			for (var i = 1; i < email.value.length; i++)
			{
				var ch = email.value.substring(i, i + 1);
				if (ch == ".")
				{
					flag = "true";
				}
				if (ch == "@")
				{
					flag1 = "true";
				}
				if (ch==" ")
				{
					flag2="false";
				}

			}
			if (flag == "false" || flag1 == "false" || flag2 == "false")
			{
				emailvalid=false;
			}
		}
		return emailvalid;
}
function IsNumeric(sText)
 {
   var ValidChars = "0123456789";
   var IsNumber=true;
   var Char;


   for (i = 0; i < sText.length && IsNumber == true; i++)
      {
      Char = sText.charAt(i);
      if (ValidChars.indexOf(Char) == -1)
         {
         IsNumber = false;
         }
      }
   return IsNumber;

 }
 function emptyvalue2(x) {
 if(x.value=="First Name" || x.value=="Last Name" || x.value=="Street Address" || x.value=="City" || x.value=="Club" || x.value=="County" || x.value=="Precinct" || x.value=="Zip Code" ||  x.value=="Email Address" || x.value=="Phone Number" || x.value=="Home Phone" || x.value=="Work Phone" || x.value=="Mobile Phone") {
  pretext2=x.value;
  x.style.color='#000000';
  x.value="";
 } else {
  switch(x.name) {
   case "firstname":
    pretext2="First Name";
    break;
   case "lastname":
    pretext2="Last Name";
    break;
   case "address":
    pretext2="Street Address";
    break;
   case "city":
    pretext2="City";
    break;
	 case "county":
    pretext2="County";
    break;
	
    break;
   case "zip":
    pretext2="Zip Code";
    break;	
   case "email":
    pretext2="Email Address";
    break;
   case "phone":
    pretext2="Phone Number";
    break;
	case "homephone":
    pretext2="Home Phone";
    break;
	case "workphone":
    pretext2="Work Phone";
    break;
	case "mobilephone":
    pretext2="Mobile Phone";
    break;
   default: pretext2="";
  }
 }
}

function fillvalue2(x) {
 if (x.value=="") {
  x.style.color = '#000000';
  x.value = pretext2;
 }
}
function changecolor(x)
{
  x.style.color = '#000000';
 
 }
 function validateVoterShoutBox()
{
	if(mytrim(document.frmvotershoutbox.firstname.value)=="" || mytrim(document.frmvotershoutbox.firstname.value)=="First Name")
		{
			  alert("Please Enter First Name");
			  document.frmvotershoutbox.firstname.focus();
			  return false;
		}
		if(mytrim(document.frmvotershoutbox.lastname.value)=="" || mytrim(document.frmvotershoutbox.lastname.value)=="Last Name")
		{
			  alert("Please Enter Last Name");
			  document.frmvotershoutbox.lastname.focus();
			  return false;
		}
		
		if(mytrim(document.frmvotershoutbox.selectstate.value)=="")
		{
			  alert("Please Select State/Province");
			  document.frmvotershoutbox.selectstate.focus();
			  return false;
		}
		if(mytrim(document.frmvotershoutbox.city.value)=="" || mytrim(document.frmvotershoutbox.city.value)=="City")
		{
			  alert("Please Enter City");
			  document.frmvotershoutbox.city.focus();
			  return false;
		}
		
		var chkFilter=/\w{1,}[@][\w\-]{1,}([.]([\w\-]{1,})){1,3}$/;
		if (!(chkFilter.test(document.frmvotershoutbox.email.value))) {
			  alert("Please Enter a Valid Email Address");
			  document.frmvotershoutbox.email.focus();
			  return false;
		}
		
		if (mytrim(document.frmvotershoutbox.comment.value)=="")
		{
			alert("Please Enter Comments Below 1000 Words.");
			document.frmvotershoutbox.comment.focus();
			return false;
			
		}
		if (document.frmvotershoutbox.comment.value.length>1000)
			{
				alert("Please Enter Comments Below 1000 Words.");
				document.frmvotershoutbox.comment.focus();
				return false;
			}
}
function validateVolunteer()
{
	if(mytrim(document.volunteer.firstname.value)=="" || mytrim(document.volunteer.firstname.value)=="First Name")
		{
			  alert("Please Enter First Name");
			  document.volunteer.firstname.focus();
			  return false;
		}
		if(mytrim(document.volunteer.lastname.value)=="" || mytrim(document.volunteer.lastname.value)=="Last Name")
		{
			  alert("Please Enter Last Name");
			  document.volunteer.lastname.focus();
			  return false;
		}
		if(mytrim(document.volunteer.address.value)=="" || mytrim(document.volunteer.address.value)=="Street Address")
		{
			  alert("Please Enter Street Address");
			  document.volunteer.address.focus();
			  return false;
		}
		if(mytrim(document.volunteer.state.value)=="")
		{
			  alert("Please Select State/Province");
			  document.volunteer.state.focus();
			  return false;
		}
		if(mytrim(document.volunteer.city.value)=="" || mytrim(document.volunteer.city.value)=="City")
		{
			  alert("Please Enter City");
			  document.volunteer.city.focus();
			  return false;
		}
		
		if(mytrim(document.volunteer.zip.value)=="" || mytrim(document.volunteer.zip.value)=="Zip Code")
		{
			  alert("Please Enter Zip Code");
			  document.volunteer.zip.focus();
			  return false;
		}
		if (!IsNumeric(document.volunteer.zip.value))
		{
			alert("Please Enter Valid Zip");
			document.volunteer.zip.focus();
			return false;
		}
		if (document.volunteer.zip.value.length<5)
		{
			alert("Please Enter Valid Zip");
			document.volunteer.zip.focus();
			return false;
		}
		var chkFilter=/\w{1,}[@][\w\-]{1,}([.]([\w\-]{1,})){1,3}$/;
		if (!(chkFilter.test(document.volunteer.email.value))) {
			  alert("Please Enter a Valid Email Address");
			  document.volunteer.email.focus();
			  return false;
		}
		
		if (!mytrim(document.volunteer.comments.value)=="")
		{
			if (document.volunteer.comments.value.length>1000)
			{
				alert("Please Enter Comments Below 1000 Words.");
				document.volunteer.comments.focus();
				return false;
			}
			
		}
		
}
function validateContact()
{
	if(mytrim(document.contact.firstname.value)=="" || mytrim(document.contact.firstname.value)=="First Name")
		{
			  alert("Please Enter First Name");
			  document.contact.firstname.focus();
			  return false;
		}
		if(mytrim(document.contact.lastname.value)=="" || mytrim(document.contact.lastname.value)=="Last Name")
		{
			  alert("Please Enter Last Name");
			  document.contact.lastname.focus();
			  return false;
		}
		if(mytrim(document.contact.county.value)=="" || mytrim(document.contact.county.value)=="County")
		{
			  alert("Please Enter County");
			  document.contact.county.focus();
			  return false;
		}
		
		
		if(mytrim(document.contact.zip.value)=="" || mytrim(document.contact.zip.value)=="Zip Code")
		{
			  alert("Please Enter Zip Code");
			  document.contact.zip.focus();
			  return false;
		}
		if (!IsNumeric(document.contact.zip.value))
		{
			alert("Please Enter Valid Zip");
			document.contact.zip.focus();
			return false;
		}
		if (document.contact.zip.value.length<5)
		{
			alert("Please Enter Valid Zip");
			document.contact.zip.focus();
			return false;
		}
		var chkFilter=/\w{1,}[@][\w\-]{1,}([.]([\w\-]{1,})){1,3}$/;
		if (!(chkFilter.test(document.contact.email.value))) {
			  alert("Please Enter a Valid Email Address");
			  document.contact.email.focus();
			  return false;
		}
		
		if (mytrim(document.contact.comments.value)=="")
		{
			alert("Please Enter Comments Below 1000 Words.");
				document.contact.comments.focus();
				return false;
			
		}
		if (document.contact.comments.value.length>1000)
			{
				alert("Please Enter Comments Below 1000 Words.");
				document.contact.comments.focus();
				return false;
			}
		
}
function validateHispanic()
{
	
		if(mytrim(document.hispanicfrm.lastname.value)=="")
		{
			  alert("Please Enter Last Name");
			  document.hispanicfrm.lastname.focus();
			  return false;
		}
		if(mytrim(document.hispanicfrm.firstname.value)=="")
		{
			  alert("Please Enter First Name");
			  document.hispanicfrm.firstname.focus();
			  return false;
		}
		
		
		var chkFilter=/\w{1,}[@][\w\-]{1,}([.]([\w\-]{1,})){1,3}$/;
		if (!(chkFilter.test(document.hispanicfrm.email.value))) {
			  alert("Please Enter a Valid Email Address");
			  document.hispanicfrm.email.focus();
			  return false;
		}
		if(mytrim(document.hispanicfrm.phone.value)=="")
		{
			  alert("Please Enter Phone Number");
			  document.hispanicfrm.phone.focus();
			  return false;
		}
		if (!IsNumeric(document.hispanicfrm.phone.value))
		{
			alert("Please Enter Phone Number");
			document.hispanicfrm.phone.focus();
			return false;
		}
		
		
}

function emptyemailsign(x) {
 if(x.value=="Email Address" || x.value=="Zip") {
  pretextsign=x.value;
  x.style.color='#000000';
  x.value="";
 } else {
  switch(x.name) {
   case "email__sValue":
    pretextsign="Email Address";
    break;
   case "lastname":
    pretextsign="Zip";
    break;
	default: pretextsign="";
  }
 }
}
function fillvaluesignup(x) {
 if (x.value=="") {
  x.style.color = '#000000';
  x.value = pretextsign;
 }
}
function validateSignUp()
{

		var chkFilter=/\w{1,}[@][\w\-]{1,}([.]([\w\-]{1,})){1,3}$/;
		if (!(chkFilter.test(document.IBNSubscribe.email__sValue.value))) {
			  alert("Please Enter a Valid Email Address");
			  document.IBNSubscribe.email__sValue.focus();
			  return false;
		}
		
		if(mytrim(document.IBNSubscribe.cf_4__sValue.value)=="" || mytrim(document.IBNSubscribe.cf_4__sValue.value)=="Zip")
		{
			  alert("Please Enter Zip Code");
			  document.IBNSubscribe.cf_4__sValue.focus();
			  return false;
		}
		if (!IsNumeric(document.IBNSubscribe.cf_4__sValue.value))
		{
			alert("Please Enter Valid Zip");
			document.IBNSubscribe.cf_4__sValue.focus();
			return false;
		}
		if (document.IBNSubscribe.cf_4__sValue.value.length<5)
		{
			alert("Please Enter Valid Zip");
			document.IBNSubscribe.cf_4__sValue.focus();
			return false;
		}
		
}
function CopyToClipboard()

{

   document.Form1.txttwitter.focus();

   document.Form1.txttwitter.select();

 

}