var _url="d";
var _cdsrm = 1;
var _shtid = "0";

function track(){
    var w = screen.width * 0.75;
    var h = screen.height * 0.75;
    window.open(arguments[0],'tracking','top=40, left=70, resizable=yes, scrollbars=yes, width='+w+', height='+h);
}
function shasm(){
    document.getElementById("shnsab").style.display=arguments[0]?"":"none";
    document.getElementById("shnsal").style.display=arguments[0]?"none":"";
}
function shwait(){
    arguments[0].style.visibility="hidden";
    arguments[0].width="0px";
    wbtn = document.getElementById("waitbnt");
    wbtn.style.visibility="visible";
    wbtn.style.width="";
    if(arguments.length>1){
      wbtn.style.paddingLeft=wbtn.style.paddingRight=arguments[1]/2+"px";
    }
}
function sreview(){gotoURL("?act=AJ&rv_id="+arguments[0]+"&fd="+arguments[1]+"&prd_id="+arguments[2]);}
function gotoOrd(){gotoURL("?act=pF&o_id="+arguments[0]);}
function countcom(){
    if(arguments[0].value.length > _mcom){
        arguments[0].value = arguments[0].value.substring(0, arguments[0].value.length - 1);
    }
    document.getElementById(arguments[1]).innerHTML = _mcom - arguments[0].value.length;
}
function countttl(){
    if(arguments[0].value.length > _mtitle){
        arguments[0].value = arguments[0].value.substring(0, arguments[0].value.length - 1);
    }
    document.getElementById("cttl").innerHTML = _mtitle - arguments[0].value.length;
}
function shstar(){
    for(var i = 1; i < 6; i++){ 
        document.getElementById("str"+i).src = "../images/rpts/"+(i<=arguments[0]?"star.gif":"starh.gif");
    }
    document.rvw_frm.rtng.value = arguments[0];
}
function flipstar(){
    for(var i = arguments[0]; i > 0; i--){
        document.getElementById("str"+i).src = "../images/rpts/star.gif";
    }
}
function defstar(){shstar(document.rvw_frm.rtng.value);}
function gotoma(){gotoURL("?act=pG");}
function cancelord(){
    document.shc_frm.act.value="aQ";
    document.shc_frm.submit();
}
function gotofmpwd(){gotoURL("?act=ZX");}
function findPosition(el){
    if(typeof(el.offsetParent)!='undefined'){
        for(var x=0, y=0; el; el=el.offsetParent){
            x+=el.offsetLeft;
            y+=el.offsetTop;
        }
        return [x,y];
    }else{
        return [el.x, el.y];
    }
}
function showpmt(){
    try{
      document.getElementById("pppmt").style.display = "none";
      document.getElementById("ppbtn").style.display = "none";
    }catch(e){}
    try{
      document.getElementById("ccpmt").style.display = "none";
      document.getElementById("ccbtn").style.display = "none";
    }catch(e){}
    try{
      document.getElementById("gcpmt").style.display = "none";
      document.getElementById("gcbtn").style.display = "none";
    }catch(e){}
    document.getElementById(arguments[0]+"pmt").style.display = "";
    document.getElementById(arguments[0]+"btn").style.display = "";

    var bsat = document.getElementById("ccps");
    var cact = document.getElementById("nacct");
    var sh1 = document.getElementById("shd1");
    var sh2 = document.getElementById("shd2");
    var slc = document.getElementsByTagName("select");
    
    if(arguments[0]=="cc"){
        sh1.style.visibility = "hidden";
        sh2.style.visibility = "hidden";
        for(var i=0; i<slc.length; i++)if(slc[i].name=="b_state" ||(slc[i].name=="s_state" && shc_frm.billship.checked))slc[i].style.visibility="";
    }else{
        var xy = findPosition(bsat);
        sh1.style.width = bsat.offsetWidth;
        sh1.style.height = bsat.offsetHeight;
        sh1.style.left = xy[0];
        sh1.style.top = xy[1];

        xy = findPosition(cact);
        sh2.style.width = cact.offsetWidth;
        sh2.style.height = cact.offsetHeight;
        sh2.style.left = xy[0];
        sh2.style.top = xy[1];
        
        sh1.style.visibility = "visible";
        sh2.style.visibility = "visible";
        for(var i=0; i<slc.length; i++)if(slc[i].name=="b_state" ||(slc[i].name=="s_state" && shc_frm.billship.checked))slc[i].style.visibility="hidden";
    }
//    try{document.getElementById("nacct").style.display = arguments[0] == "cc"?"":"none";}
//    catch(e){}
//    try{document.getElementById("ccps").style.display = arguments[0] == "cc"?"":"none";}
//    catch(e){}
//    try{document.getElementById("pmts").style.paddingLeft = arguments[0] == "cc"?"20px":"0px";}
//    catch(e){}
}
function gotobillto(){gotoURL("?act=pS&btid="+arguments[0]+"&orpg="+arguments[1]);}
function chshipto(){
    if(_shtid == arguments[0].value){
        return;
    }else{
        _shtid = arguments[0].value;
        gotoURL("?act=pR&stid="+arguments[0].value);
    }
}
function gotoshipto(){gotoURL("?act=pN&stid="+arguments[0]+"&orpg="+arguments[1]);}
function fusername(){document.getElementById("usrnm").value = arguments[0].value;}
function showshipto(){
    var tbl = document.getElementById("shiptotbl");
    var ttl = document.getElementById("bilshipttl");
//    var csph = document.getElementsByName("csphn");
    if(arguments[0].checked){
        ttl.innerHTML = "Billing Address";
        tbl.style.position = "relative";
        tbl.style.visibility = "visible";
//        for(var i=0; i<csph.length; i++)csph[i].style.visibility = "visible";
    }else{
        ttl.innerHTML = "Billing/Shipping Address <span style='font: normal 8pt Verdana;'>(no PO Box addresses)</span>";
        tbl.style.position = "absolute";
        tbl.style.top = "0px";
        tbl.style.left = "0px";
        tbl.style.visibility = "hidden";
//        for(var i=0; i<csph.length; i++)csph[i].style.visibility = "hidden";
    }
}
function upttl(){
    var total = _itemspr + _taxpr + arguments[0];
    total = formatMoney(total.toFixed(2));
    document.getElementById("shc_total_d").innerHTML = total;
    document.getElementById("shc_total").innerHTML = total;
}
function setzip(){gotoURL("?act=aC&sh_to_zip="+document.getElementById("sh_to_zip").value);}
function zoom(){
    document.getElementById("srchc").style.visibility = "hidden";
    document.getElementById("img_w").style.visibility = "visible";
    var sh = document.getElementById("shadow");
    sh.style.visibility = "visible";
    sh.style.height = document.body.scrollHeight;
    sh.style.width = document.body.scrollWidth;
}
function czoom(){
    document.getElementById("shadow").style.visibility = "hidden";
    document.getElementById("img_w").style.visibility = "hidden";
    document.getElementById("srchc").style.visibility = "visible";
}
function printprd(){
    document.getElementById("print_screen").innerHTML = "<img src='../images/rpts/logo.gif'><br><br><br><br><br>" + document.getElementById("prd_cnt").innerHTML;
    window.print();
}
function gotomn(){
    var gturl = "?act=MA&m1="+arguments[0]+"&m2="+arguments[1]+"&m3="+arguments[2];
    if(arguments.length>3){
        gturl+="&pnum="+arguments[3];
    }
    if(arguments.length>4){
        gturl+="&dspall="+arguments[4];
    }
    gotoURL(gturl,_http);
}
function gotomf(){
    var gturl = "?act=MB&mfr="+arguments[0];
    if(arguments.length>1){
        gturl+="&pnum="+arguments[1];
    }
    if(arguments.length>2){
        gturl+="&dspall="+arguments[2];
    }
    gotoURL(gturl);
}
function gotosrch(){
    var s = trim(document.getElementById("srcht").value);
    if(s == "" || s.length < 3){
        return;
    }
    var opt = document.getElementById("srchc");
    gotosrchp(opt.options[opt.options.selectedIndex].value, s);
}
function gotosrchp(){
    var gturl = "?act=MC&srchc="+arguments[0]+"&srcht="+replaceplus(arguments[1]);
    if(arguments.length > 2){
        gturl+="&pnum="+arguments[2];
    }
    if(arguments.length > 3){
        gturl+="&dspall="+arguments[3];
    }
    gotoURL(gturl,_http);
}
function gotohm(){gotoURL("",_http);}
function gotoprd(){gotoURL("?act=PA&prd_id="+replaceplus(arguments[0]), _http);}
function delfromshc(){gotoURL("?act=aB&prd_id="+replaceplus(arguments[0])+"&"+replaceplus(arguments[0])+"_qty=0");}
function gotoshc(){gotoURL("?act=aA",_https);}
function updateshc(){
    document.shc_frm.act.value = "aB";
    document.shc_frm.submit();
}
function addtoshc(){
    var qty = arguments.legth == 1 ? document.getElementById(arguments[0]+"_qty").value : arguments[1];
    var gturl = "?act=ZZ&qty="+qty+"&prd_id="+replaceplus(arguments[0]);
    gotoURL(gturl,_https);
}
function keycode(ev){
    var ekey;
    if(!ev){ 
        if(window.event)ev = window.event; 
        else return ""; 
    } 
    if(typeof(ev.which) == 'number'){ 
    //NS 4, NS 6+, Mozilla 0.9+, Opera 
        ekey = ev.which; 
    }else if(typeof(ev.keyCode) == 'number'){ 
    //IE, NS 6+, Mozilla 0.9+ 
        ekey = ev.keyCode; 
    }else if(typeof(ev.charCode) == 'number'){ 
    //also NS 6+, Mozilla 0.9+ 
        ekey = ev.charCode; 
    }else{ 
        return ""; 
    }  
    return ekey;
}
function gotoURL(){window.location.href=(arguments.length>1?arguments[1]+"/rpts/":"")+_url+arguments[0];}
function hmn(){arguments[0].className=arguments[1]?"mrh":"mr"; }
function sdsr(){	
    document.getElementById("dsmtb"+_cdsrm).className="dsm";
    document.getElementById("dsmtl"+_cdsrm).className="dsm";
    document.getElementById("dsmr"+_cdsrm).className="dsm";
    document.getElementById("dsmb"+_cdsrm).className="dsmb";
    _cdsrm = arguments[0];
    document.getElementById("dsmtb"+_cdsrm).className="dsmh";
    document.getElementById("dsmtl"+_cdsrm).className="dsmh";
    document.getElementById("dsmr"+_cdsrm).className="dsmh";
    document.getElementById("dsmb"+_cdsrm).className="dsmbh";
}
function trim(){return arguments[0].replace(/^\s+|\s+$/g, "");}
function replaceplus(){return arguments[0].replace(/\+/g, "%2B");}
function formatMoney(){
    var val=""+arguments[0];
    if(arguments[0]>=1000000){
        return val.substring(0,val.length-9)+","+val.substring(val.length-9,val.length-6)+","+val.substring(val.length-6);
    }else if(arguments[0]>=1000){
        return val.substring(0,val.length-6)+","+val.substring(val.length-6);
    }else{
        return val;
    }
}