﻿(function ($) {
    $.fn.cross = function (options) {
        return this.each(function (i) {
            var $$ = $(this); var target = $$.css('backgroundImage').replace(/^url|[\(\)'"]/g, ''); $$.wrap('<span style="position: relative;"></span>').parent().prepend('<img>').find(':first-child').attr('src', target); if ($.browser.msie || $.browser.mozilla) { $$.css({ 'position': 'absolute', 'left': 0, 'background': '', 'top': this.offsetTop }); } else if ($.browser.opera && $.browser.version > 9.5) { $$.css({ 'position': 'absolute', 'left': 0, 'background': '', 'top': this.offsetTop }); } else if ($.browser.opera && $.browser.version < 9.5) { $$.css({ 'position': 'absolute', 'left': 0, 'background': '', 'top': "0" }); } else { $$.css({ 'position': 'absolute', 'left': 0, 'background': '' }); }
            $$.hover(function () { $$.stop().animate({ opacity: 0 }, 250); }, function () { $$.stop().animate({ opacity: 1 }, 250); });
        });
    };
})(jQuery);

$(window).bind('load', function () { $('.highlight img').cross(); });

$(document).ready(function () {
    $('.jsShow').hide();

    /*Menu fade*/
    //$('#menu img').cross();

    /*Sub menu*/
    $(" #navigation ul ").css({ display: "none" }); // Opera Fix
    $(" #navigation li").hover(function () { $(this).find('ul:first').css({ visibility: "visible", display: "none" }).show(250); }, function () { $(this).find('ul:first').css({ visibility: "hidden" }); });

    Cufon.replace('h1, h2, h3, h4, #copyright, #footer ul li a', { hover: 'true' });
    Cufon.replace('#nav, .rotator-points li', { textShadow: '1px 1px rgba(51, 51, 51, 0.6)' });
    if ($.browser.msie == undefined) { Cufon.replace('#navigation li ul a', { textShadow: '1px 1px rgba(51, 51, 51, 0.6)' }); }


    $('#slideshow').cycle({
        fx: 'scrollLeft',
        speed: 'medium',
        timeout: 7000,
        pause: true,
        pager: '.rotator-nav',
        pagerAnchorBuilder: function (idx, slide) { return '.rotator-nav li:eq(' + idx + ') a'; }
    });

    $('#snapper').cycle({
        fx: 'scrollRight',
        speed: 'medium',
        timeout: 2000
    });

    $('#snapper a').mouseenter(function () { $('#snapper').cycle('pause'); }).mouseout(function () { $('#snapper').cycle('resume', true); });
});

//Ratings
$(document).ready(function () {
    $(".rating").each(function () {
        var rate = $(this).find("span").html();
        for (var i = 0; i < Math.floor(rate); i++) { $(this).find("a:eq(" + i + ")").css("background-position", "0 0"); }
        if (Math.floor(rate) < Math.round(rate)) { $(this).find("a:eq(" + i + ")").css("background-position", "0 -16px"); }
    });
});
