
var PopUp=new MO.popUp("cw_lb");
MO.addEvent(document,"keydown",onkeydown);
if (document.addEventListener == undefined){
 MO.addEvent(document,"mouseup",onkeydown);
} else {
 MO.addEvent(document,"contextmenu",onkeydown);
}

PopUp.usi_iframe_loaded_twice=false;
PopUp._open=PopUp.open;
PopUp.initialized=false;
PopUp.usi_iframe=null;
PopUp.doPop=true;
PopUp.opened=false;

PopUp.sensor.onmouseover = do_pop_up;

function do_pop_up() {
 if (document.getElementById("lcp_div_Main") != null) {
/* California location for CarWoo */
  var o_isotree_carwoo_screen = document.getElementById("bg_isotree_carwoo");
  var o_isotree_screen = document.getElementById("bg_isotree");
  if (o_isotree_carwoo_screen != null && o_isotree_screen != null) {
   if (lcp_arrTechData != null && lcp_arrTechData['state'] == "CA") {
    o_isotree_carwoo_screen.style.display = "";
    o_isotree_screen.style.display = "none";
   } else {
    o_isotree_carwoo_screen.style.display = "none";
    o_isotree_screen.style.display = "";
   }
  }
/*********************************/
  if (document.getElementById("lcp_div_newCarPurchaseForm") != null && document.getElementById("lcp_div_newCarPurchaseForm").style.display != "none" && document.getElementById("lcp_div_Loading").style.display == "none" && document.lcp_newCarPurchaseForm.btn_submit.disabled == false) {
   if(PopUp.doPop===true){
    PopUp.doPop=false;
    PopUp.opened=true;
    PopUp.open();
    if ( != 0) callServer('POST', '/wp-content/plugins/isotree/scripts/track_popup_window_event.php', 'event=SHOW_POP_UP&session_id=', null, showNothing, null);
    return true;
   }
  }
 } else {
   if(PopUp.doPop===true){
    PopUp.doPop=false;
    PopUp.opened=true;
    PopUp.open();
    if ( != 0) callServer('POST', '/wp-content/plugins/isotree/scripts/track_popup_window_event.php', 'event=SHOW_POP_UP&session_id=', null, showNothing, null);
    return true;
   }
 }
 return false;
}

function onkeydown(e){
 var keyCode = e.keyCode ? e.keyCode : e.which ? e.which : e.charCode;
// if ((e.ctrlKey && keyCode == 87) || (e.altKey && keyCode == 115) || keyCode == 116 || e.button == 2) {
 if (e.ctrlKey || e.altKey || (e.which && (e.which == 3 || e.which == 17)) || (e.button && e.button == 2)) {
// if (e.which == 3) {
  if (do_pop_up()==true) {
   MO.stopEvent(e);
//   return true;
  }
 }
}

function track_popup_window_event(event, script, session_id) {
 if (script == null) script = '/wp-content/plugins/isotree/scripts/track_popup_window_event.php';
 if (session_id == null) session_id = '';
 if (typeof(callServer) != "function") return false;
 if (session_id != 0) callServer('POST', script, 'event='+event+'&session_id='+session_id, null, showNothing, null);
 if (event == "THIRD_PART_CLICK") {
  var params = "";
  if (document.lcp_newCarPurchaseForm != null) {
   var make  = (document.lcp_newCarPurchaseForm.make.value.length > 0) ? document.lcp_newCarPurchaseForm.make.value : "";
   var model = (document.lcp_newCarPurchaseForm.model.value.length > 0) ? document.lcp_newCarPurchaseForm.model.value : "";
   var zip   = (document.lcp_newCarPurchaseForm.zip.value.length > 0) ? document.lcp_newCarPurchaseForm.zip.value : "";
  }
  if (make.length > 0) params += "&make="+escape(make);
  if (model.length > 0) params += "&model="+escape(model);
  if (zip.length == 5) params += "&zipcode="+zip;

  window.location = "http://traffic.buyingadvice.com/?partner=carwoo"+params;
 } else {
  if (PopUp != null) PopUp.close();
 }
}

PopUp.open=function(){
 this._open();
 this.grayOut(true,{zindex:"-99"});
 if(!this.initialized){
  this.initialized=true
 }
};

PopUp.grayOut=function(a,k){
 k=(k===undefined)?{}:k;
 var j=(k.zindex===undefined)?50:k.zindex,e=(k.opacity===undefined)?70:k.opacity,d=(e/100),l=(k.bgcolor===undefined)?"#000000":k.bgcolor,b=null,g=null,f=null,i=null,h=null,c=null;
 this.dark=document.getElementById("darkenScreenObject");
 if(!this.dark){
  b=document.createElement("div");
  if(MO.isIE6()){
   b.style.position="absolute"
  } else {
   b.style.position="fixed";
   b.style.top="0px";
   b.style.left="0px"
  }
  b.style.overflow="hidden";
  b.style.display="none";
  b.id="darkenScreenObject";
  this.dlg.appendChild(b);
  this.dark=document.getElementById("darkenScreenObject");
  if(MO.isIE6()){
   this.dark.style.display="block";
   i=MO.getElementDimensions(this.dlg);
   f=MO.getElementDimensions();
   this.dark.style.top=-parseInt(f.h/2-i.h/2,10)+"px";
   this.dark.style.left=-parseInt(f.w/2-i.w/2,10)+"px";
   this.dark.style.display="none";
   this.shim.style.display="block";
   this.shim.style.top=this.dark.style.top;
   this.shim.style.left=this.dark.style.left;
   this.shim.style.width="100%";
   this.shim.style.zIndex=-999
  }
 }
 if(a){
  f=MO.getElementDimensions();
  h=f.w+"px";
  c=f.h+"px";
  if(f.w===0&&f.h===0){
   h="100%";
   c="100%"
  }
  this.dark.style.opacity=d;
  this.dark.style.MozOpacity=d;
  this.dark.style.filter="alpha(opacity="+e+")";
  this.dark.style.zIndex=j;
  this.dark.style.backgroundColor=l;
  this.dark.style.width=h;
  this.dark.style.height=c;
  if(MO.isIE6()){
   this.shim.style.width=h;
   this.shim.style.height=c
  }
  this.dark.style.display="block"
 } else {
  this.dark.style.display="none"
 }
};
/*
PopUp.iframe_load=function(a){
 var b=PopUp.usi_iframe;
 PopUp._usiIFrameOnload(b);
 return false
};

PopUp._iframeBackBtnBreaker=function(){
 var a="usiIFrame";
 if(this.usi_iframe){
  this.usi_iframe.src="/blank.php?usiBack=back";
  return
 }
 this.usi_iframe=document.createElement("iframe");
 this.usi_iframe.id=a;
 this.usi_iframe.name=a;
 this.usi_iframe.frameBorder="0";
 this.usi_iframe.src="/blank.php";
 this.usi_iframe.style.cssText="height:0px;width:0px;visibility:hidden";
 this.usi_iframe.onload=this.iframe_load;
 this.dlg.appendChild(this.usi_iframe);
 this.usi_iframe=document.getElementById(a);
 if(MO.isIE()){
  this.usi_iframe.src="/blank.php?ie";
  this._usiIFrameOnload(this.usi_iframe);
  MO.addEvent(this.usi_iframe,"readystatechange",function(){if(PopUp.usi_iframe.readyState==="complete"){PopUp.iframe_load()}})
 }
};

PopUp._usiIFrameOnload=function(a){
 if(!this.usi_iframe_loaded_twice&&this.usi_iframe.src.indexOf("?usiBack=back")===-1){
  this.usi_iframe.src="/blank.php?usiBack=back"
 } else {
  if(!this.usi_iframe_loaded_twice&&this.usi_iframe.src.indexOf("?usiBack=back")!==-1){
  this.usi_iframe_loaded_twice=true
  } else {
   if(this.usi_iframe_loaded_twice){
    PopUp.doPop=false;
    if(!PopUp.opened){
     history.back()
    }
   }
  }
 }
};

PopUp.loadEPop=function(){
 var b,a;PopUp._iframeBackBtnBreaker();
 b=document.getElementsByTagName("a");
 for(a=0;a<b.length;a+=1){
  if(b[a].href.toLowerCase().indexOf("javascript")===-1&&b[a].href.toLowerCase().indexOf("#")===-1&&b[a].href.toLowerCase().indexOf("whyform")===-1){
   b[a].onclick=function(){
    PopUp.doPop=false;
    return true
   }
  }
 }
 PopUp.toForm=Local.toForm;
 Local.toForm=function(){
  PopUp.doPop=false;
  PopUp.toForm();
  return false
 }
};

MO.addEvent(window,"load",PopUp.loadEPop);
*/