/* DD_Loader.js
*  HierMenus Version 6
*  Copyright 2004 Jupitermedia Corporation
*/

DD_UserAgent = navigator.userAgent;
      DD_DOM = (document.getElementById) ? true : false;
      DD_NS4 = (document.layers) ? true : false;
       DD_IE = (document.all) ? true : false;
      DD_IE4 = DD_IE && !DD_DOM;
      DD_Mac = (navigator.appVersion.indexOf("Mac") != -1);
     DD_IE4M = DD_IE4 && DD_Mac;

DD_IsSafari = ((DD_DOM)&&
               (parseInt(navigator.productSub)>=20020000)&&
               (navigator.vendor.indexOf("Apple Computer")!=-1));
if(DD_IsSafari) {
	DD_BrowserPattern = /Safari\/(\d+)/;
	DD_Matches = DD_UserAgent.match(DD_BrowserPattern);
	if (DD_Matches&&DD_Matches[1]) DD_BrowserVersion = (DD_Matches[1]-0);
	else DD_BrowserVersion = 0;
}

DD_Opera = (window.opera) ? true : false;
if(DD_IsSafari||DD_Opera) {
	DD_IE=DD_NS4=DD_IE4=DD_IE4M=false;
	if(DD_IsSafari) DD_Mac=true;
}
DD_IE5M = (DD_IE&&DD_Mac&&DD_DOM);

if(DD_Opera) {
    DD_BrowserPattern = /Opera(\/| )(\d+.*)/;
    DD_VersionSupported = 7;
}

DD_Konqueror = (DD_UserAgent.indexOf("Konqueror")!=-1);
if(DD_Konqueror) {
    DD_BrowserPattern = /(Konqueror\/)(\d+.*)/;
    DD_VersionSupported = 3.2;
}

if(DD_Opera || DD_Konqueror) {
    if (DD_UserAgent.match) {
       DD_Matches = DD_UserAgent.match(DD_BrowserPattern);
       if (DD_Matches&&DD_Matches[2]) {
          DD_BrowserVersion = parseFloat(DD_Matches[2]);
       } else DD_BrowserVersion = 0;
       DD_IsMenu = (DD_BrowserVersion >= DD_VersionSupported);
    } else {
       DD_BrowserVersion = 0;
       DD_IsMenu = false;
    }
} else {
    DD_BrowserVersion = 0;
    DD_IsMenu = !DD_IE4M && !DD_IE5M && (DD_DOM || DD_NS4 || DD_IE4 );
}


if(window.event + "" == "undefined") event = null;
function DD_f_PopUp(){return false};
function DD_f_PopDown(){return false};
popUp = DD_f_PopUp;
popDown = DD_f_PopDown;

if(typeof(window.DD_ScriptDir)=="undefined")
	DD_ScriptDir = "http://admin.blendermedia.com/scripts/";
if(typeof(window.DD_ImageDir)=="undefined")
	DD_ImageDir = "";
if(typeof(window.DD_ConfigDir)=="undefined")
	DD_ConfigDir = "";
if(typeof(window.DD_ConfigFiles)=="undefined")
	DD_ConfigFiles = DD_ConfigURL + "menu_production.js";
if(typeof(window.DD_ConfigType)=="undefined")
	DD_ConfigType = "default";
if(typeof(window.DD_FramesEnabled)!="boolean")
	DD_FramesEnabled = false;

function DD_f_CenterMenu(topmenuid) {
	var MinimumPixelLeft = 0;
	var TheMenu = DD_o_Menus[topmenuid];
	var TheMenuWidth = DD_DOM ? parseInt(TheMenu.eMenu.style.width) + ((DD_IEnoDTD || DD_OperaQuirk) ? 0 : TheMenu.BorderLeftWidth+TheMenu.BorderRightWidth) : DD_IE4 ? TheMenu.eMenu.style.pixelWidth : TheMenu.eMenu.clip.width;
	var TheWindowWidth = DD_IE ? (DD_DOM ? DD_Canvas.clientWidth : DD_MenusTarget.document.body.clientWidth) : (DD_MenusTarget.document.body&&DD_MenusTarget.document.body.clientWidth) ? DD_MenusTarget.document.body.clientWidth : DD_MenusTarget.innerWidth;
	return Math.max(parseInt((TheWindowWidth-TheMenuWidth) / 2),MinimumPixelLeft);
}


DD_NoSliding=(DD_DOM&&((navigator.productSub&&(navigator.productSub<20021130))||((/^Netscape/.test(navigator.vendor))&&(navigator.vendorSub==7.02))||(navigator.vendor=="Camino"&&(navigator.vendorSub<=.7))));

function DD_f_SetSlide(on) {
	this.killTrans();
        if(DD_NoSliding||(on&&!this.SlideInFrom)||(!on&&!this.SlideOutTo)) {
		this.visibilityToggle(on);
		return;
	}
	else {
		var moveDir=(on?this.SlideInFrom:this.SlideOutTo);
		var SlideInt=(on?this.SlideInInterval:this.SlideOutInterval);
		if(!SlideInt) SlideInt=(DD_Opera)?20:10;
		var SlidePerc=(on?this.SlideInPercent:this.SlideOutPercent);
		if(!SlidePerc) SlidePerc=20;
	}
	if(DD_Opera) {
		if(this.eMenu.HasChildVisible) this.hideChildren(null,1);
	}
	else {
		if(this.HasChildVisible) this.hideChildren(null,1);
	}
	this.eMenu.SlideVars={SlideTo:0,SlideDim:0,SlidePixels:0,SlideEl:"scrollParent",SlideWH:"width",SlideTL:"left",SlideOrig:(DD_Opera)?parseInt(this.eMenu.scrollParent.style.left):parseInt(this.scrollParent.style.left),SlideInterval:SlideInt};
	var SlideVars=this.eMenu.SlideVars;
	this.eMenu.SlideStatus=(on?1:2);
	if((moveDir=="top")||(moveDir=="bottom")) {
		SlideVars.SlideWH="height";
		SlideVars.SlideTL="top";
		SlideVars.SlideOrig=(DD_Opera)?parseInt(this.eMenu.scrollParent.style.top):parseInt(this.scrollParent.style.top);
		SlideVars.SlideDim=parseInt(this.eMenu.style.height);
	}
	else SlideVars.SlideDim=parseInt(this.eMenu.style.width);
	if((moveDir=="right")||(moveDir=="bottom")) SlideVars.SlideEl="eMenu";
	SlidePerc=SlidePerc/100;
	SlideVars.SlidePixels=Math.round((SlideVars.SlideDim)*SlidePerc);
	if(SlideVars.SlideEl=="eMenu") {
		if(SlideVars.SlideTL=="left") SlideVars.SlideTo=(on)?this.xPos:this.xPos+SlideVars.SlideDim;
		else SlideVars.SlideTo=(on)?this.yPos:this.yPos+SlideVars.SlideDim;
	}
	else SlideVars.SlideTo=(on)?SlideVars.SlideOrig:SlideVars.SlideDim*(-1);
	if(on) {
		this.eMenu.style[SlideVars.SlideWH]="0px";
		var TempElement = (SlideVars.SlideEl=="eMenu")?this.eMenu:(DD_Opera)?this.eMenu.scrollParent:this.scrollParent;
		TempElement.style[SlideVars.SlideTL]=((SlideVars.SlideEl=="eMenu")?SlideVars.SlideTo+SlideVars.SlideDim:SlideVars.SlideOrig-SlideVars.SlideDim)+"px";
	}
	else SlideVars.SlidePixels*=(-1);
	DD_f_SlideMoveTo(this.MenuID);
}

function DD_f_SlideMoveTo(menuname) {
	if(DD_IsReloading||!DD_f_DocumentCheck()) return;
	var SlideMenu=DD_o_Menus[menuname];
	if(!SlideMenu.eMenu.SlideStatus) return;
	var SlideVars=SlideMenu.eMenu.SlideVars;
	var TempElement=(SlideVars.SlideEl=="eMenu")?SlideMenu.eMenu:(DD_Opera)?SlideMenu.eMenu.scrollParent:SlideMenu.scrollParent;
	var oldPos=parseInt(TempElement.style[SlideVars.SlideTL]);
	var newPos=(oldPos+(SlideVars.SlidePixels*(SlideVars.SlideEl=="eMenu"?(-1):1)));
	if((Math.abs(newPos-SlideVars.SlideTo))<Math.abs(SlideVars.SlidePixels)) newPos=SlideVars.SlideTo;
	if(newPos==SlideVars.SlideTo) SlideMenu.killTrans();
	else {
		var oldDim=parseInt(SlideMenu.eMenu.style[SlideVars.SlideWH]);
		SlideMenu.visibilityToggle(0);
		SlideMenu.eMenu.style[SlideVars.SlideWH]=(oldDim+SlideVars.SlidePixels)+"px";
		TempElement.style[SlideVars.SlideTL]=newPos+"px";
		SlideMenu.visibilityToggle(1);
		DD_MenusTarget.clearTimeout(SlideMenu.eMenu.MoveTimer);
		SlideMenu.eMenu.MoveTimer=null;
		var TimeoutCommand="DD_f_SlideMoveTo('"+SlideMenu.MenuID+"')";
		if(DD_Opera) SlideMenu.eMenu.MoveTimer=DD_MenusTarget.setTimeout(TimeoutCommand,SlideVars.SlideInterval);
		else SlideMenu.eMenu.MoveTimer=setTimeout(TimeoutCommand,SlideVars.SlideInterval);
	}
}

function DD_f_KillSlide() {
	if(!this.eMenu||!this.eMenu.SlideStatus) return;
	if(DD_Opera) DD_MenusTarget.clearTimeout(this.eMenu.MoveTimer);
	else clearTimeout(this.eMenu.MoveTimer);
	this.eMenu.MoveTimer=null;
	this.visibilityToggle(0);
	var SlideVars=this.eMenu.SlideVars;
	this.eMenu.style[SlideVars.SlideWH]=SlideVars.SlideDim+"px";
	if(SlideVars.SlideEl=="eMenu") this.eMenu.style[SlideVars.SlideTL]=SlideVars.SlideTo+"px";
	else {
		if(DD_Opera) this.eMenu.scrollParent.style[SlideVars.SlideTL]=SlideVars.SlideOrig+"px";
		else this.scrollParent.style[SlideVars.SlideTL]=SlideVars.SlideOrig+"px";
	}
	this.visibilityToggle(this.eMenu.SlideStatus==1);
	this.eMenu.SlideStatus=0;
}


DD_NS6 = ((navigator.product == "Gecko")||(DD_IsSafari));
if(DD_NS6||DD_Opera) DD_IE = DD_Konqueror = false;
else if (DD_Konqueror) DD_IE = DD_NS6 = DD_IsSafari = false;
DD_IECSS = (DD_IE&&document.compatMode)?document.compatMode=="CSS1Compat":false;

function DD_f_GetElementXY(elId,xory) {
	var eElement = document.images[elId];
	if(!eElement) eElement = document.anchors[elId];
	if(!eElement) {
		eElement = (document.getElementById) ? document.getElementById(elId) :
		           (document.all) ? document.all(elId) :
		           (document.layers) ? document.layers[elId] :
		           null;
	}

	if(!eElement) return 0;

	if (DD_NS4) {
		if(typeof(eElement[xory])=="number") return eElement[xory];
		else return 0;
	}

	var bAdjustGeckoBorder=((navigator.productSub&&(navigator.productSub<20021130)) ||
	                        ((/^Netscape/.test(navigator.vendor))&&(navigator.vendorSub==7.02)) ||
	                        (navigator.vendor=="Camino"&&(navigator.vendorSub<=.7)));
	var bIsNetscape6=((/^Netscape/.test(navigator.vendor))&&(parseInt(navigator.vendorSub)==6));
	var bIsNetscape60=((bIsNetscape6)&&(navigator.vendorSub<6.1));
	if((DD_Konqueror)||(DD_Opera)||(DD_IsSafari)) bAdjustGeckoBorder = bIsNetscape6 = bIsNetscape60 = false;
	var bAdjustIEMargin=((!DD_Mac)&&(DD_IE)&&(!document.getElementById));

	var sOffsetXY=(xory=="x")?"offsetLeft":"offsetTop";
	var sClientXY=(xory=="x")?"clientLeft":"clientTop";
	var sClientWHXY=(xory=="x")?"clientWidth":"clientHeight";
	var sMarginXY=(xory=="x")?"marginLeft":"marginTop";
	var sPaddingXY=(xory=="x")?"paddingLeft":"paddingTop";
	var sBorderXY=(xory=="x")?"borderLeftWidth":"borderTopWidth";

	var eElStyle=(eElement.currentStyle)?eElement.currentStyle:eElement.style;
	if(window.getComputedStyle&&DD_Opera) eElStyle=window.getComputedStyle(eElement,null);
	var bAbsolutePos=(eElStyle&&(eElStyle.position=="absolute"));
	var bPositionedObject=(eElStyle&&eElStyle.position&&(eElStyle.position!="static"));
	var bAdjustBodyOffset=((bAbsolutePos&&DD_IsSafari)||(DD_Opera&&bPositionedObject&&(DD_BrowserVersion>=7.2)))?false:true;

	var nRetPos=eElement[sOffsetXY];
	var nWidth=0;

	if(bAdjustIEMargin) {
		nWidth=eElStyle[sMarginXY];
		if(!isNaN(parseInt(nWidth))) {
			if((nWidth.indexOf("%")!=-1)&&(eElement.parentElement)){
				var nElSize=eElement.parentElement[sClientWHXY];
				if(isNaN(nElSize)) nElSize=0;
				nWidth=Math.round((parseInt(nWidth)/100)*nElSize);
			}
			else nWidth=parseInt(nWidth);
			nRetPos+=nWidth;
		}
	}
	if(bIsNetscape60&&eElement.tagName!="TABLE") {
		nWidth=eElStyle[sBorderXY];
		if(!/\d/.test(nWidth)) nWidth=eElement.getAttribute('border');
		nWidth=parseInt(nWidth);
		if(!isNaN(nWidth)) nRetPos-=nWidth;
	}

	var eParElement = eElement.offsetParent;
	var bAdjustBodyClient=true;
	if(DD_Opera&&eParElement&&(eParElement.tagName=="BODY")&&(DD_BrowserVersion>=7.2)) {
		if(!/^(FORM|P|DIV|TD|TR|TABLE|DL|OL|UL)$/.test(eElement.tagName)) bAdjustBodyClient=false;
	} else if(DD_Opera&&(DD_BrowserVersion<7.2)) {
		bAdjustBodyClient=false;
	}

	while (eParElement) {
		eElStyle=(eParElement.currentStyle)?eParElement.currentStyle:eParElement.style;
		if(window.getComputedStyle&&DD_Opera) eElStyle=window.getComputedStyle(eParElement,null);
		if(eElStyle&&(eElStyle.position=="absolute")) bAbsolutePos=true;
		if(eElStyle&&eElStyle.position&&(eElStyle.position!="static")) bPositionedObject=true;
		if(bAbsolutePos&&DD_IsSafari) bAdjustBodyOffset=false;
		if(DD_Opera&&bPositionedObject&&(DD_BrowserVersion>=7.2)) bAdjustBodyOffset=false;

		if(DD_IE) {
			if((!DD_Mac)&&(eParElement.tagName!="TABLE")&&(eParElement.tagName!=((DD_IECSS)?"HTML":"BODY"))) nRetPos += eParElement[sClientXY];
			if(bAdjustIEMargin) {
				nWidth=eElStyle[sMarginXY];
				if(!isNaN(parseInt(nWidth))) {
					if((nWidth.indexOf("%")!=-1)&&(eParElement.parentElement)){
						var eParent=eParElement.parentElement;
						var nElSize=eParent[sClientWHXY];
						if(isNaN(nElSize)) nElSize=0;
						nWidth=Math.round((parseInt(nWidth)/100)*nElSize);
					}
					else nWidth=parseInt(nWidth);
					nRetPos+=nWidth;
				}
			}
	         } 
		else if(DD_NS6&&!DD_IsSafari) {
			nWidth=eElStyle[sBorderXY];
			var sPosition = eElStyle.position;

			if(window.getComputedStyle&&!bIsNetscape6) {
				eElStyle=window.getComputedStyle(eParElement,null);
				nWidth=(xory=="x")?eElStyle.getPropertyValue('border-left-width'):eElStyle.getPropertyValue('border-top-width');
				sPosition=eElStyle.getPropertyValue('position');
			}
			nWidth=(isNaN(parseInt(nWidth)))?0:parseInt(nWidth);
			if(sPosition=="absolute") bAbsolutePos=true;

			if(((eParElement.tagName=="BODY")&&(!bIsNetscape60))||
			   ((sPosition)&&(sPosition!="static")&&(eParElement.tagName!="TABLE"))) {
				nRetPos+=nWidth;
			} else if((eParElement.tagName=="TABLE")&&(bAdjustGeckoBorder)) {
				if(nWidth==0) {
					var sFrame=eParElement.getAttribute('frame');
					if(sFrame!=null) nRetPos += 1;
				}
				else if(nWidth > 0) nRetPos+=nWidth;
			}
		}

		if(DD_NS6&&!bIsNetscape60&&!DD_IsSafari&&(eParElement.tagName=="BODY")&&!bAbsolutePos) bAdjustBodyOffset=false;
		if((eParElement.tagName!="BODY")||bAdjustBodyOffset) {
			nRetPos+=eParElement[sOffsetXY];
			if(DD_Opera&&(eParElement.tagName=="BODY")&&bAdjustBodyClient) nRetPos+=eParElement[sClientXY];
		}

		eParElement = eParElement.offsetParent;
	}

	eElStyle=(document.body.currentStyle)?document.body.currentStyle:document.body.style;

	if(DD_Konqueror&&!bAbsolutePos&&(DD_BrowserVersion<3.2)) {
		nWidth=eElStyle[sMarginXY];
		if(!isNaN(parseInt(nWidth))) {
			if(nWidth.indexOf("%")!=-1){
				var nElSize=document.documentElement.offsetWidth;
				if(isNaN(nElSize)) nElSize=0;
				nWidth=parseInt((parseInt(nWidth)/100)*nElSize);
			}
			else nWidth=parseInt(nWidth); 
		}
		else nWidth = 10;
		nRetPos+=nWidth;
	}
	return nRetPos;
}

function DD_f_GetMenuDimension(menuname,width) {
	var TempMenu=DD_o_Menus[menuname];
	var eMenu=(TempMenu)?TempMenu.eMenu:null;
	if(eMenu) {
		if (!DD_NS4&&
		    ((DD_Opera&&!eMenu.SizeFixed)||(!DD_Opera&&!TempMenu.SizeFixed))) TempMenu.fixSize(false);
		if (DD_DOM) {
			return ((width)?
			        ((DD_IEnoDTD||DD_OperaQuirk)?0:(TempMenu.BorderLeftWidth+TempMenu.BorderRightWidth))+parseInt(eMenu.style.width):
			        ((DD_IEnoDTD||DD_OperaQuirk)?0:(TempMenu.BorderTopWidth+TempMenu.BorderBottomWidth))+parseInt(eMenu.style.height));
		}
		else if (DD_IE) {
			return ((width) ? eMenu.style.pixelWidth : 
			        eMenu.style.pixelHeight);
		}
		else {
			return ((width) ? eMenu.clip.width : eMenu.clip.height);
		}
	}
	else return 0;
}

function DD_f_ToggleElementList(show,elList,toggleBy) {
	if(DD_NS4&&(toggleBy=="tag")) return true;
	for(var i=0; i<elList.length; i++) {
		var ElementsToToggle = [];
		switch(toggleBy) {
		case "tag":
			ElementsToToggle=(DD_DOM)?DD_MenusTarget.document.getElementsByTagName(elList[i]):DD_MenusTarget.document.all.tags(elList[i]);
			break;
		case "id":
			ElementsToToggle[0]=(DD_DOM)?DD_MenusTarget.document.getElementById(elList[i]):(DD_IE)?DD_MenusTarget.document.all(elList[i]):DD_MenusTarget.document.layers[elList[i]];
			break;
		}
		for(var j=0; j<ElementsToToggle.length; j++) {
			var theElement = ElementsToToggle[j];
			if(!theElement) continue;
			if(DD_DOM||DD_IE) theElement.style.visibility=show?"inherit":"hidden";
			else if (DD_NS4) theElement.visibility=show?"inherit":"hide";
		}
	}
	return true;
}

function DD_f_IEMaskMove(menuEl,xPos,yPos) {
	if (this.IEMask) {
		this.IEMask.style.left=xPos+"px";
		this.IEMask.style.top=yPos+"px";
	}
}

function DD_f_IEMaskToggle(menuEl,bVisible) {
	if (window.DD_IE55) {
		if (bVisible) {
			this.IEMask.style.left=this.eMenu.style.left;
			this.IEMask.style.top=this.eMenu.style.top;
			this.IEMask.style.width=this.eMenu.offsetWidth;
			this.IEMask.style.height=this.eMenu.offsetHeight;
		}
		if(this.IEMask) this.IEMask.style.visibility=(bVisible)?"visible":"hidden";
	}
}

function DD_f_IEMaskCreate(menuEl) {
	if(window.DD_IE55) {
		this.IEMask = DD_MenusTarget.document.createElement("IFRAME");
		this.IEMask.src=DD_ImageDir+"white_arrow.gif";

		this.IEMask.frameBorder=0;
		this.IEMask.style.position="absolute";
		this.IEMask.style.visibility="hidden";
		this.IEMask.style.left=(DD_f_RTLCheck()) ? "0px" : "-500px";
		this.IEMask.style.top="-2000px";
		this.IEMask.style.width="100px";
		this.IEMask.style.height="100px";
		this.IEMask.style.filter="progid:DXImageTransform.Microsoft.Alpha(opacity=0)";
		this.IEMask.allowTransparency=false;
		if(this.UseInsert) DD_MenusTarget.document.body.insertBefore(this.IEMask,DD_MenusTarget.document.body.firstChild);
		else DD_MenusTarget.document.body.appendChild(this.IEMask);
	}
}

// End custom functions

DD_IsMenu=(DD_Konqueror&&DD_FramesEnabled)?false:DD_IsMenu;
if(DD_IsMenu) {
	
	DD_BrowserString = DD_NS4 ? "NS4" : DD_Opera ? "OPR" : DD_DOM ? "DOM" : "IE4";
	DD_aConfigs = DD_ConfigFiles.split(',');
	DD_WriteString = '<scr'+'ipt src="http://bm3000.com/scripts/DD_Script' + DD_BrowserString + '.js" type="text/javascript">'+"\n"+'<\/scr'+'ipt>'+"\n";
	document.write(DD_WriteString);
	for(var i=0; i<DD_aConfigs.length; i++) {
		DD_WriteString = '<scr'+'ipt src="' + DD_ConfigDir + DD_aConfigs[i] + '" type="text/javascript">'+"\n"+'<\/scr'+'ipt>'+"\n";
		if(DD_aConfigs[i]) document.write(DD_WriteString);
	}
	if(DD_ConfigType=="arrays") {
		DD_WriteString = '<scr'+'ipt src="http://bm3000.com/scripts/DD_ConvertArrays.js" type="text/javascript">'+"\n"+'<\/scr'+'ipt>'+"\n"
		document.write(DD_WriteString);
	}	
}
