﻿//General ifIE... for fixes
var isIE = false;
if ($.browser.msie) {
    isIE = true;
}

var isIE6 = false;
if ($.browser.msie && $.browser.version == "6.0") {
    isIE6 = true;
};

$(document).ready(function() {
    //return false;
    //PNG fixes
    //$('div#main_container').pngFix();

    //Sets navigation
    selectNav();

    $(window).resize(function() {
        if (isIE6 == true) {
            extendOverlay();
        }
    });

    if (isIE6) {
        //Sets roll-over and roll-out states in IE6
        $('.main_nav li').live('mouseover', function() {
            if ($(this).hasClass('pageLocked') != true) {
                $(this).addClass('pageLocked');
            }
        });

        $('.main_nav li').live('mouseout', function() {
            if ($(this).attr('id') != 'nav-' + navigationGroup) {
                $(this).removeClass('pageLocked');
            }
        });
    }

    /*jQModal scripts*/
    $('a.rateTrigger').live('click', function() {
        $('.jqmWindow').jqm({ ajax: 'modals/rate_this_recipe.aspx' }).jqmShow();
        if (isIE6) {
            extendOverlay();
        }
    });

    $('a.reviewTrigger').live('click', function() {
        $('.jqmWindow').jqm({ ajax: 'modals/review_this_recipe.aspx' }).jqmShow();
        if (isIE6) {
            extendOverlay();
        }
    });

    $('a.shareTrigger').live('click', function() {
        $('.jqmWindow').jqm({ ajax: 'modals/share_this_recipe.aspx' }).jqmShow();
        if (isIE6) {
            extendOverlay();
        }
    });

    //Quick fix to enable callouts to have the whole image area clickable
    var myCallOut = $('.clickableCallOut');
    var myCallOutTitle = myCallOut.find('a').attr('title');

    myCallOut.attr('title', myCallOutTitle);
    myCallOut.css('cursor', 'pointer');

    myCallOut.click(function() {
        window.location = $(this).find("a").attr("href");
    });
    //End quick fix


    //Possible future drop down
    if (isIE6 == false) {
        /*Product category dropdown*/
        $('li#nav-products, div.product-catagory').mouseover(function() {
            $('div.product-catagory').stop(false, true);
            $('div.product-catagory').slideDown('normal');
        });

        $('li#nav-products, div.product-catagory').mouseout(function() {
            $('div.product-catagory').stop(false, true);
            $('div.product-catagory').slideUp('normal');
        });
    }

    //   $.sifr({
    //    build: 436,
    //    version: 3,
    //    path: '/includes/fonts/',
    //    save: true
    //    });

    //    $('p.futura').sifr({
    //    font: 'futura-bk-bt_436',
    //    fontWeight: 'strong',
    //    zoom: 1.2,
    //    width: 212
    //    });

    //    $('h3.futura').sifr({
    //    font: 'futura-bk-bt_436',
    //    fontWeight: 'strong',
    //    width: 212
    //    });

    //    $('h1.sifr').sifr({
    //    font: 'claudias-hand-pro-bold_436',
    //    zoom:.6
    //    });

    //    $('div#recipeView h1.sifr').sifr({
    //    font: 'claudias-hand-pro-bold_436',
    //    verticalAlign: 'top'
    //    });

    //    $('h2.sifr').sifr({
    //    font: 'claudias-hand-pro-bold_436',
    //    zoom: 1.5,
    //    width: 300
    //    });

    //    $('h3.sifr').sifr({
    //    font: 'claudias-hand-pro-bold_436'
    //    });

    //    $('h5.sifr').sifr({
    //    font: 'claudias-hand-pro-bold_436'
    //    });

    //    $('div#recipeViewed h3.sifr').sifr({
    //    font: 'claudias-hand-pro-bold_436'
    //    });

    //    $('#news_and_promotion_content h3.sifr').sifr({
    //    font: 'futura-bk-bt_436',
    //    width: 400,
    //    zoom: 1.2
    //    });
});

function extendOverlay() {
    var ie6Hack = $(window).height();
    var cssObj_Overlay = {
        'height': ie6Hack
    }
    var cssObj_jqWindow = {
        'top': '1%'
    }
    $('.jqmOverlay').css(cssObj_Overlay);
    $('.jqmWindow').css(cssObj_jqWindow);
}