
function stopError() { return true; }
window.onerror = stopError;

if (window != top) top.location.href = location.href;

var message="";
function clickIE() { if (document.all) {(message);return false;}}
function clickNS(e) { 
if (document.layers || (document.getElementById&&!document.all)) {
if (e.which==2||e.which==3) {(message);return false;}}}
if (document.layers) 
{document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}
document.oncontextmenu=new Function("return false")

function eyePop(item) {
 var url ='http://ww2.ChristmasDepot.com/ssi/imagepop.cgi?'+item;
 var options = "resizable=yes,scrollbars=no,status=no,menubar=no";
 options += ",toolbar=no,location=no,directories=no";
 options += ",width=260,height=325,top=99,left=99";
 var EyePop = window.open(url,item,options);
// if (navigator.appVersion.indexOf('MSIE')<0) { window.eyepop.focus(); } 
}

function posPop(item) {
 var url = "http://ww2.christmasdepot.com/db/db-pos.cgi?" + item;
 var options = "width=380,height=130,";
 options += "resizable=yes,scrollbars=no,status=no,menubar=no";
 options += ",toolbar=no,location=no,directories=no";
 var newWin = window.open(url,'newWin',options);
 if (navigator.appVersion.indexOf("MSIE")<0) { window.newWin.focus(); }
}

function PopPage(aURL,w,h) {
 window.open(aURL,"popPage","directories=0,height=400,width=300,location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,toolbar=no");
 if (navigator.appVersion.indexOf("MSIE")<0) { window.popPage.focus(); } 
}

if ( typeof(ipNumber) === 'undefined') { 
  var ipNumber='<!--#echo var="REMOTE_ADDR"-->';
}

function getCookieVal(offset) {  
  var endstr=document.cookie.indexOf(";", offset);  
  if (endstr==-1) { endstr=document.cookie.length; }
  return unescape(document.cookie.substring(offset, endstr));
}

function getCookie(name) {
  var arg  = name+"=";
  var alen = arg.length;
  var clen = document.cookie.length;
  var i=0;
  while (i<clen) {
    var j=i+alen;
    if (document.cookie.substring(i, j)==arg) {
      return getCookieVal(j);
    }
    i=document.cookie.indexOf(" ", i) + 1;
    if (i == 0) break;
  }
  return "";
}


function fixDate(date) {
  var base = new Date(0);
  var skew = base.getTime();
  if (skew > 0) {
    date.setTime(date.getTime() - skew);
  }
}

  var current = new Date();
  fixDate(current);

//  current=current.toGMTString();

  var year = current.getYear();
  if (year*1<2000) { year=year+1900; }
  var mon  =current.getMonth()+1;
  if (mon*1<10) { day=("0"+mon); }
  var day  =current.getDate();
  if (day*1<10) { day=("0"+day); }

  var hour = current.getHours();
  var min  = current.getMinutes();
  var sec  = current.getSeconds();

  if (hour*1<10) { hour=("0"+hour); }
  if (min*1<10)  { min=("0"+min); }
  if (sec*1<10)  { sec=("0"+sec); }

  year=year+"";
  mon =mon +"";
  day =day +"";
  hour=hour+"";
  min =min +"";
  sec =sec +"";
  
  var dates= "" + mon + "/" + day + "/" + year + "" ;
  var times= "" + hour + ":" + min + ":" + sec + "" ;

  var string = year+mon+day+hour+min+sec;

  var code=0;
  var IPcode = new Array();
  IPcode = ipNumber.split(".");
  for(i=0;i<IPcode.length;i++) { 
    var ic=IPcode[i]*1;
    code = code * 1 + ic * 1;
  }
  code=code.toString();

  if (code.length<3) { code="0"+code; }
  if (code.length<3) { code="0"+code; }
  if (code.length<3) { code="0"+code; }

  var newCookie = "" + string + "." + code + "";
  var oldCookie = "" + getCookie('POPCARTID') + "";

  var oldCookieLength=oldCookie.length;
  if (oldCookieLength<14 || oldCookie.lastIndexOf('NaN')>0) {
    document.cookie='POPCARTID'+'='+escape(newCookie)+'; domain=.christmasdepot.com';
    document.cookie='CODE='+ code + '; domain=.christmasdepot.com';
  }

