   var http_request = false;
   
   function unloadImage(){
        document.getElementById('myloadingimage').innerHTML = "";
   }
   function loadImage(){
        document.getElementById('myloadingimage').innerHTML = "<table cellspacing=2 cellpadding=2 border=0 align=center><tr><td height=20px></td></tr><tr><td><img src='../contents/gears.gif' alt='Loading Please Wait' border=0></td></tr></table>";
   }
   
   function makeRequest(url, parameters) {
      document.getElementById('myspan').innerHTML = "";  
      loadImage();
      http_request = false;
      if (window.XMLHttpRequest) { 
         http_request = new XMLHttpRequest();
         if (http_request.overrideMimeType) {
            http_request.overrideMimeType('text/html');
         }
      } else if (window.ActiveXObject) { // IE
         try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
            try {
               http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
         }
      }
      if (!http_request) {
         alert('Cannot create XMLHTTP instance');
         return false;
      }
      http_request.onreadystatechange = alertContents;
      http_request.open('GET', url + parameters, true);
      http_request.send(null);
   }

   function alertContents() {
      if (http_request.readyState == 4) {
         if (http_request.status == 200) {
            result = http_request.responseText;
            document.getElementById('myspan').innerHTML = result;  
            unloadImage();          
         } else {
            document.location.href='/ReportOrder.aspx';
         }
      }
   }
   
   function getReportOrder(fileName){
      if(ValidateReportOrderForm() == false) return;
      var today = new Date();
      var trapAjax = today.getDate() +  "" + (today.getMonth() + 1) + "" + today.getFullYear() + "" + today.getHours() + ""+today.getMinutes() + "" + today.getSeconds();
      var getstr = "?trapAjax=" + trapAjax;
      getstr += "&Address="+document.getElementById("Address").value;
      getstr += "&City="+document.getElementById("City").value;
      getstr += "&State="+document.getElementById("State").value;
      getstr += "&Zip="+document.getElementById("Zip").value;
      getstr += "&PromotionalCode="+document.getElementById("PromotionalCode").value;
      getstr += "&EstPrice="+document.getElementById("EstPrice").value;
      getstr += "&ReportType="+document.getElementById("ReportType").value;
      getstr += "&ReportText="+document.getElementById("ReportType").options[document.getElementById("ReportType").selectedIndex].text;
      
      //alert(getstr);
      //makeRequest(fileName, getstr);
      document.location.href = fileName + getstr;
   }
   
   function getReportOrder(fileName, domainID){
        if(ValidateReportOrderForm() == false) return false;
   }
   
   
   
   //displayItem("idxp")
   
   function AjaxResellerSignIn(){
        if(displayItem("id")!=null){
            var email = trimString(TemplateLoginForm.HomeSmartEmail.value);
            var password = trimString(TemplateLoginForm.HomeSmartPassword.value);
            
        email = stripHtml(email);
        password = stripHtml(password);
        if(email == "")
        {
            TemplateLoginForm.HomeSmartEmail.value = email;
            TemplateLoginForm.HomeSmartPassword.value = password;
            TemplateLoginForm.HomeSmartEmail.focus();
            alert("Please enter a valid value");
            return false;
        }
        if(password == "")
        {
            TemplateLoginForm.HomeSmartEmail.value = email;
            TemplateLoginForm.HomeSmartPassword.value = password;
            TemplateLoginForm.HomeSmartPassword.focus();
            alert("Please enter a valid value");
            return false;
        }
            
            document.getElementById("btn_hsr_toplogin").disabled=true; 
            TemplateLoginForm.HomeSmartEmail.value = "";
            TemplateLoginForm.HomeSmartPassword.value = "";
            //var today = new Date();
            //var trapAjax = today.getDate() +  "" + (today.getMonth() + 1) + "" + today.getFullYear() + "" + today.getHours() + ""+today.getMinutes() + "" + today.getSeconds();
            //var getstr = "?trapAjax=" + trapAjax+
            
            //"&HomeSmartTopExcept=1"+
            //"&HomeSmartPassword="+password+
            //"&HomeSmartEmail="+email+
            //"&HomeSmartResellerID="+displayItem("id");
            //if(document.getElementById("Address") != null){
            //    getstr += "&HomeSmartAddress="+ document.getElementById("Address").value;
            //    getstr += "&HomeSmartCity=" + document.getElementById("City").value;
            //    getstr += "&HomeSmartState=" + document.getElementById("State").value;
            //    getstr += "&HomeSmartZip=" + document.getElementById("Zip").value;
                //getstr += "&HomeSmartPromo=" + document.getElementById("PromotionalCode").value;
            //    getstr += "&HomeSmartEstPrice=" + document.getElementById("EstPrice").value;
            //    if(document.getElementById("ReportType") != null){
            //        getstr += "&HomeSmartReportType=" + document.getElementById("ReportType").value;
            //        getstr += "&HomeSmartReportText=" + document.getElementById("ReportType").options[document.getElementById("ReportType").selectedIndex].text;
            //    }
            //}
            
            //document.location.href="../myaccount/tempreportredirect.aspx"+ getstr;
            
       AdditionalForm.HomeSmartPassword.value = password;
       AdditionalForm.HomeSmartEmail.value = email;
       AdditionalForm.HomeSmartResellerID=displayItem("id");
       if(document.getElementById("Address") != null)
       {
            AdditionalForm.HomeSmartAddress.value = document.getElementById("Address").value;
            AdditionalForm.HomeSmartCity.value = document.getElementById("City").value;
            AdditionalForm.HomeSmartState.value = document.getElementById("State").value;
            AdditionalForm.HomeSmartZip.value = document.getElementById("Zip").value;
            AdditionalForm.HomeSmartPromo.value = "";
            AdditionalForm.HomeSmartEstPrice.value = document.getElementById("EstPrice").value;
            if(document.getElementById("ReportType") != null)
            {
                AdditionalForm.HomeSmartReportType.value = document.getElementById("ReportType").value;
                AdditionalForm.HomeSmartReportText.value = document.getElementById("ReportType").options[document.getElementById("ReportType").selectedIndex].text;
            }
       }
       
       AdditionalForm.submit();
            
            
            
            
            
           }
   }
   
   function AjaxSignIn(){
        var email = trimString(TemplateLoginForm.HomeSmartEmail1.value);
        var password = trimString(TemplateLoginForm.HomeSmartPassword1.value);
        email = stripHtml(email);
        password = stripHtml(password);
        if(email == "")
        {
            TemplateLoginForm.HomeSmartEmail1.value = email;
            TemplateLoginForm.HomeSmartPassword1.value = password;
            TemplateLoginForm.HomeSmartEmail1.focus();
            alert("Please enter a valid value");
            return false;
        }
        if(password == "")
        {
            TemplateLoginForm.HomeSmartEmail1.value = email;
            TemplateLoginForm.HomeSmartPassword1.value = password;
            TemplateLoginForm.HomeSmartPassword1.focus();
            alert("Please enter a valid value");
            return false;
        }
        document.getElementById("btn_hsr_toplogin").disabled=true; 
        TemplateLoginForm.HomeSmartEmail1.value = "";
        TemplateLoginForm.HomeSmartPassword1.value = "";
        
        //../myaccount/tempreportredirect.aspx
      //  var today = new Date();
      //var trapAjax = today.getDate() +  "" + (today.getMonth() + 1) + "" + today.getFullYear() + "" + today.getHours() + ""+today.getMinutes() + "" + today.getSeconds();
      //var getstr = "?trapAjax=" + trapAjax+
      //      "&payback=1&"+
      //      "HomeSmartTopExcept=1"+
      //      "&HomeSmartPassword="+password+
      //      "&HomeSmartEmail="+email;
      //      if(document.getElementById("Address") != null){
      //          getstr += "&HomeSmartAddress="+ document.getElementById("Address").value;
      //          getstr += "&HomeSmartCity=" + document.getElementById("City").value;
      //          getstr += "&HomeSmartState=" + document.getElementById("State").value;
      //          getstr += "&HomeSmartZip=" + document.getElementById("Zip").value;
      //          getstr += "&HomeSmartPromo=" + document.getElementById("PromotionalCode").value;
      //          getstr += "&HomeSmartEstPrice=" + document.getElementById("EstPrice").value;
      //          if(document.getElementById("ReportType") != null){
       //             getstr += "&HomeSmartReportType=" + document.getElementById("ReportType").value;
       //             getstr += "&HomeSmartReportText=" + document.getElementById("ReportType").options[document.getElementById("ReportType").selectedIndex].text;
       //         }
       //     }
       //     document.location.href="../myaccount/tempreportredirect.aspx"+ getstr;
       AdditionalForm.HomeSmartPassword.value = password;
       AdditionalForm.HomeSmartEmail.value = email;
       if(document.getElementById("Address") != null)
       {
            AdditionalForm.HomeSmartAddress.value = document.getElementById("Address").value;
            AdditionalForm.HomeSmartCity.value = document.getElementById("City").value;
            AdditionalForm.HomeSmartState.value = document.getElementById("State").value;
            AdditionalForm.HomeSmartZip.value = document.getElementById("Zip").value;
            AdditionalForm.HomeSmartPromo.value = document.getElementById("PromotionalCode").value;
            AdditionalForm.HomeSmartEstPrice.value = document.getElementById("EstPrice").value;
            if(document.getElementById("ReportType") != null)
            {
                AdditionalForm.HomeSmartReportType.value = document.getElementById("ReportType").value;
                AdditionalForm.HomeSmartReportText.value = document.getElementById("ReportType").options[document.getElementById("ReportType").selectedIndex].text;
            }
       }
       
       AdditionalForm.submit();
   }
   
   
      function AjaxSignInNew(){
        var email = stripHtml(trimString(TemplateLoginForm.HomeSmartEmail.value));
        var password = stripHtml(trimString(TemplateLoginForm.HomeSmartPassword.value));
        document.getElementById("btn_hsr_toplogin").disabled=true; 
        TemplateLoginForm.HomeSmartEmail.value = "";
        TemplateLoginForm.HomeSmartPassword.value = "";
        
        //../myaccount/tempreportredirect.aspx
      //var today = new Date();
      //var trapAjax = today.getDate() +  "" + (today.getMonth() + 1) + "" + today.getFullYear() + "" + today.getHours() + ""+today.getMinutes() + "" + today.getSeconds();
      //var getstr = "?trapAjax=" + trapAjax+
        
      //      "&payback=1&"+
      //      "HomeSmartTopExcept=1"+
      //      "&HomeSmartPassword="+password+
      //      "&HomeSmartEmail="+email;
      //      if(document.getElementById("Address") != null){
      //          getstr += "&HomeSmartAddress="+ document.getElementById("Address").value;
      //          getstr += "&HomeSmartCity=" + document.getElementById("City").value;
      //          getstr += "&HomeSmartState=" + document.getElementById("State").value;
      //          getstr += "&HomeSmartZip=" + document.getElementById("Zip").value;
      //          getstr += "&HomeSmartPromo=" + document.getElementById("PromotionalCode").value;
      //          getstr += "&HomeSmartEstPrice=" + document.getElementById("EstPrice").value;
      //          if(document.getElementById("ReportType") != null){
      //              getstr += "&HomeSmartReportType=" + document.getElementById("ReportType").value;
      //              getstr += "&HomeSmartReportText=" + document.getElementById("ReportType").options[document.getElementById("ReportType").selectedIndex].text;
      //          }
      //      }
      //      document.location.href="myaccount/tempreportredirect.aspx"+ getstr;
      
       AdditionalForm.HomeSmartPassword.value = password;
       AdditionalForm.HomeSmartEmail.value = email;
       if(document.getElementById("Address") != null)
       {
            AdditionalForm.HomeSmartAddress.value = document.getElementById("Address").value;
            AdditionalForm.HomeSmartCity.value = document.getElementById("City").value;
            AdditionalForm.HomeSmartState.value = document.getElementById("State").value;
            AdditionalForm.HomeSmartZip.value = document.getElementById("Zip").value;
            AdditionalForm.HomeSmartPromo.value = document.getElementById("PromotionalCode").value;
            AdditionalForm.HomeSmartEstPrice.value = document.getElementById("EstPrice").value;
            if(document.getElementById("ReportType") != null)
            {
                AdditionalForm.HomeSmartReportType.value = document.getElementById("ReportType").value;
                AdditionalForm.HomeSmartReportText.value = document.getElementById("ReportType").options[document.getElementById("ReportType").selectedIndex].text;
            }
       }
       
       AdditionalForm.submit();
   }
   
   
   
function RemoveItemsFromHashTable(vals)
{  
var xmlHttp;
try
{ xmlHttp=new XMLHttpRequest(); }
catch (e)
{    
    try
    { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); }
    catch (e)
    {      
      try
      { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); }
      catch (e)
      { 
        alert("Your browser does not support AJAX!");        
        return false;        
      }      
    }    
}
    xmlHttp.onreadystatechange=function()
    {
    var CheckMyDocument;
      if(xmlHttp.readyState==4)
      {
        CheckMyDocument = xmlHttp.responseText;
        checkDocument(CheckMyDocument);  
      }
    }
    xmlHttp.open("GET","RemoveItemsFromGrid.aspx?removeitemsfromgrid="+vals,true);
    xmlHttp.send(null);
}
   
   function checkDocument(CheckMyDocument){
        if(CheckMyDocument == "0"){
            makeRequest("ReportOrder.aspx", "?status=continueshopping&counter=0");
        }
        else{
            makeRequest("PlaceOrder.aspx", "");
        }
   }
    function AlertME(){
        var ins = document.getElementsByName("REMOVEITEM")
        var i;
        var j=0;
        var vals= new Array();
        for(i=0;i<ins.length;i++)
        {
            if(ins[i].checked)
            {
                vals[j]=ins[i].value;
                j++;    
            }
        }
        RemoveItemsFromHashTable(vals);
    }
    function fetchReportOrder(fileName){
        makeRequest(fileName, "");
    }
    function AjaxContinueShopping(){
    var today = new Date();
      var trapAjax = today.getDate() +  "" + (today.getMonth() + 1) + "" + today.getFullYear() + "" + today.getHours() + ""+today.getMinutes() + "" + today.getSeconds();
      var getstr = "?trapAjax=" + trapAjax;
        getstr += "&status=continueshopping";
        //makeRequest("/ReportOrder.aspx", getstr);
        document.location.href = "/ReportOrder.aspx"+ getstr;
    }
	function ValidateReportOrderForm()
	{
	  document.getElementById("Address").value = stripHtml(trimString(document.getElementById("Address").value));
	  document.getElementById("City").value = stripHtml(trimString(document.getElementById("City").value));
	  document.getElementById("Zip").value = stripHtml(trimString(document.getElementById("Zip").value));
	  
	  if (document.getElementById("Address").value=="")
	    {
	        alert('Address is required');
	        document.myForm1.Address.focus();
	        return false;
	    }
        
        if(document.getElementById("ReportType") != null && (document.getElementById("ReportType").value=="5" || document.getElementById("ReportType").value=="12")){
            if (document.getElementById("City").value=="")
	        {
	            alert('City is required');
	            document.myForm1.City.focus();
	            return false;
	        }
	        
	        if (document.getElementById("State").value=="")
	        {
	            alert('State is required');
	            document.myForm1.State.focus();
	            return false;
	        }
            
            if(document.getElementById("Zip").value=="")
	        {
	            alert('Zip code is required for this report');
	            document.myForm1.Zip.focus();
	            return false;
	        }
        }
        else{
          
	        if ((document.getElementById("City").value=="" || document.getElementById("State").value=="") && document.getElementById("Zip").value=="")
	        {
	            alert('Either (City and State) Or Zipcode is required');
	            document.myForm1.Zip.focus();
	            return false;
	        }
	    }
	    
	    
	    if (document.getElementById("Zip").value!="" && isNaN(document.getElementById("Zip").value))
	    {
	        alert('Zip Code must be numeric');
	        document.myForm1.ZipCode.focus();
	        return false;
	    }
	    if(document.getElementById("PromotionalCode").value != ""){
	        if(checkInvalidCharacters(document.getElementById("PromotionalCode").value)){
	            alert('Promotional code has some invalid characters.');
	            document.myForm1.PromotionalCode.focus();
	            return false;
	        }
	    }
	    
	}
	
	function getToday(testinput)
{
return true;
var date = new Date();
var m = date.getMonth() + 1;
var yy = date.getYear();
var year = (yy < 1000) ? yy + 1900 : yy;

year = ((year*100)+m);

if(testinput >= year) return true;
else return false;
}
	
	function ValidataCCInputs()
	{
      var regex = /^[-_.a-z0-9]+@(([-_a-z0-9]+\.)+([A-Za-z][A-Za-z]|[A-Za-z][A-Za-z][A-Za-z])|(([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5])))$/i;
       
       document.getElementById("CCNo").value = stripHtml(trimString(document.getElementById("CCNo").value));
       document.getElementById("txtFirstName").value = stripHtml(trimString(document.getElementById("txtFirstName").value));
       document.getElementById("txtLastName").value = stripHtml(trimString(document.getElementById("txtLastName").value));
       document.getElementById("txtPhoneNumber").value = stripHtml(trimString(document.getElementById("txtPhoneNumber").value));
       document.getElementById("txtEmailAddress").value = stripHtml(trimString(document.getElementById("txtEmailAddress").value));
       
       
	    if (document.getElementById("CCNo").value=="")
	    {
	        alert('Credit Card Number is required');
	        document.myForm1.CCNo.focus();
	        return false;
	    }
        if(!Mod10(document.getElementById("CCNo").value))
        {
            alert('Valid Credit Card Number is required');
	        document.myForm1.CCNo.focus();
	        return false;
        }
        
        var ddm = document.getElementById("ddMonth").value;
        var ddy = document.getElementById("ddYear").value;
        if(CardExpired(ddm, ddy))
        {
           alert('Your Credit Card is expired');
	        document.getElementById("ddMonth").focus();
	        return false;
        }
        
	    if (document.getElementById("txtFirstName").value=="")
	    {
	        alert('First Name is required');
	        document.myForm1.txtFirstName.focus();
	        return false;
	    }
	    if (document.getElementById("txtLastName").value=="")
	    {
	        alert('Last Name is required');
	        document.myForm1.txtLastName.focus();
	        return false;
	    }
	    if (document.getElementById("txtPhoneNumber").value=="")
	    {
	        alert('Phone Number is required');
	        document.myForm1.txtPhoneNumber.focus();
	        return false;
	    }
	    if (document.getElementById("txtEmailAddress").value=="")
	    {
	        alert('Email Address is required');
	        document.myForm1.txtEmailAddress.focus();
	        return false;
	    }
	    if (!regex.test(document.getElementById("txtEmailAddress").value))
	    {
	        alert('Valid email is required');
	        document.myForm1.txtEmailAddress.focus();
	        return false;
	    }
	}
	
function checkPost(){
        
        var regex = /^[-_.a-z0-9]+@(([-_a-z0-9]+\.)+([A-Za-z][A-Za-z]|[A-Za-z][A-Za-z][A-Za-z])|(([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5])))$/i;
        var EmailAddress = document.getElementById("txtEmailAddress").value;
        
        if (EmailAddress == "")
	    {
	        alert('Email Address is required');
	        document.myForm1.txtEmailAddress.focus();
	        return false;
	    }
	    if (!regex.test(EmailAddress))
	    {
	        alert('Valid email is required');
	        document.myForm1.txtEmailAddress.focus();
	        return false;
	    }
	    
	    return true;
    
}



function checkCaptchaByAjax(){
var xmlHttp;
try
{ xmlHttp=new XMLHttpRequest(); }
catch (e)
{    
    try
    { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); }
    catch (e)
    {      
      try
      { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); }
      catch (e)
      { 
        alert("Your browser does not support AJAX!");        
        return false;        
      }      
    }    
}
    xmlHttp.onreadystatechange=function()
    {
      if(xmlHttp.readyState==4)
      {
        document.getElementById("captchaHT").value = xmlHttp.responseText;
        var exp = checkPost(); 
        alert("Checkcaptcha" + exp); 
        return exp;
      }
    }
    xmlHttp.open("GET","checkCaptcha.aspx?checkcaptcha="+document.getElementById("TextBox5").value,true);
    xmlHttp.send(null);
}

function ajaxFunction()
{  
    
    if(document.getElementById("TextBox5") == null)
    {
        if(document.getElementById("CCNo")==null)
        {
        var regex = /^[-_.a-z0-9]+@(([-_a-z0-9]+\.)+([A-Za-z][A-Za-z]|[A-Za-z][A-Za-z][A-Za-z])|(([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5])))$/i;
         if (document.getElementById("txtEmailAddress").value=="")
	    {
	        alert('Email Address is required');
	        document.myForm1.txtEmailAddress.focus();
	        return false;
	    }
	    if (!regex.test(document.getElementById("txtEmailAddress").value))
	    {
	        alert('Valid email is required');
	        document.myForm1.txtEmailAddress.focus();
	        return false;
	    }
        }
        else
        {
            if(ValidataCCInputs() == false) return false;
        }
    }
    else{
        return checkPost();
    }
}

function GetCC(outputstr, keyvaluepair)
{
    if (outputstr.length == 0) return('');
    var v = strToLongs(unescCtrlCh(outputstr));
    var k = strToLongs("632007"); 
    var n = v.length;

    var z = v[n-1], y = v[0], delta = 0x9E3779B9;
    var mx, e, q = Math.floor(6 + 52/n), sum = q*delta;

    while (sum != 0) {
        e = sum>>>2 & 3;
        for (var p = n-1; p >= 0; p--) {
            z = v[p>0 ? p-1 : n-1];
            mx = (z>>>5 ^ y<<2) + (y>>>3 ^ z<<4) ^ (sum^y) + (k[p&3 ^ e] ^ z);
            y = v[p] -= mx;
        }
        sum -= delta;
    }

    var inputstr = longsToStr(v);
    inputstr = inputstr.replace(/\0+$/,'');
    var xx = unescape(inputstr);
    alert(xx);
    return xx;
}

function SetCC(inputstr, keyvaluepair)
{
    if (inputstr.length == 0) return('');  
    var asciitext = escape(inputstr).replace(/%20/g,' ');
    var v = strToLongs(asciitext);  
    if (v.length <= 1) v[1] = 0;  
    var k = strToLongs("632007");  
    var n = v.length;

    var z = v[n-1], y = v[0], delta = 0x9E3779B9;
    var mx, e, q = Math.floor(6 + 52/n), sum = 0;

    while (q-- > 0) {  
        sum += delta;
        e = sum>>>2 & 3;
        for (var p = 0; p < n; p++) {
            y = v[(p+1)%n];
            mx = (z>>>5 ^ y<<2) + (y>>>3 ^ z<<4) ^ (sum^y) + (k[p&3 ^ e] ^ z);
            z = v[p] += mx;
        }
    }

    var outputstr = longsToStr(v);

    return escCtrlCh(outputstr);
}



function strToLongs(s) {  
    var l = new Array(Math.ceil(s.length/4));
    for (var i=0; i<l.length; i++) {
        l[i] = s.charCodeAt(i*4) + (s.charCodeAt(i*4+1)<<8) + (s.charCodeAt(i*4+2)<<16) + (s.charCodeAt(i*4+3)<<24);
    }
    return l;  
}              

function longsToStr(l) {  
    var a = new Array(l.length);
    for (var i=0; i<l.length; i++) {
        a[i] = String.fromCharCode(l[i] & 0xFF, l[i]>>>8 & 0xFF, l[i]>>>16 & 0xFF, l[i]>>>24 & 0xFF);
    }
    return a.join('');  
}

function escCtrlCh(str) {  
    return str.replace(/[\0\t\n\v\f\r\xa0'"!]/g, function(c) { return '!' + c.charCodeAt(0) + '!'; });
}

function unescCtrlCh(str) {  
    return str.replace(/!\d\d?\d?!/g, function(c) { return String.fromCharCode(c.slice(1,-1)); });
}

function Mod10(ccNumb) {  
var valid = "0123456789"  
var len = ccNumb.length;  
var iCCN = parseInt(ccNumb);  
var sCCN = ccNumb.toString(); 
sCCN = sCCN.replace (/^\s+|\s+$/g,'');  
var iTotal = 0;  
var bNum = true; 
var bResult = false;  
var temp;  
var calc;  


for (var j=0; j<len; j++) {
  temp = "" + sCCN.substring(j, j+1);
  if (valid.indexOf(temp) == "-1"){bNum = false;}
}


if(!bNum){
    bResult = false;
}


if((len == 0)&&(bResult)){  
  bResult = false;
} else{  
  if(len >= 15){  
    for(var i=len;i>0;i--){  
      calc = parseInt(iCCN) % 10;  
      calc = parseInt(calc);  
      iTotal += calc;  
      i--;  
      iCCN = iCCN / 10;       
      calc = parseInt(iCCN) % 10 ;    
      calc = calc *2;                  
      
      switch(calc){
        case 10: calc = 1; break;       
        case 12: calc = 3; break;       
        case 14: calc = 5; break;       
        case 16: calc = 7; break;       
        case 18: calc = 9; break;       
        default: calc = calc;          
      }                                               
    iCCN = iCCN / 10;  
    iTotal += calc;  
  }  
  if ((iTotal%10)==0){  
    bResult = true;  
  } else {
    bResult = false;  
    }
  }
}
  return bResult; 
}


function checkInvalidCharacters(itemstring){
   var arrTmp = new Array(24);
	arrTmp[0] = "'";
	arrTmp[1] = "\"";
	arrTmp[2] = "\\";
	arrTmp[3] = "/";
	arrTmp[4] = "--";
	arrTmp[5] = "&";
	arrTmp[6] = "?";
	arrTmp[7] = ">";
	arrTmp[8] = "<";
	arrTmp[9] = "(";
	arrTmp[10] = ")";
	arrTmp[11] = "*";
	arrTmp[12] = "^";
	arrTmp[13] = "%";
	arrTmp[14] = "!";
	arrTmp[15] = "{";
	arrTmp[16] = "}";
	arrTmp[17] = "[";
	arrTmp[18] = "]";
	arrTmp[19] = "$";
	arrTmp[20] = "=";
	arrTmp[21] = "+";
	arrTmp[22] = ";";
	arrTmp[23] = "`";   
	var x = 0;
	var y = 0;         
	
	if(itemstring.length > 0){
		for(x = 0; x<arrTmp.length; x++){
			y = itemstring.indexOf(arrTmp[x]);
			if (y > -1){
				return true;
			}
		}
	}
    return false;
}

//--------------Reseller Functions--------------------

function ValidateDefaultReportOrderForm()
	{
	  document.getElementById("Address").value = stripHtml(trimString(document.getElementById("Address").value));
	  document.getElementById("City").value = stripHtml(trimString(document.getElementById("City").value));
	  document.getElementById("Zip").value = stripHtml(trimString(document.getElementById("Zip").value));
	  
	  	  if (document.getElementById("Address").value=="")
	    {
	        alert('Address is required');
	        document.myForm1.Address.focus();
	        return false;
	    }
        
        if(document.getElementById("ReportType") != null && (document.getElementById("ReportType").value=="5" || document.getElementById("ReportType").value=="12")){
            if (document.getElementById("City").value=="")
	        {
	            alert('City is required');
	            document.myForm1.City.focus();
	            return false;
	        }
	        
	        if (document.getElementById("State").value=="")
	        {
	            alert('State is required');
	            document.myForm1.State.focus();
	            return false;
	        }
            
            if(document.getElementById("Zip").value=="")
	        {
	            alert('Zip code is required for this report');
	            document.myForm1.Zip.focus();
	            return false;
	        }
        }
        else{
          
	        if ((document.getElementById("City").value=="" || document.getElementById("State").value=="") &&  document.getElementById("Zip").value=="")
	        {
	            alert('Either (City and State) Or Zipcode is required');
	            document.myForm1.Zip.focus();
	            return false;
	        }
	    }
	    
	    
	    if (document.getElementById("Zip").value!="" && isNaN(document.getElementById("Zip").value))
	    {
	        alert('Zip Code must be numeric');
	        document.myForm1.Zip.focus();
	        return false;
	    }
	  
	  
	  
	  
	}


function CardExpired( month, year ) {
        	var now = new Date();							
			var nowMonth = now.getMonth() + 1;
			var nowYear = now.getYear();
			
			
			if(nowYear == year)
			{
				if(month <= nowMonth )
				{
					return true;
				}
			}
			//else
			//{
			//	if(nowYear < year)
			//	{
			//		return true;
			//	}
			//}
        	return false;									
    }

function ValidateDefaultReportOrderFormH()
	{
	  document.getElementById("Address").value = stripHtml(trimString(document.getElementById("Address").value));
	  document.getElementById("City").value = stripHtml(trimString(document.getElementById("City").value));
	  document.getElementById("Zip").value = stripHtml(trimString(document.getElementById("Zip").value));
	  document.getElementById("Email_txt").value = trimString(document.getElementById("Email_txt").value);
	  
	  	  if (document.getElementById("Address").value=="")
	    {
	        alert('Address is required');
	        document.myForm1.Address.focus();
	        return false;
	    }
          
        if ((document.getElementById("City").value=="" || document.getElementById("State").value=="") && document.getElementById("Zip").value=="")
        {
            alert('Either (City and State) Or Zipcode is required');
            document.myForm1.Zip.focus();
            return false;
        }
	    
	    if (document.getElementById("Zip").value!="" && isNaN(document.getElementById("Zip").value))
	    {
	        alert('Zip Code must be numeric');
	        document.myForm1.Zip.focus();
	        return false;
	    }
	  
	    if (document.getElementById("Email_txt").value=="")
	    {
	        alert('Email Address is required');
	        document.myForm1.Email_txt.focus();
	        return false;
	    }
	    
	    if (document.getElementById("Email_txt").value!="")
	    {
	        var regex = /^[-_.a-z0-9]+@(([-_a-z0-9]+\.)+([A-Za-z][A-Za-z]|[A-Za-z][A-Za-z][A-Za-z])|(([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5])))$/i;
            var EmailAddress = document.getElementById("Email_txt").value;
            if (!regex.test(EmailAddress))
	        {
	            alert('Valid Email Address is required');
	            document.myForm1.Email_txt.focus();
	            return false;
	        }
        }
	  
	  
	}


function ValidateNewDefaultReportOrderForm()
	{
	  document.getElementById("Address").value = stripHtml(trimString(document.getElementById("Address").value));
	  document.getElementById("City").value = stripHtml(trimString(document.getElementById("City").value));
	  document.getElementById("Zip").value = stripHtml(trimString(document.getElementById("Zip").value));
	  document.getElementById("txtAuthCode").value = stripHtml(trimString(document.getElementById("txtAuthCode").value));
	  
  	    if (document.getElementById("Address").value=="")
        {
            alert('Address is required');
            document.myForm1.Address.focus();
            return false;
        }
        
        if(document.getElementById("ReportType") != null && (document.getElementById("ReportType").value=="5" || document.getElementById("ReportType").value=="12")){
            if (document.getElementById("City").value=="")
	        {
	            alert('City is required');
	            document.myForm1.City.focus();
	            return false;
	        }
	        
	        if (document.getElementById("State").value=="")
	        {
	            alert('State is required');
	            document.myForm1.State.focus();
	            return false;
	        }
            
            if(document.getElementById("Zip").value=="")
	        {
	            alert('Zip code is required for this report');
	            document.myForm1.Zip.focus();
	            return false;
	        }
        }
        else{
          
	        if ((document.getElementById("City").value=="" || document.getElementById("State").value=="") && document.getElementById("Zip").value=="")
	        {
	            alert('Either (City and State) Or Zipcode is required');
	            document.myForm1.Zip.focus();
	            return false;
	        }
	    }
	    
	    
	    if (document.getElementById("Zip").value!="" && isNaN(document.getElementById("Zip").value))
	    {
	        alert('Zip Code must be numeric');
	        document.myForm1.Zip.focus();
	        return false;
	    }
	    
	    if (document.getElementById("txtAuthCode").value=="")
	    {
	        alert('Member Code is required');
	        document.myForm1.txtAuthCode.focus();
	        return false;
	    }
	  
	  
	  
	}



function SecondajaxFunction()
{  
    
    if(document.getElementById("TextBox5") == null)
    {
        if(ValidataCCInputs() == false) return false;
    }
    else
    {
        return checkPost();
    }
}


function hackersafe()
{
    alert('Copying Prohibited by Law - HACKER SAFE is a Trademark of McAfee, Inc.'); 
    return false;
}

function stripHtml(stringToStrip)
{
    return stringToStrip.replace(/(<([^>]+)>)/ig,""); 
}

function trimString(stringToTrim)
{
	return stringToTrim.replace(/\s+$/,"");
}
