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 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_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
}

function dobuy() {
//alert("in the dobuy function!");
document.addtocartorbuy.buyoradd.value = "buy";
document.addtocartorbuy.submit();
}

function docart() {
//alert("in the docart function!");
document.addtocartorbuy.buyoradd.value = "addtocart";
document.addtocartorbuy.submit();
}

function ValDirectPay() {
//alert("in the ValDirectPay function!");
FirstName = document.DPForm.DP_FirstName.value;
//LastName = document.DPForm.DP_LastName.value;
BankName = document.DPForm.DP_BankName.value;
BankRouteNum = document.DPForm.DP_BankRouteNum.value;
CheckAcctNumber = document.DPForm.DP_CheckAcctNumber.value;
CheckAcctNumber2 = document.DPForm.DP_CheckAcctNumber2.value;
DP_AccountFunds = document.DPForm.DP_AccountFunds.value;

if (FirstName == ""){
alert("Please fill out the Name On Account field.");
document.DPForm.DP_FirstName.focus();
return false;	
}
//if (LastName == ""){
//alert("Please fill out the Last Name field.");
//document.DPForm.DP_LastName.focus();
//return false;	
//}
if (BankName == ""){
alert("Please fill out the Bank Name field.");
document.DPForm.DP_BankName.focus();
return false;	
}
if (BankRouteNum == ""){
alert("Please fill out the Bank Routing Number field.");
document.DPForm.DP_BankRouteNum.focus();
return false;	
}
if (CheckAcctNumber == ""){
alert("Please fill out the Checking Account Number field.");
document.DPForm.DP_CheckAcctNumber.focus();
return false;	
}
if (CheckAcctNumber2 == ""){
alert("Please fill out the Verify Checking Account Number field.");
document.DPForm.DP_CheckAcctNumber2.focus();
return false;	
}
if (CheckAcctNumber == CheckAcctNumber2){
}
else{
alert("The Checking Account Number fields must match.");
document.DPForm.DP_CheckAcctNumber.focus();
return false;	
}

if (DP_AccountFunds == ""){
alert("Please supply an initial account funding amount.");
document.DPForm.DP_AccountFunds.focus();
return false;	
}


var answer = confirm("Attention:\n\nBy submitting the following information, you are agreeing for your account to be charged in thew amount of $" + DP_AccountFunds + ".")
if (answer)
document.DPForm.submit()
else
return false;
}


function CityVal(){
CityValue = document.LocationForm.frmlocationval.options[document.LocationForm.frmlocationval.selectedIndex].value;
//alert ("The value of CityValue is: " + CityValue);
if ((CityValue == "0") || (CityValue == "NONE")) {
alert ("You may only choose a city or group of cities from the drop down.\n(If you wish to search by entire state, please use the State link at the left).");
return false;
}
else {
document.LocationForm.submit();
}
}

function StateVal(){
iNumSelected = 0
for (iTmp=0; iTmp<document.StateForm.Company_State.options.length; iTmp++) {
 if (document.StateForm.Company_State.options[iTmp].selected) iNumSelected++
}
if (iNumSelected==0) {
	alert("You must choose at least one state from the list.")
	//alert ("The value of iNumSelected is: " + iNumSelected);
	return false;
}
else {
//alert ("The value of iNumSelected is: " + iNumSelected);
//alert ("YOU CHOSE A VALUE - SUBMITTING FORM...");
document.StateForm.submit();
}
}

function Check25000(){
NumLeads = document.ProcForm.FrmLeadsTotal.value;
//alert ("The value of NumLeads is: " + NumLeads);
if (NumLeads > 25000) {
alert ("You may only purchase up to 25,000 leads at a time. Please delete some entries until your total number of leads is 25,000 or less. \nIf you are intersted in downloading more than 25,000 leads at a time, please call 318-590-2424, or 318-590-2426 and ask for James or Andy.");
//return false;
}
else {
document.ProcForm.submit();
}
}

function centerpopup(url,popupwidth,popupheight) {
//alert('The url is ' + url );
    var url = url;
    var popup_width=popupwidth;
    var popup_height=popupheight;
    var screen_width=window.screen.width;
    var screen_height=window.screen.height;
    var popup_left=Math.round((screen_width-popup_width)/2);
    var popup_top=Math.round((screen_height-popup_height)/2)  ;   
    var popupwindow=window.open(url,"NewWindow","height="+popup_height+",width="+popup_width+",resizable=yes,left="+popup_left+",top="+popup_top+",scrollbars=yes,");
}