﻿function ChangeLang(ctr){
    var url = document.location.href;
    if (url.indexOf('?')>-1)
        url = url + '&lang=' + ctr.value;
    else
        url = url + '?lang=' + ctr.value;
    document.location.href = url;
}
    
function PosBottom(){
    var tp = document.getElementById('TopContainer');
    var mnu = document.getElementById('MenuContainer');
    var mn = document.getElementById('MainContainer');
    var bt = document.getElementById('BottomContainer');
    try{bt.style.visibility = 'visible';}catch(e){}
        
    //if (bt.offsetTop < (document.body.clientHeight - (tp.offsetHeight + mnu.offsetHeight + mn.offsetHeight)))
    if (document.body.clientHeight > (document.getElementById('BottomContainer').offsetTop + document.getElementById('BottomContainer').offsetHeight))
        document.getElementById('BottomContainer').style.top = document.body.clientHeight - (tp.offsetHeight + mnu.offsetHeight + mn.offsetHeight + bt.offsetHeight);
  
    //FixFlash();
    //try{document.body.onclick=HideAllCalendars;}catch(e){}
} 

function RePosBottom(){
    document.getElementById('BottomContainer').style.top = 10;
    PosBottom();
}


window.onload=PosBottom;
window.onresize=RePosBottom;

// MENU
function GetMeNextSiblingObject(obj,tagName){
    /*WHY DO I NEED THIS FUNCTION? BECAUSE MOZILLA HANDLES WHITESPACES AS OBJECTS...*/
    if (!obj.nextSibling)
        return;
    else if (obj.nextSibling.tagName==tagName)
        return obj.nextSibling
    else{
        return GetMeNextSiblingObject(obj.nextSibling,tagName)
    }
        
}

function ExpandOrLinkLvl1(obj,DontFollowURLS){
    if((!DontFollowURLS) && obj.getAttribute("URL") && obj.getAttribute("URL").length>1 && obj.getAttribute("URL")!='undefined' && document.location.href.indexOf(obj.getAttribute("URL"))==-1){
        document.location.href = obj.getAttribute("URL");
        return;
    }

    //FIRST, DEHIGHLIGHT ALL DIVS
    var divs = document.getElementsByTagName('DIV');
    for (i=0;i<divs.length;i++){
        if (divs[i].id.indexOf('MenuLvl2')>-1)
            divs[i].style.display = 'none';
            
        //RESTORE MOUSE OVER FOR ALL LEVEL1 ITEMS
        if (divs[i].id.indexOf('MenuLvl1')>-1){
            divs[i].className = 'LeftMenuLvl1Item';
            divs[i].onmouseover = function(){HighLightLVL1(this,true)};
            divs[i].onmouseout = function(){HighLightLVL1(this,false)};
        }
    }

    var dv = GetMeNextSiblingObject(obj,'DIV');
    if (dv && dv.id.indexOf('MenuLvl2')>-1){
        dv.style.display = '';
    }
    obj.className = "LeftMenuLvl1Item_On";
    obj.onmouseover = function(){};
    obj.onmouseout = function(){};
}

function ExpandOrLinkLvl2(obj,DontFollowURLS){
    if((!DontFollowURLS) && obj.getAttribute("URL") && obj.getAttribute("URL").length>1 && obj.getAttribute("URL")!='undefined' && document.location.href.indexOf(obj.getAttribute("URL"))==-1){
        document.location.href = obj.getAttribute("URL");
        return;
    }

    //FIRST, DEHIGHLIGHT ALL DIVS
    var divs = document.getElementsByTagName('DIV');
    for (i=0;i<divs.length;i++){
        if (divs[i].id.indexOf('MenuLvl3')>-1)
            divs[i].style.display = 'none';
            
        //RESTORE MOUSE OVER FOR ALL LEVEL1 ITEMS
        if (divs[i].className == "LeftMenuLvl2Item_On"){
            divs[i].className = 'LeftMenuLvl2Item';
            divs[i].onmouseover = function(){HighLightLVL2(this,true)};
            divs[i].onmouseout = function(){HighLightLVL2(this,false)};
        }
    }

    var dv = GetMeNextSiblingObject(obj,'DIV');
    if (dv && dv.id.indexOf('MenuLvl3')>-1){
        dv.style.display = '';
    }
    obj.className = "LeftMenuLvl2Item_On";
    obj.onmouseover = function(){};
    obj.onmouseout = function(){};
}

function ExpandOrLinkLvl3(obj,DontFollowURLS){
    if((!DontFollowURLS) && obj.getAttribute("URL") && obj.getAttribute("URL").length>1 && obj.getAttribute("URL")!='undefined' && document.location.href.indexOf(obj.getAttribute("URL"))==-1){
        document.location.href = obj.getAttribute("URL");
        return;
    }

    //FIRST, DEHIGHLIGHT ALL DIVS
    var divs = document.getElementsByTagName('DIV');
    for (i=0;i<divs.length;i++){
        //RESTORE MOUSE OVER FOR ALL LEVEL3 ITEMS
        if (divs[i].className == "LeftMenuLvl3Item_On"){
            divs[i].className = 'LeftMenuLvl3Item';
            divs[i].onmouseover = function(){HighLightLVL3(this,true)};
            divs[i].onmouseout = function(){HighLightLVL3(this,false)};
        }
    }

    var dv = GetMeNextSiblingObject(obj,'DIV');
    obj.className = "LeftMenuLvl3Item_On";
    obj.onmouseover = function(){};
    obj.onmouseout = function(){};
}

function HighLightLVL1(obj,bool){
    if (bool){obj.className='LeftMenuLvl1Item_On'}
    else{obj.className='LeftMenuLvl1Item'}
}

function HighLightLVL2(obj,bool){
    if (bool){obj.className='LeftMenuLvl2Item_On'}
    else{obj.className='LeftMenuLvl2Item'}
}

function HighLightLVL3(obj,bool){
    if (bool){obj.className='LeftMenuLvl3Item_On'}
    else{obj.className='LeftMenuLvl3Item'}
}

function findDIVByMenuCategoryID(ctgid){
    var divs = document.getElementsByTagName('DIV');
    for (i=0;i<divs.length;i++){
        if (divs[i].getAttribute('MenuCategoryID') && divs[i].getAttribute('MenuCategoryID') == ctgid){
            return divs[i];
        }
    }
}

function CheckTopSearch(obj,originalValue){
    if (document.getElementById(obj).value == originalValue || document.getElementById(obj).value.length == 0){
        document.getElementById(obj).className='txt'
        document.getElementById(obj).value = '';
        return false;
    }
    else
        return true;
}

//HOME TABS
function HomeResources_SelectTab(tb){
    for (i=1;i<=3;i++){
        document.getElementById('Title' + i).className='txtWh';
        document.getElementById('Descr' + i).style.display='none';
    }
   document.getElementById('Title' + tb).className='txt';
   document.getElementById('Descr' + tb).style.display='';
   document.getElementById('TabTable').className = 'HomeThreeTabsTable' + tb; //style.backgroundImage = 'url(images/3Tabs/Tab' + tb + '.gif)';
}

