function ResetAllDropDownLists()
{   
    var m = document.getElementsByTagName("select");
    var obj = null;
    for (i=0; i<m.length; i++)
    {
        obj = document.getElementById(m[i].name);
        obj.selectedIndex = 0;
    }
}

function GotoTipPage(obj)
{
    var ObjectChanged = document.getElementById(obj);
    if (ObjectChanged[ObjectChanged.selectedIndex].value != "0")
        window.location = ObjectChanged[ObjectChanged.selectedIndex].value;
}


function ToggleEvents(id)
{    
    var name = "HiddenEvents"+id;
    var obj = document.getElementById(name);
    if (obj != null)
    {
        if (obj.style.display == 'block')
            obj.style.display = 'none';
        else
            obj.style.display = 'block';
    }
}

function ShowLangMenu()
{
    var obj = getElementByClassName('LangMenu');
    
    if (obj.style.display == 'none')
        obj.style.display = 'block';
    else
        obj.style.display = 'none';
}

function getElementByClassName(findClass)
{
    var aElm=document.body.getElementsByTagName('*');
    for(var i=0; i<aElm.length; i++) 
    {
        if(aElm[i].className == findClass) 
        {
            return aElm[i];
        }
    }
    return null;
}

function SetHeight()
{    
    //ResetAllDropDownLists();   
    
    //Om detta är en sida med vänstermeny och huvudyta
    if (document.getElementById("LeftMenuMiddle") && document.getElementById("MainAreaMiddle"))
    {     
        var MenuObjTop = document.getElementById("LeftMenuTop");
        var MenuObjMiddle = document.getElementById("LeftMenuMiddle");
        var MenuObjBottom = document.getElementById("LeftMenuBottom");
        var MainObjTop   = document.getElementById("MainAreaTop");
        var MainObjMiddle   = document.getElementById("MainAreaMiddle");
        var MainObjBottom   = document.getElementById("MainAreaBottom");
        
        var tot = 0;
        if (MainObjTop.offsetHeight != 8)
            tot = MainObjTop.offsetHeight - 8;
        
        //Om huvudytan är längre än menyytan
        if ((MainObjMiddle.offsetHeight+MainObjTop.offsetHeight) > (MenuObjMiddle.offsetHeight+MenuObjTop.offsetHeight))
        {            
            MenuObjMiddle.style.height = tot + MainObjMiddle.offsetHeight-1+"px";
            //alert("1:" + tot+"" +" " +MainObjMiddle.offsetHeight+"px1");
            return;
        }
        //Om menyytan är längre än huvudytan 
        if ((MainObjMiddle.offsetHeight+MainObjTop.offsetHeight) < (MenuObjMiddle.offsetHeight+MenuObjTop.offsetHeight))
        {
            //Om toppbilden är högre än 8 px så är det inte defaultbilden
            if (MainObjTop.offsetHeight > 8)
                MainObjMiddle.style.height = MenuObjMiddle.offsetHeight-tot-42+"px";
            else
                MainObjMiddle.style.height = MenuObjMiddle.offsetHeight-tot-24+"px";
               
            //alert("2:" + tot+"" +" " +MainObjMiddle.offsetHeight+"px1");
            return;
        }
    }
    
     //Sida med tre spalter (vänstermeny och huvudyta och högerspalt)
    if (document.getElementById("LeftMenuMiddle") && document.getElementById("Main3AreaMiddle") && document.getElementById("Main3RightColumnMiddle"))
    {
        var MenuObjTop = document.getElementById("LeftMenuTop");
        var MenuObjMiddle = document.getElementById("LeftMenuMiddle");
        var MenuObjBottom = document.getElementById("LeftMenuBottom");
        var MainObjTop   = document.getElementById("Main3AreaTop");
        var MainObjMiddle   = document.getElementById("Main3AreaMiddle");
        var MainObjBottom   = document.getElementById("Main3AreaBottom");
        
        var RightObjTop = null;
        if (document.getElementById("Main3RightColumnTop") != null)
            RightObjTop = document.getElementById("Main3RightColumnTop")
        if (document.getElementById("Main3LastRightColumnTop") != null)
            RightObjTop = document.getElementById("Main3RightColumnTop")        
        var RightObjMiddle = document.getElementById("Main3RightColumnMiddle")
        var RightObjBottom = document.getElementById("Main3RightColumnBottom")
        
        var tot = 0;
        if (MainObjTop.offsetHeight != 8)
            tot = MainObjTop.offsetHeight - 10;

        //Om huvudytan är den längsta ytan
        if ((MainObjMiddle.offsetHeight+MainObjTop.offsetHeight) > (MenuObjMiddle.offsetHeight+MenuObjTop.offsetHeight) && (MainObjMiddle.offsetHeight+MainObjTop.offsetHeight) > (RightObjMiddle.offsetHeight))
        {               
            MenuObjMiddle.style.height = tot + MainObjMiddle.offsetHeight+1+"px";
            
            if (MainObjTop.offsetHeight > 10)
                RightObjMiddle.style.height = MainObjMiddle.offsetHeight+84+"px";
            else
                RightObjMiddle.style.height = MainObjMiddle.offsetHeight-39+"px";            
           
            return;
        }
        //Om menyytan är största ytan
        if ((MenuObjMiddle.offsetHeight+MenuObjTop.offsetHeight) > (MainObjMiddle.offsetHeight+MainObjTop.offsetHeight)  && (MenuObjMiddle.offsetHeight+MenuObjTop.offsetHeight) > (RightObjMiddle.offsetHeight))
        {
            tot = MenuObjTop.offsetHeight + 26;
            if (MainObjTop.offsetHeight > 20)
                MainObjMiddle.style.height = MenuObjMiddle.offsetHeight-173+"px";
            else
                MainObjMiddle.style.height = MenuObjMiddle.offsetHeight-63+"px";
            RightObjMiddle.style.height = MenuObjMiddle.offsetHeight-36+"px";
            return;
        }
        //Om högerspalten är den största ytan
        if ((RightObjMiddle.offsetHeight) > (MainObjMiddle.offsetHeight+MainObjTop.offsetHeight)  && (RightObjMiddle.offsetHeight) > (MenuObjMiddle.offsetHeight+MenuObjTop.offsetHeight))
        {
            MainObjMiddle.style.height = RightObjMiddle.offsetHeight-177+"px";
            MenuObjMiddle.style.height = RightObjMiddle.offsetHeight-4+"px";
            return;
        }
    }
    
    
    if (document.getElementById("ProductTop") && document.getElementById("ProductTopPuff"))  
    {
        var DivObjTop = document.getElementById("ProductTop");
        var DivObjPuff = document.getElementById("ProductTopPuff");
               
        if (DivObjTop.offsetHeight < DivObjPuff.offsetHeight)
        {
            var DivObjMiddle = document.getElementById("ProductTopMiddle");
            var old = DivObjMiddle.offsetHeight;
            var browserName=navigator.appName; 
            if (browserName == "Netscape")
                DivObjMiddle.style.height = (DivObjPuff.offsetHeight-35)+"px"; 
            else
                DivObjMiddle.style.height = (DivObjPuff.offsetHeight-35)+"px";         
        }
    }
    
    if (document.getElementById("ProductsMiddle1") && document.getElementById("ProductsMiddle2"))
    {
        var DivObj1 = document.getElementById("ProductsMiddle1");
        var DivObj2 = document.getElementById("ProductsMiddle2");
        if (DivObj1.offsetHeight < DivObj2.offsetHeight)
        {
            DivObj1.style.height = DivObj2.offsetHeight + "px";
            DivObj2.style.height = DivObj2.offsetHeight + "px";    
        }
        if (DivObj2.offsetHeight < DivObj1.offsetHeight)
        {
            DivObj2.style.height = DivObj1.offsetHeight + "px";
            DivObj1.style.height = DivObj1.offsetHeight + "px";
         }
    }
    
    if (document.getElementById("ProductsBottom1") && document.getElementById("ProductsBottom2"))
    {
        var DivObj1 = document.getElementById("ProductsBottom1");
        var DivObj2 = document.getElementById("ProductsBottom2");
        if (DivObj1.offsetHeight < DivObj2.offsetHeight)
        {
            DivObj1.style.height = DivObj2.offsetHeight + "px";
            DivObj2.style.height = DivObj2.offsetHeight + "px";    
        }
        if (DivObj2.offsetHeight < DivObj1.offsetHeight)
        {
            DivObj2.style.height = DivObj1.offsetHeight + "px";
            DivObj1.style.height = DivObj1.offsetHeight + "px";
         }
    }
}
