	
var headingFont = {
    src: '/Fonts/fontin.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]
    };
var quoteFont = {
    src: '/Fonts/segoe-print.swf'//,
    //ratios: [6, 1.93, 10, 1.92, 14, 1.86, 18, 1.83, 22, 1.81, 26, 1.8, 29, 1.79, 36, 1.78, 37, 1.77, 41, 1.78, 52, 1.77, 53, 1.76, 56, 1.77, 57, 1.76, 60, 1.77, 61, 1.76, 62, 1.77, 101, 1.76, 1.75]
    };
sIFR.activate(headingFont, quoteFont);

function pageLoad(hash) {
    if (hash) {
        $("#content-wrapper").load(hash + ".aspx #Content", '', function() {
            $("#content-wrapper").fadeIn("normal");
            onContentLoaded();
        });
    } else { //default
        $("#content-wrapper").load("Default.aspx #Content", '', onContentLoaded());
    }
}

function onContentLoaded() {
    $("#Footer").fadeIn("normal");
    $("#Content").css("zoom", '');
    setContentLinkHandlers();
    styleTables();
    setCustomFonts();
    setFaqHandlers();
    setDemoLoader();
    setHeights();
}


function setCustomFonts() {
    sIFR.replace(headingFont, {
        selector: 'h1',
        css: [
              '.sIFR-root { font-size:32px; font-weight:normal; text-align: center; color: #2763A5; background-color: #EAEAEA; }'
              ],
        wmode: 'transparent'
    });
    sIFR.replace(headingFont, {
        selector: 'h2',
        css: [
              '.sIFR-root { font-size:18px; font-weight:normal; text-align: left; color: #2763A5; background-color: #EAEAEA; }'
              ],
        wmode: 'transparent'
    });
    sIFR.replace(headingFont, {
        selector: 'h3',
        css: [
              '.sIFR-root { font-size:16px; font-weight:normal; text-align: left; color: #2763A5; background-color: #EAEAEA; }'
              ],
        wmode: 'transparent'
    });
    sIFR.replace(headingFont, {
        selector: '#ContactList dt',
        css: [
              '.sIFR-root { font-size:16px; font-weight:normal; text-align: right; color: #2763A5; background-color: #EAEAEA; }'
              ],
        wmode: 'transparent'
    });
    sIFR.replace(headingFont, {
        selector: '#Content thead th',
        css: [
              '.sIFR-root { font-size:18px; font-weight:normal; color: #2763A5; background-color: #EAEAEA; }'
              ],
        wmode: 'transparent'
    });
    sIFR.replace(quoteFont, {
        selector: '#Content blockquote p.Quote',
        css: [
              '.sIFR-root { font-size:14px; font-weight:normal; text-align: left; color: #444444; background-color: #EAEAEA; }'
              ],
        wmode: 'transparent'
    });
}

function setContentLinkHandlers() {
    $("a.ContentLink").unbind("click");
    $("a.ContentLink").click(function() {
        loadContent($(this));
        return false;
    });
}

function setDemoLoader() {
    if ($('.DemoLinks').length > 0) {
        $(".DemoLinks a[rel^='prettyPhoto']").prettyPhoto({ theme: 'light_rounded' });
    }
}

function setFaqHandlers() {
    $('.faq').find('dd').hide();
    $('.faq').find("dt").click(function() {
        $(this).next().toggle();
    });
}

function setHeights() {
    var windowHeight = $(window).height();
    var contentHeight = windowHeight - 140;
    if (contentHeight > 0) {
        $("#ContentContainer").css('min-height', contentHeight + 'px');
        var verbiageHeight = contentHeight - 225;
        if (verbiageHeight > 0) {
            $(".Verbiage").height(verbiageHeight + 'px');
        }
    }
}

function styleTables() {
    $('tbody tr td:odd').addClass('Price');
}

function loadHeadingImages() {
    var options = { sleep: 5, fade: 2 };
    $('#HeadingImages').crossSlide(options, headingImages);
}

function initHistory() {
    var initialHash = $.history.getCurrent();
    if (initialHash == '') {
        var pageURL = $(window).attr("location").pathname;
        initialHash = getURLHash(pageURL);
    }
    $.history.add(initialHash);

    $(window).historyadd(function(e, currentHash, previousHash) {
        if (currentHash == '') {
            currentHash = 'Default';
        }
        pageLoad(currentHash);
    });

    $(window).history(function(e, hash) {
        if (hash == '') {
            hash = 'Default';
        }
        pageLoad(hash);
    });
}

function initMainMenu() {
    $('#MainMenu ul').kwicks({
        duration: 300,
        max: 200,
        spacing: 0
    });
}

function getURLHash(url) {
    var hash = url;
    hash = hash.replace(/^.*#/, '');
    hash = hash.substr(0, hash.length - 5);
    return hash;
}

function loadContent(link) {
    var currentHash = $.history.getCurrent();
    var nextHash = getURLHash(link.attr("href"));
    if (nextHash != currentHash) {
        $("#Footer").fadeOut("fast");
        $("#content-wrapper").fadeOut("fast", function() { $.history.add(nextHash) });
    }
}

$(document).ready(function() {
	$("#Content").wrap('<div id="content-wrapper"></div>');
    var border = RUZEE.ShadedBorder.create({ corner:8, shadow:16 });

	setHeights();
    initHistory();
	loadHeadingImages();
    initMainMenu();
    $("#Header").fadeIn("fast");
    border.render('Header');
    $("#PageContainer").fadeIn("fast", function() {
        onContentLoaded();
        border.render('ContentContainer');
    });
    $(window).resize(function(){
        setHeights();
    });
});

