﻿var PREDICTOR = '#';
var WLDZERO = '#';
var WLD = '#';
var PREDICT10 = '#';
var ALLPOOLS = '#';
var FOOTBALLMANIA = '#';
var FIRSTTOSCORE = '#';

$(document).ready(function () {
    var qString = window.location.href;
    var domain = qString.substr(0, qString.lastIndexOf('/') + 1).replace('..', '');
    TopMenuHighlight();
    //window.onbeforeunload = ConfirmClose;
    //window.onunload = HandleOnClose;
});

var myclose = false;

function ConfirmClose() {
    if (event.clientY < 0) {
        event.returnValue = 'Any message you want';

        setTimeout('myclose=false', 100);
        myclose = true;
    }
}

function HandleOnClose() {
    if (myclose == true) alert("Window is closed");
}
function TopMenuHighlight() {
    $('#toc .current').removeClass('current');
    var l = window.location.href.toLowerCase();
    var filename = l.substr(l.lastIndexOf("/") + 1);

    switch (filename) {
        case 'index.aspx':
            $("#li_HOME").attr('class', $("#li_HOME").attr('class') + '_ov');
            break;
        case 'sixgames.aspx':
            $("#li_1").attr('class', $("#li_1").attr('class') + '_ov');
            break;
        case 'sixgames.aspx?t=sm':
            $("#li_1").attr('class', $("#li_1").attr('class') + '_ov');
            break;
        case 'sixgames.aspx?t=wld':
            $("#li_1").attr('class', $("#li_1").attr('class') + '_ov');
            break;
        case 'sixgames.aspx?t=wldzero':
            $("#li_1").attr('class', $("#li_1").attr('class') + '_ov');
            break;
        case 'sixgames.aspx?t=afg':
            $("#li_1").attr('class', $("#li_1").attr('class') + '_ov');
            break;
        case 'sixgames.aspx?t=oneoff':
            $("#li_1").attr('class', $("#li_1").attr('class') + '_ov');
            break;
        case 'sixgames.aspx?t=fts':
            $("#li_1").attr('class', $("#li_1").attr('class') + '_ov');
            break;
        case 'stfb_index.aspx':
            $("#li_STFB").attr('class', $("#li_STFB").attr('class') + '_ov');
            break;
        case 'resultsprem.aspx':
            $("#li_RESULTPREM").attr('class', $("#li_RESULTPREM").attr('class') + '_ov');
            break;
        case 'myaccount.aspx':
            $("#li_MYACCOUNT").attr('class', $("#li_MYACCOUNT").attr('class') + '_ov');
            break;
        default:

    }
}

function cookie(key, value, options) {

    // key and at least value given, set cookie...
    if (arguments.length > 1 && String(value) !== "[object Object]") {
        options = jQuery.extend({}, options);

        if (value === null || value === undefined) {
            options.expires = -1;
        }

        if (typeof options.expires === 'number') {
            var days = options.expires, t = options.expires = new Date();
            t.setDate(t.getDate() + days);
        }

        value = String(value);

        return (document.cookie = [
            encodeURIComponent(key), '=',
            options.raw ? value : encodeURIComponent(value),
            options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
            options.path ? '; path=' + options.path : '',
            options.domain ? '; domain=' + options.domain : '',
            options.secure ? '; secure' : ''
        ].join(''));
    }

    // key and possibly options given, get cookie...
    options = value || {};
    var result, decode = options.raw ? function (s) { return s; } : decodeURIComponent;
    return (result = new RegExp('(?:^|; )' + encodeURIComponent(key) + '=([^;]*)').exec(document.cookie)) ? decode(result[1]) : null;
};
$(document).ready(function () {
    if (window.location.href.toLowerCase().indexOf("/telegraph") != -1) {
        if (cookie("telegraph") == null) {
            $("#popuptelegraph").show();
            cookie("telegraph", "1", { expires: 1 });
        }
        else
            $("#popuptelegraph").hide();
    }
    if (window.location.href.toLowerCase().indexOf('sixgames.aspx') == -1 && window.location.href.toLowerCase().indexOf('lgin.aspx') == -1 && window.location.href.toLowerCase().indexOf('ecommtransparlay.aspx') == -1) {
        if (readCookielogin() != null) {
            //window.location.href = "sixgames.aspx";
        }
    }
});


function readCookielogin() {
    var nameEQ = "login=";
    var ca = document.cookie.split(';');
    for (var i = 0; i < ca.length; i++) {
        var c = ca[i];
        while (c.charAt(0) == ' ') c = c.substring(1, c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
    }
    return null;
}
