/*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="-92px -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('f').style.backgroundPosition="-273px -49px";
        else if((str=='n')||(reqUrl.indexOf('/media-news')>=0))
            document.getElementById('n').style.backgroundPosition="-365px -49px";
    }
}

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

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

function firstLoad(param){

    var pageIdFeatures = $('pageIdFeatures');
    if(document.getElementById('f')){
        document.getElementById('f').style.backgroundPosition="-182px -49px";
    }
    if(pageIdFeatures){
        var linkId = $(pageIdFeatures.value +'_link');
        if(linkId){
            linkId.style.color = 'black';
            linkId.style.cursor = 'text';
            linkId.style.textDecoration = 'none';
            linkId.onclick = function (){
                return false;
            };
        }
    }
}
