// JavaScript Document

function retrieveReport() {
_kmq.push(['record', 'Clicked Retrieve Report']);
}

function orderNow() {
_kmq.push(['record', 'Clicked Order Now']);
}

function showPopup() {
 $(".popup").fadeIn(300);	
 $(".pagebg").fadeIn(300);	
}

function closePopup() {
 $(".popup").fadeOut(300);	
 $(".pagebg").fadeOut(300);	
}

	
	

image1 = new Image(); 
image1.src = "images/home-service-bg2.jpg";

image2 = new Image(); 
image2.src = "images/nav-active.jpg";

image3 = new Image(); 
image3.src = "images/nav-active-left.jpg";

image4 = new Image(); 
image4.src = "images/nav-active-right.jpg";

image5 = new Image(); 
image5.src = "images/check.jpg";

image6 = new Image(); 
image6.src = "images/error.jpg";

var cityCache;

function homeServices(homeServiceId, homeServiceBgId) {

document.getElementById(homeServiceId).style.backgroundImage = homeServiceBgId;

}

function homeServicesDiv(homeServicesDivId) {

document.getElementById("homeServicesDiv1").style.display = "none";
document.getElementById("homeServicesDiv2").style.display = "none";
document.getElementById("homeServicesDiv3").style.display = "none";
document.getElementById("homeServicesDiv4").style.display = "none";


document.getElementById(homeServicesDivId).style.display = "block";

}


function firstNameVerify() {
	
var firstNameInput = document.getElementById("firstNameInput");

if(firstNameInput.value == "") {

firstNameInput.style.border = '2px solid #d6495d';

}	

else {

firstNameInput.style.border = '1px inset';

}

}


function lastNameVerify() {
	
var lastNameInput = document.getElementById("lastNameInput");

if(lastNameInput.value == "") {

lastNameInput.style.border = '2px solid #d6495d';

}	

else {

lastNameInput.style.border = '1px inset';

}

}





function phone1Verify() {
	
var phone1Input = document.getElementById("txtAccPhone1");

if(phone1Input.value == "" && phone1Input.value != 3) {

phone1Input.style.border = '2px solid #d6495d';

}	

else {

phone1Input.style.border = '1px inset';

}

}


function phone2Verify() {
	
var phone2Input = document.getElementById("txtAccPhone2");

if(phone2Input.value == "" && phone2Input.value != 3) {

phone2Input.style.border = '2px solid #d6495d';

}	

else {

phone2Input.style.border = '1px inset';

}

}


function phone3Verify() {
	
var phone3Input = document.getElementById("txtAccPhone3");

if(phone3Input.value == "" && phone3Input.value != 3) {

phone3Input.style.border = '2px solid #d6495d';

}	

else {

phone3Input.style.border = '1px inset';

}

}









var addressCache;

function addressVerify() {

var addressInput = document.getElementById("txtAccAddress");

if(addressInput.value == "") {

addressInput.style.border = '2px solid #d6495d';

}	

else {

addressInput.style.border = '1px inset';

if (document.getElementById("txtCCAddress").value == "" || document.getElementById("txtCCAddress").value == addressCache) {

document.getElementById("txtCCAddress").value = addressInput.value;

addressCache = addressInput.value;

}


}

}

function cityVerify() {

var cityInput = document.getElementById("txtAccCity");

if(cityInput.value == "") {

cityInput.style.border = '2px solid #d6495d';

}	

else {

cityInput.style.border = '1px inset';

if (document.getElementById("txtCCCity").value == "" || document.getElementById("txtCCCity").value == cityCache) {

document.getElementById("txtCCCity").value = cityInput.value;

cityCache = cityInput.value;

}

}

}

var stateCache;
function stateVerify() {

var stateInput = document.getElementById("ddlAccState");

if(stateInput.value == "-") {

stateInput.style.border = '2px solid #d6495d';

}	

else {

stateInput.style.border = '1px inset';

if (document.getElementById("ddlCCState").selectedIndex == "0" || document.getElementById("ddlCCState").selectedIndex == stateCache) {

document.getElementById("ddlCCState").selectedIndex = stateInput.selectedIndex;

stateCache = stateInput.selectedIndex;

}

}

}



var zipCache;

function zipVerify() {

var zipInput = document.getElementById("txtAccZip");

if(zipInput.value == "") {

zipInput.style.border = '2px solid #d6495d';

}	

else {

zipInput.style.border = '1px inset';

if (document.getElementById("txtCCZip").value == "" || document.getElementById("txtCCZip").value == zipCache) {

document.getElementById("txtCCZip").value = zipInput.value;

zipCache = zipInput.value;

}

}

}






function ccNumberVerify() {

var ccNumberInput = document.getElementById("txtCCNbr");

if(ccNumberInput.value == "") {

ccNumberInput.style.border = '2px solid #d6495d';

}	

else {

ccNumberInput.style.border = '1px inset';

}

}



function ccTypeVerify() {

var ccTypeInput = document.getElementById("ddlCCType");

if(ccTypeInput.value == "- Select -") {

ccTypeInput.style.border = '2px solid #d6495d';

}	

else {

ccTypeInput.style.border = '1px inset';

}

}





function ccMonthVerify() {

var ccMonthInput = document.getElementById("ddlCCMonth");

if(ccMonthInput.value == "-") {

ccMonthInput.style.border = '2px solid #d6495d';

}	

else {

ccMonthInput.style.border = '1px inset';

}

}




function ccYearVerify() {

var ccYearInput = document.getElementById("ddlCCYear");

if(ccYearInput.value == "-") {

ccYearInput.style.border = '2px solid #d6495d';

}	

else {

ccYearInput.style.border = '1px inset';

}

}



function cvvVerify() {

var cvvInput = document.getElementById("txtCCCVVCd");

if(cvvInput.value == "") {

cvvInput.style.border = '2px solid #d6495d';

}	

else {

cvvInput.style.border = '1px inset';

}

}


var ccAddressCache = "";

function ccAddressFocus() {

var ccAddressInput = document.getElementById("txtCCAddress");

if(ccAddressInput.value == document.getElementById("txtAccAddress").value) {
ccAddressCache = ccAddressInput.value;
ccAddressInput.value = "";
}

}

function ccAddressVerify() {

var ccAddressInput = document.getElementById("txtCCAddress");

if(ccAddressInput.value == "" && ccAddressCache != "") {

ccAddressInput.value = ccAddressCache;
}	

else if(ccAddressInput.value == "") {

ccAddressInput.style.border = '2px solid #d6495d';

}	

else {

ccAddressInput.style.border = '1px inset';

}

}



var ccCityCache = "";

function ccCityFocus() {

var ccCityInput = document.getElementById("txtCCCity");

if(ccCityInput.value == document.getElementById("txtAccCity").value) {
ccCityCache = ccCityInput.value;
ccCityInput.value = "";
}

}


function ccCityVerify() {

var ccCityInput = document.getElementById("txtCCCity");

if(ccCityInput.value == "" && ccCityCache != "") {

ccCityInput.value = ccCityCache;
}	

else if(ccCityInput.value == "") {

ccCityInput.style.border = '2px solid #d6495d';

}	

else {

ccCityInput.style.border = '1px inset';

}

}







function ccStateVerify() {

var ccStateInput = document.getElementById("ddlCCState");

if(ccStateInput.value == "-") {

ccStateInput.style.border = '2px solid #d6495d';

}	

else {

ccStateInput.style.border = '1px inset';

}

}



var ccZipCache = "";

function ccZipFocus() {

var ccZipInput = document.getElementById("txtCCZip");

if(ccZipInput.value == document.getElementById("txtAccZip").value) {
ccZipCache = ccZipInput.value;
ccZipInput.value = "";
}

}




function ccZipVerify() {

var ccZipInput = document.getElementById("txtCCZip");

if(ccZipInput.value == "" && ccZipCache != "") {

ccZipInput.value = ccZipCache;
}	


else if(ccZipInput.value == "") {

ccZipInput.style.border = '2px solid #d6495d';

}	

else {

ccZipInput.style.border = '1px inset';

}

}

function emailVerify() {
	
var emailInput = document.getElementById("emailInput");
var filter = /^.+@.+\..{2,3}$/;


if (emailInput.value == "example: john@chexsafe.com") {

emailInput.style.border = '2px solid #d6495d';

}


else if(filter.test(emailInput.value)) {

emailInput.style.border = '1px inset';


}

else if (emailInput.value == "") {

emailInput.style.border = '2px solid #d6495d';

emailInput.value = "example: john@chexsafe.com";
emailInput.style.color = "#bbb";

}

else {

emailInput.style.border = '2px solid #d6495d';


}

}





function emailFocus() {

var emailInput = document.getElementById("emailInput");

if(emailInput.value == "example: john@chexsafe.com") {
	
	emailInput.value = "";
	emailInput.style.color = "#1d2329";
	
	}
	
}



function sampleImage(sampleImageId, sampleImagePos) {

document.getElementById(sampleImageId).style.backgroundPosition = sampleImagePos;
	
}


function createAccount() {

	
var errorCount, firstNameError, lastNameError, emailError, addressError, phoneError, stateError, cityError, zipError, stateError, ccNumberError, ccTypeError, ccMonthError, ccYearError, ccAddressError, ccStateError, ccCityError, ccvError, ccZipError, errorCopy, errorCopy1, errorCopy2, errorCopy3, errorCopy4, errorCopy5, errorCopy6, errorCopy7, errorCopy8, errorCopy9, errorCopy10, errorCopy11, errorCopy12, errorCopy13, errorCopy14, errorCopy15, errorCopy16, errorCopy17, errorCopy18;

errorCopy = "";
errorCopy1 = "";
errorCopy2 = "";
errorCopy3 = "";
errorCopy4 = "";
errorCopy5 = "";
errorCopy6 = "";
errorCopy7 = "";
errorCopy8 = "";
errorCopy9 = "";
errorCopy10 = "";
errorCopy11 = "";
errorCopy12 = "";
errorCopy13 = "";
errorCopy14 = "";
errorCopy15 = "";
errorCopy16 = "";
errorCopy17 = "";
errorCopy18 = "";
errorCount = 0;
firstNameError = 0;
lastNameError = 0;
emailError = 0;
addressError = 0;
cityError = 0;
stateError = 0;
zipError = 0;
ccNumberError = 0;
ccTypeError = 0;
ccMonthError = 0;
ccYearError = 0;
ccvError = 0;
ccAddressError = 0;
ccCityError = 0;
ccStateError = 0;
ccZipError = 0;
checkError = 0;
phoneError = 0;
	
var firstNameInput = document.getElementById("firstNameInput");

if(firstNameInput.value == "") {

firstNameError = 1;
firstNameInput.style.border = '2px solid #d6495d';
}


var lastNameInput = document.getElementById("lastNameInput");

if(lastNameInput.value == "") {

lastNameError = 2;
lastNameInput.style.border = '2px solid #d6495d';
	
}

var emailInput = document.getElementById("emailInput");
var filter = /^.+@.+\..{2,3}$/;

if(filter.test(emailInput.value)) {
	
}

else {

emailError = 3;

emailInput.style.border = '2px solid #d6495d';

	
}


if (emailInput.value == "example: john@chexsafe.com") {

emailError = 4;
emailInput.style.border = '2px solid #d6495d';


}


var addressInput = document.getElementById("txtAccAddress");

if(addressInput.value == "") {

addressError = 1;
addressInput.style.border = '2px solid #d6495d';


}


var phone1Input = document.getElementById("txtAccPhone1");
var phone2Input = document.getElementById("txtAccPhone2");
var phone3Input = document.getElementById("txtAccPhone3");

if(phone1Input.value == "") {

phone1Input.style.border = '2px solid #d6495d';

phoneError = 1;

}

if(phone2Input.value == "") {

phone2Input.style.border = '2px solid #d6495d';

phoneError = 1;

}

if(phone3Input.value == "") {

phone3Input.style.border = '2px solid #d6495d';

phoneError = 1;

}



var cityInput = document.getElementById("txtAccCity");

if(cityInput.value == "") {

cityError = 1;
cityInput.style.border = '2px solid #d6495d';


}



var stateInput = document.getElementById("ddlAccState");

if(stateInput.value == "-") {

stateError = 1;
stateInput.style.border = '2px solid #d6495d';

}



var zipInput = document.getElementById("txtAccZip");

if(zipInput.value == "") {

zipError = 1;
zipInput.style.border = '2px solid #d6495d';
}



var ccNumberInput = document.getElementById("txtCCNbr");

if(ccNumberInput.value == "") {

ccNumberError = 1;
ccNumberInput.style.border = '2px solid #d6495d';
}



var ccTypeInput = document.getElementById("ddlCCType");

if(ccTypeInput.value == "- Select -") {

ccTypeError = 1;
ccTypeInput.style.border = '2px solid #d6495d';
}



var ccMonthInput = document.getElementById("ddlCCMonth");

if(ccMonthInput.value == "-") {

ccMonthError = 1;
ccMonthInput.style.border = '2px solid #d6495d';
}



var ccYearInput = document.getElementById("ddlCCYear");

if(ccYearInput.value == "-") {

ccYearError = 1;
ccYearInput.style.border = '2px solid #d6495d';
}


var ccvInput = document.getElementById("txtCCCVVCd");

if(ccvInput.value == "") {

ccvError = 1;
ccvInput.style.border = '2px solid #d6495d';
}

var ccAddressInput = document.getElementById("txtCCAddress");

if(ccAddressInput.value == "") {

ccAddressError = 1;
ccAddressInput.style.border = '2px solid #d6495d';
}


var ccCityInput = document.getElementById("txtCCCity");

if(ccCityInput.value == "") {

ccCityError = 1;
ccCityInput.style.border = '2px solid #d6495d';
}

var ccStateInput = document.getElementById("ddlCCState");

if(ccStateInput.value == "-") {

ccStateError = 1;
ccStateInput.style.border = '2px solid #d6495d';
}

var ccZipInput = document.getElementById("txtCCZip");

if(ccZipInput.value == "") {

ccZipError = 1;
ccZipInput.style.border = '2px solid #d6495d';
}


var terms = document.getElementById("terms");

if(terms.checked == false) {
checkError = 7;
terms.style.border = '2px solid #d6495d';
}


if(firstNameError + lastNameError + emailError + addressError + phoneError + stateError + zipError + stateError + ccNumberError + ccTypeError + ccMonthError + ccYearError + ccAddressError + ccStateError + ccvError + ccZipError + checkError == 0) {

return true;
	
}

else if (firstNameError + lastNameError + emailError + addressError + phoneError + stateError + zipError + stateError + ccNumberError + ccTypeError + ccMonthError + ccYearError + ccAddressError + ccStateError + ccvError + ccZipError == 0) {

alert("Oops, you forgot to agree to our Terms of Use\n\n");

return false;


}

else {
	
	if(firstNameError != 0) {
	
	errorCopy1 = "First Name\n";
	
	}
	if(lastNameError != 0) {
	
	errorCopy2 = "Last Name\n";
	
	}
	if(emailError != 0) {
	
	errorCopy3 = "Valid Email Address\n";
	
	}
	if(addressError != 0) {
	
	errorCopy4 = "Valid Address\n";
	
	}
	if(phoneError != 0) {
	
	errorCopy18 = "Valid Phone Number\n";
	
	}
		if(cityError != 0) {
	
	errorCopy16 = "Valid City\n";
	
	}
	if(stateError != 0) {
	
	errorCopy5 = "Valid State\n";
	
	}
	if(zipError != 0) {
	
	errorCopy6 = "Valid ZIP Code\n";
	
	}
	if(ccNumberError != 0) {
	
	errorCopy7 = "Valid Credit Card Number\n";
	
	}
	if(ccTypeError != 0) {
	
	errorCopy8 = "Valid Credit Card Type\n";
	
	}
		if(ccMonthError != 0) {
	
	errorCopy9 = "Valid Credit Card Exp Month\n";
	
	}
	if(ccYearError != 0) {
	
	errorCopy10 = "Valid Credit Card Exp Year\n";
	
	}
		if(ccvError != 0) {
	
	errorCopy11 = "Valid Credit Card CVV Number\n";
	
	}
	if(ccAddressError != 0) {
	
	errorCopy12 = "Valid Billing Address\n";
	
	}
		if(ccCityError != 0) {
	
	errorCopy17 = "Valid Billing City\n";
	
	}
		if(ccStateError != 0) {
	
	errorCopy13 = "Valid Billing State\n";
	
	}
		if(ccZipError != 0) {
	
	errorCopy14 = "Valid Billing ZIP\n";
	
	}
	if(checkError != 0) {
	
	errorCopy15 = "\nAlso, please don't forget to agree to our Terms of Use\n\n";
	
	}
	
	alert("Before we can setup your account, please provide us with the following:\n\n"+errorCopy1+errorCopy2+errorCopy3+errorCopy4+errorCopy18+errorCopy16+errorCopy5+errorCopy6+errorCopy7+errorCopy8+errorCopy9+errorCopy10+errorCopy11+errorCopy12+errorCopy17+errorCopy13+errorCopy14+errorCopy15);
	
	return false;

}


}









var timerlen = 5;
var slideAniLen = 300;

var timerID = new Array();
var startTime = new Array();
var obj = new Array();
var endHeight = new Array();
var moving = new Array();
var dir = new Array();

function slidedown(objname){
        if(moving[objname])
                return;

        if(document.getElementById(objname).style.display != "none")
                return; // cannot slide down something that is already visible

        moving[objname] = true;
        dir[objname] = "down";
        startslide(objname);
}

function slideup(objname){
        if(moving[objname])
                return;

        if(document.getElementById(objname).style.display == "none")
                return; // cannot slide up something that is already hidden

        moving[objname] = true;
        dir[objname] = "up";
        startslide(objname);
}

function startslide(objname){
        obj[objname] = document.getElementById(objname);

        endHeight[objname] = parseInt(obj[objname].style.height);
        startTime[objname] = (new Date()).getTime();

        if(dir[objname] == "down"){
                obj[objname].style.height = "1px";
        }

        obj[objname].style.display = "block";

        timerID[objname] = setInterval('slidetick(\'' + objname + '\');',timerlen);
}

function slidetick(objname){
        var elapsed = (new Date()).getTime() - startTime[objname];

        if (elapsed > slideAniLen)
                endSlide(objname)
        else {
                var d =Math.round(elapsed / slideAniLen * endHeight[objname]);
                if(dir[objname] == "up")
                        d = endHeight[objname] - d;

                obj[objname].style.height = d + "px";
        }

        return;
}

function endSlide(objname){
        clearInterval(timerID[objname]);

        if(dir[objname] == "up")
                obj[objname].style.display = "none";

        obj[objname].style.height = endHeight[objname] + "px";

        delete(moving[objname]);
        delete(timerID[objname]);
        delete(startTime[objname]);
        delete(endHeight[objname]);
        delete(obj[objname]);
        delete(dir[objname]);

        return;
}


function toggleSlide(objname){
  if(document.getElementById(objname).style.display == "none"){
    // div is hidden, so let's slide down
    slidedown(objname);
  }else{
    // div is not hidden, so slide up
    slideup(objname);
  }
}


function slideVerify(objname) {

slideup('answer1')
slideup('answer2')
slideup('answer3')
slideup('answer4')
slideup('answer5')
slideup('answer6')
slideup('answer7')
slideup('answer8')
slideup('answer9')



toggleSlide(objname);

}
    
if((window.location.protocol.toLowerCase()== 'https:') && (location.href.toLowerCase().indexOf('register.aspx')==-1))
    location.href = location.href.replace('https:','http:');
    
//if(window.location.href.toLowerCase().indexOf('chexsafe.com') >0 && window.location.href.toLowerCase().indexOf('www') == -1)
//    window.location.href = window.location.href.replace('chexsafe.com','www.chexsafe.com');
    
    
	

