﻿function Redirect(s) {
    window.location.href = s;
}

function UsernameChangeSuccess() {
    alert("Username / Password information has been updated");
}

function disableEnterKey(e)
{
     var key;     
     if(window.event)
          key = window.event.keyCode; //IE
     else
          key = e.which; //firefox     

     return (key != 13);
 }

function NoEntityMatchingSearch(s) {
    alert("No matches found for " + s);
}

function ShowNoEntity() {
    alert("Please enter the entity name first then press GO");
}

function ShowNoAccessMessage()
{
    alert("You do not have access to the system. Please contact Redburn on 020 7000 2020 for assistance.");
}

function ShowIncorrectPassword() {
    alert("Your user logon is incorrect. For assistance, please call Redburn on +44 (0) 20 7000 2020.");
}

function DisclaimerDisagree() {
    alert("To view the Redburn Research website, you must agree to the Disclaimer. ");
}

function EmailNotFound() {
    alert("The email address you have entered does not match our records. Please try again or contact Redburn on 020 7000 2020 for assistance.");
}

function EmailSent() {
    alert("Your user details have been sent to your email address. Please check in a few minutes.");
}

function DetailsNotFound() {
    alert("We are unable to find your login details. Please contact Redburn on 020 7000 2020 for assistance");
}

function AccessDenied() {
    alert("You do not have access to this page. Please call Redburn on 020 7000 2020");
}

function CheckUniversePermission(DDL)
{
    if(DDL.options[DDL.selectedIndex].lang)
    {
        alert("You do not have permission to see this region. Please make another selection.");
        
        //Set dropdown back to universe specified in the querystring
        var selectedValue = ReadQSValue('R');
        
        for(i=0;i<DDL.length;i++)
        {
            if (DDL.options[i].innerHTML == selectedValue)
            {
                DDL.selectedIndex=i
            }
        }
        
        return false;
    }
}

function CheckUniversePermissionWithPostback(DDL) 
{

    if (DDL.options[DDL.selectedIndex].lang) 
    {
        alert("You do not have permission to see this region. Please make another selection.");

        //Set dropdown back to universe specified in the querystring
        var selectedValue = ReadQSValue('R');

        for (i = 0; i < DDL.length; i++) {
            if (DDL.options[i].innerHTML == selectedValue) {
                DDL.selectedIndex = i
            }
        }

        return false;
    }
    else 
    {
        __doPostBack(DDL.name,'');
        //return true;
    }
}



function CheckUniversePermissionNonPostback(DDL) {
    if (DDL.options[DDL.selectedIndex].lang) 
    {
        alert("You do not have permission to see this region. Please make another selection.");
        DDL.selectedIndex = 0;
        return false;
    }
}

function ReadQSValue(key) {
    qs();

    if (qsParm[key]) {
        return qsParm[key];
    }else{
        return 0;
    }

}

var qsParm = new Array();
function qs() {
    var query = window.location.search.substring(1);
    var parms = query.split('&');
    for (var i = 0; i < parms.length; i++) {
        var pos = parms[i].indexOf('=');
        if (pos > 0) {
            var key = parms[i].substring(0, pos);
            var val = parms[i].substring(pos + 1);
            qsParm[key] = val;
        }
    }
    
} 