

//c right 
var status = charFromCharCode(169) + "2010 Globet";

// create charFrom charcode 
function charFromCharCode(charCode) {
    return unescape('%' + charCode.toString(16));
}

// to be deleted once i dentified 
function ChangeUserLevel() {
    var level = document.all.item(getClientID() + "_Level").value;
    var href = window.location.href;
    document.location.href = getApplicationUrl() + "/ChangeLevel.aspx?form=" + href + "&level=" + level;
}

// -- SportBook 
function getApplicationUrl(){
    var location = window.location.pathname.substr(0, 23).toLowerCase();

    if (location == "/globet_sportsbook_host") {
        if (window.location.port) {
            return window.location.protocol + "//" + window.location.host + "/GLOBET_SPORTSBOOK_HOST";
        }
        return window.location.protocol + "//" + window.location.hostname + "/GLOBET_SPORTSBOOK_HOST";
    }
    else {
        return window.location.protocol + "//" + window.location.hostname;
    }
}

// --enter site session transfer  
function EnterSite() {
    var href = window.location.href;
    var clientId = document.getElementById("id").value;
    document.location.href = getApplicationUrl() + "/SessionTransfer.aspx?site=1&page=" + href + "&ClientId=" + clientId;
}

// submit for with enter 
function SubmitIDChange(event) {
    var charCode = (event.charCode) ? event.charCode :
		((event.which) ? event.which : event.keyCode);
    if (charCode == 13 || charCode == 3) {
        document.all.item(getClientID() + "_Go").focus();
        ChangeUserLevel();
    }

}
// show password field 
function showPassword(o) {
    /* 
    Displays the invisible password form field, and 
    hides the "display" text form field.
    */
    var oPWD = o.form.elements["ctl00_Header1_pwd"];
    if (oPWD == undefined) {
        var oPWD = o.form.elements["Header1_pwd"];
    }
    o.style.display = "none";
    oPWD.style.display = "inline";
    oPWD.focus();
}

function trim(str) {
    if (!str || typeof str != 'string') return null; return str.replace(/^[\s]+/, '').replace(/[\s]+$/, '').replace(/[\s]{2,}/, ' ');
}

function clearInput(o, s) {
    /*
    Clears the contents of the client id text form 
    field if the default value is applied. The default 
    value is passed in by the parameter s.
    */
    if (trim(o.value) == trim(s)) o.value = '';
}

function checkID(o, s) {
    /*
    Sets the value of the client id text form field to 
    the default if no other value has been specified.
    */
    if (o.value == '') o.value = s;
}

function checkPWD(o, s) {
    /*
    If the form password field has had no value 
    specified, then hide it and display the "fake" 
    password (text input) field.
    */
    var oNoPWD = o.form.elements['nopwd'];
    if (o.value == '') {
        o.style.display = 'none';
        oNoPWD.style.display = 'inline';
    }
}

//This function opens window Modal dialog
function fnOpenModalDialog(pageUrl, arguments, modalWindowFeatures, normalWindowFeatures) {
    ///<param name="pageUrl">This is the page url including query string</param>
    ///<param name="arguments">This is the arguments passed to the modal window</param>
    ///<param name="modalWindowFeatures">Features for the modal window which is opened</param>
    ///<param name="normalWindowFeatures">Features for the normal window which is opened</param>

    var dialogResults = "";
    var windowName = "";

    //consider an alternative action if the user's browser doesn't support the desired method
    if (window.showModalDialog) {
        dialogResults = window.showModalDialog(pageUrl, arguments, modalWindowFeatures);
        if ((dialogResults != undefined) && (dialogResults != '') && (dialogResults.substring(0, 6).toLowerCase() == "error:")) {
            window.location.href = dialogResults.substring(6);
        }
    }
    else {
        dialogResults = window.open(pageUrl, windowName, normalWindowFeatures);
    }

    return dialogResults;
}


function MM_openBrWindow(theURL, winName, features, myWidth, myHeight, isCenter) {
    if (window.screen) if (isCenter) if (isCenter == "true") {
        var myLeft = (screen.width - myWidth) / 2;
        var myTop = (screen.height - myHeight) / 2;
        features += (features != '') ? ',' : '';
        features += ',left=' + myLeft + ',top=' + myTop;
    }

    var newWindow = window.open(theURL, winName, features + ((features != '') ? ',' : '') + 'width=' + myWidth + ',height=' + myHeight);
    return newWindow;
    //window.open(theURL, winName);
}

function ShowEventStats(url) {
    var h = 500;
    var w = 725;
    var winl = (screen.width - w) / 2;
    var wint = (screen.height - h) / 2;
    var features = 'height=' + h + ',width=' + w + ',top=' + wint + ',left=' + winl + 'resizable=no,scrollbars=yes,status=no'

    window.open(url, "EventStats", features);
    return false;
}

function SelectTheme(btnNum, theme) {
    //alert(btnNum);
    for (i = 1; i <= 5; i++) {
        tempBtnVal = document.getElementById(hdnTheme)
        tempBtn = document.getElementById('btn' + i)
        //tempBtn.style.backgroundColor=(i==btnNum?'#ff9900':'') 
        tempBtn.style.border = (i == btnNum ? '2px solid #fff' : '1px solid #fff')
        // tempBtn.style= 'buttonDivblueselect';
    }
    //    alert(theme) ;   
    tempBtnVal.value = theme;
} 
