

var g2_img = "<center>Enroll in the OnePass frequent flyer program</center>"
var g2_a = "http://www.continental.com/web/en-US/apps/account/enroll.aspx"
var wint = self.setInterval('mileStone()', 20000);
var randomnumber = Math.floor(Math.random() * 19);
var url_extra = '?num=' + randomnumber
var progressNum = '_5'

$(document).ready(function () {
    $("#m12email").colorbox({ width: "728px", height: "710px", iframe: true, opacity: 0.3, scrolling: false });
    $("#m12video").colorbox({ width: "738px", height: "750px", inline: true, opacity: 0.3, href: "#inline_example1" });

    $('#gauge_01').attr('src', '/web/format/img/onepass/mileathon/onepass/mileathon/m12_gauge_01' + progressNum + '.gif' + url_extra);
    $('#gauge_02').attr('src', '/web/format/img/onepass/mileathon/onepass/mileathon/m12_gauge_02_2.gif' + url_extra);

    $('#m12Gauge02 img').attr('title', g2_img);
    $('#m12Gauge02 a').attr('href', g2_a);

    $('a.tTip').tinyTips('title');
    $('img.tTip').tinyTips('title');

});



function mileStone() {

    var rdNum = Math.floor(Math.random() * 5)


    if (rdNum == '0') {
        $('#m12Gauge02 img').attr('title', 'Sign up for Continental e-mail subscriptions');
        $('#m12Gauge02 a').attr('href', 'http://www.continental.com/web/en-US/apps/account/email/subscription/emailSubscription.aspx');
        $('#gauge_02').attr('src', '/web/format/img/onepass/mileathon/onepass/mileathon/m12_gauge_02_3.gif' + url_extra);
    }

    else if (rdNum == '1') {
        $('#m12Gauge02 img').attr('title', '<center>Acquire the Continental Airlines Presidential Plus<sup>SM</sup> World MasterCard<sup>&reg;</sup></center>');
        $('#m12Gauge02 a').attr('href', 'http://www.continental.com/web/en-US/content/products/chase/presidentialplus.aspx?offer=PPC95SC');
        $('#gauge_02').attr('src', '/web/format/img/onepass/mileathon/onepass/mileathon/m12_gauge_02_50.gif' + url_extra);
    }

    else if (rdNum == '2') {
        $('#m12Gauge02 img').attr('title', '<center>Purchase or renew a Presidents Club<sup>&reg;</sup> membership</center>');
        $('#m12Gauge02 a').attr('href', 'http://www.continental.com/web/en-US/content/travel/airport/lounge/default.aspx');
        $('#gauge_02').attr('src', '/web/format/img/onepass/mileathon/onepass/mileathon/m12_gauge_02_20.gif' + url_extra);
    }

    else if (rdNum == '3') {
        $('#m12Gauge02 img').attr('title', 'Acquire a Continental Airlines World World MasterCard<sup>&reg;</sup> from Chase');
        $('#m12Gauge02 a').attr('href', 'http://www.continental.com/web/en-US/content/products/chase/continental.aspx?offer=OPP255AUF');
        $('#gauge_02').attr('src', '/web/format/img/onepass/mileathon/onepass/mileathon/m12_gauge_02_30.gif' + url_extra);
    }

    else if (rdNum == '4') {
        $('#m12Gauge02 img').attr('title', 'Purchase a full-fare Economy Class round-trip ticket');
        $('#m12Gauge02 a').attr('href', 'http://www.continental.com/web/en-US/apps/booking/flight/searchRT.aspx');
        $('#gauge_02').attr('src', '/web/format/img/onepass/mileathon/onepass/mileathon/m12_gauge_02_12.gif' + url_extra);
    }

    else {
        $('#m12Gauge02 img').attr('title', g2_img);
        $('#m12Gauge02 a').attr('href', g2_a);
        $('#gauge_02').attr('src', '/web/format/img/onepass/mileathon/onepass/mileathon/m12_gauge_02_2.gif' + url_extra);
    }

}




function changeScreen(link_id, class_id, anc, div_id) {
    $('#m12ScreenInfo').addClass('m12ScreenOff');
    $('#m12ScreenRewards').addClass('m12ScreenOff');
    $('#m12ScreenCredits').addClass('m12ScreenOff');
    $('#m12ScreenMilestones').addClass('m12ScreenOff');

    document.getElementById(div_id).className = 'm12ScreenOn';

    var frm = document.getElementById('m12navArea');
    var links = frm.getElementsByTagName('a');
    var link, i = 0;
    while (link = links[i++]) {
        link.className = (link != anc) ? 'off' : 'on';
    }

    if (link_id == 'm12Milestones') {
        $('#m12ScreenBtm').attr('src', '/web/format/img/onepass/mileathon/onepass/mileathon/m12_blue_screen_bottom3.jpg');
    }
    else {
        $('#m12ScreenBtm').attr('src', '/web/format/img/onepass/mileathon/onepass/mileathon/m12_blue_screen_bottom.jpg');
    }

    if (link_id == 'm12Rewards') {

    }

}

function gaugesToggle() {

    var g = document.getElementById('battery_btn');

    if (g.name == "1") {
        wint = window.clearInterval(wint)
        g.name = '0';
        g.className = 'btn_off'
        document.getElementById('lights_btn').src = '/web/format/img/onepass/mileathon/onepass/mileathon/m12_light_off.jpg';
        document.getElementById('gauge_01').src = '/web/format/img/onepass/mileathon/onepass/mileathon/m12_gauge_01_off.gif';
        document.getElementById('gauge_02').src = '/web/format/img/onepass/mileathon/onepass/mileathon/m12_gauge_02_off.gif';
        document.getElementById('gauge_03').src = '/web/format/img/onepass/mileathon/onepass/mileathon/m12_gauge_03_off.gif';
        document.getElementById('gauge_04').src = '/web/format/img/onepass/mileathon/onepass/mileathon/m12_gauge_04_off.gif';
        //alert('GAUGE OFF');
    }
    else {
        wint = self.setInterval('mileStone()', 20000);
        g.name = '1';
        g.className = 'btn_on'
        document.getElementById('lights_btn').src = '/web/format/img/onepass/mileathon/onepass/mileathon/m12_light_on.jpg';
        document.getElementById('gauge_01').src = '/web/format/img/onepass/mileathon/onepass/mileathon/m12_gauge_01' + progressNum + '.gif';
        document.getElementById('gauge_02').src = '/web/format/img/onepass/mileathon/onepass/mileathon/m12_gauge_02.gif';
        $('#m12Gauge02 img').attr('title', g2_img);
        $('#m12Gauge02 a').attr('href', g2_a);
        document.getElementById('gauge_03').src = '/web/format/img/onepass/mileathon/onepass/mileathon/m12_gauge_03.gif';
        document.getElementById('gauge_04').src = '/web/format/img/onepass/mileathon/onepass/mileathon/m12_gauge_04.gif';
    }

}

function unloadReward() {
    $('#content').removeClass('content_On').addClass('content_Off');
    $('#content').children().removeClass('content_On').addClass('content_Off');
    $('#m12RewardsMenu').removeClass('content_Off').addClass('content_On');
    $('#m12ScreenRewards').css('background-image', 'url(/web/format/img/onepass/mileathon/onepass/mileathon/m12_blue_screen5.jpg)');
    $('#m12ScreenRewards2').css('background-image', 'url(/web/format/img/onepass/mileathon/onepass/mileathon/m12_blue_screen6.jpg)');

    $("#content ul").attr("style", ""); //Clear any styles on the slider ul element

}

function loadReward(reward, page_id, anc) {
    $('#m12ScreenRewards').css('background-image', 'url(/web/format/img/onepass/mileathon/onepass/mileathon/m12_blue_screen2.jpg)');
    $('#m12RewardsMenu').removeClass('content_On').addClass('content_Off');
    $('#content').removeClass('content_Off').addClass('content_On');

    if (page_id == '1') {
        $('#m12ScreenRewards2').css('background-image', 'url(/web/format/img/onepass/mileathon/onepass/mileathon/m12_blue_screen2.jpg)');
        var frm = document.getElementById('m12navArea');
        var links = frm.getElementsByTagName('a');
        var link, i = 0;
        while (link = links[i++]) {
            link.className = (link != anc) ? 'off' : 'on';
        }
    }

    if (reward == 'm12Elite1') {
        $('#slider').removeClass('content_Off').addClass('content_On');
        $('#slider').easySlider({
            auto: false,
            continuous: false
        });
    }
    else if (reward == 'm12Elite2') {
        $('#slider2').removeClass('content_Off').addClass('content_On');
        $("#slider2").easySlider({
            auto: false,
            continuous: false,
            nextId: "slider1next",
            prevId: "slider1prev"

        });
    }
    else if (reward == 'm12Elite3') {
        $('#slider3').removeClass('content_Off').addClass('content_On');
        $("#slider3").easySlider({
            auto: false,
            continuous: false,
            nextId: "slider2next",
            prevId: "slider2prev"
        });
    }
    else {
        $('#slider4').removeClass('content_Off').addClass('content_On');
        $("#slider4").easySlider({
            auto: false,
            continuous: false,
            nextId: "slider3next",
            prevId: "slider3prev"
        });
    }

}


function toggleLayer(divID) {
    var e, f;
    e = document.getElementById(divID);
    f = document.getElementById('oc' + divID);
    e.style.visibility = (e.style.visibility == 'visible' ? 'hidden' : 'visible');
    e.style.display = (e.style.display == 'block' ? 'none' : 'block');

    if (f.name == "0") {
        f.src = '/web/format/img/onepass/mileathon/open_Btn.gif';
        f.name = '1';
    }
    else {
        f.src = '/web/format/img/onepass/mileathon/close_Btn.gif';
        f.name = '0';
    }

}
