function makeSearchDealers() {
	var url = '/www/live/ladders/terfrsljare.aspx?TreeID=26746';
	var searchStr = document.getElementById('aterforsaljare_txt').value;

	if (searchStr != 'Dealers') {
		url += '&contactsearchstring=*' + searchStr + '*';
	} else {
		url += '&contactsearchstring=*';
	}
	location.href = url;
}
function makeSearchProduct() {
	var url = '/www/live/gemensam/iframe.aspx?TreeID=26705';
	var searchStr = document.getElementById('produkt_txt').value;

	if (searchStr != 'Products') {
		url += '&searchstring=*' + searchStr + '*';
	} else {
		url += '&searchstring=*';
	}
	location.href = url;
}
function toggleImg() {
	document.getElementById('imgToggler').src = imageList[currentImg][0];
	document.getElementById('imgToggler').alt = imageList[currentImg][1];
	currentImg++;
	if (currentImg == imageList.length)
		currentImg = 0;
}
var currentImg = 0;
function toggleImg_two() {
	document.getElementById('imgToggler2').src = imageList_two[currentImg_two][0];
	document.getElementById('imgToggler2').alt = imageList_two[currentImg_two][1];
	currentImg_two++;
	if (currentImg_two == imageList_two.length)
		currentImg_two = 0;
}
var currentImg_two = 0;

//****************************************************************************
// LOGIN FORM ****************************************************************
//****************************************************************************
function showLogin() {
	if (document.getElementById('loginFormHolder')) {
		document.getElementById('loginBtnHolder').style.display = 'none';
		document.getElementById('loginFormHolder').style.display = 'block';
	} else {
		alert('login knapp hittas inte:' + document.getElementById('loginFormHolder'));
	}
}
function hideLogin() {
	if (document.getElementById('loginFormHolder')) {
		document.getElementById('loginBtnHolder').style.display = 'block';
		document.getElementById('loginFormHolder').style.display = 'none';
	}
}
/*
function clearOnFocus(control) {
if (control.value.toLowerCase() == 'anv' + unescape("%C4").toLowerCase() + 'ndarnamn') {
control.value = '';
}
if (control.value.toLowerCase() == 'l' + unescape("%D6").toLowerCase() + 'senord') {
control.value = '';
}
}
function resetOnBlur(control) {
if (document.getElementById('loginUN').value == '' && document.getElementById('loginPW').value == '') {
document.getElementById('loginBtnHolder').style.display = '';
document.getElementById('loginFormHolder').style.display = 'none';
document.getElementById('loginUN').value = 'anv' + unescape("%C4").toLowerCase() + 'ndarnamn';
document.getElementById('loginPW').value = 'l' + unescape("%D6").toLowerCase() + 'senord';
}
}
*/
function logout() {
	document.getElementById('loginLO').value = 'ok';
	document.forms[0].submit();
}
//****************************************************************************
// TOP MENU ******************************************************************
//****************************************************************************
var menuTimeout = null;
var currentId = null;
function mainItemsOver(id) {
	if (currentId != null) {
		if (currentId != id) {
			closeSubMenu(currentId);
			currentId = id;
		}
		if (menuTimeout != null) {
			clearTimeout(menuTimeout);
			menuTimeout = null
		}
	}

	if (document.getElementById('sub_' + id)) {
		var root = document.getElementById('sub_' + id);
		currentId = id;
		//var listItems = root.getElementsByTagName('td');
		//var listLength = listItems.length;
		//var i

		root.style.display = '';
		root.style.position = 'absolute';
		root.style.top = '';
		//    for (i = 0; i < listLength; i++) {
		//        listItems[i].style.position = 'absolute';
		//        listItems[i].style.display = 'block';
		//    }
	}
}
function subItemsOver(id) {
	if (menuTimeout != null) {
		clearTimeout(menuTimeout);
		menuTimeout = null
	}
}
function hideDropdownmenu(id) {
	if (document.getElementById('sub_' + id)) {
		var root = document.getElementById('sub_' + id);
		//var listItems = root.getElementsByTagName('td');
		//var listLength = listItems.length;
		//var i

		//new setTimeout(closeSubMenu(root),2000);
		menuTimeout = setTimeout('closeSubMenu(\'' + id + '\')', 1000);

		//    for (i = 0; i < listLength; i++) {
		//        if (listItems[i].id != 'item_' + id) {
		//            listItems[i].style.position = 'static';
		//            listItems[i].style.display = 'none';
		//        } else {

		//        }
		//    }
	}
}
function closeSubMenu(id) {
	//alert(id);
	if (document.getElementById('sub_' + id)) {
		var root = document.getElementById('sub_' + id);
		//alert(root.nodeName);
		root.style.display = 'none';
		root.style.position = 'relative';
		root.style.top = '';
	}
}

function selectRetailerSearchCountry(treeId, selObj) {
	document.location.replace(document.location.pathname + "?TreeID=" + treeId + "&contactsearchddtid=" + selObj.value);
}

function searchRetailer(url, countryDDTID, city, searchstring) {
	document.location.replace(document.location.protocol + '//' + document.location.host + url + '&contactsearchddtid=' + countryDDTID + '&customfieldvalues=' + encodeURIComponent(city) + '&contactsearchstring=' + escape(searchstring) + '&newsearch=1');
}
