//var CA_USItimerID = ''; //var CA_properClickThrough = false; //var CA_USIdone = false; //var yBasedSuppress = false; //var void_verify = false; //var ca_test = false; function verifyCACollaterals() { //cart total amount check: ca_total_chk = 0; // checks if customer is logged in via the CUSTOMERID cookie, if its present or not customer_cookie_check = ''; // checks whether traffic is from Affiliate is_affiliate = false; // checks whether traffic is from PPC is_ppc = false; // checks whether traffic is from e-mail is_email = false; // checks whether cas popup was previously fired cas_loaded = false; //alert("DEBUG MODE:\n\nca_total_chk:"+ca_total_chk+"\ncustomer_cookie_check:"+customer_cookie_check+"\nCA_properClickThrough:"+CA_properClickThrough+"\nyBasedSuppress:"+yBasedSuppress+"\nis_ppc:"+is_ppc+"\nis_affiliate:"+is_affiliate+"\nis_email:"+is_email); if( ca_total_chk > 0 && customer_cookie_check == '' && (!CA_properClickThrough && !yBasedSuppress) && !is_ppc && !is_affiliate && !is_email ) { if(cas_loaded == true){ return false; }else{ /* sets the cookie expiration to one day */ today = new Date(); today.setTime( today.getTime() ); expires = 1; expires = expires * 1000 * 60 * 60 * 24; expires_date = new Date( today.getTime() + (expires) ); document.cookie = "cas=true;expires="+expires_date.toGMTString()+";path=/;domain=.usautoparts.com"; /* end - set cookie expiration */ return true; } } else { return false; } } $(function() { $("#myDialog").dialog({ autoOpen: false, bgiframe: true, height: 360, width: 515, modal: true }) }); var CA_onPage = 0; function CA_testYPos(e) { Y_pos = document.all? event.clientY: e.pageY - document.body.scrollTop - document.documentElement.scrollTop; if( Y_pos < 20 && CA_onPage == 1 ) { CA_onPage = 0 } if( Y_pos > 20 && CA_onPage == 0 ) { CA_onPage = 1; } } if (document.attachEvent) { document.attachEvent("onmousemove", CA_testYPos); } if (document.addEventListener) { document.addEventListener("mousemove", CA_testYPos, true); } function showCADialog() { $("#myDialog").dialog("open"); $("#myDialog").parents(".ui-widget-content:first").css("border","0"); $("#myDialog").parents(".ui-widget-content:first").css("background","transparent"); $("#myDialog").parents(".ui-dialog:first").css("background-image","url('/images/popup-bg.gif')"); $("#myDialog").parents(".ui-dialog:first").find(".ui-icon-closethick").remove(); } /*function hideCADialog() { $("#myDialog").dialog("close"); }*/ function applyCADiscount() { void_verify = true; window.location = "http://www2.partstrain.com/basket.php?ptcoupon=NXB0&intcmpid=F1234517133W49953c8de7b21"; } window.onbeforeunload = function() { CA_USIdone = true; if (CA_USItimerID != '') clearTimeout(CA_USItimerID); yBasedSuppress = false; if (CA_onPage == 1) yBasedSuppress = true; if(CA_onPage == 0) { CA_properClickThrough = false; yBasedSuppress = false; } if( void_verify == false ) { ca_test = verifyCACollaterals(); if( ca_test == true ) { ca_test = false; showCADialog(); return 'Wait we have a last minute exclusive discount for you!'; } } else { return; } } function CA_TestClick() { if (CA_USItimerID != '') clearTimeout(CA_USItimerID); CA_properClickThrough = true; CA_USItimerID = setTimeout("CA_usiInterval();", 1000); if(CA_onPage == 0) CA_properClickThrough = false; } function CA_usiInterval() { if(!CA_USIdone){ CA_properClickThrough = false; } CA_USItimerID = ''; } document.documentElement.onmousedown = CA_TestClick; document.documentElement.onclick = CA_TestClick; document.documentElement.onkeypress = CA_TestClick;