/* ****************************************************************************
Header
Date: 					2007.11.29
Modified:				2008.01.24
**************************************************************************** */

function clearInputValue(inputBox)
{
	if (inputBox.defaultValue==inputBox.value)
	{
		inputBox.value = "";				
	}
}
function writeInputValue(inputBox, inputDefault)
{
	if (inputBox.value=="")
	{
		inputBox.value = inputDefault;				
	}
}
	
function searchFormAction(defaultvalue,inputBox)
{	
	searchStr=document.getElementsByName(inputBox)[0].value;
	if((searchStr==defaultvalue) ||(searchStr="")){
		return false;
	}
	return true;
}
	
function hideCSDropDown(dropDownLink, dropDownLinkClass, dropDownPane, dropDownOverlay)
{	
	document.getElementById(dropDownLink).className	= dropDownLinkClass;
	document.getElementById(dropDownPane).style.visibility = 'hidden';
	document.getElementById("pipeLeft").style.visibility = 'visible';
	document.getElementById("pipeRight").style.visibility = 'visible';
	document.getElementById('localizationPaneShop2').style.visibility = 'hidden';
	document.getElementById('localizationPaneShop2').style.display= 'none';
}
function showCSDropDown(dropDownLink, dropDownLinkClass, dropDownPane, dropDownOverlay, showPipeLeft, showPipeRight)
{			
	document.getElementById(dropDownLink).className	= dropDownLinkClass+"ON";
	document.getElementById(dropDownPane).style.top =  '33px';
	document.getElementById(dropDownPane).style.visibility = 'visible';

		
	
	document.getElementById("localizationPanePartners2").style.marginLeft  = 
		document.getElementById("localizationPartnersLink").offsetWidth-1+"px";
	document.getElementById("localizationPaneServices2").style.marginLeft  = 
		document.getElementById("localizationServicesLink").offsetWidth-1+"px";	
	document.getElementById("localizationPaneStore2").style.marginLeft  = 
		document.getElementById("localizationStoreLink").offsetWidth-1+"px";	
		
	document.getElementById('localizationPaneShop2').style.left  = 		
		document.getElementById("localizationShopLink").offsetWidth
		-1+"px";
	document.getElementById('localizationPaneShop2').style.width = 		
		document.getElementById("localizationPaneShop").offsetWidth
		- document.getElementById("localizationShopLink").offsetWidth
		+"px";
	if (dropDownLink == 'localizationShopLink')
	{
		document.getElementById('localizationPaneShop2').style.visibility = 'visible';
		document.getElementById('localizationPaneShop2').style.display= 'block';
	}
	if (showPipeLeft)
	{
		document.getElementById("pipeLeft").style.visibility = 'visible';
	}
	else
	{
		document.getElementById("pipeLeft").style.visibility = 'hidden';
	}
	if (showPipeRight)
	{
		document.getElementById("pipeRight").style.visibility = 'visible';
	}
	else
	{
		document.getElementById("pipeRight").style.visibility = 'hidden';
	}
}

function hideSNDropDown(dropDownLink, dropDownFly)
{	
	document.getElementById(dropDownLink).className	= 'segNavMainTab';
	if (document.getElementById(dropDownFly)!=null)
	{
		document.getElementById(dropDownFly).style.visibility = 'hidden';
	}
	if (segNavSelected != null && dropDownLink == segNavSelected)
	{
		document.getElementById(dropDownLink).className	= 'segNavMainTab segNavMainTabOn';
	}
}

	
function showSNDropDown(dropDownLink, dropDownFly)
{	
	document.getElementById(dropDownLink).className	= 'segNavMainTab segNavMainTabOver';
	if (document.getElementById(dropDownFly)!=null)
	{
		document.getElementById(dropDownFly).style.visibility = 'visible';
	}
}

function highlightNav(currentUrl, navTabs, onClass, type)
{
	var tabId = "";		
	var tabIdInner = "";		
	var navTab = "";	
	
	for (i = 0; i < navTabs.length; i++) 
	{	
		if (currentUrl.indexOf(navTabs[i].path) > -1) 
		{	
			tabId = navTabs[i].id;
			tabIdInner = navTabs[i].idInner;			
			break;				
		}
	}		
	navTab = document.getElementById(tabId);
	navTab.className = onClass;	  
	if (type == "globalNav")
	{
			navTabInner = document.getElementById(tabIdInner);				
			navTabInner.className = "globalSegNavOn";	  
	}	
	return tabId;
}		


// ------------------------------------------------------------------------------------------------------------------
//Right Nav, Rounded Corners
function Rounded(selector,wich,bk,color,opt){
var i,prefixt,prefixb,cn="r",ecolor="",edges=false,eclass="",b=false,t=false;

if(color=="transparent"){
    cn=cn+"x";
    ecolor=bk;
    bk="transparent";
    }
else if(opt && opt.indexOf("border")>=0){
    var optar=opt.split(" ");
    for(i=0;i<optar.length;i++)
        if(optar[i].indexOf("#")>=0) ecolor=optar[i];
    if(ecolor=="") ecolor="#666";
    cn+="e";
    edges=true;
    }
else if(opt && opt.indexOf("smooth")>=0){

    cn+="a";
    ecolor=Mix(bk,color);
    }
if(opt && opt.indexOf("small")>=0) cn+="s";
prefixt=cn;
prefixb=cn;
if(wich.indexOf("all")>=0){t=true;b=true}
else if(wich.indexOf("top")>=0) t="true";
else if(wich.indexOf("tl")>=0){
    t="true";
    if(wich.indexOf("tr")<0) prefixt+="l";
    }
else if(wich.indexOf("tr")>=0){
    t="true";
    prefixt+="r";
    }
if(wich.indexOf("bottom")>=0) b=true;
else if(wich.indexOf("bl")>=0){
    b="true";
    if(wich.indexOf("br")<0) prefixb+="l";
    }
else if(wich.indexOf("br")>=0){
    b="true";
    prefixb+="r";
    }
var v=getElementsBySelector(selector);
var l=v.length;
for(i=0;i<l;i++){
    if(edges) AddBorder(v[i],ecolor);
    if(t) AddTop(v[i],bk,color,ecolor,prefixt);
    if(b) AddBottom(v[i],bk,color,ecolor,prefixb);
    }
}

function AddBorder(el,bc){
var i;
if(!el.passed){
    if(el.childNodes.length==1 && el.childNodes[0].nodeType==3){
        var t=el.firstChild.nodeValue;
        el.removeChild(el.lastChild);
        var d=CreateEl("span");

        d.style.display="block";
        d.appendChild(document.createTextNode(t));
        el.appendChild(d);
        }
    for(i=0;i<el.childNodes.length;i++){
        if(el.childNodes[i].nodeType==1){
            el.childNodes[i].style.borderLeft="0px solid "+bc;
            el.childNodes[i].style.borderRight="1px solid "+bc;
            }
        }
    }
el.passed=true;
}
    
function AddTop(el,bk,color,bc,cn){
var i,lim=4,d=CreateEl("b");

if(cn.indexOf("s")>=0) lim=2;
if(bc) d.className="artop";
else d.className="rtop";
d.style.backgroundColor=bk;
for(i=1;i<=lim;i++){
    var x=CreateEl("b");
    x.className=cn + i;
    x.style.backgroundColor=color;
    if(bc) x.style.borderColor=bc;
    d.appendChild(x);
    }
el.style.paddingTop=0;
el.insertBefore(d,el.firstChild);
}

function AddBottom(el,bk,color,bc,cn){
var i,lim=4,d=CreateEl("b");

if(cn.indexOf("s")>=0) lim=2;
if(bc) d.className="artop";
else d.className="rtop";
d.style.backgroundColor=bk;
for(i=lim;i>0;i--){
    var x=CreateEl("b");
    x.className=cn + i;
    x.style.backgroundColor=color;
    if(bc) x.style.borderColor=bc;
    d.appendChild(x);
    }
el.style.paddingBottom=0;
el.appendChild(d);
}

function CreateEl(x){
return(document.createElement(x));
}

function getElementsBySelector(selector){
var i,selid="",selclass="",tag=selector,f,s=[],objlist=[];

if(selector.indexOf(" ")>0){  //descendant selector like "tag#id tag"
    s=selector.split(" ");
    var fs=s[0].split("#");
    if(fs.length==1) return(objlist);
    f=document.getElementById(fs[1]);
    if(f) return(f.getElementsByTagName(s[1]));
    return(objlist);
    }
if(selector.indexOf("#")>0){ //id selector like "tag#id"
    s=selector.split("#");
    tag=s[0];
    selid=s[1];
    }
if(selid!=""){
    f=document.getElementById(selid);
    if(f) objlist.push(f);
    return(objlist);
    }
if(selector.indexOf(".")>0){  //class selector like "tag.class"
    s=selector.split(".");
    tag=s[0];
    selclass=s[1];
    }
var v=document.getElementsByTagName(tag);  // tag selector like "tag"
if(selclass=="")
    return(v);
for(i=0;i<v.length;i++){
    if(v[i].className.indexOf(selclass)>=0){
        objlist.push(v[i]);
        }
    }
return(objlist);
}

function Mix(c1,c2){
var i,step1,step2,x,y,r=new Array(3);
if(c1.length==4)step1=1;
else step1=2;
if(c2.length==4) step2=1;
else step2=2;
for(i=0;i<3;i++){
    x=parseInt(c1.substr(1+step1*i,step1),16);
    if(step1==1) x=16*x+x;
    y=parseInt(c2.substr(1+step2*i,step2),16);
    if(step2==1) y=16*y+y;
    r[i]=Math.floor((x*50+y*50)/100);
    }
return("#"+r[0].toString(16)+r[1].toString(16)+r[2].toString(16));
} 





////////////////////////////// ITM BELOW ////////////////////////////////

// get browser version
// NN4 layers, IE4+ all, IE5+ NN6+ getElementById

// bCode_itm = 0, no browser support
// bCode_itm = 1, isIE5 = false, supports all
// bCode_itm = 2, isIE5 = true, supports getElementById
// bCode_itm = 2, isNN6 = true, supports getElementById
// bCode_itm = 3, isNN4 = true, supports layers 

var bCode_itm = 0;

var isIE_itm = false;
var isIE5_itm = false;
var isNN4 = false;
var isNN6_itm = false;

var isOpera_itm	= (navigator.userAgent.toLowerCase().indexOf('opera') != -1);
var isFirefox_itm	= (navigator.userAgent.toLowerCase().indexOf('firefox') != -1);



// get browser version function
function getBrowserVersion_itm()
{
	if(document.all){
		isIE_itm = true; bCode_itm = 1;
	}	
	if(document.getElementById){
		if(isIE_itm){
			isIE5_itm = true; bCode_itm = 2;
		}
		else{
			isNN6_itm = true; bCode_itm = 2;
		}
	}	
	if(document.layers){
		isNN4_itm = true; 
		bCode_itm = 3;
	}
}

// get browser version
getBrowserVersion_itm();


// get element function
function getElement_itm(elementName){


	if(bCode_itm==1){
		return document.all[elementName];
	}
	else if(bCode_itm==2){
		return document.getElementById(elementName);
	}
	else {
		return null;
	}
}


// get position of x and y when mouse is clicked

// Register DOM style events
if (document.addEventListener)
	document.addEventListener("mouseover", handleHover_itm, true);

// Register IE style events
if (document.attachEvent)
	document.attachEvent("onmouseover",handleHover_itm);

var eventX_itm = 0;
var eventY_itm = 0;


function handleHover_itm(e)
{
	if (!e)
	var e = window.event;

	eventX_itm = e.clientX;
	eventY_itm = e.clientY;

}


// set x-coordinate of layer function
function setX_itm(elementName)
{
	 var theElement = getElement_itm(elementName);

	if(isOpera_itm){
			theElement.style.pixelLeft = eventX_itm-779;
	 }
	 else{
			theElement.style.left = eventX_itm-779+"px";
	 }
}


// set y-coordinate of layer function
function setY_itm(elementName)
{
	 var theElement = getElement_itm(elementName);

	 if(isOpera_itm){
			theElement.style.pixelTop = 20;

	 }
	 else{
			theElement.style.top = 20+"px";
	 }
}


function resetX_itm(elementName)
{
	 var theElement = getElement_itm(elementName);
	 
	 if (theElement) {
	 	setVisibility_itm(theElement, "hidden")
	 
		if(isOpera_itm){
			theElement.style.pixelLeft = eventX_itm-2000;
	 	}
	 	else{
			theElement.style.left = eventX_itm-2000+"px";
	 	}
	}
}


// set y-coordinate of layer function
function resetY_itm(elementName)
{
	 var theElement = getElement_itm(elementName);
	 
	 if (theElement) {
	 	setVisibility_itm(theElement, "hidden")
	 
	 	if(isOpera_itm){
			theElement.style.pixelTop = 20;
		 }
	 	else{
			theElement.style.top = 20+"px";
	 	}
	}
}




var newCount_itm = 0;


var visibilityTimeoutId_itm = null;

var opacityTimeoutId1_itm = null;
var opacityTimeoutId2_itm = null;
var opacityTimeoutId3_itm = null;
var opacityTimeoutId4_itm = null;
var opacityTimeoutId5_itm = null;
var opacityTimeoutId6_itm = null;
var opacityTimeoutId7_itm = null;
var opacityTimeoutId8_itm = null;
var opacityTimeoutId9_itm = null;



var newOpacityLevel_itm = 0;



function showSmallITMBackground_Popupbox(id1, src, id2){

	clearTimeouts_itm();
	
	resetOpacity_itm();

	var element1= getElement_itm("itm_small_" + id1);
	var element2= getElement_itm("itm_small_" + id2);

	if(element1 && element2){
		element1.style.backgroundImage = src;

		setX_itm("itm_small_" + id2);
		setY_itm("itm_small_" + id2);
		
		// alert("x is " + eventX_itm + " y is " + eventY_itm);	

		setOpacity_itm(element2, 0);
		
		visibilityTimeoutId_itm = setTimeout(function() { setVisibility_itm(element2,"visible");	}, 0);
		

		opacityTimeoutId1_itm = setTimeout(function() { setOpacity_itm(element2, .15); }, 200);
		opacityTimeoutId2_itm = setTimeout(function() { setOpacity_itm(element2, .25); }, 250);
		opacityTimeoutId3_itm = setTimeout(function() { setOpacity_itm(element2, .35); }, 300);
		opacityTimeoutId4_itm = setTimeout(function() { setOpacity_itm(element2, .45); }, 350);
		opacityTimeoutId5_itm = setTimeout(function() { setOpacity_itm(element2, .55); }, 400);
		opacityTimeoutId6_itm = setTimeout(function() { setOpacity_itm(element2, .65); }, 450);
		opacityTimeoutId7_itm = setTimeout(function() { setOpacity_itm(element2, .75); }, 500);
		opacityTimeoutId8_itm = setTimeout(function() { setOpacity_itm(element2, .85); }, 550);
		opacityTimeoutId9_itm = setTimeout(function() { setOpacity_itm(element2, .99); }, 600);	
	
											
	}
	


}

function setVisibility_itm(element2, visibility) {

		element2.style.visibility = "visible";	


}


function setOpacity_itm(element2, newCount_itm) {

	newOpacityLevel_itm = newCount_itm;

	if(document.all){
		element2.style.filter = "alpha(opacity=" + 100*newCount_itm + ")";
		
			
	}else if(document.getElementById){
    	element2.style.opacity = newCount_itm;
	}

}


function resetOpacity_itm(){

	setOpacity_itm(getElement_itm("itm_small_popupbox1"), .0);
	setOpacity_itm(getElement_itm("itm_small_popupbox2"), .0);
	setOpacity_itm(getElement_itm("itm_small_popupbox3"), .0);
	setOpacity_itm(getElement_itm("itm_small_popupbox4"), .0);	


}

function clearTimeouts_itm(){

	if(visibilityTimeoutId_itm)
		clearTimeout(visibilityTimeoutId_itm);
	
	if(opacityTimeoutId1_itm)
		clearTimeout(opacityTimeoutId1_itm);
	
	if(opacityTimeoutId2_itm)	
		clearTimeout(opacityTimeoutId2_itm);
	
	if(opacityTimeoutId3_itm)	
		clearTimeout(opacityTimeoutId3_itm);
	
	if(opacityTimeoutId4_itm)	
		clearTimeout(opacityTimeoutId4_itm);
	
	if(opacityTimeoutId5_itm)	
		clearTimeout(opacityTimeoutId5_itm);
	
	if(opacityTimeoutId6_itm)	
		clearTimeout(opacityTimeoutId6_itm);
	
	if(opacityTimeoutId7_itm)	
		clearTimeout(opacityTimeoutId7_itm);
	
	if(opacityTimeoutId8_itm)	
		clearTimeout(opacityTimeoutId8_itm);
	
	if(opacityTimeoutId9_itm)	
		clearTimeout(opacityTimeoutId9_itm);

}


function pausecomp_itm(millis)
{
date = new Date();
var curDate = null;

do { var curDate = new Date(); }
while(curDate-date < millis);
} 



function hideSmallITMBackground_Popupbox(id1, src, id2){

	clearTimeouts_itm();

			
	var element1= getElement_itm("itm_small_" + id1);
	var element2= getElement_itm("itm_small_" + id2);
	
	if(element1 && element2){
	
		resetX_itm("itm_small_popupbox1");
		resetY_itm("itm_small_popupbox1");
		resetX_itm("itm_small_popupbox2");
		resetY_itm("itm_small_popupbox2");
		resetX_itm("itm_small_popupbox3");
		resetY_itm("itm_small_popupbox3");
		resetX_itm("itm_small_popupbox4");
		resetY_itm("itm_small_popupbox4");	

		element1.style.backgroundImage = src;
		fadeOutPopupbox_itm(element2);
	 
	}
}


function fadeOutPopupbox_itm(element2) {

		
		// reset and hide box code
		setOpacity_itm(element2, .0);
		setVisibility_itm(element2,"hidden");
						

}

