
/*Function to add onload event to web page*/
function addLoadEvent(func,param) {

    var oldonload = window.onload;
    if (typeof window.onload != 'function') {
        window.onload = func;
    } else {
        window.onload = function() {
            oldonload();
            func(param);
        }
    }
}

/*Function to hide div element*/
function hideDiv(divName){

    var navigationDiv = document.getElementById(divName);
    if(navigationDiv){

        navigationDiv.style.display = "none";
    }
}

/*Function to highlight selected header*/
function defaultLinkSelection(){
    
    var pageId = $('pageId');
    if(document.getElementById('e')){
        document.getElementById('e').style.backgroundPosition="-92px -49px";
    }
    
    if(pageId){
        var linkId = $(pageId.value +'Link');
        if(linkId){
            linkId.style.color = 'black';
            linkId.style.cursor = 'text';
            linkId.style.textDecoration = 'none';
            linkId.onclick = function (){
                return false;
            };
        }
    }
     
}

/*Function to focus on selected tab*/
function highlightHeader(){

    /*Changed for defect GMX 421 on 3 March*/

    var GETstr = location.search.substr(1);
    var reqUrl = location.href;

    if(reqUrl.indexOf('/home.jsf')>=0){//if(GETstr.length==0){
        document.getElementById('h').style.backgroundPosition="0px -49px";
    }else{

        var str =  GETstr.substring(GETstr.indexOf('=')+1);

        if(str=='h')
            document.getElementById(str).style.backgroundPosition="0px -49px";
        else if((str=='jg')||((reqUrl.indexOf('/join-media-exchange')>=0)))
            document.getElementById('jg').style.backgroundPosition="-77px -49px";
        else if((str=='e')||(reqUrl.indexOf('/explore')>=0))
            document.getElementById('e').style.backgroundPosition="-182px -49px";
        else if((str=='f')||(reqUrl.indexOf('/features')>=0))
            document.getElementById('a').style.backgroundPosition="-273px -49px";
        else if((str=='n')||(reqUrl.indexOf('/media-news')>=0))
            document.getElementById('n').style.backgroundPosition="-374px -49px";
    }

}
