
if (document.createElement && document.getElementsByTagName && document.getElementById) {
if (window.addEventListener) window.addEventListener('load', setupScripts, false);
else if (window.attachEvent) window.attachEvent('onload', setupScripts);
}

function setupScripts() {


//Dropdown Menu
applyDropDownF('full','topnavigation_r','',true,1,0,0,'hoveredspan',450,150,1,20,10, 'hoverediv');

//ImageSwap
if (!document.usePageSpecificHover) prepareImageSwap(document.body);
}



var apP = new Array() , pcdR = new Array();
apP.earlyDivId = 'earlymenu';
apP.earlyStyle = 'position:absolute;width:240px;height:auto;padding:10px;border:1px solid #ccc;background-color:white;font-size:12px;z-index:100;visibility:hidden;'
apP.preload = true;
apP.divIds = new Array ("menucontainer","menucontent","menucontdouble","menubottom","menuboxmodeltest");


function writeEarlyDrop() {
document.write("<div id='"+apP.earlyDivId+"' style='"+apP.earlyStyle+"'></div>");
}
var m_wdth=0
function applyDropDownF(procType,tElId,navIdRep,fxBdMrgn,mLoc,xOf,yOf,hvrCl,hiDly,whiDly,rSty,rStps,rvInt, divClass)
{
	if (document.getElementById(tElId)) {
		var dGv = new Array(), dOb = new Array(), revSteps, early;
		dOb.revStep = 0;
		dOb.revInt = new Array();


		if (fxBdMrgn == true && document.body.style) document.body.style.margin = '0px';
		if (pcdR.hoverParent) {
			pcdR.hoverParent.className = pcdR.hoverParent.revClass;
			pcdR.hoverParent.getElementsByTagName('div')[0].className=pcdR.hoverParent.divrevClass
	
			}
			
		var BMdependency = new Array (true,true,false);
		early = (procType != 'early') ? false : true;
		var targetList = document.getElementById(tElId);
		var ulLis = targetList.getElementsByTagName("ul");
		var spLis = targetList.getElementsByTagName("span");
//		alert(		m_wdth=spLis[0].parentNode.offsetWidth)
	//	m_wdth=spLis[0].parentNode.offsetWidth
//		for (i=0;i<spLis.length; i++)
//			{
//			spLis[i].style.width=m_wdth+"px"
//			}

		
		if (navIdRep != '') targetList.id = navIdRep;
		if (procType != 'early') 
				var bMO = addDropdownDiv();
		else {	
				pcdR.tDiv = document.getElementById(apP.earlyDivId); pcdR.cDiv = pcdR.tDiv;
				pcdR.tDiv.onmouseover = keepAlive; pcdR.tDiv.onmouseout = hideDrop;
				}
				
		if (targetList.listHolder) {
			var cTM = targetList.listHolder.childNodes, tE = cTM.length
			for (var i = 0; i < tE; i++) {pcdR.cDiv.appendChild(cTM[0]);}
		}
		
		targetList.listHolder = pcdR.cDiv;
		for (var i=0; i<spLis.length; i++) {
			var newBranch = spLis[i].parentNode.getElementsByTagName('ul');
			if (newBranch.length > 0 || spLis[i].processed) {
				if (!spLis[i].processed) spLis[i].expcol = newBranch[0];
				spLis[i].expcol.style.display = 'none'
		
				spLis[i].revClass = spLis[i].className;
				spLis[i].divrevClass = spLis[i].getElementsByTagName('div')[0].className

				if (spLis[i].id=='lft') spLis[i].positionSubMenu = posRight;
				else spLis[i].positionSubMenu = posUnder;

				spLis[i].onmouseover = showDrop;
				spLis[i].onmouseout = hideDrop;
				if (!early) {
					if (bMO == true && BMdependency[rSty] == true) revSteps = 0;
					else revSteps = rStps;
					if (rSty == 2) spLis[i].reveal = sliderInit;
					else if (rSty == 1) spLis[i].reveal = warperInit;
					else spLis[i].reveal = placeDrop;
					if (revSteps == 0) spLis[i].reveal = placeDrop;
				} else {
					spLis[i].reveal = placeDrop; revSteps = 0;
				}
				if (!spLis[i].processed) pcdR.cDiv.appendChild(newBranch[0]);

				spLis[i].processed = true;
			}
			
			
	
			
		}
	} else return;


function showDrop() {
	window.clearTimeout(dOb.hidetimer);
	clearRevIntervals();
	dOb.revStep = 0;
	if (pcdR.hoverParent) 
		{
		pcdR.hoverParent.className = pcdR.hoverParent.revClass;
		pcdR.hoverParent.getElementsByTagName('div')[0].className=pcdR.hoverParent.divrevClass
		}
	this.className = hvrCl; 

	this.getElementsByTagName('div')[0].className = divClass
	
	pcdR.tDiv.style.clip = 'rect(auto auto auto auto)';
	if (pcdR.displayed) pcdR.displayed.style.display = 'none';
	pcdR.displayed = this.expcol;
	this.expcol.style.display = 'block';
	pcdR.hoverParent = this;
	if (this.id=="lft")
		dOb.subMenuPos = this.positionSubMenu('lft');
	else
		dOb.subMenuPos = this.positionSubMenu();
	document.body.style.cursor = 'pointer';
	this.reveal();
}

function placeDrop() {
	
	if (revSteps == 0 && !early) 
	pcdR.dDiv.style.height = pcdR.cDiv.offsetHeight+'px';
//	alert (pcdR.hoverParent.offsetWidth )
//	pcdR.tDiv.style.width=1.6*pcdR.hoverParent.offsetWidth+"px"
	pcdR.tDiv.style.width="auto"



if (pcdR.hoverParent.id == "lft")
{
	if (pcdR.tlDiv)
		pcdR.tlDiv.style.display="none"
	if (pcdR.tmDiv)
		pcdR.tmDiv.style.display="none"
	if (pcdR.trDiv)
		pcdR.trDiv.style.display="none"
	if (pcdR.tlDiv_r)
		pcdR.tlDiv_r.style.display="block"
	if (pcdR.tmDiv_r)
		pcdR.tmDiv_r.style.display="block"
	if (pcdR.trDiv_r)
		pcdR.trDiv_r.style.display="block"
	


if (pcdR.tmDiv_r)
//		pcdR.tmDiv_r.style.width=(1.6*pcdR.hoverParent.offsetWidth-pcdR.hoverParent.offsetWidth)+"px"
		pcdR.tmDiv_r.style.width="auto"
}
else
{
	if (pcdR.tlDiv)
		pcdR.tlDiv.style.display="block"
	if (pcdR.tmDiv)
		pcdR.tmDiv.style.display="block"
	if (pcdR.trDiv)
		pcdR.trDiv.style.display="block"
	if (pcdR.tlDiv_r)
		pcdR.tlDiv_r.style.display="none"
	if (pcdR.tmDiv_r)
		pcdR.tmDiv_r.style.display="none"
	if (pcdR.trDiv_r)
		pcdR.trDiv_r.style.display="none"
	
	


if (pcdR.tmDiv)
//		pcdR.tmDiv.style.width=(1.6*pcdR.hoverParent.offsetWidth-pcdR.hoverParent.offsetWidth)+"px"
		pcdR.tmDiv.style.width="auto"
}

//	pcdR.rDiv.style.width=pcdR.hoverParent.offsetWidth+"px"
if (pcdR.hoverParent.id == "lft")
	pcdR.tDiv.style.left = (dOb.subMenuPos[0]-pcdR.tDiv.offsetWidth)+"px";
else
	pcdR.tDiv.style.left = dOb.subMenuPos[0] - 2 + "px";
	pcdR.tDiv.style.top =  dOb.subMenuPos[1] - 4 + "px";
	pcdR.tDiv.style.visibility = 'visible';
}

function warperInit() {
	placeDrop();
	pcdR.dDiv.style.height = '0px';
	dOb.tHeight = pcdR.cDiv.offsetHeight;
	dOb.revInt[dOb.revInt.length] = window.setInterval(
		function(){
			if (dOb.revStep < revSteps+1) {
			pcdR.dDiv.style.height = easeInOut(0,dOb.tHeight,revSteps,dOb.revStep,0.5) + "px";
			dOb.revStep++;
			} else clearRevIntervals();
		},rvInt);
}

function sliderInit() {
	pcdR.tDiv.style.clip = 'rect(0 0 0 0)';
	placeDrop();
	pcdR.dDiv.style.height = 'auto';
	dOb.tWidth = pcdR.tDiv.offsetWidth;
	dOb.tHeight = pcdR.tDiv.offsetHeight;
	if (!early) pcdR.dDiv.style.height = pcdR.cDiv.offsetHeight;
	dOb.revInt[dOb.revInt.length] = window.setInterval(
		function() {
			if (dOb.revStep < revSteps) {
			var yLevel = easeInOut(0,dOb.tHeight,revSteps,dOb.revStep,0.5);
			pcdR.tDiv.style.clip = 'rect(0px '+dOb.tWidth+'px '+yLevel+'px 0px)';
			dOb.revStep++;
			} else {pcdR.tDiv.style.clip = 'rect(auto auto auto auto)'; clearRevIntervals();}
		},rvInt)

}

function hideDrop() {
	if (!pcdR.hoverParent) return;
	document.body.style.cursor = 'auto';
	var hideDelay = (revSteps > 0 && dOb.revStep < revSteps && revSteps != 0) ? whiDly : hiDly
	dOb.hidetimer = window.setTimeout(function() {
		if (revSteps > 0) clearRevIntervals();
		pcdR.tDiv.style.visibility = 'hidden';
		pcdR.hoverParent.className = pcdR.hoverParent.revClass;
		pcdR.hoverParent.getElementsByTagName('div')[0].className=pcdR.hoverParent.divrevClass
		},hideDelay);
}


function keepAlive() {
window.clearTimeout(dOb.hidetimer);
}

function posUnder() {
var elmPos = findPos(this);
return Array (elmPos[0]+xOf,elmPos[1]+this.offsetHeight+yOf)
}

function posRight() {
var elmPos = findPos(this);

//alert(this.parentNode.parentNode.parentNode.innerHTML)
return Array (elmPos[0]+xOf+this.offsetWidth, elmPos[1]+this.offsetHeight+yOf)
}

function clearRevIntervals() {
for (i=0;i<dOb.revInt.length;i++) window.clearInterval(dOb.revInt[i]);
dOb.revInt = new Array();
}

function addDropdownDiv() {
	if (document.getElementById(apP.earlyDivId)) 
		document.getElementById(apP.earlyDivId).parentNode.removeChild(document.getElementById(apP.earlyDivId));
	
	var ttDiv = new Array(), 
	prefix = "", 
	boxModelOld = false;
	if (apP.useDefStyle==true) prefix = "M_"
	
	for (var i=0;i<apP.divIds.length;i++) {
		if (document.getElementById(apP.divIds[i]) != null) document.getElementById(apP.divIds[i]).parentNode.removeChild(document.getElementById(apP.divIds[i]));
		ttDiv[i]=document.createElement('div');
		ttDiv[i].id = prefix + apP.divIds[i];
		ttDiv[i].activeStyle = dGetActiveStyle;
	}
	var c = new Array("margin","padding","top","left")
	for (i=0;i<c.length;i++) {
		eval("ttDiv[2].style."+c[i]+" = '0px'");
		eval("ttDiv[4].style."+c[i]+" = '0px'");
		eval("ttDiv[0].style."+c[i]+" = '0px'")
		}
//	ttDiv[0].style.width = m_wdth+ "px";
	ttDiv[2].style.position = "relative"; ttDiv[2].style.width = "100%";
	ttDiv[4].style.visibility = "hidden"; ttDiv[4].style.position = "absolute";
	ttDiv[0].style.visibility = "hidden"; ttDiv[0].style.position = "absolute";
	ttDiv[1].appendChild(ttDiv[2]); ttDiv[0].appendChild(ttDiv[1]); 

	
	ttDiv[0].appendChild(ttDiv[3]);
	

//		alert(ttDiv[0].innerHTML)
	document.body.appendChild(ttDiv[0]);
	
	for (var i=0;i<apP.divIds.length;i++) {
		var bgIm = ttDiv[i].activeStyle("background-image","backgroundImage");
		if (bgIm.indexOf("url") > -1 && apP.preload == true) dPreLoadImage(dStripURL(bgIm))
	}
	document.body.appendChild(ttDiv[4])
	ttDiv[1].style.overflow = "hidden";

	ttDiv[4].style.padding = "10px"; ttDiv[4].style.height = "100px";
	if (ttDiv[4].offsetHeight == 100) boxModelOld = true;
	document.body.removeChild(ttDiv[4]);
	
	for(var i=3;i<=4;i+=2){
	ttDiv[i].innerHTML = "&nbsp;";
	if (window.getComputedStyle && ttDiv[i].activeStyle('background-image','').indexOf("url") == -1)
		ttDiv[0].removeChild(ttDiv[i]);
	else if (ttDiv[i].currentStyle && (ttDiv[i].currentStyle.backgroundImage.indexOf("url") == -1 && ttDiv[i].currentStyle.filter.indexOf("AlphaImageLoader") == -1))
		ttDiv[0].removeChild(ttDiv[i]);
	}
	if (apP.useDefStyle == true) {
		ttDiv[0].style.width = apP.defWidth;
		ttDiv[0].style.zIndex = apP.defZindex;
		for (var i=0;i<apP.defCSS.length;i+=2) eval("ttDiv[1].style."+apP.defCSS[i]+"='"+apP.defCSS[i+1]+"'");
	}
	pcdR.cDiv = ttDiv[2]; 
	pcdR.tDiv = ttDiv[0]; 
	pcdR.dDiv = ttDiv[1];
	pcdR.bDiv = ttDiv[3];
	
	
	
	pcdR.tDiv.onmouseover = keepAlive;
	pcdR.tDiv.onmouseout = hideDrop;
	
	return boxModelOld;
}


function dGetActiveStyle(style,stylecc) {
if (window.getComputedStyle) return window.getComputedStyle(this,null).getPropertyValue(style);
if (this.currentStyle) return eval("this.currentStyle."+stylecc);
return '';
}

function dStripURL(s) {
s = s.substring(s.indexOf("url(")+4,s.lastIndexOf(")"));if (s.indexOf('"')>-1) s = s.substring(s.indexOf('"')+1,s.lastIndexOf('"'));return s;
}

function dPreLoadImage(imageurl) {var img = new Image();img.src = imageurl;	return img;}

function findPos(obj) {
//function modified from www.quirksmode.org
var curleft = 0;
var curtop = 0;
if (obj.offsetParent) {
	while (obj.offsetParent) {
		curleft += obj.offsetLeft
		curtop += obj.offsetTop
		obj = obj.offsetParent;
	}
} else if (obj.x && obj.y) {curleft += obj.x; curtop += obj.y;}
return Array(curleft,curtop);
}


}



function easeInOut(minValue,maxValue,totalSteps,actualStep,powr){
//Generic Animation Step Value Generator By www.hesido.com
var delta = maxValue - minValue;
var stepp = minValue+(Math.pow(((1 / totalSteps)*actualStep),powr)*delta);
return Math.ceil(stepp)
}


//ImageSwapper Script by Hesido.

function prepareImageSwap(elem,mouseOver,mouseOutRestore,mouseDown,mouseUpRestore,mouseOut,mouseUp) {
//Non-Obtrusive Image Swap Script by Hesido.com
//V1.1
	if (typeof(elem) == 'string') elem = document.getElementById(elem);
	if (elem == null) return;
	var regg = /(.*)(_nm\.)([^\.]{3,4})$/
	var prel = new Array(), img, imgList, imgsrc, mtchd;
	imgList = elem.getElementsByTagName('img');

	for (var i=0; img = imgList[i]; i++) {
		if (!img.rolloverSet && img.src.match(regg)) {
			mtchd = img.src.match(regg);
			img.hoverSRC = mtchd[1]+'_hv.'+ mtchd[3];
			img.outSRC = img.src;
			if (typeof(mouseOver) != 'undefined') {
				img.hoverSRC = (mouseOver) ? mtchd[1]+'_hv.'+ mtchd[3] : false;
				img.outSRC = (mouseOut) ? mtchd[1]+'_ou.'+ mtchd[3] : (mouseOver && mouseOutRestore) ? img.src : false;
				img.mdownSRC = (mouseDown) ? mtchd[1]+'_md.' + mtchd[3] : false;
				img.mupSRC = (mouseUp) ? mtchd[1]+'_mu.' + mtchd[3] : (mouseOver && mouseDown && mouseUpRestore) ? img.hoverSRC : (mouseDown && mouseUpRestore) ? img.src : false;
				}
			if (img.hoverSRC) {preLoadImg(img.hoverSRC); img.onmouseover = imgHoverSwap;}
			if (img.outSRC) {preLoadImg(img.outSRC); img.onmouseout = imgOutSwap;}
			if (img.mdownSRC) {preLoadImg(img.mdownSRC); img.onmousedown = imgMouseDownSwap;}
			if (img.mupSRC) {preLoadImg(img.mupSRC); img.onmouseup = imgMouseUpSwap;}
			img.rolloverSet = true;
		}
	}

	function preLoadImg(imgSrc) {
		prel[prel.length] = new Image(); prel[prel.length-1].src = imgSrc;
	}

}

function imgHoverSwap() {this.src = this.hoverSRC;}
function imgOutSwap() {this.src = this.outSRC;}
function imgMouseDownSwap() {this.src = this.mdownSRC;}
function imgMouseUpSwap() {this.src = this.mupSRC;}

function  show_r(obj, dir) {
	if (dir)
		{obj.parentNode.className="div_r"}
	else
		{obj.parentNode.className=""}
	
	}