﻿function GetId(e) {return document.getElementById(e);}
function focusFlash(val) {

}
function Swf(url, w, h) {
    document.write('<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 + '">');
    document.write('<param name="allowScriptAccess" value="sameDomain"><param name="movie" value="'+url+'"><param name="quality" value="high"><param name="menu" value="false">');
    document.write('<embed src="'+url+'" quality="high" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="' + w + '" height="' + h + '"></embed>');
    document.write('</object>');
}
$(function() {
    var bg = { "background-image": "url(/App_Themes/default/Images/MenuAow.gif)" };
    var nbg = { "background-image": "" };
    var cd = ".topMenu .current + div";
    FixIe6();
    $('.topMenu > ul > li').hover(function() {
        var d = $(this).children('div');

        $(".topMenu > ul > li div").stop(true, true).hide();
        $(".topMenu > ul > li > a").css(nbg);
        if (d.length > 0) {
            d.stop(true, true).show();
            $(this).children('a').css(bg);
        }
    }, function() {
        if ($(this).children('.current').length > 0) {
            return;
        }
        $(".topMenu > ul > li div").stop(true, true).hide();
        $(".topMenu > ul > li > a").css(nbg);
        if ($(".topMenu .current").length > 0) {
            if ($(cd).length > 0) {
                $(".topMenu .current").css(bg);
                $(cd).stop(true, true).show();
            }
        }
    });
    var tw = $(".topMenu").width();
    $(".topMenu > ul > li").each(function(i, e) {
        var o = $(e).children("div");
        if (o.length > 0) {
            var l = $(e).width() * i;
            var w = o.width();
            if (w + l < tw) {
                o.css("left", l + 5);
            }
            else {
                o.css("left", tw - w - 5);
            }
        }
        o.hide();
    });
    $(".topMenu > ul > li > a").css(nbg);
    if ($(".topMenu .current").length > 0) {
        if ($(cd).length > 0) {
            $(".topMenu .current").css(bg);
            $(cd).stop(true, true).show();
        }
    }
});
$(function() {
    if ($("#formSearch").length == 0) {
        return;
    }
    var k = $("#txtKeyWord");
    var txt = k.val();
    k.focus(function() {
        if (this.value == txt) {
            this.value = "";
            this.style.color = "#333";
        }
    });
    k.blur(function() {
        if (this.value == "") {
            this.value = txt;
            this.style.color = "#666";
        }
    });
    $("#formSearch").submit(function() {
        if (k.val() == txt || k.val().length == 0) {
            k.focus();
            return false;
        }
        return true;
    });
});

function FixIe6() {
    $(".topMenu > ul > li > div").each(function(i, e) {
        var w = $(e).find("p > a").length * 92 - 2;
        $(e).children("p").width(w);
    });
}
