// Boieng JavaScript Document

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_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 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 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 validateSignPetition()
{
	if(mytrim(document.signpetition.firstname.value)=="" || mytrim(document.signpetition.firstname.value)=="First Name")
		{
			  alert("Please Enter First Name");
			  document.signpetition.firstname.focus();
			  return false;
		}
		if(mytrim(document.signpetition.lastname.value)=="" || mytrim(document.signpetition.lastname.value)=="Last Name")
		{
			  alert("Please Enter Last Name");
			  document.signpetition.lastname.focus();
			  return false;
		}
		
		if(mytrim(document.signpetition.state.value)=="")
		{
			  alert("Please Select State/Province");
			  document.signpetition.state.focus();
			  return false;
		}
		if(mytrim(document.signpetition.city.value)=="" || mytrim(document.signpetition.city.value)=="City")
		{
			  alert("Please Enter City");
			  document.signpetition.city.focus();
			  return false;
		}
		
		if(mytrim(document.signpetition.zip.value)=="" || mytrim(document.signpetition.zip.value)=="Zip Code")
		{
			  alert("Please Enter Zip Code");
			  document.signpetition.zip.focus();
			  return false;
		}
		if (!IsNumeric(document.signpetition.zip.value))
		{
			alert("Please Enter Valid Zip");
			document.signpetition.zip.focus();
			return false;
		}
		if (document.signpetition.zip.value.length<5)
		{
			alert("Please Enter Valid Zip");
			document.signpetition.zip.focus();
			return false;
		}
		var chkFilter=/\w{1,}[@][\w\-]{1,}([.]([\w\-]{1,})){1,3}$/;
		if (!(chkFilter.test(document.signpetition.email.value))) {
			  alert("Please Enter a Valid Email Address");
			  document.signpetition.email.focus();
			  return false;
		}
		
		if (mytrim(document.signpetition.comments.value)=="")
		{
			alert("Please Enter Comments Below 1000 Words.");
			document.signpetition.comments.focus();
			return false;
			
		}
		if (document.signpetition.comments.value.length>1000)
			{
				alert("Please Enter Comments Below 1000 Words.");
				document.signpetition.comments.focus();
				return false;
			}
}
function emptyvalue(x) {
 if(x.value=="First Name" || x.value=="Last Name" || x.value=="Street Address" || x.value=="City" || x.value=="Zip Code" ||  x.value=="Email Address" || x.value=="Cell Phone" ||  x.value=="Your Email" || x.value=="Friends Email" || x.value=="Subject" || x.value=="Your First Name" || x.value=="Your Last Name") {
  pretext=x.value;
  x.style.color='#000000';
  x.value="";
 } else {
  switch(x.name) {
   case "firstname":
    pretext="First Name";
    break;
   case "lastname":
    pretext="Last Name";
    break;
   case "address":
    pretext="Street Address";
    break;
   case "city":
    pretext="City";
    break;
   case "zip":
    pretext="Zip Code";
    break;	
   case "email":
    pretext="Email Address";
    break;
   case "phone":
    pretext="Cell Phone";
    break;
	case "yourtellemail":
    pretext="Your Email";
    break;
   case "frndtellemail":
    pretext="Friends Email";
    break;
	case "subject":
    pretext="Subject";
    break;
	case "faxlast":
    pretext="Your Last Name";
    break;
	case "faxname":
    pretext="Your First Name";
    break;
   default: pretext="";
  }
 }
}

function fillvalue(x) {
 if (x.value=="") {
  x.style.color = '#000000';
  x.value = pretext;
 }
}
function ValidateEmailSignUp()
{
	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)=="")
	{
		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 Code");
		document.IBNSubscribe.cf_4__sValue.focus();
		return false;
	}
	if (document.IBNSubscribe.cf_4__sValue.value.length<5)
	{
		alert("Please Enter Valid Zip Code");
		document.IBNSubscribe.cf_4__sValue.focus();
		return false;
	}
}
function showTellAFriend(youremail,friendemail)
{
		var chkFilter=/\w{1,}[@][\w\-]{1,}([.]([\w\-]{1,})){1,3}$/;
	if (!(chkFilter.test(youremail))) {
		  alert("Please Enter a Valid Email Address");
		  
		  return false;
	}
	if (!(chkFilter.test(friendemail))) {
		  alert("Please Enter a Valid Email Address");
		  //document.IBNSubscribe.cf_4__sValue.focus();
		  return false;
	}
		
		var tempURL;
		//alert("Hello, " + studentName + "! So nice to meet you.") /
		tempURL="http://www.c17foramerica.com/tellafriend.asp?email=" + youremail + "&friend1=" + friendemail +"";
		GB_showCenter('', tempURL,500,470);
}
function ValidateSendToFriend()
	{
		var ret=true;
		if (mytrim(document.frmsendtofriend.friend1.value)!="")
		{
			if (!chkemail(document.frmsendtofriend.friend1))
			{
				alert("Please Enter Valid Email Address");
				document.frmsendtofriend.friend1.focus();
				return false;
			}
			ret=false;
		 }
		 if (mytrim(document.frmsendtofriend.friend2.value)!="")
		{
			if (!chkemail(document.frmsendtofriend.friend2))
			{
				alert("Please Enter Valid Email Address");
				document.frmsendtofriend.friend2.focus();
				return false;
			}
			ret=false;
		 }
		 //if (mytrim(document.frmsendtofriend.friend3.value)!="")
//		{
//			if (!chkemail(document.frmsendtofriend.friend3))
//			{
//				alert("Please Enter Valid Email Address");
//				document.frmsendtofriend.friend3.focus();
//				return false;
//			}
//			ret=false;
//		 }
		//	 if (mytrim(document.frmsendtofriend.friend4.value)!="")
//		{
//			if (!chkemail(document.frmsendtofriend.friend4))
//			{
//				alert("Please enter valid Email Address");
//				document.frmsendtofriend.friend4.focus();
//				return false;
//			}
//			ret=false;
//		 }
//		  if (mytrim(document.frmsendtofriend.friend5.value)!="")
//		{
//			if (!chkemail(document.frmsendtofriend.friend5))
//			{
//				alert("Please enter valid Email Address");
//				document.frmsendtofriend.friend5.focus();
//				return false;
//			}
//			ret=false;
//		 }
		
		if(ret==true)
		{
				alert("Please Enter Atleast One Email Address");
				document.frmsendtofriend.friend1.focus();
				return false;
		}
		else
		{
			 if (mytrim(document.frmsendtofriend.email.value)!="")
			{
				if (!chkemail(document.frmsendtofriend.email))
				{
					alert("Please Enter Valid Email Address");
					document.frmsendtofriend.email.focus();
					return false;
				}
			}
			else
			{
					alert("Please Enter Your Email Address");
					document.frmsendtofriend.email.focus();
					return false;
			}
		}
		
	
		
	}
function showstoryform(state)
{
		if (mytrim(state)=="")
	{
		alert("Please Select Your State");
		
		return false;
	}
		var tempURL;
		//alert("Hello, " + studentName + "! So nice to meet you.") /
		tempURL="http://www.c17foramerica.com/sharestory.asp?state=" + state + "";
		GB_showCenter('', tempURL,500,470);
}	
function validateShareStory()
{
	if(mytrim(document.sharestory.firstname.value)=="" || mytrim(document.sharestory.firstname.value)=="First Name")
		{
			  alert("Please Enter First Name");
			  document.sharestory.firstname.focus();
			  return false;
		}
		if(mytrim(document.sharestory.lastname.value)=="" || mytrim(document.sharestory.lastname.value)=="Last Name")
		{
			  alert("Please Enter Last Name");
			  document.sharestory.lastname.focus();
			  return false;
		}
		
		if(mytrim(document.sharestory.state.value)=="")
		{
			  alert("Please Select State/Province");
			  document.sharestory.state.focus();
			  return false;
		}
		if(mytrim(document.sharestory.city.value)=="" || mytrim(document.sharestory.city.value)=="City")
		{
			  alert("Please Enter City");
			  document.sharestory.city.focus();
			  return false;
		}
		
		if(mytrim(document.sharestory.zip.value)=="" || mytrim(document.sharestory.zip.value)=="Zip Code")
		{
			  alert("Please Enter Zip Code");
			  document.sharestory.zip.focus();
			  return false;
		}
		if (!IsNumeric(document.sharestory.zip.value))
		{
			alert("Please Enter Valid Zip");
			document.sharestory.zip.focus();
			return false;
		}
		if (document.sharestory.zip.value.length<5)
		{
			alert("Please Enter Valid Zip");
			document.sharestory.zip.focus();
			return false;
		}
		var chkFilter=/\w{1,}[@][\w\-]{1,}([.]([\w\-]{1,})){1,3}$/;
		if (!(chkFilter.test(document.sharestory.email.value))) {
			  alert("Please Enter a Valid Email Address");
			  document.sharestory.email.focus();
			  return false;
		}
		
		if (mytrim(document.sharestory.comments.value)=="")
		{
			alert("Please Enter Share Your C-17 Story Below 2500 Words.");
			document.sharestory.comments.focus();
			return false;
			
		}
		if (document.sharestory.comments.value.length>2500)
			{
				alert("Please Enter Share Your C-17 Story Below 2500 Words.");
				document.sharestory.comments.focus();
				return false;
			}
}
function showcongressional(zip)
{
	if(mytrim(zip)=="" || mytrim(zip)=="Zip Code")
		{
			  alert("Please Enter Zip Code");
			  //document.sharestory.zip.focus();
			  return false;
		}
		if (!IsNumeric(zip))
		{
			alert("Please Enter Valid Zip");
			//document.sharestory.zip.focus();
			return false;
		}
		tempURL="http://www.c17foramerica.com/congressional.asp?zip=" + zip + "";
		GB_showCenter('', tempURL,800,700);
		
}
function showFax(firstname,lastname)
{
		if(mytrim(firstname)=="" || mytrim(firstname)=="Your First Name")
		{
			  alert("Please Enter Your First Name");
			  //document.faxcongress.firstname.focus();
			  return false;
		}
		if(mytrim(lastname)=="" || mytrim(lastname)=="Your Last Name")
		{
			  alert("Please Enter Your Last Name");
			//  document.faxcongress.lastname.focus();
			  return false;
		}
		
		
		var tempURL;
		//alert("Hello, " + studentName + "! So nice to meet you.") /
		tempURL="http://www.c17foramerica.com/faxcongress.asp?firstname=" + firstname + "&lastname=" + lastname +"";
		GB_showCenter('', tempURL,750,490);
}
function validateFaxCongress()
{
		if(mytrim(document.faxcongress.firstname.value)=="" || mytrim(document.faxcongress.firstname.value)=="First Name")
		{
			  alert("Please Enter First Name");
			  document.faxcongress.firstname.focus();
			  return false;
		}
		if(mytrim(document.faxcongress.lastname.value)=="" || mytrim(document.faxcongress.lastname.value)=="Last Name")
		{
			  alert("Please Enter Last Name");
			  document.faxcongress.lastname.focus();
			  return false;
		}
		
		if(mytrim(document.faxcongress.state.value)=="")
		{
			  alert("Please Select State/Province");
			  document.faxcongress.state.focus();
			  return false;
		}
		if(mytrim(document.faxcongress.city.value)=="" || mytrim(document.faxcongress.city.value)=="City")
		{
			  alert("Please Enter City");
			  document.faxcongress.city.focus();
			  return false;
		}
		
		if(mytrim(document.faxcongress.zip.value)=="" || mytrim(document.faxcongress.zip.value)=="Zip Code")
		{
			  alert("Please Enter Zip Code");
			  document.faxcongress.zip.focus();
			  return false;
		}
		if (!IsNumeric(document.faxcongress.zip.value))
		{
			alert("Please Enter Valid Zip");
			document.faxcongress.zip.focus();
			return false;
		}
		if (document.faxcongress.zip.value.length<5)
		{
			alert("Please Enter Valid Zip");
			document.faxcongress.zip.focus();
			return false;
		}
		var chkFilter=/\w{1,}[@][\w\-]{1,}([.]([\w\-]{1,})){1,3}$/;
		if (!(chkFilter.test(document.faxcongress.email.value))) {
			  alert("Please Enter a Valid Email Address");
			  document.faxcongress.email.focus();
			  return false;
		}
		
		if (!mytrim(document.faxcongress.comments.value)=="")
		{
			if (document.faxcongress.comments.value.length>1000)
			{
				alert("Please Enter Comments Below 1000 Words.");
				document.faxcongress.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.state.value)=="")
		{
			  alert("Please Select State/Province");
			  document.contact.state.focus();
			  return false;
		}
		if(mytrim(document.contact.city.value)=="" || mytrim(document.contact.city.value)=="City")
		{
			  alert("Please Enter City");
			  document.contact.city.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.subject.value)=="" || mytrim(document.contact.subject.value)=="Subject")
		{
			  alert("Please Enter Subject");
			  document.contact.subject.focus();
			  return false;
		}
		
		if (mytrim(document.contact.message.value)=="")
		{
			alert("Please Enter Message Below 2000 Words.");
			document.contact.message.focus();
			return false;
			
		}
		
		if (document.contact.message.value.length>2000)
			{
				alert("Please Enter Message Below 2000 Words.");
				document.contact.message.focus();
				return false;
			}
}