$(function() {
    var ifocus = $("#focus .focus");
    var ifocusCount = ifocus.length;
    var curNum = 0;
    function play() {
        ifocus.hide();
        if (curNum++ >= (ifocusCount - 1)) {
            curNum = 0;
        }
        else { }
        ifocus.eq(curNum).fadeIn(1000);
    }
    setInterval(play, 5000);
    $(".mailtxt").focus(function() {
        if ($(this).val() == this.defaultValue) {
            $(this).val("");
        }
    }).blur(function() {
        if ($(this).val() == '') {
            $(this).val(this.defaultValue);
        }
    });
    var popup = $("#menu strong a");
    var setIDIn;
    var setIDOut;
    var objid;
    popup.hover(
		function() {
		    var fid = this.id;
		    if (fid != null) {
		        var oid;
		        for (n = 1; n < 8; n++) {
		            oid = "sub0" + n;
		            //alert(oid);
		            if (fid != oid) {
		                $("#h" + oid).stop(false, true).slideUp();
		            }
		        }
		        clearTimeout(setIDOut);
		        setIDIn = setTimeout(function() {
		            $("#h" + fid).stop(false, true).slideDown();
		        }, 200);
		    }
		},
			function() {
			    var fid = this.id;
			    if (fid != null) {
			        clearTimeout(setIDIn);
			        setIDOut = setTimeout(function() {
			            $("#h" + fid).stop(false, true).slideUp();
			        }, 200);
			    }
			}
	);
    $("#submenu").hover(function() {
        clearTimeout(setIDOut);
    }, function() {
        setIDOut = setTimeout(function() {
            var oid;
            for (n = 1; n < 8; n++) {
                oid = "sub0" + n;
                $("#h" + oid).stop(false, true).slideUp();
            }
        }, 200);
    });
    $("#leftmenu h2 span").click(function() {
        if (this.className == "icon") {
            $(this).addClass("h_icon");
            $(this).removeClass("icon");
            var o = $(this).parent("h2").parent("div").find("ul");
            $(o).slideDown();
        }
        else {
            $(this).addClass("icon");
            $(this).removeClass("h_icon");
            var o = $(this).parent("h2").parent("div").find("ul");
            $(o).slideUp();
        }
    });
    var lh = $(".cleft").height();
    var rh = $(".cright").height();    
    if (lh > rh) {
        $(".cright").css("height", lh-26);
    }
    else {
        $(".cleft").css("height", rh+26);
    }
});
