//for ms_cn by Biner<huanghuibin#gmail.com>, Sep 6th, 2008

/*
    tab switch
    Demo
    <div>
        <div class="tab">
            <a href="#" class="hover" name="solved_content">已解決</a><a href="#" name="unsolved_content">待解決</a>
        </div>
        <div id="solved_content">
            <ul>
                <li><a href="#"><span class="time">[2008-08-08]</span>  已解決問題</a></li>
            </ul>
        </div>
        <div id="unsolved_content" style="display:none;">
            <ul>
                <li><a href="#"><span class="time">[2008-08-08]</span>  待解決問題</a></li>
            </ul>
        </div>
    </div>
*/




$(function (){
    tabswitch();
   mousePic();
    changeHeight();
    fixPng();
    tabclick();
});
//首页轮播图片
function picAuto() {
    var t = n = 0; count = $("#play_list a").size();
	$("#play_list a:not(:first-child)").hide();
	$("#play_text li").click(function() {
		var i = $(this).text() - 1;
		n = i;
		if (i >= count) return;
		$("#play_list a").filter(":visible").fadeOut(500).parent().children().eq(i).fadeIn(1000);
		$(this).css({"background":"#fff",'color':'#000'}).siblings().css({"background":"#000",'color':'#fff'});
	});
	t = setInterval("showAuto()", 2000);
	$("#pic").hover(function(){clearInterval(t)}, function(){t = setInterval("showAuto()", 2000);});
    //移动到图片上后不自动跳转图片
}
function showAuto() {
	n = n >= (count - 1) ? 0 : ++n;
	$("#play_text li").eq(n).trigger('click');
}
//tab切换，moveover
function tabswitch() {
    $(".tab>a").mouseover(
      function () {
        $(this).siblings().removeClass("hover");
        $(this).parent().siblings("div").hide();
        $(this).addClass("hover");
        mytest = $(this).attr("name");
        $(mytest).show();
      }
    );
}
//tab切换，onclick
function tabclick() {
    $(".tabclick>a").click(
      function () {
        $(this).siblings().removeClass("hover");
        $(this).parent().siblings("div").hide();
        $(this).addClass("hover");
        mytest = $(this).attr("name");
        $(mytest).show();
      }
    );
}
//iteamall 首页物品滚动
function AutoScroll(obj){
    var li_height = $(obj).find("ul:first > li").height();
    $(obj).find("ul:first").animate({
        marginTop:'-'+li_height
        },500,function(){
        $(this).css({marginTop:"0px"}).find("li:first").appendTo(this);
        }
    );
}
//class="on"的图片mouseover，mouseout效果
function mousePic() {
    $(".on").mouseover(
      function () {
        mytest = $(this).attr("src");
        mytest = mytest.split('images/')[0] + 'images/pic_on/' + mytest.split('images/')[1];
        $(this).attr("src",mytest);
      }
    ).mouseout(
      function () {
        mytest = $(this).attr("src");
        mytest = mytest.split('pic_on/')[0] + mytest.split('pic_on/')[1];
        $(this).attr("src",mytest);
      }
    );
}
//自动延伸
function changeHeight() {
    var left = $("#primary_sidebar").height();
    var right= $("#right").height();
    if(left>right) {
    $("#right").css({"min-height":left,"height":left});
    }
    //alert("高度是：" + left);
}