function getHTTPObject() {
	var xhr = false;
	if (window.XMLHttpRequest) {
		var xhr = new XMLHttpRequest();
	} else if (window.ActiveXObject) {
		try {
			var xhr = new ActiveXObject("Msxml2.XMLHTTP");
		} catch(e) {
			try {
				var xhr = new ActiveXObject("Microsoft.XMLHTTP");
			} catch(e) {
			var xhr = false;
			}
		}
	}
	return xhr;
}

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_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_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 openWindow3(theURL)
	{ //v2.0
  window.open(theURL,"","scrollbars=yes,width=720,height=550");
	}
	
function open_win1(ship) {
	New_Win1 = window.open(ship,"new_Window1","height=333,width=430,toolbar=no,scrollbars=no,menubar=no");
	}
	var ship = "shipping_info.asp"
	
function open_win2(tax) {
	New_Win2 =window.open(tax,"new_Window2","HEIGHT=133,WIDTH=340,scrollbars=no,menubar=no");
	}
	var tax = "tax.asp"
	
function open_win3(zoom) {
	New_Win3 =window.open(zoom,"new_Window3","HEIGHT=700,WIDTH=500,scrollbars=no,menubar=no");
	}
	var zoom = "/zoom.asp"	
	
function open_terms(part) {
	var terms = "/terms.asp?item=" + part;	
	New_WinTerms =window.open(terms,"new_WindowTerms","HEIGHT=700,WIDTH=500,scrollbars=yes,menubar=no").focus();
	}
	
	
function open_win7(billme) {
	New_Win7 =window.open(billme,"new_Window4","HEIGHT=480,WIDTH=470,scrollbars=yes,menubar=no");
	}
	var billme = "http://www.checkout-store.com/v30/popups/bml/whatis.asp"

function open_win8(pala) {
	New_Win7 =window.open(pala,"new_Window4","HEIGHT=535,WIDTH=470,scrollbars=yes,menubar=no");
	}
	var pala = "http://www.checkout-store.com/v30/popups/bml/pala.asp"

function open_winSA(SA){
    sa_win = window.open(SA,"window_SA","height=480,width=470,scroolbars=yes,menubar=no");
}
    var SA = "/extended_service_agreement.asp"

//yui function
function submitCallback(obj) {
	var response = obj.responseText;
	response = response.split("<!")[0];
	document.getElementById("resp").innerHTML = response;
	eval(response);
}

function showButton(buttonNumber) {
	document.getElementById(buttonNumber).style.display="";
}

function hideButton(buttonNumber) {
	document.getElementById(buttonNumber).style.display="none";
}

function swapImageIn(i) {		
	document.getElementById("qImg_"+i).src="/images/b_quickviewON.png";	
}

function swapImageOut(i) {		
	document.getElementById("qImg_"+i).src="/images/b_quickview.png";	
}

function initQuickView() {
	var handleCancel = function() {
		this.cancel();
	}
	var handleSubmit = function() {
		this.submit();
	}
	

	quickViewDialog = new YAHOO.widget.Dialog("QVdlg", { modal:true, visible:false, fixedcenter:true, constraintoviewport:true, draggable:true, close:false });
	var listeners = new YAHOO.util.KeyListener(document, { keys : 27 }, {fn:handleCancel,scope:quickViewDialog,correctScope:true} );
	quickViewDialog.cfg.queueProperty("keylisteners", listeners);
	
	var handleManual = function(type, args, obj) {
		alert("Manual submission of " + this.id + " detected");
	}

	quickViewDialog.manualSubmitEvent.subscribe(handleManual, quickViewDialog, true);
	quickViewDialog.render();
}	


function selectAll() {
	var form = document.recalculate; 
	for (i = 0; i < form.elements.length; i++) {
		if (form.elements[i].type == "checkbox")
			form.elements[i].checked = true;
	}			
}	

function Tax(x) {
	if (x == "show") {
		document.getElementById("taxBox").style.display = "block";
		document.getElementById("shipBox").style.display = "none";
	}
	else if (x == "hide")
		document.getElementById("taxBox").style.display = "none";
}

function Survey(x) {
	if (x == "show") {
		document.getElementById("surveyDiv").style.display = "block";
	}
	else if (x == "hide")
		document.getElementById("surveyDiv").style.display = "none";
}

function Shipping(x) {
	if (x == "show") {
		document.getElementById("shipBox").style.display = "block";
		document.getElementById("taxBox").style.display = "none";
	}
	else if (x == "hide")
		document.getElementById("shipBox").style.display = "none";
}

function shipreturnBox(x) {
	if (x == "show") {
		document.getElementById("shipreturnBox").style.display = "block";
		if(document.getElementById("sizeBox")){
		    document.getElementById("sizeBox").style.display = "none";
		}
	}
	else if (x == "hide")
		document.getElementById("shipreturnBox").style.display = "none";
}

function qv(current,total,fixed){
    if(current == 0){
         for (i=1;i<=total;i++){
         //close em all
           var block = "qv_" + i;
           document.getElementById(block).style.display = "none";
         }
    } else {
        for (i=1;i<=total;i++){
            if(i==current){
                var block = "qv_" + i;
                var vers = navigator.appVersion;
                document.getElementById(block).style.display = "block";
                if(fixed == 1){
                if (vers.indexOf("MSIE 6") > 0){
                    document.getElementById(block).style.position = "absolute";
                    document.getElementById(block).style.left = "50%";
                    document.getElementById(block).style.top = "50%";
                } else {
                    document.getElementById(block).style.position = "fixed";
                    document.getElementById(block).style.left = "50%";
                    document.getElementById(block).style.top = "50%";
                }
                    
                    document.getElementById(block).style.zIndex = 99;               
                }
               
            } else {
                block = "qv_" + i;
                document.getElementById(block).style.display = "none";
            }
        }
    }
}
function validateSearch(){
	var form = document.searchForm;
	var formVal = form.searchBox.value;
	if (formVal == "" || formVal == " " || formVal == "Search Store"){
		alert("Please enter a Keyword Search Phrase into this field before submitting");
		form.searchBox.focus();
		return false;
	}
}

function validateQty() {
 
    if (document.addtocart.ptext1){
        var personal1 = document.addtocart.ptext1.value;
        var personal2 = document.addtocart.ptext2.value;
        
        if (personal1 != personal2){
            alert("Make sure your Validation text equals your original Personalize text.");
            return false;
        }
        else if(personal1.replace(/^\s+|\s+$/g,"") == ""){
            alert("Please fill in your Personalized Text.");
            return false;
        }
    }
    
   if (document.addtocart.ptext3){
        var personal3 = document.addtocart.ptext3.value;
        var personal4 = document.addtocart.ptext4.value;
        
        if (personal3 != personal4){
            alert("Make sure your Validation text for line 2 equals your original Personalize text.");
            return false;
        }        
        else if(personal3.replace(/^\s+|\s+$/g,"") == ""){
            alert("Please fill in your Personalized Text.");
            return false;
        }
    }

    var vpcheck1 = document.getElementById('ckacceptterms1'); 
     if (vpcheck1){
        //If not checked then set error
        if (vpcheck1.checked == false){
            alert('Please read the terms and conditions associated with the sale of this product. Once read, you may check the box stating you have agreed to these terms and conditions and proceed with the purchase.'); return false;
        }
     }

	var value = document.addtocart.cnt.value;
	var re = /^([1-9]|[1-9]\d|99)$/
	if ( re.test(value) ) return true;
	
	alert("Enter a Valid Numeric Quantity and Click Add To Cart"); return false;
	
	
	
}


function valPersonalize1() {
    var form = document.addtocart
    if (form.ptext1.value == "") {
        alert("Please fill in your Personalized Text.");
    } else {
        document.addtocart.ptext1.disabled=false;
        form.submit();
    }
}
function valPersonalize2() {
    var form = document.addtocart
    if (form.ptext1.value == "" || form.ptext3.value == "") {
        alert("Please fill in your Personalized Text.");
    } else {
        document.addtocart.ptext1.disabled=false;
        document.addtocart.ptext3.disabled=false;
        form.submit();
    }
}
function valPersonalize3() {
    var form = document.addtocart
    if (form.ptext1.value == "" || form.ptext3.value == "" || form.ptext5.value == "") {
        alert("Please fill in your Personalized Text.");
    } else {
        document.addtocart.ptext1.disabled=false;
        document.addtocart.ptext3.disabled=false;
        document.addtocart.ptext5.disabled=false;
        form.submit();
    }
}
function valPersonalize4() {
    var form = document.addtocart
    if (form.ptext1.value == "" || form.ptext3.value == "" || form.ptext5.value == "" || form.ptext7.value == "") {
        alert("Please fill in your Personalized Text.");
    } else {
        document.addtocart.ptext1.disabled=false;
        document.addtocart.ptext3.disabled=false;
        document.addtocart.ptext5.disabled=false;
        document.addtocart.ptext7.disabled=false;
        form.submit();
    }
}


function showPersonalize1() {
    document.getElementById("btnAddtoCart").style.display = "none";
    document.getElementById("validateButtons").style.display = "block";
    document.getElementById("ptextPreview").style.display = "block";
    document.getElementById("ptextfill1").innerHTML = "Line 1: " + document.addtocart.ptext1.value;
    document.addtocart.ptext1.disabled=true;
    return false;    
}
function showPersonalize2() {
    document.getElementById("btnAddtoCart").style.display = "none";
    document.getElementById("validateButtons").style.display = "block";
    document.getElementById("ptextPreview").style.display = "block";
    document.getElementById("ptextfill1").innerHTML = "Line 1: " + document.addtocart.ptext1.value;
    document.getElementById("ptextfill3").innerHTML = "Line 2: " + document.addtocart.ptext3.value;
    document.addtocart.ptext1.disabled=true;
    document.addtocart.ptext3.disabled=true;
    return false;    
}
function showPersonalize3() {
    document.getElementById("btnAddtoCart").style.display = "none";
    document.getElementById("validateButtons").style.display = "block";
    document.getElementById("ptextPreview").style.display = "block";
    document.getElementById("ptextfill1").innerHTML = "Line 1: " + document.addtocart.ptext1.value;
    document.getElementById("ptextfill3").innerHTML = "Line 2: " + document.addtocart.ptext3.value;
    document.getElementById("ptextfill5").innerHTML = "Line 3: " + document.addtocart.ptext5.value;
    document.addtocart.ptext1.disabled=true;
    document.addtocart.ptext3.disabled=true;
    document.addtocart.ptext5.disabled=true;
    return false;    
}
function showPersonalize4() {
    document.getElementById("btnAddtoCart").style.display = "none";
    document.getElementById("validateButtons").style.display = "block";
    document.getElementById("ptextPreview").style.display = "block";
    document.getElementById("ptextfill1").innerHTML = "Line 1: " + document.addtocart.ptext1.value;
    document.getElementById("ptextfill3").innerHTML = "Line 2: " + document.addtocart.ptext3.value;
    document.getElementById("ptextfill5").innerHTML = "Line 3: " + document.addtocart.ptext5.value;
    document.getElementById("ptextfill7").innerHTML = "Line 4: " + document.addtocart.ptext7.value;
    document.addtocart.ptext1.disabled=true;
    document.addtocart.ptext3.disabled=true;
    document.addtocart.ptext5.disabled=true;
    document.addtocart.ptext7.disabled=true;
    return false;
}
