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 null;
}
function SetCookie (name, value) {
  var argv = SetCookie.arguments;
  var argc = SetCookie.arguments.length;
  var expires = (argc > 2) ? argv[2] : null;
  var path = (argc > 3) ? argv[3] : null;
  var domain = (argc > 4) ? argv[4] : null;
  var secure = (argc > 5) ? argv[5] : false;
  document.cookie = name + " = " + escape (value) +
    ((expires == null) ? "" : ("; expires = " + expires.toGMTString())) +
    ((path == null) ? "" : ("; Path = " + path)) +
    ((domain == null) ? "" : ("; domain = " + domain)) +
    ((secure == true) ? "; secure" : "");
}
function deleteCookie (name) {
  var exp = new Date();
  exp.setTime (exp.getTime() - 1);  // trash cookie
  var cval = GetCookie (name);
  if (cval != null)
    document.cookie = name + "=" + cval + ";  expires=" + exp.toGMTString();
}

function settest(){
var expDays = 5; // number of days the cookie should last
var expDate = new Date();
expDate.setTime(expDate.getTime() +  (24 * 60 * 60 * 1000 * expDays)); 
var test = "OK";

SetCookie('test', test, expDate);

}



function addurl()
{
var theHost = self.location.hostname;
var theUrl = self.location.href;
var theUrllength = self.location.length;
var theUrloffset = theUrl.indexOf(".com/");

theUrl = theUrl.substring(theUrloffset+5,theUrllength);

var theLength = document.referrer.length;





var refdate = new Date();
var  me = "No ID"+refdate;

if(document.referrer.indexOf('source=')!=-1)
{
   var  thesourceoffset = document.referrer.indexOf('source=')
   var  me = document.referrer.substring(thesourceoffset,theLength); 
   var expDays = 1; // number of days the cookie should last
   var expDate = new Date();
   expDate.setTime(expDate.getTime() +  (24 * 60 * 60 * 1000 * expDays)); 
   var tk = GetCookie('tk');
   var tklength =0

   if (tk !=null){
   var tklength =  tk.length;  
   }


   if (tklength>0 ){

     tk = tk.substring(0,tklength-5); 
     tk = tk+"@@"+me+"**.**";
     SetCookie('tk', tk, expDate);

   }
   else{
   tk = me+"**.**";
  
    SetCookie('tk', tk, expDate);
   }
}





if(document.referrer.indexOf(theHost)<0)
{

if(theLength != 0){

if (document.referrer.indexOf(theHost) == -1 || document.referrer.indexOf('bell-outlet.com')== -1) {
  
var  me = document.referrer.substring(7,theLength); 



var expDays = 1; // number of days the cookie should last
var expDate = new Date();
expDate.setTime(expDate.getTime() +  (24 * 60 * 60 * 1000 * expDays)); 
var tk = GetCookie('tk');


  if (tk!=me+"**.**"){
tk = me+"**.**";
 }



// if (tk != GetCookie('tk')) SetCookie('tk', tk);
SetCookie('tk', tk, expDate);
}
}
}
}

function popship(product,weight,express)
{
window.open('shipcost.php?product='+product+'&weight='+weight+'&express='+express+'',"theWindow","scrollbars=no,menubar=no,personalbar=no,width=500,height=500,screenX=220,screenY=0");
}
function openform(url) {
var url = url + "?url=" + document.location
	var NS = (document.layers) ? true : false;
	var IE = (document.all) ? true : false;

if(NS) {
	window.open(url,"","scrollbars=no,menubar=no,personalbar=no,width=500,height=500,screenX=220,screenY=0");
} else if(IE) {
	window.open(url,"","scrollbars=no,menubar=no,personalbar=no,width=500,height=500,left=220,top=0");
}

}

function popwin(item){
window.open('pics/'+item+'.jpg','part','dependant=1,width=300,height=300');
}
function popinfo(product)
{

this.open(product+'.htm',"CtrlWindow","toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,width=450,height=400")
}
//No Right Click
if (window.Event)
  document.captureEvents(Event.MOUSEUP);

function nocontextmenu() {
  event.cancelBubble = true, event.returnValue = false;

  return false;
} 

function norightclick(e) {
  if (window.Event) {
    if (e.which == 2 || e.which == 3) return false;
  }
  else if (event.button == 2 || event.button == 3) {
    event.cancelBubble = true, event.returnValue = false;
    return false;
  }
}

if (document.layers)
  document.captureEvents(Event.MOUSEDOWN);

document.oncontextmenu = nocontextmenu;
document.onmousedown = norightclick;
document.onmouseup = norightclick;

function popUp(URL) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=450,height=400,left = 200,top = 100');");
}

function keroinfo(product)
{

this.open(product+'.htm',"CtrlWindow","toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,width=625,height=400")
}
function nocookie(product)
{

this.open(product+'.htm',"CtrlWindow","toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,width=500,height=375")
}
function popholiday(product)
{

this.open(product+'.htm',"CtrlWindow","toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,width=475,height=600")
}
function popwindow(product)
{

this.open(product+'.htm',"CtrlWindow","toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,width=525,height=350")
}

