function showTerms(thisURL, thisSize) {
    needToConfirm = false;
    window.open(thisURL, "", thisSize);
}

$(document).ready(function() {

    // store url for current page as global variable
    current_page = document.location.href
    // apply selected states depending on current page
    if (current_page.match(/Default/)) {
        $("#nav ul li:eq(0)").addClass('navselected');
    } else if (current_page.match(/Activate/)) {
        $("#nav ul li:eq(1)").addClass('navselected');
    } else if (current_page.match(/EarnMore/)) {
        $("#nav ul li:eq(2)").addClass('navselected');
    } else if (current_page.match(/Redeem/)) {
        $("#nav ul li:eq(3)").addClass('navselected');
    } else if (current_page.match(/Blueprint/)) {
        $("#nav ul li:eq(4)").addClass('navselected');
    } else if (current_page.match(/LearnMore/)) {
        $("#nav ul li:eq(5)").addClass('navselected');
    } else { // mark home
        $("#nav ul li:eq(0)").addClass('navselected');
    };

    if (current_page.match(/LearnMore/)) {
        //  replace static styles (that are for when JS is disabled)
        $('#learn_main_left').css('height', 320);
        $('div.cash_back:not(:first)').css('visibility', 'hidden');
        //  following line redundant, but necessary for IE  ;-)
        $('#cash_back_5_pct_show').css('visibility', 'visible');
        $('div.cash_back').css('top', 0);

        $('#learn_main_left a.top_link').click(function(e) {
            e.preventDefault();
            $('#learn_main_left div.cash_back').css('visibility', 'hidden');
            $('#learn_main_left div.cash_back').eq($(this).index('#learn_main_left a.top_link')).css('visibility', 'visible');
            $('#learn_main_left a.top_link span.link_sprites').removeClass('selected');
            $('span.link_sprites', this).addClass('selected');
        });
    }

    if (current_page.match(/Blueprint/)) {
        $('#blueprint #rightcol').css('height', 360);
        //$('#blueprint #rightcol .bp_feature').addClass('show_for_js');
        $('#blueprint #rightcol .bp_feature').css({ left: '132px', visibility: 'hidden', top: '0' });
        $('#blueprint #rightcol #fullpay').css('visibility', 'visible');

        //  show/hide content to the right of links
        $('#blueprint #rightcol > a').click(function(e) {
            e.preventDefault();
            $('#blueprint #rightcol .bp_feature').css('visibility', 'hidden');
            $('#blueprint #rightcol .bp_feature').eq($(this).index('#blueprint #rightcol > a')).css('visibility', 'visible');

            //  massage sprite links
            $('#blueprint #rightcol > a').removeClass('sel_link');
            $('#blueprint #rightcol > a span.link_sprites').removeClass('sel_span');
            $(this).addClass('sel_link');
            $('span.link_sprites', this).addClass('sel_span');
        });
    }

    //the following is for modals
    //select all the a tag with name equal to modal
    $('a[name=modal]').click(function(e) {
        //Cancel the link behavior
        e.preventDefault();

        //Get the A tag
        var id = $(this).attr('href');

        //Get the screen height and width
        var maskHeight = $(document).height();
        var maskWidth = $(window).width();

        //Set heigth and width to mask to fill up the whole screen
        $('#mask').css({ 'width': maskWidth, 'height': maskHeight });

        //transition effect		
        $('#mask').fadeIn(1000);
        $('#mask').fadeTo("slow", 0.8);

        //Get the window height and width
        var winH = $(window).height();
        var winW = $(window).width();

        //Set the popup window to center
        $(id).css('top', winH / 2 - $(id).height() / 2);
        $(id).css('left', winW / 2 - $(id).width() / 2);

        //transition effect
        $(id).fadeIn(2000);

    });


    //if close button is clicked
    $('.window .close').click(function(e) {
        //Cancel the link behavior
        e.preventDefault();

        $('#mask').hide();
        $('.window').hide();

    });



    //if mask is clicked
    $('#mask').click(function() {
        $(this).hide();
        $('.window').hide();
    });


});
    
    
    
