﻿function addLoadEvent(f) { var _o = window.onload; if (typeof window.onload != 'function') { window.onload = f; } else { window.onload = function() { _o(); f(); } } };

function Swf(url, w, h, o) {
    var swf = [];
    var parm = [];
    var attr = [];
    o = jQuery.extend({ allowScriptAccess: "always", quality: "high", menu: false }, o);
    swf.push('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="' + w + '" height="' + h + '">');
    swf.push('<param name="movie" value="' + url + '">');
    $.each(o, function (i, e) {
        //parm.push("<param name=\"" + i + "\" value=\"" + e + "\">");
        attr.push(i + "=\"" + e + "\"");
    });
    swf.push(parm.join(""));
    swf.push("<embed type=\"application/x-shockwave-flash\" ");
    swf.push(attr.join(" "));
    swf.push(' src="' + url + '" width="' + w + '" height="' + h + '"></embed>');
    swf.push('</object>');
    document.write(swf.join(""));
}


function oFlash(url, w, h) {
    Swf(url, w, h, { wmode: "transparent" });
}

function FocusFlash(s, w, h) {
    Swf("/Images/FocusSkinA.swf?xml=" + s, w, h, { wmode: "transparent" });
}

//TopMenu
$(function () {
    //$("#subMenuPos div").hide();
    $("#SubNav" + $(".topMenu .current").attr("rel")).show();
    $(".topMenu a").hover(function () {
        $("#subMenuPos div::visible").hide();
        var rel = $(this).attr("rel");
        if (rel) {
            $("#SubNav" + rel).show();
        }
    }, function(){});
});

function ShowDefaultLink() {
    $("#subMenuPos div::visible").hide();
    $("#SubNav" + $(".topMenu .current").attr("rel")).show();
}

var slideBannerIndex = 0;
var slideBanne_Interval = null;
var slideBanne_Timer = null;
var slideBanne_Object = null;
var slideBanner_Length = 0;
$(function () {
    slideBanne_Object = "#slideBanner";
    slideBanner_Length = $(slideBanne_Object + " img").length;
    if (slideBanner_Length < 2) {
        return;
    }



    slideBanne_Interval = parseInt($(slideBanne_Object).attr("rel"), 10) * 1000;

    $(slideBanne_Object + " div a").click(function () {
        var index = parseInt($(this).attr("rel"), 10);
        if (slideBannerIndex != index) {
            index--;
            if (slideBanne_Timer) {
                clearInterval(slideBanne_Timer);
            }
            slideBannerIndex = index;
            SlideBanne_OnRun();

            slideBanne_Timer = setInterval(SlideBanne_OnRun, slideBanne_Interval);
        }
        return false;
    });
    slideBanne_Timer = setInterval(SlideBanne_OnRun, slideBanne_Interval);
});

function SlideBanne_OnRun() {
    slideBannerIndex++;
    if (slideBannerIndex >= slideBanner_Length) {
        slideBannerIndex = 0;
    }
    $(slideBanne_Object + " img:visible").hide();
    $(slideBanne_Object + " div .on").removeClass("on");
    $(slideBanne_Object + " div a:eq(" + slideBannerIndex + ")").addClass("on");
    $(slideBanne_Object + " img:eq(" + slideBannerIndex + ")").fadeIn("slow");
}

function initHomeNavPic() {
    $("#HomeNavPic a:has(img)").hover(function () {
        var img = $("img", this);
        img.attr("src", img.attr("src").replace(/HomeNavPic_/, "HomeNavPicOn_"));
    }, function () {
        var img = $("img", this);
        img.attr("src", img.attr("src").replace(/HomeNavPicOn_/, "HomeNavPic_"));
    });
}
