﻿var Mars = {};

Mars.fonts = {
    Serifa: {
        light: {
            src: 'swf/serifalight.swf',
            ratios: [7, 1.32, 11, 1.31, 13, 1.24, 14, 1.25, 19, 1.23, 27, 1.2, 34, 1.19, 42, 1.18, 47, 1.17, 48, 1.18, 69, 1.17, 74, 1.16, 75, 1.17, 1.16]
        },
        roman: {
            src: 'swf/serifaroman.swf',
            ratios: [7, 1.32, 11, 1.31, 13, 1.24, 14, 1.25, 19, 1.23, 27, 1.2, 34, 1.19, 42, 1.18, 47, 1.17, 48, 1.18, 69, 1.17, 74, 1.16, 75, 1.17, 1.16]
        }
    }
}

Mars.do_sIFR = function() {

    sIFR.activate(Mars.fonts.Serifa.light);
    sIFR.activate(Mars.fonts.Serifa.roman);

    sIFR.replace(Mars.fonts.Serifa.light, {
        selector: '.sifr-light',
        wmode: 'transparent',
        css: {
            '.sIFR-root': { 'color': '#3b1000', 'leading': -10 }
        }
    });

    sIFR.replace(Mars.fonts.Serifa.light, {
        selector: 'h1.sifr-light',
        wmode: 'transparent',
        css: {
            '.sIFR-root': { 'font-size': '40px', 'font-weight': 'bold', 'leading': -10 }
        }
    });

    sIFR.replace(Mars.fonts.Serifa.roman, {
        selector: '.sifr-roman',
        wmode: 'transparent',
        css: {
            '.sIFR-root': { 'color': '#3b1000' },
            'a': { 'color': '#d17fc7', 'text-decoration': 'none' },
            'a:hover': { 'color': '#cc33cc' }
        }
    });

};

Mars.do_sIFR();

function EndRequestHandler(sender, args) {
    try {
        supersleight.limitTo(null);
        supersleight.run();
    } catch (e) { }

    Mars.do_sIFR();
}

$(document).ready(function() {
    Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);

    //Mars.Tooltip(".help-ttip");
});

/* 	Mars.Tooltip object - builds a tooltip with its lower left corner positioned over the trigger
- requires only the class name of the tool tip trigger
- "message" of the tooltip should be placed within a title tag on the tool tip trigger
*/
Mars.Tooltip = function(trg_class) {
    var self = this;
    var trgs = $(trg_class);

    self.build = function() {
        trgs.each(function(i) {
            var msg = $(this).attr('title');
            var trg_ID = this.id + "_tt";

            var html = '<div id="' + trg_ID + '" class="tt-container">';
            html += '<img src="i/ttip_top.png" class="tt-top" />';
            html += '<div class="tt-body">';
            html += '<img src="i/ttip_close_btn.gif" class="tt-close-btn" />';
            html += '<h3 class="sifr-roman">' + msg + '</h3>';
            html += '</div>';
            html += '<img src="i/ttip_btm.png" class="tt-btm" />';
            html += '</div>';

            self.populate(this, html);
        });
    }

    self.populate = function(trg, tt) {
        $(tt)
            .insertAfter(trg)
            .css('left', -1000000); // positioned off screen rather than hidden, so supersleight png fix can work in IE 6

        self.display(trg);
    }

    self.position = function(trg) {
        var tPos = $(trg).position().top;
        var lPos = $(trg).position().left;
        var tt = $(trg).next();

        // currently this will position the tooltip's lower left corner just over the trigger
        tt.css({
            'top': parseInt(tPos) - (parseInt(tt.height()) - (parseInt($(trg).height()) + parseInt($(trg).css('margin-top')))),
            'left': parseInt(lPos)
        });
    }

    self.display = function(trg) {
        $(trg).click(function() {

            self.position(trg); // must run on click, otherwise position() will not get right values in webkit browsers
            
            $('.tt-container').hide();
            var tt = '#' + $(this).attr('id') + '_tt';
            $(tt)
            .show()
            .find('.tt-close-btn').click(function() {
            $('.tt-container').hide();
            });
        });
    }

    return self.build();
}

// flash video tracking functions
function videoStart() {
    s.linkTrackVars = "prop16,eVar17,events";
    s.linkTrackEvents = arguments[0];
    s.Media.trackVars = "prop16,eVar17,events";
    s.Media.trackEvents = arguments[0];
    s.events = arguments[0];
    s.prop14 = "video";
    s.prop16 = s.eVar17 = arguments[1] + ":start";
    //s.trackLink(document.location.url, 'o', 'video start');
    s.linkTrackVars = "None";
    s.linkTrackEvents = "None";

    s_code = s.t();
}
function videoEnd() {
    s.linkTrackVars = "prop16,eVar17,events";
    s.linkTrackEvents = arguments[0];
    s.Media.trackVars = "prop16,eVar17,events";
    s.Media.trackEvents = arguments[0];
    s.events = arguments[0];
    s.prop14 = "video";
    s.prop16 = s.eVar17 = arguments[1] + ":end";
    //s.trackLink(document.location.url, 'o', 'video end');
    s.linkTrackVars = "None";
    s.linkTrackEvents = "None";

    s_code = s.t();
}
function videoPause() {
    s.linkTrackVars = "eVar20,events"
    s.linkTrackEvents = arguments[0];
    s.Media.trackVars = "eVar20,events "
    s.Media.trackEvents = arguments[0];
    s.events = arguments[0];
    s.eVar17 = arguments[1] + ":pause"
    //s.trackLink(url,'o','video interaction')
    s.linkTrackVars = "None"
    s.linkTrackEvents = "None"

    s_code = s.t();
}
function videoPlay() {
    s.linkTrackVars = "eVar20,events"
    s.linkTrackEvents = arguments[0];
    s.Media.trackVars = "eVar20,events "
    s.Media.trackEvents = arguments[0];
    s.events = arguments[0];
    s.eVar17 = arguments[1] + ":play"
    //s.trackLink(url,'o','video interaction')
    s.linkTrackVars = "None"
    s.linkTrackEvents = "None"

    s_code = s.t();
}

function doTandC() {
    windso('TermsandConditions.aspx', 680, 480);
}
function windso(argline, height, width) {
    var sStr = ",scrollbars=yes,resizable=yes,toolbar=no,location=no,directories=no,status=no,menubar=no";
    if (window.screen) {
        var aw = screen.availWidth - 30;
        var ah = screen.availHeight - 50;
        sStr = "width=" + width + ",height=" + height + sStr;
        sStr += ",left=" + ((aw - width) / 2);
        var nTop = (ah - height) / 2;
        if (nTop < 0)
            nTop = 0;
        sStr += ",top=" + nTop;
    }
    window.open(argline, "printWin", sStr);
}