var WebnogPopUp = new function(){};
WebnogPopUp.resetCookie = false;
WebnogPopUp.debugPopUp = false;

WebnogPopUp.showPopUpBox = function(){

   if(WebnogPopUp.runTest()){ 
       var webnogPopUpBuildScript = document.createElement('script');
       webnogPopUpBuildScript.src='http://www.webnographer.com/popUpBox/build/2';
       webnogPopUpBuildScript.onLoadDone = false;
       webnogPopUpBuildScript.onload= function(){
           webnogPopUpBuildScript.onLoadDone =  true;
       }
       webnogPopUpBuildScript.onreadystatechange = function(){
             if("loaded" === webnogPopUpBuildScript.readyState && !webnogPopUpBuildScript.onLoadDone){
                webnogPopUpBuildScript.onLoadDone =  true;
              }
       }
       document.getElementsByTagName('head')[0].appendChild(webnogPopUpBuildScript);
   }
}

WebnogPopUp.runTest = function(){
  if(WebnogPopUp.debug()) return true;
  if(!WebnogPopUp.urlCheck()) return false;
  if(WebnogPopUp.checkOurUrl()) return false;
  //this is so that we do not show a pop up if there is a
  //pop up from eDigitalResearch
  if(typeof ecos_go != 'undefined'){
      if(ecos_go) return false;
  }
  if(WebnogPopUp.test() || false){
    var rnd = (Math.random()*10);
    var weight = 0
    if(WebnogPopUp.resetCookie || weight >= rnd){
        return true;
    }
  }
  return false;
}

WebnogPopUp.checkOurUrl = function(){
    if(window.location.href.indexOf("px.webnographer.com")>-1){
         return true;
    }
    return false;
}

WebnogPopUp.urlCheck = function(){
   if(true){
     var restrictedURLs = "http://www.travelinesw.com/cms/index.xhtml".split(',');
     for (var i = 0; i < restrictedURLs.length; i++){
        if(window.location.href.indexOf(restrictedURLs[i])==0){
          return true;
        }
     return false;
     }
   }else{
     return true;
   }
}

WebnogPopUp.debug = function(){
  if(window.location.href.indexOf('webnogPopUp=debug') > 0){
     WebnogPopUp.debugPopUp = true;
     return true
  }else{
     return false;
  }
}


WebnogPopUp.test = function(){
  if(window.location.href.indexOf('webnogPopUp=test') > 0){
     return true
  }else if(window.location.href.indexOf('webnogPopUp=reset') > 0){
    WebnogPopUp.resetCookie = true;
    return true;
  }else{
     return false;
  }
}



//-------------------------------------------------