function HideContent(d) {
document.getElementById(d).style.display = "none";
}
function ShowContent(d) {
document.getElementById(d).style.display = "block";
}
function ReverseDisplay(d) {
if(document.getElementById(d).style.display == "none") { document.getElementById(d).style.display = "block"; }
else { document.getElementById(d).style.display = "none"; }
}

function getQuerystring(key, default_)
{
  if (default_==null) default_=""; 
  key = key.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regex = new RegExp("[\\?&]"+key+"=([^&#]*)");
  var qs = regex.exec(window.location.href);
  if(qs == null)
    return default_;
  else
    return qs[1];
} 


var strText = getQuerystring('toemail').replace("%20", " ");
var str2Text = strText.replace("%20", " ");
var str3Text = str2Text.replace("%20", " ");
var str4Text = str3Text.replace("%20", " ");


function feedbackEmail()
{
//var a =location.search; 
//var email = (a.substring(a.indexOf("=")+1,a.length));
//var fname = (email.substring(email.indexOf("=")+1,email.length));

document.getElementById("LabelTo").innerHTML=str4Text
document.getElementById("tocode").value=getQuerystring('tocode');

//document.getElementById("fname").value=getQuerystring('fname');
}

function validateForm(obj)
{

var phonenumber = document.getElementById("phone").value;
var numberstripped = phonenumber.replace(/[\(\)\.\-\ ]/g, '');
var email = document.getElementById("email").value;
var emailFilter=/^.+@.+\..{2,3,4,6}$/;
	if (isNaN(parseInt(numberstripped))) {
	alert('The phone number contains illegal characters');
	document.getElementById("phone").value="";
	return ;
	 }

	else if (!(emailFilter.test(email))) { 
	alert("Please enter a valid email address.\n");
	document.getElementById("email").value="";
	return ;
	}
}

function termwin()
{
	var win = window.open ("terms_popup.html", "TermsWindow","menubar=0,resizable=1,scrollbars=1,width=770,height=600");
	
}

function privacywin()
{
	window.open ("privacy_compensation_popup.html", "PrivacyWindow","menubar=0,resizable=1,scrollbars=1,width=770,height=600");
}
function marketupdate()
{
	window.open ("marketupdate_popup.html", "MarketUpdateWindow","menubar=0,resizable=1,scrollbars=1,width=770,height=600");
}
function webquote()
{
	window.open ("https://aicagentweb.iaicc.com/webquote", "WebQuoteLogin","menubar=0,resizable=1,scrollbars=1,width=770,height=600");
	
}
function brainshark()
{
	window.open ("http://www.brainshark.com/brainshark/vu/GuestBook.asp?referer=vu&pi=499682869&sid=35370850&sky=723C432087374279A2D67C554F0C402C&uid=0", "BrainSharkLogin","menubar=0,resizable=1,scrollbars=1,width=770,height=600");
	
}

//Function added as on 06/02/2009
function chkLogin()
{
	if (document.getElementById("username").value=="") 
	{
		alert("Field cannot be blank!");
		document.getElementById("username").focus();
		return false;}
	if (document.getElementById("password").value=="") 
	{
		alert("Password is required!");
		document.getElementById("password").focus();
		return false;}
	else
	{	
		return true;}
}

function agentApplRequest()
{

	var themessage = "You are required to complete the following fields: ";
	if (document.agree.fname.value=="") {
		themessage = themessage + " - First Name";
		alert(themessage);
		document.agree.fname.focus();
		return false;
		}
	if (document.agree.lname.value=="") {
		themessage = themessage + " -  Last Name";
		alert(themessage);
		document.agree.lname.focus();
		return false;
		}
	if (document.agree.agencyName.value=="") {
		themessage = themessage + " -  Agency Name";
		alert(themessage);
		document.agree.agencyName.focus();
		return false;
		}
	if (document.agree.role.selectedIndex==0) {
		themessage = themessage + " -  Role";
		alert(themessage);
		document.agree.role.focus();
		return false;
		}
	if (document.agree.sales_rep.selectedIndex==0) {
		themessage = themessage + " -  Sales Rep";
		alert(themessage);
		document.agree.sales_rep.focus();
		return false;
		}
	if(document.agree.add1.value=="") {
		themessage = themessage + " -  Address";
		alert(themessage);
		document.agree.add1.focus();
		return false;
		}
	if (document.agree.state.selectedIndex==0) {
		themessage = themessage + " -  State";
		alert(themessage);
		document.agree.state.focus();
		return false;
		}
	if (document.agree.city.value=="") {
		themessage = themessage + " -  City";
		alert(themessage);
		document.agree.city.focus();
		return false;
		}
	if (document.agree.pcode.value=="") {
		themessage = themessage + " -  Postal/Zip Code";
		alert(themessage);
		document.agree.pcode.focus();
		return false;
		}
	if (document.agree.phone.value=="") {
		themessage = themessage + " -  Phone";
		alert(themessage);
		document.agree.phone.focus();
		return false;
		}
	if (document.agree.email.value=="") {
		themessage = themessage + " -  Email";
		alert(themessage);
		document.agree.email.focus();
		return false;
		}
	if(!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(agree.email.value)))
	{
		alert("Invalid E-mail Address! Please re-enter.")
		return (false);
		}
	if ((document.agree.IAIC=="checkbox")&&(document.agree.IAIC.checked=false)) {
		themessage = themessage + " -  IAIC";
		document.agree.IAIC.focus();
		return false;
		}
	if (themessage == "You are required to complete the following fields: ") {
		window.location.href="confirmation.html";
		}
		else {
		alert(themessage);
		return false;
	   }
}

//for include header and footer by vikram sohal on 10feb
document.include = function (url) {
 if ('undefined' == typeof(url)) return false;
 var p,rnd;
 if (document.all){
   // For IE, create an ActiveX Object instance 
   p = new ActiveXObject("Microsoft.XMLHTTP");
 } 
 else {
   // For mozilla, create an instance of XMLHttpRequest.
   p = new XMLHttpRequest();
 }
 // Prevent browsers from caching the included page
 // by appending a random  number
 rnd = Math.random().toString().substring(2);
 url = url.indexOf('?')>-1 ? url+'&rnd='+rnd : url+'?rnd='+rnd;
 // Open the url and write out the response
 p.open("GET",url,false);
 p.send(null);
 document.write( p.responseText );
 
}

//select ooffice js
function selectOffice(){
	if(document.getElementById('selectMap').selectedIndex==0){
	window.location.href="locate_representative.html";
	}
	
	else if(document.getElementById('selectMap').selectedIndex==1){
	window.location.href="locateus.html";
	}
	
	else if(document.getElementById('selectMap').selectedIndex==2){
	window.location.href="atlanta.html";
	}
	
	else if(document.getElementById('selectMap').selectedIndex==3){
	window.location.href="chicago.html";
	}

	else if(document.getElementById('selectMap').selectedIndex==4){
	window.location.href="jerseycity.html";
	}
	
	else if(document.getElementById('selectMap').selectedIndex==5){
	window.location.href="houston.html";
	}

	else if(document.getElementById('selectMap').selectedIndex==6){
	window.location.href="northeast.html";
	}
	
	else if(document.getElementById('selectMap').selectedIndex==7){
	window.location.href="Philadelphia.html";
	}
	
	else if(document.getElementById('selectMap').selectedIndex==8){
	window.location.href="sanfrancisco.html";
	}
	
	else if(document.getElementById('selectMap').selectedIndex==9){
	window.location.href="southCoastMetro.html";
	}
	else if(document.getElementById('selectMap').selectedIndex==10){
	window.location.href="cary.html";
	}
	else if(document.getElementById('selectMap').selectedIndex==11){
	window.location.href="fresnoServiceCenter.html";
	}
}
