﻿var cntTD = '';
var hideTD = false;

function fonster(URL)
{	
	var oppna = window.open(URL, "AF", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes, width=770,height=460,top=50,left=50");
    oppna.focus();
} 

function Country_onchange(sel)
{
    var sAction = document.forms[0].action;
    var iId = sel.options[sel.selectedIndex].value;    
    sAction = buildAction(sAction, "c=", iId);
    window.location = sAction;
}

function City_onchange(sel)
{
    var sAction = document.forms[0].action;
    var iId = sel.options[sel.selectedIndex].value;    
    sAction = buildAction(sAction, "t=", iId);
    window.location = sAction;
}


function ProdCat_onchange(sel)
{
    var sAction = document.forms[0].action;
    var iId = sel.options[sel.selectedIndex].value;    
    sAction = buildAction(sAction, "pc=", iId);
    sAction = buildAction(sAction, "page=", 1);
    sAction = buildAction(sAction, "p=", 0);
    window.location = sAction;
}
function Design_onchange(sel)
{
    var sAction = document.forms[0].action;
    var iId = sel.options[sel.selectedIndex].value;
    sAction = buildAction(sAction, "d=", iId);
    sAction = buildAction(sAction, "page=", 1);
    sAction = buildAction(sAction, "p=", 0);
    window.location = sAction;
}
function buildAction(action, qsKey, qsValue)
{
    var aryAction = action.split("?");
    
    if(aryAction.length == 1)
        return "?" + qsKey + "=" + qsValue;
        
    var aryQS = aryAction[1].split("&");
    var bKeyFound = false;

    action = aryAction[0] + "?";
    for(var i = 0; i < aryQS.length; i++)
    {
        if(i > 0)
            action += "&";
            
        if(aryQS[i].substring(0, qsKey.length) == qsKey)
        {
            action += qsKey + qsValue;
            bKeyFound = true;
        }
        else
            action += aryQS[i];
    }
    
    if(!bKeyFound)
        action += "&" + qsKey + qsValue;
    
    return action;
}
function Highlight(TD) {
	UnlightAll();
	hideMenu();
	TD.className = 'bottommenyover';
	TD.getElementsByTagName("A")[0].className = 'menyover';
	TD.getElementsByTagName("SPAN")[0].className = 'menyover';
}
function UnHighlight(TD) {
	hideMenu();
	var allowUnhighlight = true;
	if(navigator.appName == 'Microsoft Internet Explorer')
	{
		// Flicker reduction
		elem = window.document.elementFromPoint( event.x, event.y );
		while(elem != null && elem.tagName != "TD")
		{
			elem = elem.parentElement;
		}
		allowUnhighlight = elem != TD;
	}
	if(allowUnhighlight)
	{
		TD.className = 'bottommeny';
		TD.getElementsByTagName("A")[0].className = 'meny';
		TD.getElementsByTagName("SPAN")[0].className = 'meny';
	}
	UnlightAll();
}

function HighlightDrop(TD, cntShow) {
	hideMenu();
	showMenu( cntShow );
	cntTD = TD,
	hideTD = true;
	TD.className = 'bottommenydropover';
	TD.getElementsByTagName("A")[0].className = 'menyover';
	TD.getElementsByTagName("SPAN")[0].className = 'menyover';
}

function UnHighlightDrop(TD) {
	hideTD == false;
	var allowUnhighlight = true;
	if(navigator.appName == 'Microsoft Internet Explorer')
	{
		// Flicker reduction
		elem = window.document.elementFromPoint( event.x, event.y );
		while(elem != null && elem.tagName != "TD")
		{
			elem = elem.parentElement;
		}
		allowUnhighlight = elem != TD;
	}
	if(allowUnhighlight)
	{
		TD.className = 'bottommeny';
		TD.getElementsByTagName("A")[0].className = 'meny';
		TD.getElementsByTagName("SPAN")[0].className = 'meny';
	}
	UnlightAll();
}

var loaded = false;
function showMenu( cntShow ) {
	if(loaded == true) {
		hideMenu();
		var elm = document.getElementById("menu" + cntShow);
		if(elm){elm.style.display = "";}
		document.getElementById("menuTrans").style.display = "";
		document.getElementById("menuTrans2").style.display = "";
	}

}
var menus = new Array();
function hideMenu() {
	if(hideTD == true) {
		UnHighlightDrop(cntTD);
	}
	if(loaded == true) {
	    var elm;
	    for(i = 0; i < menus.length; i++) {
	        elm = document.getElementById(menus[i]);
	        if(elm){elm.style.display = "none";}
		}
		/*for(i = 1; i < 5; i++) {
			document.getElementById("menu" + i).style.display = "none";
		}*/
		document.getElementById("menuTrans").style.display = "none";
		document.getElementById("menuTrans2").style.display = "none";
	}
}


function UnlightAll() {
/*	
	for( var i = 1; i < 8; i++) {
		cntObj = document.getElementById("MenuId" + i);
		cntObj.className = 'bottommeny';
	}
*/}

function go(TD)
{
	window.location=TD.getElementsByTagName("A")[0].href;
}

function fixUglyIE()
{
	for (a in document.links) document.links[a].onfocus = document.links[a].blur;
}
if (document.all )
{
	document.onmousedown = fixUglyIE;
}
