var counter;
var pageLoaded = 0; 
var images = new Array("../images/buttons/ro_over.gif","../images/buttons/wo_over.gif","../images/buttons/bn_over.gif","../images/buttons/go_over.gif","../images/buttons/bra_over.gif","../images/buttons/cat_over.gif","../tooltips/images/tinyframe.gif","../tooltips/images/smallframe.gif","../tooltips/images/mediumframe.gif","../tooltips/images/largeframe.gif","../tooltips/images/hugeframe.gif"); 
var imageList = new Array();
var LServer = isLocal();
var LocalServer = isLocal(); 
var MyLoc = window.location.href;
var MyArray = MyLoc.split("/"); 
var pCategory = ""  
var IE = document.all?true:false;
var Local = "/" + isLocal() + "/"
if (LServer="") {
    // Is NOT Local 
    pCategory = MyArray[4];
}
else {
    // Is LOCAL
    pCategory = MyArray[5];
}
function loadFast() { 
    for(counter in images){ 
        imageList[counter]=new Image(); 
        imageList[counter].src=images[counter]; 
    } 
}
loadFast();
function isCategory() {
    // get current directory for dynamic content
    var MyLoc = window.location.href;
    var MyArray = MyLoc.split("/");
    var pCategory = "";
    var x;
    for (x=0;x<6;x++) {
        if (MyArray[x]=="products") {
            pCategory = MyArray[x+1];
        }
    }            
    return pCategory;
}        
function isLocal() {
    // get current directory for dynamic content
    var MyLoc = window.location.href;
    var MyArray = MyLoc.split("/");
    var pLocal = "";
    var LeftCoord;
    var x;
    for (x=0;x<6;x++) {
        if (MyArray[x]=="BO") {
            pLocal = MyArray[x];
        }
    }
    return pLocal;
} 
function SetLoadingCoords(IdText) {
    //alert(IdText);
    var ProgressId = document.getElementById(IdText);
    //alert(ProgressId);
    //alert("Click Coords: " + window.event.clientX + "x" + window.event.clientY);
    if (ProgressId) {
        // Picture id gets changed when using updatepanel so add ct_100_ in front of pic id
        var PicId = document.getElementById('ctl00_LoadPic1');
        //alert(PicId.id);
        var NewI = new Image();
        NewI.src = PicId.src;
        //alert("Screen is: " + document.body.clientWidth + " x " + document.body.clientHeight);
        //alert("Control size: " + NewI.width + " x " + NewI.height);
        TopCoord = ((document.body.clientHeight - NewI.height) / 2);
        LeftCoord = ((document.body.clientWidth - NewI.width) / 2);
        //alert("SetLoadingCoords: " + LeftCoord );             
        ProgressId.style.left = LeftCoord + document.body.scrollLeft - 20;
        //ProgressId.style.top = TopCoord + document.body.scrollTop;
        //ProgressId.style.top = 125;
        var _x;
        var _y;
        if (IE) {
            _x = event.clientX + document.body.scrollLeft;
            _y = event.clientY + document.body.scrollTop;
        }    
        else {_x = e.pageX;_y = e.pageY;}        
        //alert("Moving Progress... " + "left: " + _x + " top: " +  _y);   
        ProgressId.style.top = _y;
        ProgressId.style.left = _x;
    }
} 
function jsResetScroll() {            
    window.scroll(0,0);
} 
function LimitCharsROfD(f,n){
    var f = String(f);
    var c = f.slice( 0,f.indexOf(".",0) + n + 1);
    return Number(c);
};
function GetDate(type) {
	var currentTime = new Date();
	var month = currentTime.getMonth() + 1;
	var day = currentTime.getDate();
	var dow = currentTime.getDay();
	var dowStr = "";
	var monStr = "";
	switch(dow) {case 0:dowStr="Sunday";break;case 1:dowStr="Monday";break;case 2:dowStr="Tuesday";break;case 3:dowStr="Wednesday";break;case 4:dowStr="Thursday";break;case 5:dowStr="Friday";break;case 6:dowStr="Saturday";break;}
	switch(month) {case 1:monStr="January";break;case 2:monStr="February";break;case 3:monStr="March";break;case 4:monStr="April";break;case 5:monStr="May";break;case 6:monStr="June";break;case 7:monStr="July";break;case 8:monStr="August";break;case 9:monStr="September";break;case 10:monStr="October";break;case 11:monStr="November";break;case 12:monStr="December";break;}
	var year = currentTime.getFullYear();
    switch(type) {
        case 1:document.write(dowStr + " " + month + "/" + day + "/" + year);break;
        case 2:document.write(dowStr + " " + monStr + " " + day + ", " + year);break;
    }	
}		
function showFlash(obj){
    var flashdiv = document.getElementById(obj);
    flashdiv.style.display = "block";
    flashdiv.style.visibility = "visible";
}
function ModalOff() {
    //alert("ModalOff");
    var obj = $find("ctl00_BookmarkModalPopupExtender");
    if (obj) {obj.hide();}
    var obj = $find("ctl00_ContentPlaceHolder1_BookmarkModalPopupExtender");
    if (obj) {obj.hide();}    
}
function Adjust2DivHeights(one,two) {
//
// Makes a TWO(2) div column have equal column heights
//
    if (document.getElementById(one)) {
        var lh=document.getElementById(one).offsetHeight;
        var rh=document.getElementById(two).offsetHeight;
        var nh = Math.max(lh, rh); 
        document.getElementById(one).style.height=nh+"px";
        document.getElementById(two).style.height=nh+"px";
    }
}
//
// Makes a THREE(3) div column have equal column heights
//
function sortNum(a,b) { return b-a} 
function Adjust3DivHeights(one,two,three) {
    //alert("Adjusting Height: ");
    if (document.getElementById(one)) {
        var obj=new Array(3);
        var option=[one,two,three];
        for(var i=0; i<option.length; i++) {
            document.getElementById(option[i]).style.height="auto";
            obj[i]=document.getElementById(option[i]).offsetHeight;
            nh=obj.sort(sortNum);
        } 
        nh1=nh.splice(1,2);
        for(var i=0; i<option.length; i++) {
            document.getElementById(option[i]).style.height=nh+"px";
        }
    }
    else {
        alert("Cant find divs - Call Tech Support");
    }
}
//
// Delays the div column height adjustment 
//
function DelayAdjust3DivHeights(dela) {
    //alert("delaying");
    window.setTimeout("Adjust3DivHeights('PageBodyLeft','PageBodyRightLeft','PageBodyRightRight');",250);
    return false;
}
function ActiveTabChanged(sender, e) 
{
    //alert("Tab Changed");
    DelayAdjust3DivHeights(250);
}
//
// Changes google video player size
//
function ChangeVideoSize(tObj, tSize) {
    var tempObj = document.getElementById(tObj);
    if (tempObj) {
        tempObj.setSize(tSize,tSize);
    }
    else { alert("Cant find Video Object"); }
}   
window.onload=function(){
    Adjust3DivHeights('PageBodyLeft','PageBodyRightLeft','PageBodyRightRight');
}
//////////////////////////////////////////////////////////////////////////////////
//  For Floating Menus
//////////////////////////////////////////////////////////////////////////////////

var disappeardelay=250; //menu disappear speed onMouseout (in miliseconds)
var enableanchorlink=1; //Enable or disable the anchor link when clicked on? (1=e, 0=d)
var hidemenu_onclick=1; //hide menu when user clicks within menu? (1=yes, 0=no)
var horizontaloffset=0; //horizontal offset of menu from default location. 
var verticaloffset=0;   //vertical offset of menu from default location.
var MenuObj2;

//
//  
//
function getposOffset(what, offsettype){
    var totaloffset = (offsettype=="left")? what.offsetLeft : what.offsetTop;
    var parentEl = what.offsetParent;
    while (parentEl != null){
        totaloffset = (offsettype=="left")? totaloffset+parentEl.offsetLeft : 
            totaloffset+parentEl.offsetTop;
        parentEl = parentEl.offsetParent;
    }
    return totaloffset;
}
function getPosition(obj){
    var xLoc=0;var yLoc=0;var oHeight=obj.offsetHeight;var oWidth=obj.offsetWidth;
    while(obj){xLoc+=obj.offsetLeft;yLoc+=obj.offsetTop;obj=obj.offsetParent;}
    return {height:oHeight,width:oWidth,x:xLoc,y:yLoc}
}
function ShowOrHide(obj, e, visible, hidden) {
    obj.style.left = obj.style.top = -500
    if (e.type=="click" && obj.visibility==hidden || e.type=="mouseover") {
        obj.style.visibility=visible;
    }
    else if (e.type=="click") {obj.style.visibility = hidden;}
}
//
//  Displays Menu Window...
//
function SideMenu(obj,e,dropmenuID){
    var PicObj = document.getElementById(dropmenuID+"TT");
    //PicObj.src = Local + "images/showover.png";
    //
    var horizontaloffset=0;var verticaloffset=0;
    var lMargin=((document.body.clientWidth-1024)/2);
    if (lMargin%2!=0) lMargin-=1;
    var LMarg=(lMargin<1)?LMarg=0:Lmarg=lMargin;    
    if (!IE){ /* Non-Microsoft */ horizontaloffset=16;verticaloffset=125;}
    else{ /* IE Browser */ var horizontaloffset=16;var verticaloffset=0;}       
    if (window.event) event.cancelBubble=true;
    else if (e.stopPropagation) e.stopPropagation()
    if (typeof MenuObj2!="undefined") {MenuObj2.style.visibility="hidden"}
    clearhidemenu2();obj.onmouseout=delayhidemenu2
    MenuObj2=document.getElementById(dropmenuID)
    if (hidemenu_onclick) MenuObj2.onclick=function(){MenuObj2.style.visibility='hidden';}
    MenuObj2.onmouseover=clearhidemenu2;
    MenuObj2.onmouseout=function(event) {
        dynamichide2(event);
    }
    ShowOrHide(MenuObj2,e,"visible","hidden")
    MenuObj2.x=getPosition(obj).x;MenuObj2.y=getPosition(obj).y;
    MenuObj2.style.left=MenuObj2.x-LMarg+horizontaloffset+"px";
    MenuObj2.style.top=MenuObj2.y+verticaloffset+"px";   
    return clickreturnvalue();
}
function clickreturnvalue(){if (!enableanchorlink) return false;else return true;}
function dynamichide2(e){delayhidemenu2();}
function delayhidemenu2(){delayhide2 = setTimeout("MenuObj2.style.visibility='hidden'",disappeardelay);}
function clearhidemenu2(){if (typeof delayhide2!="undefined") {clearTimeout(delayhide2);}}
//
//
function GoBack() {
    //alert("Go Back");
    if (history.length == 0) {window.location = Local + "default.aspx";}
    else {history.go(-1);}    
}
function GoToUrlOrBack() {
    var Location = unescape(window.document.location);
    if (Location.indexOf("?") > -1) { 
        //whether the location contains a "=" or not
        var Url = Location.split("=");
        if (Url) {window.document.location=Url[1];}
        else {
            if (history.length==0) {window.document.location='default.aspx';}
            else {history.go(-1);}
        }
    }
    else {
        window.document.location='default.aspx';
    }
}
function RefreshPage() {
    document.forms[0].submit();
    return false;
}
////////////////////////////////////////////////////////////////////
var ModalInterval;
function StartModal(obj) {
    var command =  'ShowModal("' + String(obj) + '")';
    window.clearInterval(ModalInterval);
    ModalInterval = window.setInterval(command, 350);
}
function ShowModal(obj) {
    //alert("Show");
    var MD = $find(obj)
    if (MD) {MD.show();}
}
function StopModal() {window.clearInterval(ModalInterval);}
function ChangeAccordion(obj, paneIndex) {
    //alert(obj);
    var PA =  $get(obj).AccordionBehavior;
    if (PA) { PA.set_SelectedIndex(paneIndex); }
    else { alert("Unable to locate: "+obj); }    
    
}
function ChangeDiv(active, inactive) {
    //alert(active+","+inactive);
    var Activee = document.getElementById(active);
    var Inactivee = document.getElementById(inactive);
    Activee.style.display = 'block';
    Activee.style.visibility = 'visible';
    Inactivee.style.display = 'none';
    Inactivee.style.visibility = 'hidden';
}
//
// preloadImages
//
function PreloadImages(fnames) {
    //alert("Files: " + fnames);
    var counter;
    var images = new Array(fnames.split(","));
    var imageList = new Array();
    for (counter = 0; counter < images[0].length; counter++) {
        imageList[counter] = new Image();
        imageList[counter].src = images[0][counter];
    }
}
///////////////////////////////////////////////////////////////////