var bV=parseInt(navigator.appVersion);
var NS4=(document.layers)?true:false;
var IE4=((document.all)&&(bV>=4))?true:false;
var tPopWait=0;
var showPopStep=100;
var popOpacity=100;

var sPop=null;
var curShow=null;
var tFadeOut=null;
var tFadeIn=null;
var tFadeWaiting=null;

var noDirection=false;
var cashDirection=-1;

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];}
}
function layer (layerID){
    if (document.getElementById(layerID)){
        return document.getElementById(layerID);
    } else if (document.all(layerID)){
        return document.all(layerID);
    }
}
function findobj(n, d) {
        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 reload(){
  window.location.href=unescape(window.location.pathname);
}
function go(url){
  window.location.href=url;
}
function showPopupText(){
        var o=event.srcElement;
        MouseX=event.x;
        MouseY=event.y;
        if(o.alt!=null && o.alt!="") { o.pop=o.alt;o.alt="" }
        if(o.title!=null && o.title!=""){ o.pop=o.title;o.title="" }
        if(o.pop) { o.pop=o.pop.replace("\n","<br>"); o.pop=o.pop.replace("\n","<br>"); }
        if(o.pop!=sPop) {
                sPop=o.pop;
                clearTimeout(curShow);
                clearTimeout(tFadeOut);
                clearTimeout(tFadeIn);
                clearTimeout(tFadeWaiting);
                if(sPop==null || sPop=="") {
                        popLayer.innerHTML="";
                        popLayer.style.filter="Alpha()";
                        popLayer.filters.Alpha.opacity=0;
                } else {
                        if(o.dyclass!=null) popStyle=o.dyclass
                        else popStyle="cPopText";
                        curShow=setTimeout("showIt()",tPopWait);
                }
        }
}
function fadeOut(){
        if(popLayer.filters.Alpha.opacity<popOpacity) {
                popLayer.filters.Alpha.opacity+=showPopStep;
                tFadeOut=setTimeout("fadeOut()",1);
        }
}

function showIt() {
        popLayer.className=popStyle;
        popLayer.innerHTML=sPop;
        popWidth=popLayer.clientWidth;
        popHeight=popLayer.clientHeight;
        if(MouseX+12+popWidth>document.body.clientWidth) popLeftAdjust=-popWidth-24
                else popLeftAdjust=0;
        if(MouseY+12+popHeight>document.body.clientHeight) popTopAdjust=-popHeight-24
                else popTopAdjust=0;
        popLayer.style.left=MouseX+12+document.body.scrollLeft+popLeftAdjust;
        popLayer.style.top=MouseY+12+document.body.scrollTop+popTopAdjust;
        popLayer.style.filter="Alpha(Opacity=0)";
        fadeOut();
}


function ctlent(obj) {
        if((event.ctrlKey && window.event.keyCode == 13) || (event.altKey && window.event.keyCode == 83)) {
                //if(validate(this.document.input))
                this.document.input.submit();
        }
}
function copycode(obj) {
        var rng = document.body.createTextRange();
        rng.moveToElementText(obj);
        rng.scrollIntoView();
        rng.select();
        rng.execCommand("Copy");
        rng.collapse(false);
}
function popwin(url,wnd,width,height){
        window.open(url,wnd,'width=' + width + ',height=' + height + ',top=' + (document.body.clientWidth/2-width/2) + ',left=' + (document.body.clientHeight/2-height/2) + ',directories=no,status=no,scrollbars=no,resize=no,menubar=no');
}
function keyHook(){
  //if(event.keyCode==16&&layer("qtPanel")){
  // layer("qtPanel").style.display=((layer("qtPanel").style.display=="block")?"none":"block");
  //}
  //if(event.keyCode==13&&document.form){
  // document.form.submit();
  //}
  //window.status = event.keyCode;
  //return (event.keyCode!=27);
}

function clearBox(initstr,id){
    if (layer(id).value==initstr)
      layer(id).value='';
}
function quickCopyIt(newVal) {
 var temp = document.createElement('TEXTAREA');
 temp.innerHTML=newVal;
 temp.select();
 var hv=temp.createTextRange();
 hv.execCommand("Copy");
}
var keepGoing = false;
function quantityGo(stepIn, obj){
 if(keepGoing) {
  if(layer('quantity'+obj).value>1||stepIn>0)
   layer('quantity'+obj).value=parseInt(layer('quantity'+obj).value)+((stepIn>0)?stepIn:stepIn);
  layer('quantity'+obj).value=((parseInt(layer('quantity'+obj).value)<=0)?1:layer('quantity'+obj).value);
  if(layer('subtotal'+obj)!=null) changeTotal(obj);
  setTimeout("quantityGo("+stepIn+", '"+obj+"');", 600);
 }
}
function implode( delim, arr) {
  var str="";
  for(i=0;i<arr.length;i++) {
   str+=arr[i];
   if((i+1)<arr.length) str+=delim;
  }
  return str;
}

//document.write("<style type='text/css' id='defaultPopStyle'>");
//document.write(".cPopText { font-family: Verdana, Tahoma; background-color: #FFEDF0; border: 1px #FF3399 solid; font-size: 11px; padding-right: 6px; padding-left: 6px; Height: 20px; padding-top: 4px; padding-bottom: 3px; filter: Alpha(Opacity=0)}");
//document.write("</style>");
//document.write("<div id='popLayer' style='position:absolute;z-index:1000;' class='cPopText'></div>");
//document.onmouseover=showPopupText;
//document.onkeydown=keyHook;
document.onerror = new Function("return false")
//document.ondragstart = new Function("return false")        
//document.onselectstart = new Function("return false")     
//document.oncontextmenu = new Function("return false")    


