var loginInitialized= false;
var loginWindow;

function getImageRoot(img)
{
	var slashArray = new Array();
	slashArray = img.src.split('/');
	var language = slashArray[slashArray.length-2];
	return language;
}

function getPath(filename) {
	var path = filename.substring(0, filename.lastIndexOf("/"));
	return path;
}

function launch(url, width, height){
	var productSelector= window.open(url, 'productSelector', 'width='+width+ ',height='+ height);
	productSelector.focus();
}

//TOP RIGHT HAND SIDE LOGIN PAGE ONFOCUS SCRIPT 

function clearDefault(obj)
{
	if (obj.defaultValue==obj.value) obj.value = "";
}

function feedHideShow(obj,cookieNum)
{
	articlesDiv = getNextDiv(obj);	
	first = getFirstChild(obj);//gets the first child
	plusMinus = getNextDiv(first);//gets the next div to the first child
	
	//alert("Parent:"+prevDiv);
	//alert("Inside Div:"+plusMinus.className);
	
	//alert("Cookie Number: "+cookieNum);
	
	if(articlesDiv.style.display == '' || articlesDiv.style.display == 'none' )
	{
		//first.style.color= template_hilite_color; //;
		articlesDiv.style.display='inline';	
		plusMinus.style.backgroundImage='url("/template/_global/images/btn_minus.gif")';
		//modifyCookie(cookieNum, '1');
	}
	else if(articlesDiv.style.display != '')
	{
		//first.style.color= "#333333";
		articlesDiv.style.display='none';		
		plusMinus.style.backgroundImage='url("/template/_global/images/btn_plus.gif")';
		//modifyCookie(cookieNum, '0');
	}
}


function getNextDiv(d){
	var nextDiv= d.nextSibling;
	
	while(nextDiv){
		if(nextDiv.tagName && nextDiv.tagName=='DIV')
			break;
		else
			nextDiv= nextDiv.nextSibling;
	}	
	return nextDiv
}

function getFirstChild(g)
{
		var prevDiv= g.firstChild;
		while(prevDiv)
		{
				if(prevDiv.tagName && prevDiv.tagName=='DIV')
					break;
				else 
					prevDiv= prevDiv.nextSibling;
		}
		return prevDiv;
}

function getPreviousDiv(g)
{
		var prevDiv= g.previousSibling;
		while(prevDiv)
		{
				if(prevDiv.tagName && prevDiv.tagName=='DIV')
					break;
				else 
					prevDiv= prevDiv.previousSibling;
		}
		return prevDiv;
}

function ifOther(obj)
{
	var selection;
	var tr;
	selection = obj[obj.selectedIndex].value;
	if ( selection == 1 )
	{
		if(navigator.appName== "Netscape"){
			document.getElementById("otherField").style.display="table-row";
			document.getElementById("idNumber").style.display="none";
		}
		else {
			document.getElementById("otherField").style.display="block";
			document.getElementById("idNumber").style.display="none";
		}
	}
	else {
	 document.getElementById("otherField").style.display="none";
	  		if(navigator.appName == "Netscape"){
				document.getElementById("idNumber").style.display="table-row";				
			}
			else {
				document.getElementById("idNumber").style.display="block";				
			}
		
	}
	 
}

function initContentHeight(divName)
{

	var contentDiv = document.getElementById(divName);
	if(contentDiv.offsetHeight < 430 )
	{
		contentDiv.style.height = '450px';
	}

}
//***************************************************************
//******** HEADER LOGIN  ****************************************
//***************************************************************
 	
function displayLogin(){
	var d1= document.createElement('div');
	var d2= document.getElementById('loginContainer');
	
	if(!loginInitialized){
		d1.className='loginWindow';
		d1.id= 'loginWindow';
		
		var d3= document.getElementById('header_content_AD');
		
		if(d3 == null){
				d3= document.getElementById('header_content');
			if(d3 == null){
				d3= document.getElementById('header_holder');
			}
			
		}
		
		d3.appendChild(d1);
		d1.appendChild(d2);
		
		var f= document.loginForm;
		var p= f.password;
		
		//TODO: add validation
		//p.onkeyup= checkSubmit;
		loginInitialized= true;
	}
	
	d2.style.display= 'block';
	document.loginForm.remember.focus();
}

function focusLogin(){
	document.loginForm.email.focus();
}
	
function closeLogin(){
	document.getElementById('loginContainer').style.display= 'none';	
}

function checkSubmit(e){
	if(!e)
		var e = window.event;

	key= e.keyCode;
	
	if(key== 13){
		validateLoginForm();
	}
}






function initLoginWidget(task)
{			
	    triggerLoginFormHolder('appear');
	    setTimeout("triggerLoginFormWidget('appear')",500);
    
}

function closeLoginWidget()
{
	 triggerLoginFormWidget('close');
	 setTimeout("triggerLoginFormHolder('disappear')",1000);
}

function triggerLoginFormWidget(task) {
	if(task=="appear")
    	$("#login-form-holder").fadeIn("slow");
    else 
   		$("#login-form-holder").fadeOut("slow");
}

function triggerLoginFormHolder(option) {
	if(option=="appear") {       
    	$("#login").animate({ 
        width: "264px",
        height: "132px"
    	}, 500 );
    } else {
    	$("#login").animate({ 
        width: "55px",
        height: "20px"
   		}, 350 );
   }
}

////NO NEED TO EDIT BELOW THIS LINE////////////

/*function fillup(){
	if (iedom)
	{
		cross_slide=document.getElementById? document.getElementById("test2") : document.all.test2
		cross_slide2=document.getElementById? document.getElementById("test3") : document.all.test3
		cross_slide.innerHTML=cross_slide2.innerHTML=leftrightslide
		actualwidth=document.all? cross_slide.offsetWidth : document.getElementById("temp").offsetWidth
		cross_slide2.style.left=actualwidth+slideshowgap+"px"
		
	}
	else if (document.layers)
	{
		ns_slide=document.ns_slidemenu.document.ns_slidemenu2
		ns_slide2=document.ns_slidemenu.document.ns_slidemenu3
		ns_slide.document.write(leftrightslide)
		ns_slide.document.close()
		actualwidth=ns_slide.document.width
		ns_slide2.left=actualwidth+slideshowgap
		ns_slide2.document.write(leftrightslide)
		ns_slide2.document.close()
	}
	lefttime=setInterval("slideleft()",30)
}
//window.onload=fillup

function slideleft()
{
	
	if (iedom)
	{
		
		if (parseInt(cross_slide.style.left)>(actualwidth*(-1)+8))
		{
			cross_slide.style.left=parseInt(cross_slide.style.left)-copyspeed+"px"			
		}
		else
			cross_slide.style.left=parseInt(cross_slide2.style.left)+actualwidth+slideshowgap+"px"
		
		if (parseInt(cross_slide2.style.left)>(actualwidth*(-1)+8))
			cross_slide2.style.left=parseInt(cross_slide2.style.left)-copyspeed+"px"
		else
			cross_slide2.style.left=parseInt(cross_slide.style.left)+actualwidth+slideshowgap+"px"
		
	}
	else if (document.layers)
	{
		if (ns_slide.left>(actualwidth*(-1)+8))
			ns_slide.left-=copyspeed
		else
			ns_slide.left=ns_slide2.left+actualwidth+slideshowgap
	
		if (ns_slide2.left>(actualwidth*(-1)+8))
			ns_slide2.left-=copyspeed
		else
			ns_slide2.left=ns_slide.left+actualwidth+slideshowgap
	}
}*/



