// Copyright (C) 1999-2001 Richard Goode
// Email <richard.goode@virgin.net>
// This code may not be used without permission.

browser = navigator.appName;
version = parseInt(navigator.appVersion);
n4 = (document.layers)? true:false;
mozilla = (browser=="Netscape" && version>=5)? true:false;
ie4 = (navigator.userAgent.indexOf("MSIE 4")!=-1)? true:false;
ie = (navigator.userAgent.indexOf("MSIE")!=-1 && version>=4)? true:false;
msdom = (ie && !ie4)? true:false;
mac = (navigator.appVersion.indexOf("Mac") != -1);

function shiftTo(id,x,y) {
  if (n4) {
  document.layers[id].left = x;
  document.layers[id].top = y;
  }
  if (ie4) {
  document.all(id).osx = x;
  document.all(id).osy = y;
  document.all(id).style.left = x + "px";
  document.all(id).style.top = y + "px";
  }
  if (msdom || mozilla) {
  document.getElementById(id).style.left = x + "px";
  document.getElementById(id).style.top = y + "px";
  }}

function clipBy(id,t,r,b,l) {
  if (n4) {
  document.layers[id].clip.top = t;
  document.layers[id].clip.right = r;
  document.layers[id].clip.bottom = b;
  document.layers[id].clip.left = l;
  }
  if (ie) {
  document.all(id).style.clip = "rect(" + t + "px "+ r + "px " + b + "px " + l + "px)";
  }
  if (mozilla) {
  document.getElementById(id).style.clip = "rect(" + t + "px "+ r + "px " + b + "px " + l + "px)";
//  document.getElementById(id).style.overflow = "hidden";
  }}

function showLayer(id) {
  if (n4) document.layers[id].visibility = "show";
  if (ie4) document.all(id).style.visibility = "visible";
  if (msdom || mozilla) document.getElementById(id).style.visibility = "visible";
  }

function hideLayer(id) {
  if (n4) document.layers[id].visibility = "hide";
  if (ie4) document.all(id).style.visibility = "hidden";
  if (msdom || mozilla) document.getElementById(id).style.visibility = "hidden";
  }

function showNestedLayer(id,parentid) {
  if (n4) document.layers[parentid].document.layers[id].visibility = "show";
  if (ie4) document.all(id).style.visibility = "visible";
  if (msdom || mozilla) document.getElementById(id).style.visibility = "visible";
  }

function hideNestedLayer(id,parentid) {
  if (n4) document.layers[parentid].document.layers[id].visibility = "hide";
  if (ie4) document.all(id).style.visibility = "hidden";
  if (msdom || mozilla) document.getElementById(id).style.visibility = "hidden";
  }

function getLeft(id) {
  if (n4) {xpos = document.layers[id].left;}
  if (ie4) {
    if (document.all(id).osx != null) {
      xpos = document.all(id).osx;
    } else {
      xpos = parseInt(document.all(id).offsetLeft);
      document.all(id).osx = parseInt(document.all(id).offsetLeft);
    }
  }
  if (msdom || mozilla) {xpos = document.getElementById(id).offsetLeft;}
  if (mac && ie) xpos += 10;
  return xpos;
  }

function getTop(id) {
  if (n4) {ypos = document.layers[id].top;}
  if (ie4) {
    if (document.all(id).osy != null) {
      ypos = document.all(id).osy;
    } else {
      ypos = parseInt(document.all(id).offsetTop);
      document.all(id).osy = parseInt(document.all(id).offsetTop);
    }
  }
  if (msdom || mozilla) {ypos = document.getElementById(id).offsetTop;}
  if (mac && ie) ypos += 15;
  return ypos;
  }

function getWidth(id) {
  if (n4) {
    if (document.layers[id].w) {
    w = document.layers[id].w;
    } else {
    w = document.layers[id].clip.width;
    document.layers[id].w = document.layers[id].clip.width;
    }
  }
  if (ie4) {w = parseInt(document.all(id).offsetWidth);}
  if (msdom || mozilla) {w = document.getElementById(id).offsetWidth;}
  return w;
  }

function getHeight(id) {
  if (n4) {
    if (document.layers[id].h) {
    h = document.layers[id].h;
    } else {
    h = document.layers[id].clip.height;
    document.layers[id].h = document.layers[id].clip.height;
    }
  }
  if (ie4) {h = parseInt(document.all(id).offsetHeight);}
  if (msdom || mozilla) {h = document.getElementById(id).offsetHeight;}
  return h;
  }

function canvasWidth() {
  if (n4 || mozilla) { w = window.innerWidth; }
  if (ie) { w = document.body.clientWidth; }
  return w;
  }

function canvasHeight() {
  if (n4 || mozilla) { h = window.innerHeight; }
  if (ie) { h = document.body.clientHeight; }
  return h;
  }

function eventXcoord(e) {
  if (n4) { var x = e.pageX; }
  if (ie) { var x = event.x + document.body.scrollLeft - 2; }
  if (mozilla) { var x = e.clientX; }
  return x;
  }

function eventYcoord(e) {
  if (n4) { var y = e.pageY; }
  if (ie) { var y = event.y + document.body.scrollTop - 2; }
  if (mozilla) { var y = e.clientY; }
  return y;
  }

function setLeft(id,l) {
  if (n4) {document.layers[id].left = l;}
  if (ie4) {document.all(id).style.left = l + "px";}
  if (msdom || mozilla) {document.getElementById(id).style.left = l + "px";}
  }

function setTop(id,t) {
  if (n4) {document.layers[id].top = t;}
  if (ie4) {document.all(id).style.top = t + "px";}
  if (msdom || mozilla) {document.getElementById(id).style.top = t + "px";}
  }

function setWidth(id,w) {
  if (n4) {document.layers[id].width = w;}
  if (ie4) {document.all(id).style.width =w + "px";}
  if (msdom || mozilla) {document.getElementById(id).style.width = w + "px";}
  }

function setHeight(id,h) {
  if (n4) {document.layers[id].height = h;}
  if (ie4) {document.all(id).style.height = h + "px";}
  if (msdom || mozilla) {document.getElementById(id).style.height = h + "px";}
  }

function setZIndex(id,z) {
  if (n4) {document.layers[id].zIndex = z;}
  if (ie) {document.all(id).style.zIndex = z;}
  if (mozilla) {document.getElementById(id).style.zIndex = z;}
  }

function setBackgroundColor(id,color) {
  if (id==null) {
  if (n4) document.bgColor = color;
  if (ie) document.body.style.backgroundColor = color;
  if (mozilla) {document.body.style.backgroundColor = color;}
  }
  else {
  if (n4) document.layers[id].document.bgColor = color;
  if (ie4) document.all(id).style.backgroundColor = color;
  if (msdom || mozilla) document.getElementById(id).style.backgroundColor = color;
  }}


if (mozilla) {
//  eval("HTMLElement.prototype.innerHTML setter = function (str) {var r = this.ownerDocument.createRange();r.selectNodeContents(this);r.deleteContents();var df = r.createContextualFragment(str);this.appendChild(df);return str;}");
  }

function layerWrite(id,content) {
  if (n4) {
  var lyr = document.layers[id].document;
  lyr.open();
  lyr.write(content);
  lyr.close();
  }
  else if (ie) {
  document.all(id).innerHTML = content;
  }
  else if (mozilla) {
  document.getElementById(id).innerHTML = content;
  }}

function getZIndex(id) {
  var z;
  if (ie) {z = document.all(id).style.zIndex;}
  if (n4) {z = document.layers[id].zIndex;}
  if (mozilla) {z = 0;}
  return z;
  }
  
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) { //v4.01
  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);
  if(!x && d.getElementById) x=d.getElementById(n); 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];}
}

browser = navigator.appName;
version = parseInt(navigator.appVersion);
n4 = (document.layers)? true:false;
mozilla = (browser=="Netscape" && version>=5)? true:false;
ie4 = (navigator.userAgent.indexOf("MSIE 4")!=-1)? true:false;
ie5 = (navigator.userAgent.indexOf("MSIE 5")!=-1)? true:false;
ie6 = (navigator.userAgent.indexOf("MSIE 6")!=-1)? true:false;
ie = (ie4 || ie5 || ie6)? true:false;


var img1_up = new Image();
var img2_up = new Image();
var img3_up = new Image();
var img4_up = new Image();
var img5_up = new Image();
var img6_up = new Image();
var img7_up = new Image();
var img8_up = new Image();

var img1_over = new Image();
var img2_over = new Image();
var img3_over = new Image();
var img4_over = new Image();
var img5_over = new Image();
var img6_over = new Image();
var img7_over = new Image();
var img8_over = new Image();

var img1_down = new Image();
var img2_down = new Image();
var img3_down = new Image();
var img4_down = new Image();
var img5_down = new Image();
var img6_down = new Image();

img1_up.src = "navimages/btn_home.gif";
img2_up.src = "navimages/btn_news.gif";
img3_up.src = "navimages/btn_prodacts.gif";
img4_up.src = "navimages/btn_merchandise.gif"
img5_up.src = "navimages/btn_aboutus.gif";
img6_up.src = "navimages/btn_contactus.gif";
img7_up.src = "navimages/arrow_up.gif";//arrows..
img8_up.src = "navimages/arrow_down.gif";

img1_over.src = "navimages/btn_home-over.gif";
img2_over.src = "navimages/btn_news-over.gif";
img3_over.src = "navimages/btn_prodacts-over.gif";
img4_over.src = "navimages/btn_merchandise-over.gif";
img5_over.src = "navimages/btn_aboutus-over.gif";
img6_over.src = "navimages/btn_contactus-over.gif";
img7_over.src = "navimages/arrow_up_over.gif"; //arrows..
img8_over.src = "navimages/arrow_down_over.gif";

img1_down.src = "navimages/btn_home-down.gif";
img2_down.src = "navimages/btn_news-down.gif";
img3_down.src = "navimages/btn_prodacts-down.gif";
img4_down.src = "navimages/btn_merchandise-down.gif"
img5_down.src = "navimages/btn_aboutus-down.gif";
img6_down.src = "navimages/btn_contactus-down.gif";

function highlight(imgname,img,lyr){
  if (ie || mozilla||n4) document[imgname].src = eval("img"+img+"_over.src");
}
function restore(imgname,img,lyr){
  if (ie || mozilla||n4) document[imgname].src = eval("img"+img+"_up.src");
}
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

}  

