// COMBINES SPORTSWEAR, MENU, ECOM, ELUCID_PRODNAV.JS

// alternative to target="_blank" link must include rel="external"
function externalLinks() {
 if (!document.getElementsByTagName) return;
 var anchors = document.getElementsByTagName("a");
 for (var i=0; i<anchors.length; i++) {
   var anchor = anchors[i];
   if (anchor.getAttribute("href") &&
       anchor.getAttribute("rel") == "external")
     anchor.target = "_blank";
 }
}
window.onload = externalLinks;



// Used to populate multiple text fields when registering a child
function copyData(from,to) { to.value = from.value; }

// -------------------- library functions
function isIE6() {
  var av = navigator.appVersion;
  var i = av.indexOf('MSIE 6');
  return (i < 50 && i > -1);
}
//
function hideSelects() {
  if (isIE6()) {
    for(var m = 0; m < document.all.tags("SELECT").length; ++m) {
        document.all.tags("SELECT")[m].style.visibility='hidden';
    }
  }
}
//
function showSelects() {
  if (isIE6()) {
    for(var s = 0; s < document.all.tags("SELECT").length; ++s) {
        document.all.tags("SELECT")[s].style.visibility='visible';
    }
  }
}
//
function mouseX(evt) {
if (evt.pageX) return evt.pageX;
else if (evt.clientX)
   return evt.clientX + (document.documentElement.scrollLeft ?
   document.documentElement.scrollLeft :
   document.body.scrollLeft);
else return null;
}
//
function mouseY(evt) {
if (evt.pageY) return evt.pageY;
else if (evt.clientY)
   return evt.clientY + (document.documentElement.scrollTop ?
   document.documentElement.scrollTop :
   document.body.scrollTop);
else return null;
}
//--------------------------------------
function getBounds(ele) {
  var res = { x:0, y:0, w:0, h:0 }
  if (typeof(ele) == 'string') { var el = document.getElementById(ele); } else { el = ele; }
  if (el) {
    res.x = el.offsetLeft; res.y = el.offsetTop;  res.h = el.offsetHeight;  res.w = el.offsetWidth;
    while((el=el.offsetParent) != null) {
      res.x += el.offsetLeft+(el.clientLeft ? el.clientLeft : 0);
      res.y += el.offsetTop+(el.clientTop ? el.clientTop : 0);
    }
  }
  return res;
}
//--------------------------------------
function xOnPage(x,w,centerIt,ele,fixed) {
  var sw = -1;
  if (self.innerWidth){sw = self.innerWidth;}
  else if (document.documentElement && document.documentElement.clientWidth){sw = document.documentElement.clientWidth;}
  else if (document.body){sw = document.body.clientWidth;}
  var wmin = (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : (window.pageXOffset ? window.pageXOffset : 0));
  if (typeof(wmin) != 'number' || wmin < 0) { wmin = 0; }

  if (isIE6()) { fixed = false; }
  if (fixed) { wmin = 0; }

  var sw = sw + wmin;
  if (centerIt) { x = (Math.round((sw - wmin - w) / 2)) + wmin; }
  if ((sw > -1)) {	if (x<0) { x=0; }		if ((x + w) > sw - 10) {	x = sw - w - 10;	} }
		if (x < wmin) { x = wmin; }
		return x;
}
function yOnPage(y,h,centerIt,ele,fixed) { // pass ele to make sure max height is not exceeded
  var sh = -1;
  if (self.innerHeight){sh = self.innerHeight;}
  else if (document.documentElement && document.documentElement.clientHeight){sh = document.documentElement.clientHeight;}
  else if (document.body){sh = document.body.clientHeight;}
  var hmin = (document.documentElement.scrollTop ? document.documentElement.scrollTop : (window.pageYOffset ? window.pageYOffset : 0));
  if (typeof(hmin) != 'number' || hmin < 0) { hmin = 0; }

  if (isIE6()) { fixed = false; }
  if (fixed) { hmin = 0; }

  var sh = sh + hmin;
  if (centerIt) { y = (Math.round((sh - hmin - h) / 2)) + hmin; }
  if ((sh > -1)) {	if (y<0) { y=0; }		if ((y + h) > sh - 10) {	y = sh - h - 10 ; } }
		if (y < hmin) { y = hmin; }
  if (ele && h > sh) { ele.height = sh; }
		return y;
}
//--------------------------------------
// popup.... are routines to use if you want a mouse listener and optional hotspot.
// use: call popupInit(closefunc, hotid) at the start of your popup show function and pass it your hide/close function.
// hotId is the id of the click-to-close area - pass '' for anywhere on the page or !divid to close anywhere EXCEPT divid.
// If you want to manually close the popup, call popupClose('','myresult') NOT your hide/close function
// 'myresult' will be put in global var popupResult so you can control what to do in the hide/close function
var popupSafeToClose = false;
var popupOMD = null;
var popupDiv = '';
var popupCloseFunc = null;
var popupResult = '';
var popupClosing = false;
var popupPending = null;
var popupClosedTime = 0;
//
function popupInit(closeFunc, hotId) {
  if (popupClosing) { return false;  }
  popupPending = null;
  // tidy up any open popup
  if (popupSafeToClose) { popupRemoveListener(); if (popupCloseFunc) { popupCloseFunc();} popupCloseFunc = null;  popupSafeToClose = false; }
  // prep the listener for the new popup
  popupCloseFunc = closeFunc;  popupDiv = hotId;  popupAttachListener();  hideSelects();  popupSafeToClose = true;
  return true;
}
//
function popupClose(e,closeResult) {
  if (popupSafeToClose) {
    if (popupDiv.match('!')) { var pd = popupDiv.substring(1,100); var inpd = false; } else { var pd = popupDiv; var inpd = true; }
    if (pd == '' || (pd != '' && (e == '' || e == 'timer' || (inpd && popupInDiv(e,pd)) || (!inpd && !popupInDiv(e,pd))))) {
      popupClosing = true;
      popupResult = (closeResult==undefined ? null : closeResult);
//      popupResult = ((closeResult == '') || (closeResult==null) || (closeResult==undefined) ? '' : closeResult);
      popupRemoveListener();
      popupSafeToClose = false;
      if (popupCloseFunc) { popupCloseFunc();}
      popupCloseFunc = null;
      showSelects();
      popupClosing = false;
      popupClosedTime = Date.parse(new Date());

      if (popupPending) { popupPending(); popupPending = null; }
    }
  }
}
function popupJustClosed() {
  var now = Date.parse(new Date());
//  alert(now+' '+popupClosedTime);
  var i = Math.abs(now - popupClosedTime);
//  alert(i);
  popupClosedTime = 0;
  return (i < 300);
}
//
function popupAttachListener() {
   	if (document.layers) {	document.captureEvents(Event.MOUSEDOWN);	}
   	popupOMD = document.onmousedown;
   	if (popupOMD != null) {	document.onmousedown = function(event) { popupOMD(event); popupClose(event); } }
    else { document.onmousedown = function(event) { popupClose(event); } }
}
//
function popupRemoveListener() {
   	if (popupOMD != null) {	document.onmousedown = popupOMD; } else { document.onmousedown = null; }
}
//
function popupInDiv(e, divID) {
  if (!e) var e = window.event; // make sure IE has the event in e
  if (!divID) { divID = popupDiv; }
  if (document.layers) {
			var clickX = e.pageX;
			var clickY = e.pageY;
			var t = document.layers[divID];
			if ((clickX > t.left) && (clickX < t.left+t.clip.width) && (clickY > t.top) && (clickY < t.top+t.clip.height)) {
				return true;
			}
		}
		else if (e && e.srcElement) {
			var t = e.srcElement;
			while (t && t.parentElement != null) {
				if (t.id==divID) {	return true; }
				t = t.parentElement;
			}
		}
		else if (e && e.originalTarget) {
			var t = e.originalTarget;
			while (t && t.parentNode != null) {
				if (t.id==divID) { return true; }
				t = t.parentNode;
			}
		}
}
// end popup listener
//--------------------------------------
function getCookie( check_name ) {
   var a_all_cookies = document.cookie.split( ';' );
   var a_temp_cookie = '';
   var cookie_name = '';
   var cookie_value = '';
   var b_cookie_found = false; // set boolean t/f default f

   for ( i = 0; i < a_all_cookies.length; i++ )
   {
      a_temp_cookie = a_all_cookies[i].split( '=' );
      cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');  // trim
      if ( cookie_name == check_name )
      {
         b_cookie_found = true;
         if ( a_temp_cookie.length > 1 ) { cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') ); }
//alert(document.cookie);
         return cookie_value;
         break;
      }
      a_temp_cookie = null;
      cookie_name = '';
   }
   if ( !b_cookie_found ) { return ''; }
}
//--------------------------------------
// expires is in days
function setCookie( name, value, expires, path, domain, secure ) {
  var today = new Date();
  today.setTime( today.getTime() );
  if ( expires ) { expires = expires * 1000 * 60 * 60 * 24; }
  var expires_date = new Date( today.getTime() + (expires) );

  var s = name + "=" +escape( value ) +
    ( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + //expires.toGMTString()
    ( ( path ) ? ";path=" + path : "" ) +
    ( ( domain ) ? ";domain=" + domain : "" ) +
    ( ( secure ) ? ";secure" : "" );
  document.cookie = s;
}
//--------------------------------------
function deleteCookie( name, path, domain ) {
  if ( getCookie( name ) ) document.cookie = name + "=" +
     ( ( path ) ? ";path=" + path : "") +
     ( ( domain ) ? ";domain=" + domain : "" ) +
     ";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}
//----
function cssStyle(el, property) {
//alert('1 '+el.style[property]);
//alert('2 '+(el.currentStyle ? el.currentStyle[property] : 'none'));
//try {
//alert('3 '+window.getComputedStyle(el,'').getPropertyValue(property));
//} catch(err) { alert('3 none'); }
  var res = el.style[property];
  if (!res) {
    if (el.currentStyle && el.currentStyle[property]) {
      res = el.currentStyle[property];
    } else {
      // this method uses 'background-image' not the passed format of 'backgroundImage'
      prop = "";
      for (var i=0; i < property.length; i++) {
        if (property.charAt(i) == property.charAt(i).toUpperCase()) {
          prop += '-' + property.charAt(i).toLowerCase(); }
        else {
          prop += property.charAt(i); }
      }
//      alert(prop);
      res = getComputedStyle(el,'').getPropertyValue(prop);
    }
  }
  if (!res) { res = ''; }
  res = res.replace('px','');
  return res;
}
//------------
// use this to create a dynamic div -- avoiding the IE6 hidden stuff problem
var isModal = true;
var modalCover = null;

function createModalCover( ) {
  var div = document.getElementById('modalCover');
  if (!div) {
    var div = document.createElement('div');
    div.setAttribute('id', 'modalCover');
    div.setAttribute('name', 'modalCover');
    div.style.display = 'none';
    document.body.appendChild(div);
  }
  return div;
}

function documentSize() {
  if (window.innerHeight && window.scrollMaxY) {// Firefox
    var y = window.innerHeight + window.scrollMaxY;
    var x = window.innerWidth + window.scrollMaxX;
//  } else if (document.documentElement.clientHeight) {  // dumb opera return the window size not the document
//    var x = document.documentElement.clientHeight;
//    var y = document.documentElement.clientHeight;
  } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
    var y = document.body.scrollHeight;
    var x = document.body.scrollWidth;
  } else { // works in Explorer 6 Strict, Mozilla (not FF) and Safari
    var y = document.body.offsetHeight;
    var x = document.body.offsetWidth;
  }
  if (y == 0)  y = 5000;
  return { 'width':x, 'height':y };
}

function showModalCover( ) {
  var div = document.getElementById('modalCover');
  if (div) {
    div.style.left = '0px';
    div.style.width = '100%';
    div.style.top = '0px';

    var sh = -1;
    if (self.innerHeight){sh = self.innerHeight;}
    else if (document.documentElement && document.documentElement.clientHeight){sh = document.documentElement.clientHeight;}
    else if (document.body){sh = document.body.clientHeight;}

    var size = documentSize();
    var h = size.height;
    if (h < sh) { h = sh; }
    div.style.height = h+'px';
    div.style.display = 'block';
  }
}
function hideModalCover( ) {
  var div = document.getElementById('modalCover');
  if (div) {
    div.style.display = 'none';
  }
}

function createDynamicPopup(id, modal ) {
  if (modal) { var cover = createModalCover(); }

//  var div = document.getElementById(id);
// 	if (div) { div.parentNode.removeChild(div);

  var div = document.getElementById(id);
  if (!div) {
    var div = document.createElement('div');
    div.setAttribute('id', id);
    div.setAttribute('name', id);
    div.style.display = 'none';
    div.style.zIndex = 10000;
    document.body.appendChild(div);
//    if (modal) { cover.appendChild(div); } else { document.body.appendChild(div); }
  }
  div.style.zIndex = 10000;
  return div;
}
// -------------------- web site functions
function initForecastInfo(modal,titlediv,bodydiv) {
  var id = 'forecastInfo';
  var div = createDynamicPopup(id, modal);
  s = '';
  s += '<div id="forecastInfoIn">';
  s += ' <div id="forecastInfoHead">'+document.getElementById(titlediv).innerHTML+'</div>';
  s += ' <img id="forecastInfoCloseBtn" src="assets/img/closebtn1.jpg" alt="close" title="close" />';
  s += ' <div id="forecastInfoText">';
  s += '   <p>';
  s += document.getElementById(bodydiv).innerHTML
  s += '   </p>';
  s += ' </div>';
  s += ' <div id="forecastInfoFoot">';
  s += '	<a href="close" onClick="popupClose(\'\',\'close\'); return false;" alt="close" title="close">Close</a>';
  s += ' </div>';
  div.innerHTML = s;
  return div;
}
function showForecastInfo(el,titlediv,bodydiv,wid) {
  div = initForecastInfo(!isModal,titlediv,bodydiv);
  popupInit(hideForecastInfo,'forecastInfoCloseBtn');
  pos = getBounds(el);
  div.style.display = 'block';
  if (wid) {
//    div.style.width = wid + 'px';
    document.getElementById('forecastInfoIn').style.width = (wid-14) + 'px';
  }
  var x = xOnPage(pos.x-200,div.offsetWidth);
  var y = yOnPage(pos.y,div.offsetHeight);
  div.style.left = x + 'px';
  div.style.top = y + 'px';
}
function hideForecastInfo() {
  var el = document.getElementById('forecastInfo');
  if (el) { el.style.display = 'none'; }
}
//
function addLoadEvent(func, first) {  // set first to true to add this event at the front of the queue
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  }
  else {
  window.onload = function() {
      if (first) { func(); }
      if (oldonload) { oldonload(); }
      if (!first) { func(); } // an error here usually means you have passed the func with ()
    }
  }
}
//
function checkLock() {
  var el = document.getElementById('pagelock');
  if (el) {
    if (el.value=='LOCKED') {
      document.body.innerHTML = '';
      location = window.location.href;
    }
    else { var xx = window.setTimeout('checkLock2()',1); }
  }
}
function checkLock2() {
  var el = document.getElementById('pagelock');
  if (el) {
//    alert('onloadtimer'+el.value)
    if (el.value=='OK') { el.value = 'LOCKED'; }
    else {
      document.body.innerHTML = '';
      location = window.location.href;
    }
  }
}
//
//addLoadEvent(postLoadImages);
//


var root='';
var nan=navigator.appName;
var NS4 = (nan=='Netscape') ? 1 : 0;
var IE4 = (nan.substring(0,9)=='Microsoft') ? 1 : 0;
//alert('NS4=' + NS4 + '   --  IE4=' + IE4);
var bbb;
var duration;
var bn = new Array(20);
var bl = new Array(20);
bn[1] = "banners/aaaaa.gif";
bn[2] = "banners/bbbbbb.gif";
bl[1] = "default.asp?submit=Home";
bl[2] = "default.asp?prod=10";




   function noback() {
      document.location.replace('login.asp?submit=Logout');
   }

   function clearEl() {}

   function activateEl() {}

   function gotoPage(el,sub,link) {
      var e = el.name;
      var i;

      if (e != 'perpage') {
         for (i = 0; i < el.options.length; i++) {
            if (el.options[i].selected) var val = el.options[i].value;
         }
      }

      var r = document.jump1.perpage;
//      var url = 'prodpage.asp?sub=' + sub + '&type=prod&page=' + val;
       var url = 'prodpage.asp?'+link + '&page=' + val;
      if (r != undefined) {
         var pp = document.jump1.perpage.length;
         if (pp>0) {
            for (i = 0; i < pp; i++) {
               if (document.jump1.perpage.options[i].selected) var pv = document.jump1.perpage.options[i].value;
            }
            url = root+'prodpage.asp?'+ link + '&page=' + val + '&perpage='+pv;
         }
      }
      location = url;
   }

   function login() {
      location = root+"default.asp?submit=login"
   }

   function rotate(i) {
   	duration = 2000;
      ++i;
      if (i > 2) i = 1;
      document.images.banner.src = bn[i];
      document.links["blink"].href.value = bl[i];
      bbb = "window.setTimeout('rotate("+i+");',"+duration+");"
      eval(bbb);
   }

   function buyItem(f) {
//      if (NS4) {var x = "document.frm"+f+".submit()";}
//      eval(x);
   }

   function buyMe(f) {
      if (NS4) {var x = "document.frm"+f+".submit()";}
      eval(x);
   }

   function getPrice(what,which) {
      var xurl = "";
      var exp1 = "document."+what+".sp"+which+".length";
      var exp2 = "document."+what+".sp"+which+".options[i].selected";
      var exp3 = "document."+what+".sp"+which+".options[i].value";
      for (var i=0; i<eval(exp1); i++) {
         if (eval(exp2)) {
            xurl = eval(exp3);
         }
      }
     location = root+xurl;
   }

   function gotoProcess(what) {
      var xurl = ""
      var exp1 = "document.sidebar."+what+".length"
      var exp2 = "document.sidebar."+what+".options[i].selected"
      var exp3 = "document.sidebar."+what+".options[i].value"
      for (var i=0; i<eval(exp1); i++) {
         if (eval(exp2)) {
            xurl = eval(exp3)
         }
      }
     location = root+xurl
   }

   function bigpix(what,wd,ht) {
      if (wd=="") {wd=400};
      if (ht=="") {ht=500};
   	var a = "bigpix.asp?what="+what
   	var b = "picwin"
   	var c = "width="+wd+",height="+ht+",resizable,scrollbars=yes"
      var w = window.open(a,b,c);
      w.moveTo(50, 50)
   }


   function emailfriend(what,wd,ht) {
      if (wd=="") {wd=500};
      if (ht=="") {ht=600};
   	var a = "email_a_friend.asp?what="+what
   	var b = "picwin"
   	var c = "width="+wd+",height="+ht+",resizable,scrollbars=yes"
     var w = window.open(a,b,c);
     w.moveTo(50, 50)
   }

   function bigpix2(what,w,h) {
      if (w=="") {w=300};
      if (h=="") {h=200};
      if (what!="") {
         var x = "width="+w+",height="+h+",resizable,scrollbars=yes";
         var win = window.open("","BigPix",x);
         win.document.write("<html><title>The BIG picture</title><head></head>");
         win.document.write("<body><img src="+what+" border=no onClick='self.close()'><br><br><font face=Arial size=2 color=darkblue>Click in window to close</font></body></html>");
         win.moveTo(50,0);
         }
   }

   function colorSelector(what,name) {
      var w = window.open("color.asp?what="+what+"&name="+name,"colorwin","width=349,height=134");
      w.moveTo(420, 230)
   }

   function specialpopup(what,w,h) {
      if (w=="") {w=500};
      if (h=="") {h=300};
      if (what!="") {le,scr
         var x = "width="+w+",height="+h+",resizabollbars=yes";
         var win = window.open("specials.asp?what="+what,"Special",x);
         win.moveTo(50, 350);
         }
   }

   function addressFindpopup(what,num,w,h) {
      var x = "width="+w+",height="+h+",resizable,scrollbars=no";
      if (what=='register') num='';
         var a = document.getElementById('address'+num);
         var ax = '&address='+a.value;
         a = document.getElementById('city'+num);
         ax = ax+'&city='+a.value;
         a = document.getElementById('county'+num);
         ax = ax+'&county='+a.value;
         a = document.getElementById('postcode'+num);
         var aa = a.value;
         if (aa.length>2) {
            ax = ax+'&postcode='+a.value;
//alert("addressLookup.asp?calledBy="+what+"&num="+num+ax,"Details",x);
            var win = window.open("addressLookup.asp?calledBy="+what+"&num="+num+ax,"Details",x);
            win.moveTo(100, 100);
         } else {
         	 alert('Please enter a postcode.');
      }
   }

   function orderpopup(what,w,h) {
      if (what!="") {
         var x = "width="+w+",height="+h+",resizable,scrollbars=yes";
         var win = window.open("order_details.asp?order="+what,"Details",x);
         win.moveTo(100, 100);
         }
   }

   function configpopup(what,w,h) {
      if (what!="") {
         var x = "width="+w+",height="+h+",resizable,scrollbars=yes";
         var win = window.open("config_show.asp?what="+what,"Details",x);
         win.moveTo(100, 100);
         }
   }

   function friendpopup(part,w,h) {
      if (part!="") {
         if (w=="") {w=500};
         if (h=="") {h=300};
         var x = "width="+w+",height="+h+",resizable,scrollbars=yes";
         var win = window.open("friend.asp?part="+part+"&mode=ask","Email_a_friend",x);
         win.moveTo(100, 100);
         }
   }


   function windowpopup(html,title,w,h) {
      if (html!="") {
         if (w=="") {w=500};
         if (h=="") {h=300};
     var x = "width="+w+",height="+h+",resizable,scrollbars=yes";
         var win = window.open(html,title,x);
         win.moveTo(100, 100);
         }
   }



   function config_errors(what,w,h) {
      if (what!="") {
         var x = "width="+w+",height="+h+",resizable,scrollbars=yes";
         var win = window.open("config_errors.asp?what="+what,"Errors",x);
         win.moveTo(100, 100);
      }
   }

   function buypopup() {
      var w = window.open("","Cart","width=350,height=180");
      w.document.write("<style>#s1 {font-family: Arial, sans-serif; font-size: 16px; font-weight: bold; color: blue;}");
      w.document.write("#s2 {font-family: Arial, sans-serif; font-size: 16px; font-weight: bold; color: red;}</style>");
      w.document.write("<body><center><br><span id=s1>Product added to your basket</span></center></body>");
      w.moveTo(350, 100)
   }

   function cartpopup(what) {
      var w = window.open("","Cart","width=350,height=180");
      w.document.write("<style>#s1 {font-family: Arial, sans-serif; font-size: 16px; font-weight: bold; color: blue;}");
      w.document.write("#s2 {font-family: Arial, sans-serif; font-size: 16px; font-weight: bold; color: red;}</style>");
      w.document.write("<head><title>Your cart still contains items from last visit</title></head>");
      var i = "";
      if (what > 1) {i = "s"}
      w.document.write("<body><center><br><span id=s1>Your shopping trolley still contains<br><br><span id=s2>"+what+"</span><br><br>item"+i+" from your last visit.</span></center></body>");
      w.moveTo(350, 100)
   }

   function noCookies() {
      var w = window.open("","Cookies","width=500,height=200");
      w.document.write("<style>#s0 {font-family: Arial, sans-serif; font-size: 16px; font-weight: bold; color: white;}</style>");
      w.document.write("<style>#s1 {font-family: Arial, sans-serif; font-size: 16px; font-weight: bold; color: red;}</style>");
      w.document.write("<head><title>Your browser is NOT cookie enabled.</title></head>");
      w.document.write("<body><center><br><span id=s1>This site requires a cookie enabled browser to operate correctly.<br><br>Please enable your browser and visit us again or use one that is enabled, if you desire to purchase from this site.<br><br>Thank you very much.</span></center></body>");
      w.moveTo(220, 180)
   }

   function deletePages(what) {
   	 var x = document.infoPages.num.value
      var p = "num="+x
      for(var i = 0; i < x*3; i++) {
         var e = document.infoPages.elements[i];
         if (e.type=="checkbox") {
         	p = p + "&" + e.name + "=" + e.checked
         }
         if (e.type!="checkbox") {
         	p = p + "&" + e.name + "=" + e.value
         }
      }
      var w = window.open("del_info_pages.asp?"+p,"deleteInfo","width=350,height=200,scrollbars=yes");
      w.moveTo(200, 200)
   }

   function debugWindow() {
      var hw = window.open("debug.asp","Debug","width=650,height=450,scrollbars");
      hw.moveTo(158, 55)
   }

   function helpWindow() {
      var hw = window.open("HowToUse.asp","Help","width=615,height=484,scrollbars");
      hw.moveTo(158, 55)
   }

   function viewProm(what) {
      var url = "maintain_promotions.asp?submit=View&what="+what
      document.promotions.id.value = what;
      location = root+url;
   }

   function viewDisc(what) {
      var url = "maintain_discounts.asp?submit=View&what="+what
      document.discounts.id.value = what;
      location = root+url;
   }

   function submit_func() {
      document.forms[0].submit();
   }

   function submit_head(form) {
      document.head.submit();
   }

   function submit_login(form) {
      document.login.submit();
   }

   function submit_feat(form) {
      document.feat.submit();
   }

   function submit_select(form) {
      document.select.submit();
   }

   function submit_art(form) {
      document.selart.submit();
   }

   function submit_prod(form) {
      document.selprod.submit();
   }

   function submit_divs(form) {
      document.divs.submit();
   }

   function uploadPix(name) {
   	   var url = 'graphic.asp?pic=' + name
   	   var pix = window.open(url,"upload","width=520,height=100");
      pix.moveTo(170, 250)
   }

   function isblank(s)
   {
      for(var i = 0; i < s.length; i++) {
         var c = s.charAt(i);
         if ((c != ' ') && (c != '\n') && (c != '\t')) return false;
      }
      return true;
   }

   function verify(f)
   {
      var msg;
      var later = "n";
      var inv = "n";
      var empty_fields = "";
      var errors = "";
      var arr;
      var ia;
      var i;

    // Loop through the elements of the form, looking for all
    // text and textarea elements that don't have an "optional" property
    // defined. Then, check for fields that are empty and make a list of them.
    // Also, if any of these elements have a "min" or a "max" property defined,
    // then verify that they are numbers and that they are in the right range.
    // Put together error messages for fields that are wrong.
    for(i = 0; i < f.length; i++) {
        var g = f.elements[i];
        if ((g.type == "checkbox") && (g.name == "later")) {
           if (g.checked == true) later = "y";
        }
    }
    for(i = 0; i < f.length; i++) {
        var e = f.elements[i];
        if (((e.type == "text") || (e.type == "textarea") || (e.type == "file")) && !e.optional) {
            // first check if the field is empty
            if ((e.value == null) || (e.value == "") || isblank(e.value)) {
                if (later != "y") {
                	empty_fields += "\n          " + e.name;
                }
                else if (e.name != "Graphic") {
                	empty_fields += "\n          " + e.name;
                }
                continue;
            }
            if (e.name == "Email") {
               var email1 = e.value
               arr = email1.split(" ")
               for(ia = 0; ia < arr.length; ia++) {
                  if (arr[ia] != " ") {
                  	email1 = arr[ia]
                  }
               }
            }
            if (e.name == "Emailchk") {
               email2 = e.value
               arr = email2.split(" ")
               for(ia = 0; ia < arr.length; ia++) {
                  if (arr[ia] != " ") {
                  	email2 = arr[ia]
                  }
               }
               if (email1 != email2)
                  errors += "\n email address error"
            }
            // Now check for fields that are supposed to be numeric.
            if (e.numeric || (e.min != null) || (e.max != null)) {
                var v = parseFloat(e.value);
                if (isNaN(v) ||
                    ((e.min != null) && (v < e.min)) ||
                    ((e.max != null) && (v > e.max))) {
                    errors += "- The field " + e.name + " must be a number";
                    if (e.min != null)
                        errors += " that is greater than " + e.min;
                    if (e.max != null && e.min != null)
                        errors += " and less than " + e.max;
                    else if (e.max != null)
                        errors += " that is less than " + e.max;
                    errors += ".\n";
                }
            }
        }
    }

    // Now, if there were any errors, display the messages, and
    // return false to prevent the form from being submitted.
    // Otherwise return true.
    if (!empty_fields && !errors) return true;

    msg  = "__________________________________________________\n\n"
    msg += "The form was not submitted because of the following error(s).\n";
    msg += "          Please correct these error(s) and re-submit.\n";
    msg += "__________________________________________________\n\n"

    if (empty_fields) {
        msg += "- The following required field(s) are empty:\n"
                + empty_fields + "\n";
        if (errors) msg += "\n";
    }
    msg += errors;
    alert(msg);
    return false;
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
   var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
   var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
   if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v3.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function search() {
   var what = document.find.searchwhat.value;
   if (what != '') {
     document.search.searchwhat.value = what;
     document.search.submit();
   }
   else {
      alert('Please enter a keyword to search on');
   }
}

function searchI() {
   var what = document.find.searchwhat.value;
   if (what != '') {
     document.search.searchwhat.value = "item:"+what;
     document.search.submit();
   }
   else {
      alert('Please enter a keyword to search on');
   }
}

function searchP() {
   var lo = document.find.lo.value;
   var hi = document.find.hi.value;
  document.search.searchwhat.value = "price:"+lo+"#"+hi;
  document.search.submit();
}

function initialize() {
//      MM_preloadImages('NewSidebar/wrtinsbut2.gif','NewSidebar/bar2.gif','NewSidebar/calendar2.gif','NewSidebar/clocks2.gif','NewSidebar/clothing2.gif','NewSidebar/conference2.gif','NewSidebar/executive2.gif','NewSidebar/golf2.gif','NewSidebar/keytag2.gif','NewSidebar/leather2.gif','NewSidebar/mugs2.gif','NewSidebar/novelties2.gif','NewSidebar/stationery2.gif','NewSidebar/sweda2.gif','NewSidebar/custservice2.gif','NewSidebar/checkout2.gif','NewSidebar/howtoorder2.gif','NewSidebar/viewcart2.gif');
}

function M_over(n,i) {
   if (document.images)
      document.images[n].src = i
}

function M_out(n,i) {
   if (document.images)
      document.images[n].src = i
}

var buywin;
function PopCartMsg() {
   buywin = window.open("","buyme","width=430,height=120");
   buywin.document.write("<html><style>#s1 {font-family: Arial, sans-serif; font-size: 10px; font-weight: bold; color: blue;}</style>");
   buywin.document.write("<head><title>One-time buy message</title>");
   buywin.document.write('</script>');
   buywin.document.write("</head>");
   buywin.document.write('<body topmargin=0 leftmargin=0 bottommargin=0 rightmargin=0 marginwidth=0 marginheight=0>')
   buywin.document.write('<center><br><span id=s1>The product you have selected has been added to your shopping trolley. <br><br>')
   buywin.document.write('The number of items in the trolley will be shown at the top right of this page. <br><br>')
   buywin.document.write('The shopping trolley may be viewed later by clicking on the link at top of the page<br><br>')
   buywin.document.write('This message will be shown only once during your visit.')
   buywin.document.write('<FORM><INPUT TYPE="button" VALUE="Close Window" onClick="window.close()"></FORM>')
   buywin.document.write('</span></center></body></html>');
   buywin.moveTo(420, 230);
   setTimeout("shutIt()",20000);
}

function shutIt() {
   buywin.close();
}

function SCSbuy(f) {
alert('SCSbuy '+f)
   var errors = "";
   var msg = "";
   var x = "";
   var a = "";
   for (var i = 0; i < f.length; i++) {
      var e = f.elements[i];
      if (e.type == "text" && e.name != "dum") {
   	    var v = parseFloat(e.value);
   	    if (isNaN(v)) {
    	   	  x = "";
    	   	  a = "";
    	   	  a += e.name;
   	       x += a.substring(3,a.length);
    	       errors += x+" NOT numeric = "+e.value+".\n";
    	    }
      }
   }
   if (!errors) return true;
   msg = "The following errors were found - Please correct and try again.\n\n";
   msg += errors;
   alert(msg);
   return false;
}

function dobgcolors() {
//  if (NS4) {
//      var obj = eval('document.forms["prc"].elements["ie_plenty"]');
//alert(obj);
//      obj.bgcolor = "#A5F7E7";
//   }
}

var v = new Array();
function act(w) {
   var a = w.name;
   var b = a.substr(0,1);
   var n = a.substr(1,2);
   var num = parseFloat(document.matrix.elements["number"].value);
   for (var j=0; j<num; j++) {
      var m = j+(n-1)*(num)+2;
      if (b=="c") {
         var y = document.matrix.elements[m];
         v[j] = y.value;
      }
      if (b=="p") {
         document.matrix.elements[m].value = v[j];
      }
      if (b=="d") {
         document.matrix.elements[m].value = 0;
      }
   }
}

function buyCheck(x)
{
   var a;
   var b;
   var c;
   var d;
   var e;
   var f;

   a = 'document.prc.qty'+x+'.value';
   e = document.prc.fcnt.value;
   b = eval(a);
   a = 'document.prc.sp'+x+'.value';
   c = eval(a);
   d = c.split('~');
   f = 'bad~0~'+d[2];
   a = "document.prc.sp"+x+".value='"+f+"'";
   parseInt(b);
   if (isNaN(b) || b<=0) {
      alert('ERROR - quantity entered - '+b+' - is INVALID');
      c = eval(a);
      return false;
   } else {
      if (d[0]=='bad') {
         alert('Please choose colour and/or size from the dropdown list/s.');
         c = eval(a);
         return false;
      } else {
         if (d[0]=='0') {
            alert('This item is OUT of STOCK and cannot be purchased.');
            f = '0~0~0';
            a = "document.prc.sp"+x+".value='"+f+"'";
            c = eval(a);
            return false;
         } else {
            f = d[0]+'~'+b+'~'+d[2];
            a = "document.prc.sp"+x+".value='"+f+"'";
            c = eval(a);
            if (addmsg=='yes') alert("Adding to basket .....");
//alert(root+"default.asp?submit=AddToCartX&sp"+x+"="+f+"&fcnt="+e);
            location = root+"default.asp?submit=AddToCartX&sp"+x+"="+f+"&fcnt="+e;
            return true;
         }
      }
   }
}

function buyDD(x)
{
   var a;
   var b;
   var c;
   var d;
   var e;
   var f;

   a = "document.prc.qty"+x+".value";
   e = document.prc.fcnt.value;
   b = eval(a);
   parseInt(b);
   if (isNaN(b)) {
      alert("ERROR - quantity entered - "+b+" - is INVALID");
      back();
      return false;
   } else {
      a = "document.prc.sp"+x+".value";
      c = eval(a);
      d = c.split('~');
      if (d[0]=='bad') {
         alert('Please choose colour and/or size from the dropdown list/s.');
         return false;
      } else {
         f = d[0]+"~"+b+"~"+d[2];
         a = "document.prc.sp"+x+".value='"+f+"'";
         c = eval(a);
         if (addmsg=='yes') alert("Adding to basket .....");
         location = root+"default.asp?submit=AddToCartX&sp"+x+"="+f+"&fcnt="+e;
         return true;
      }
   }
}

function buySome(x)
{
   var a = "document.prc.qty"+x+".value";
   var b = eval(a);
   parseInt(b);
   if (isNaN(b)) {
      alert("ERROR - quantity entered - "+b+" - is INVALID");
      back();
   } else {
      a = "document.prc.sp"+x+".value";
      var e = document.prc.fcnt.value;
      var c = eval(a);
      var d = c.split('~')
      var f = d[0]+"~"+b+"~"+d[2];
      a = "document.prc.sp"+x+".value='"+f+"'";
      c = eval(a);
      if (addmsg=='yes') alert("Adding to basket .....");
      location.href = root+"default.asp?submit=AddToCartX&sp"+x+"="+f+"&fcnt="+e;
   }
}

function buyOne(x)
{
   if (addmsg=='yes') alert("Adding to basket .....");
   location = root+"default.asp?submit=BuyOne&part="+x;
}

   function buyThis(p) {
      var part = document.getElementById('mtxPart');
alert(p);     
      part.value = p;
alert(part.value);     
      document.matrix.submit();
   }


function formatCurrency(num) {
   num = num.toString().replace(/\$|\,/g,'');
   if(isNaN(num)) num = "0";
   sign = (num == (num = Math.abs(num)));
   num = Math.floor(num*100+0.50000000001);
   cents = num%100;
   num = Math.floor(num/100).toString();
   if(cents<10)
   cents = "0" + cents;
   for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
   num = num.substring(0,num.length-(4*i+3))+','+
   num.substring(num.length-(4*i+3));
   return (((sign)?'':'-') + num + '.' + cents)
}

function printPage() {
  if (window.print) {
    window.print();
  } else {
	alert("To print this page click OK then command+P")
  }
}

function jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location=root+'"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function goTo(url) {
   location=url;
}

function remindme(url) {
   var e = document.login.email.value;
   url = "login.asp?submit=remindme&email="+e
   location=root+url;
}

function terms_read() {
   var r = document.carrier.read_terms.checked;
   if (r==true) return true;
   alert('You must agree to our Terms and Conditions before proceeding with your order');
   return false;
}

/**
* DHTML email validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
*/
function emailCheck(str) {
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Please enter a VALID email address.")
		   return false
		}
		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID")
		   return false
		}
		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID")
		    return false
		}
		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }
		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID")
		    return false
		 }
		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID")
		    return false
		 }
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }
 		 return true
	}

function validateEmailAddress(x){
	var emailID="document."+x
	emailID = eval(emailID)

	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please enter a VALID email address.")
		emailID.focus()
		return false
	}
	if (emailCheck(emailID.value)==false){
		emailID.value=""
		emailID.focus()
		return false
	}
	return true
 }

function wrapBox(szDivID, iState, line) // iState=1 visible, 0 hidden
{
   var wl='giftwrap';
// alert('line = '+line);
  if(document.layers)  // NN4
  {
    document.layers[szDivID].visibility = iState ? "show" : "hide";
  }
  else if(document.getElementById) // gecko(NN6) + IE5+
  {
    var obj = document.getElementById(szDivID);
    obj.style.visibility = iState ? "visible" : "hidden";
  }
  else if(document.all) //IE 4
  {
    document.all[szDivID].style.visibility = iState ? "visible" : "hidden";
  }
  document.giftwrap.line.value=line;
}

function unwrapBox(szDivID, iState, line) // iState=1 visible, 0 hidden
{
   url = "buypaper.asp?submit=unwrap&line="+line
// alert(url);
   location=root+url;
}

function submitWrap(part,price) {
// alert(part+" - "+price);
    document.giftwrap.part.value=part;
    document.giftwrap.price.value=price;
    document.giftwrap.submit();
 }

function showAddressX(what,w,h) {
   var x = "width="+w+",height="+h+",resizable,scrollbars=yes";
   var win = window.open("get_address.asp?address="+what,"Details",x);
   win.moveTo(100, 100);
}


function showChoice2(control,populate,IS,ID,GA,num) {
	//alert(num);
   var element;
   var img = "pimage"+num;
   var cv = control;
   var i = cv.indexOf('~');
   var c = cv.substring(0,i);
   var x = cv.substring(i+1);
   i = x.indexOf('~');
   var p = x.substring(0,i);
   var pi = x.substring(i+1);
   document.images[img].src = "products/img/medium"+pi;
   for (var q=populate.options.length;q>=0;q--) populate.options[q]=null;
   i = 0;
   var z = 'document.prc.choice2_'+num+'[0]=new Option("Choose a SIZE")';
   eval(z);
   for (x=0;x<ID.length;x++) {
      if (GA[x]==c) {
         z = 'document.prc.choice2_'+num+'[++i]=new Option(ID[x],IS[x])';
         eval(z);
      }
   }
}
function setChoice(fullpart,fprice,choice_index,num) {
   var cv = fullpart;
   var z = "document.prc.stock"+num+".value=''"
   eval(z);
   if (cv != 'Choose a SIZE') {;
      if (cv.length > 0) {;
         var i = cv.indexOf('~');
         var c = cv.substring(0,i);
         var x = cv.substring(i+1);
         z = "document.prc.sp"+num+".value=fpart_"+num+"[x]+'~1~0'";
         eval(z);
         z = "document.prc.part"+num+".value=c";
         eval(z);
         z = "document.prc.stock"+num+".value=''";
         eval(z);
         z = "stock_mess_"+num+"[x]";
         z = eval(z);
         if (z!='buy') {
            z = "document.prc.stock"+num+".value=stock_mess_"+num+"[x]";
            eval(z);
            z = "document.prc.sp"+num+".value='0~0~0'";
            eval(z);
          }
         z = "document.prc.majorpart"+num+".value=c";
         eval(z);
         z = "document.prc.price"+num+".value=fprice_"+num+"[x]";
         eval(z);
      }
   }
}

   var col;
   var siz;
   var fromx;
   function filter(what,w1,w2) {
      fromx = 'filter';
      change_href(what,w1,w2);
      fromx = '';
      url = 'prodpage.asp?'+what+'&filter_colour='+col+'&filter_size='+siz;
      location = root+url;
   }

   function change_href(what,w1,w2) {
      var pp = document.filter_by.filter_colour.length;
      if (pp>0) {
         for (i = 0; i < pp; i++) {
            if (document.filter_by.filter_colour.options[i].selected) col = document.filter_by.filter_colour.options[i].value;
         }
      }
      pp = document.filter_by.filter_size.length;
      if (pp>0) {
         for (i = 0; i < pp; i++) {
            if (document.filter_by.filter_size.options[i].selected) siz = document.filter_by.filter_size.options[i].value;
         }
      }
      if (fromx!='filter') {
         var i1 = w1.indexOf('&filter_colour=');
         w1 = w1.substring(0,i1);
         var i2 = w2.indexOf('&filter_colour=');
         w2 = w2.substring(0,i2);
      }
      var y = document.getElementById('a_prev');
      if (y!=null) y.setAttribute('href','prodpage.asp?'+w1+'&filter_colour='+col+'&filter_size='+siz);
      var x = document.getElementById('a_next');
      if (x!=null) x.setAttribute('href', 'prodpage.asp?'+w2+'&filter_colour='+col+'&filter_size='+siz);
   }

   function XsortBy(url,yn) {
      var i = url.indexOf('sortby')
      if (i>0) {
         url = url.substring(0,i-1);
         i = -1;
      }
      if (yn=='up' & i==-1) url=url+'&sortby=UP';
      if (yn=='down' & i==-1) url=url+'&sortby=DOWN';
      if (yn=='no' & i==-1) url=url+'&sortby=NO';
      location=url;
   }

   function sortByPrice(url) {
      var sort;
      var pp = document.filter_by.sortBy.length;
      if (pp>0) {
         for (i = 0; i < pp; i++) {
            if (document.filter_by.sortBy.options[i].selected) sort = document.filter_by.sortBy.options[i].value;
         }
      }
      var i = url.indexOf('&sortby=');
      if (i>-1) url = url.substring(0,i);
      url = url+'&sortby='+sort;
      location=url;
   }

   function doTextRemoveUpdate(x) {
      var z = document.getElementById("submitX");
      z.value = x;
//      document.bsktForm.innerHTML = document.bsktForm.innerHTML + "<input type=hidden name=submitX value='" + x +"'>";
      document.bsktForm.submit();
   }

   function createCookie(name,value,days) {
//alert('createCookie name='+name+' - value='+value+' - days='+days);
      if (days) {
         var date = new Date();
         date.setTime(date.getTime()+(days*24*60*60*1000));
         var expires = "; expires="+date.toGMTString();
      }   
      else var expires = "";
      document.cookie = name+"="+value+expires+"; path=/";
   }

   function readCookie(name) {
//alert('readCookie name='+name);
      var nameEQ = name + "=";
      var ca = document.cookie.split(';');
      for(var i=0;i < ca.length;i++) {
         var c = ca[i];
         while (c.charAt(0)==' ') c = c.substring(1,c.length);
         if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
      }
      return null;
   }

   function eraseCookie(name) {
      createCookie(name,"",-1);
}


function checkStockAndBuy(x)
{
   var a;
   var b;
   var c;
   var d;
   var e;
   var f;

   a = 'document.prc.qty'+x+'.value';
   e = document.prc.fcnt.value;
   b = eval(a);
   a = 'document.prc.sp'+x+'.value';
   c = eval(a);
   d = c.split('~');
   f = 'bad~0~'+d[2];
   a = "document.prc.sp"+x+".value='"+f+"'";
   parseInt(b);
   if (isNaN(b) || b<=0) {
      alert('ERROR - quantity entered - '+b+' - is INVALID');
      c = eval(a);
      return false;
   } else {
      if (d[0]=='bad') {
         alert('Please choose colour and/or size from the dropdown list/s.');
         c = eval(a);
         return false;
      } else {
         if (d[0]=='0') {
            alert('This item is OUT of STOCK and cannot be purchased.');
            f = '0~0~0';
            a = "document.prc.sp"+x+".value='"+f+"'";
            c = eval(a);
            return false;
         } else {
            var s = parseInt(stock_value);
            if (b>s) {
               b = s;
            }
            f = d[0]+'~'+b+'~'+d[2];
            a = "document.prc.sp"+x+".value='"+f+"'";
            c = eval(a);
            if (addmsg=='yes') alert("Adding to basket .....");
            location = root+"default.asp?submit=AddToCartX&sp"+x+"="+f+"&fcnt="+e;
            return true;
         }
      }
   }
}

function showImmediateMsg() {
   document.getElementById('futureMsg').style.display = 'none';
   document.getElementById('immediateMsg').style.display = 'block';
}
function hideImmediateMsg() {
   document.getElementById('futureMsg').style.display = 'none';
   document.getElementById('immediateMsg').style.display = 'none';
}

function showFutureMsg() {
   document.getElementById('futureMsg').style.display = 'block';
   document.getElementById('immediateMsg').style.display = 'none';
}
function hideFutureMsg() {
   document.getElementById('futureMsg').style.display = 'none';
   document.getElementById('immediateMsg').style.display = 'none';
}

function hideMsg(x){
   popDiv = document.getElementById(x);
   if (popDiv) { popDiv.style.display = "none"; }
}
 
function showMsg(x,e){
   popDiv = document.getElementById(x);
   if (popDiv) {
     popDiv.style.display = "block";
     popDiv.style.top = mouseY(e)+'px';
     popDiv.style.left = mouseX(e)+10+'px';
   }
}

function mouseX(evt) {
if (evt.pageX) return evt.pageX;
else if (evt.clientX)
   return evt.clientX + (document.documentElement.scrollLeft ?
   document.documentElement.scrollLeft :
   document.body.scrollLeft);
else return null;
}

function mouseY(evt) {
if (evt.pageY) return evt.pageY;
else if (evt.clientY)
   return evt.clientY + (document.documentElement.scrollTop ?
   document.documentElement.scrollTop :
   document.body.scrollTop);
else return null;
}


/***********************************************
* Switch Menu script- by Martial B of http://getElementById.com/
* Modified by Dynamic Drive for format & NS4/IE4 compatibility
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

var persistmenu="yes" //"yes" or "no". Make sure each SPAN content contains an incrementing ID starting at 1 (id="sub1", id="sub2", etc)
var persisttype="sitewide" //enter "sitewide" for menu to persist across site, "local" for this page only

if (document.getElementById){ //DynamicDrive.com change
document.write('<style type="text/css">\n')
document.write('.submenu{display: none;}\n')
document.write('</style>\n')
}

function SwitchMenu(obj){
	if(document.getElementById){
	var el = document.getElementById(obj);
	var ar = document.getElementById("prodNav").getElementsByTagName("span"); //DynamicDrive.com change
		if(el.style.display != "block"){ //DynamicDrive.com change
			for (var i=0; i<ar.length; i++){
				if (ar[i].className=="submenu") //DynamicDrive.com change
				ar[i].style.display = "none";
			}
			el.style.display = "block";
		}else{
			el.style.display = "none";
		}
	}
}

function get_cookie(Name) { 
var search = Name + "="
var returnvalue = "";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) { 
offset += search.length
end = document.cookie.indexOf(";", offset);
if (end == -1) end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}

function onloadfunction(){
if (persistmenu=="yes"){
var cookiename=(persisttype=="sitewide")? "switchmenu" : window.location.pathname
var cookievalue=get_cookie(cookiename)
if (cookievalue!="")
document.getElementById(cookievalue).style.display="block"
}
}

function savemenustate(){
var inc=1, blockid=""
while (document.getElementById("sub"+inc)){
if (document.getElementById("sub"+inc).style.display=="block"){
blockid="sub"+inc
break
}
inc++
}
var cookiename=(persisttype=="sitewide")? "switchmenu" : window.location.pathname
var cookievalue=(persisttype=="sitewide")? blockid+";path=/" : blockid
document.cookie=cookiename+"="+cookievalue
}

if (window.addEventListener)
window.addEventListener("load", onloadfunction, false)
else if (window.attachEvent)
window.attachEvent("onload", onloadfunction)
else if (document.getElementById)
window.onload=onloadfunction

if (persistmenu=="yes" && document.getElementById)
window.onunload=savemenustate


