/*
 additional
 JavaScript functions   
 Created By AMAI for Dunlop (02-'09)
*/
var isIE6 = /msie|MSIE 6/.test(navigator.userAgent);  



function setfocus(){
	if (document.getElementById('searchField').value == "search")
		document.getElementById('searchField').value = "" ;
}

function resetSearchField(){
	if (document.getElementById('searchField').value == "")
		document.getElementById('searchField').value = "search";
}



function showOptions(pageID)
{
	//hide other elements  (hide function, when clicks are used instead of hovering)
	/*
	var divCollection = ['navRight_1', 'navRight_2', 'navRight_3'];
	
	if (pageID != 'footer_dropdown'){
		for (var d = 0; d< divCollection.length; d++){
			if (pageID != divCollection[d])
			    hideOptions(divCollection[d]);
		}
	}
	*/
	
	//show options current element
	var imagePath = 'img/wrapper/table/';
	var fileType = '.png';
	var imageCollection = ['lt', 't', 'rt', 'lm', 'm', 'rm', 'lb', 'b', 'rb']
	var rootDiv = document.getElementById(pageID);
    var Element = document.getElementById(pageID).getElementsByTagName('div')[0];
	var Links = Element.getElementsByTagName('ul')[0];
	var LinksCollection = Links.getElementsByTagName('li').length;
	var Table = Element.getElementsByTagName('table')[0];
	var TableChild = Table.getElementsByTagName('td');
	
		//show links in table + fix it's height
		Links.style.display='block';	
		Links.style.height =   Links.getElementsByTagName('li')[0].offsetHeight * LinksCollection + 'px';

		//position footer element
		if (pageID == 'footer_dropdown'){
			rootDiv.style.marginTop = '-' + ((20 * LinksCollection) + 5) + 'px';
			rootDiv.style.zIndex = 2000;
		}
		
		//show shadow
		for (var i = 0; i< imageCollection.length; i++)
		{
			if (isIE6 == true){
				rootDiv.style.background = '#FFF';
			}
			else{
				TableChild[i].style.backgroundImage = 'url(' + imagePath + imageCollection[i] + fileType + ')' ;
			}	
		}
}

function hideOptions(pageID)
{
	//restore footer position
	if (pageID == 'footer_dropdown')
		document.getElementById(pageID).style.marginTop = '5px';
	
	var Element = document.getElementById(pageID).getElementsByTagName('div')[0];
	var Table = Element.getElementsByTagName('table')[0];
	var TableChild = Table.getElementsByTagName('td')

		//hide links in table
        Element.getElementsByTagName('ul')[0].style.display='none';
		
		//hide shadow
		for (var i = 0; i< 9; i++)
		{TableChild[i].style.background = 'none';}
}


function selectCountry(country, id)
{
 	hideOptions(id);
 	if(country=="de") {
 		window.location.href = "index.php?lang=de";
 	} else if(country=="it") {
 		window.location.href = "index.php?lang=it";
 	} else if(country=="sp") {
 		window.location.href = "index.php?lang=sp";
 	} else if(country=="pt") {
 		window.location.href = "index.php?lang=pt";
 	} else if(country=="fr") {
 		window.location.href = "index.php?lang=fr";
        } else if(country=="nl") {
 		window.location.href = "index.php?lang=nl";
 	} else {
 		window.location.href = "index.php?lang=en";
 	}
}


function toggleList(pageID)
{
	var Element = document.getElementById(pageID).getElementsByTagName('div')[0];
	var FirstLine = document.getElementById(pageID).getElementsByTagName('p')[0];
	var imageLink = FirstLine.getElementsByTagName('a')[0];
	var Links = Element.getElementsByTagName('ul')[0];
	var LinksCollection = Links.getElementsByTagName('li').length;
		
	if (Element.style.display != 'block')
	{
		var DivHeight = 30 + (30 * LinksCollection);
		document.getElementById(pageID).style.height =  DivHeight + 'px';
		Element.style.display='block';
		Element.style.zIndex = 2000;
		imageLink.style.backgroundImage = 'url(img/selector/inputArrowUp.jpg)' ;
	} 
	else
	{
		var DivHeight = 32;
		document.getElementById(pageID).style.height =  DivHeight + 'px';
		Element.style.display='none';
		imageLink.style.backgroundImage = 'url(img/selector/inputArrow.jpg)' ;
	}
}


function toggleBox(linkID)
{
	if (linkID.getElementsByTagName('p')[0].style.display == 'none'){
		linkID.getElementsByTagName('p')[0].style.display = 'block';
		
		if (isIE6 == true){
			linkID.getElementsByTagName('a')[0].style.marginLeft = '30px';
		}
	}
	else {
		linkID.getElementsByTagName('p')[0].style.display = 'none';
		
		if (isIE6 == true){
			linkID.getElementsByTagName('a')[0].style.marginLeft = '33px';
		}
	}
}


function addHoverUL(ELEM)
{
	var lis = document.getElementById(ELEM).getElementsByTagName('ul');
	
	for (var i=0; i<lis.length; i++)
	{
		lis[i].onmouseover = function()
		{
			if (isIE6 == true)
			{	
				this.style.background = '#000';
				this.style.color = '#fff';
				this.style.paddingBottom = '2px';
				this.style.paddingTop = '2px';
				this.style.borderTop = '1px solid #222';
				this.style.borderBottom = '1px solid #222';
			}
		};
		
		lis[i].onmouseout = function()
		{
			if (isIE6 == true)
			{	
				this.style.background = 'none';
				this.style.color = '#888';
				this.style.paddingBottom = '3px';
				this.style.paddingTop = '3px';
				this.style.borderTop = 'none';
				this.style.borderBottom = 'none';
			}
		};
	}
}

function addHoverUL_cb(ELEM)
{
	var lis = document.getElementById(ELEM).getElementsByTagName('ul');
	
	for (var i=0; i<lis.length; i++){
		lis[i].onmouseover = function(){
			if (isIE6 == true){	
				this.style.background = '#000';
				this.style.color = '#fff';
				this.style.paddingBottom = '6px';
				this.style.paddingTop = '7px';
				this.style.borderTop = '1px solid #222';
				this.style.borderBottom = '1px solid #222';
			}
		};
		
		lis[i].onmouseout = function(){
			if (isIE6 == true){	
				this.style.background = 'none';
				this.style.color = '#888';
				this.style.paddingBottom = '7px';
				this.style.paddingTop = '8px';
				this.style.borderTop = 'none';
				this.style.borderBottom = 'none';
			}
		};
	}
	
}


