// JavaScript Document
var win = null;
function NewWindow(url,name,w,h,scroll){
  LeftPosition = (screen.width) ? (screen.width-w)/2 : 0; // this
  TopPosition = (screen.height) ? (screen.height-h)/2 : 0; // and this is for centering the popup on your screen
  settings = 'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable=false'

win = window.open(url,name,settings)
}

var ban=9;
var randomnumber=Math.floor(Math.random()*ban+1);
bannerscript = '<img src="images/testimonials/testimonial0'+randomnumber+'.gif" width="158" height="174" border="0" />';

var recallTime = 0;

function recallScript( time ) {
  recallTime += time;
  var str = "";
  str += "<";
  str += "script";
  str += " language=";
  str += "\"javascript\"";
  str += " type=";
  str += "\"text/javascript\"";
  str += " src=";
  str += "\"direct.jsp";
  str += "?";
  str += "ToPage=";
  str += "Recall";
  str += "&";
  str += "Time=";
  str += "T";
  str += recallTime;
  str += "\"";
  str += ">";
  str += "<";
  str += "/";
  str += "script";
  str += ">";
  return str;
}

var accountName = "";
var userName = "";

function recallLogin() {
  if ( accountName != "" && userName != "" ) {
    document.getElementById( "account" ).value = accountName;
    document.getElementById( "userid" ).value = userName;
    document.getElementById( "password" ).focus();
  }
}

function validateLogin() {
  var ret = true;
  var account = document.getElementById( "account" ).value;
  var userid = document.getElementById( "userid" ).value;
  var password = document.getElementById( "password" ).value;
  if ( account != "" && userid != "" && password != "" ) {
    document.getElementById( "_APValues" ).value = "0falsefalse0Noneagentsecure0" + account + "" + userid + "" + password + "truetrue00truetrue000000000000";
  } else {
    alert( "Please enter a value in all fields!" );
    ret = false;
  }
  return ret;
}

function forgotLogin() {
  var account = document.getElementById( "account" ).value;
  var userid = document.getElementById( "userid" ).value;
  var url = "display.jsp?FromPage=ASLogin&ToPage=ASForgotMyPassword&acct=" + account + "&user=" + userid;
  window.location.href = url;
}

function now() {
  return (new Date()).valueOf();
}

var ads = 
  [
    "<a href=\"javascript:NewWindow('http://www.netquote.com/agentsecure','netquote',1040,622,'yes');\"><img border=\"0\" src=\"/brand/images/NQButtonAS2.gif\"></a>"
  ];
var adIndex = 0;

function insertAds() {
  for ( var i = 0; i < ads.length; i++ ) {
    document.write( "<div id=\"ad" + i + "\" align=\"center\"" + ( i != 0 ? " style=\"display:none;\"" : "" ) + ">" + ads[ i ] + "</div>" );
  }
  window.setInterval( "toggleAds();", 10000 );
}

function toggleAds() {
  var ad = document.getElementById( "ad" + adIndex );
  ad.style.display = "none";
  adIndex++;
  if ( adIndex == ads.length ) adIndex = 0;
  ad = document.getElementById( "ad" + adIndex );
  ad.style.display = "";
}

function liveChat() {
  document.write( '<br/><div id="ciSdrB" style="z-index:100;position:absolute"></div><div id="scSdrB" style="display:inline"></div><div id="sdSdrB" style="display:none"></div><script type="text/javascript">var seSdrB=document.createElement("script");seSdrB.type="text/javascript";var seSdrBs=(location.protocol.indexOf("https")==0?"https":"http")+"://image.providesupport.com/js/insurezone/safe-textlink.js?ps_h=SdrB\u0026ps_t="+new Date().getTime()+"\u0026online-link-html=Live%20Chat%20Online\u0026offline-link-html=Live%20Chat%20Offline";seSdrB.src=seSdrBs;document.getElementById("sdSdrB").appendChild(seSdrB);</script>' );
}
