var commonFn = {};
var showtv_index = 1;

(function($){
    $(document).ready(function(){
        commonFn.stopDefault = function(e){
	if (e)
	    e.preventDefault();
	else 
	    window.event.returnValue = false;
	};

	$("li","#menu-top-block").each(function(i){
	    var_image=$(this).css("background-image");	
	    var_repeat=$(this).css("background-repeat");
	    var_position=$(this).css("background-position");
	    $(this).hover(function(){
		$(this).css({"background":"#000","color":"#fff"});
		},function(){
		    $(this).css({"background-image":var_image,"background-repeat":var_repeat,"background-position":var_position,"color":"#eeeeee"});
	    });
	});

	var_bg_menu_keyword=$("#txt-menu-keyword").css("background-image");
	$("#txt-menu-keyword").click(function(){
	    $(this).css("background","#fff");
	});
	$("#txt-menu-keyword").blur(function(){
	    $(this).css("background-image",var_bg_menu_keyword);
	});
	$("li:last","#menu-bottom-block").css("background","none");
	/* 
	 * For select start
	 * */	
	$("div.select").each(function(){
	    var_select=this;
	    var_inselect=0;
	    $("li",this).hover(function(){
		$(this).css({"background":"#fff","border":"solid 1px #d6d6d6"});
		$(".value",this).css({"color":"#000","font-weight":"bold"});
		},function(){
		    $(this).css({"background":"#000","border":"none"});
		    $(".value",this).css({"color":"#fff","font-weight":"normal"});
	    });
	    $("li",this).click(function(){
		$("ul",var_select).hide();
		$(".text",var_select).removeClass("drop-down");
		$(".text",var_select).html($(".value",this).html());
		/*location.href=$(".key",this).html();*/
	    });
	    $("ul",this).css("display","none");
		$(".text",this).click(function(){
		if($("ul",var_select).css("display")=="block"){
		    $("ul",var_select).slideUp("slowly");
		    $(this).removeClass("drop-down");
		}else{
		    $("ul",var_select).slideDown("slowly");
		    $(this).addClass("drop-down");
		}
	    });
	    $(".last-block",this).hover(function(){var_inselect=1;},function(){var_inselect=0;});
		$(document).click(function(){
		    if(var_inselect==0){
			$("ul",var_select).slideUp("slowly");
			$(".text",var_select).removeClass("drop-down");
		    }
		});
	    });

	    /*
	     * For select End 
	     * */ 
	   /* *******************************
	    * For catwalk select start
	    * ******************************/
	    $(".catwalk-select").each(function(){
			    	var inselect=0;
			    	var drop_list=$("ul",this);
				var select_text=$("a.select-text",this);
			    	$("a.select-text",this).click(function(){
						if(drop_list.css("display")=="block") 
							drop_list.css("display","none");
						else drop_list.css("display","block");
					});
				$(this).hover(function(){inselect=1;},function(){inselect=0;});
				$(document).click(function(){if(inselect==0) drop_list.css("display","none");});
				$("a.list",this).each(function(){
						$(this).click(function(){
								select_text.html('<span>'+$(".value",this).html()+'</span>');
								drop_list.css("display","none");
							});
					});
			    });
	   /*********************************
	    * For catwalk select End
	    * ******************************/

	    $(".tab",".gallery-body").each(function(i){
		$(this).hover(function(){
		    $(this).css("color","#dedede");
		    if(i==1){
			$(".head",".gallery-body").css("background-position","0 -41px");
			$(".tab:eq(0)",".gallery-body").css("color","#999");
			$(".tab:eq(2)",".gallery-body").css("color","#999");
		    }else if(i==2){
			$(".head",".gallery-body").css("background-position","0 -82px");
			$(".tab:eq(0)",".gallery-body").css("color","#999");
			$(".tab:eq(1)",".gallery-body").css("color","#999");
		    }else{
			$(".head",".gallery-body").css("background-position","0px 0px");
			$(".tab:eq(1)",".gallery-body").css("color","#999");
			$(".tab:eq(2)",".gallery-body").css("color","#999");
		    }
		});
	    });
	    $(".second-block",".final-template-scroll-block").jCarouselLite({
			btnNext:"#final-template-scroll-next",
			btnPrev:"#final-template-scroll-prev",
			speed:800,
			visible:5
	    });	
	    $("#award-list-scroll-block").jCarouselLite({
			btnNext:"#award-list-scroll-next",
			btnPrev:"#award-list-scroll-prev",
			speed:800,
			visible:4
	    });
	    $("#brand-tags-scroll-block").jCarouselLite({
			btnNext:"#btn-brand-tags-next",
			btnPrev:"#btn-brand-tags-prev",
			speed:500,
			vertical:true,
			visible:2
	    });
	    $("#brand-commence-scroll").jCarouselLite({
			btnNext:"#brand-commence-next",
			btnPrev:"#brand-commence-prev",
			speed:800,
			visible:8
	    });
	    //
            $("#fashiona_final_tabs_show").jCarouselLite({
			btnNext:"#fashiona_final_tabs_next",
			btnPrev:"#fashiona_final_tabs_prev",
			speed:800,
			visible:6
			})
			
			$("#fashiona_final_tabs_show1").jCarouselLite({
			btnNext:"#fashiona_final_tabs_next1",
			btnPrev:"#fashiona_final_tabs_prev1",
			speed:800,
			visible:5
			})
			
			$("#fashiona_final_tabs_show_astrology").jCarouselLite({
			btnNext:"#fashiona_final_tabs_next",
			btnPrev:"#fashiona_final_tabs_prev",
			speed:800,
			visible:3
			})
			
			$("#astro_zoom_final_tabs_show_astro_celebrit").jCarouselLite({
			btnNext:"#astro_zoom_final_tabs_next",
			btnPrev:"#astro_zoom_final_tabs_prev",
			speed:800,
			visible:1
			})
			
			$("#fashiona_final_tabs_show_astro_celebrit").jCarouselLite({
			btnNext:"#astro_celebrit_tabs_next",
			btnPrev:"#astro_celebrit_tabs_prev",
			speed:800,
			visible:1
			})
			
	    $(".fashion_final form").each(function(){
	                    var inselect=0;	
			    var drop_list=$("ul",this);
				var select_text=$("a.select-text",this);
			    	$("a.select-text",this).click(function(){
						if(drop_list.css("display")=="block") 
							drop_list.css("display","none");
						else drop_list.css("display","block");
					});
				$(this).hover(function(){inselect=1;},function(){inselect=0;});
				$(document).click(function(){if(inselect==0) drop_list.css("display","none");});
				$("a.list",this).each(function(){
						$(this).click(function(){
								select_text.html($(".value",this).html());
								drop_list.css("display","none");
							});
					});
			    });
           $("#fashion_final_pic_small > img").mouseover(function(){
			   bigsrc=$(this)[0].src
			   bigalt=$(this)[0].alt
			   $("#fashion_final_pic_big").attr({src:bigsrc,alt:bigalt})
			    }).mouseout(function(){
				    });

			     
	   //
	    $("tr",".award-list-block").each(function(i){
					if(i%2==0 && i!=0){$(this).css("background","#f0f0f0");}});
	    $("#btn-beauty-brand-type1").hover(function(){
					$("#btn-beauty-brand-type1").addClass("current");
					$("#btn-beauty-brand-type2").removeClass("current");
					$("div.navi","div.beauty-brand-type").css("background-position","0 0");
					$("#beauty-brand-type1").css("display","block");
					$("#beauty-brand-type2").css("display","none");
			    });
	    $("#btn-beauty-brand-type2").hover(function(){
					$("#btn-beauty-brand-type1").removeClass("current");
					$("#btn-beauty-brand-type2").addClass("current");
				$("div.navi","div.beauty-brand-type").css("background-position","0 -21px");
					$("#beauty-brand-type2").css("display","block");
					$("#beauty-brand-type1").css("display","none");
			    });
	    //$("td",".award-list-block").each(function(i){
		//		    		if(i%6==2){
						//$(this).css("border-right","solid 1px #000");
		//			}
		//	    });
	    if(!!document.getElementById("channel-home-kv")) KV.init();
	    /***************************
		 * Add By Zengrong Start
	    * **************************/

	    idTabsEffect("#hot-info-tabs");
	    idTabsEffect("#hot-top5-tabs");
	    idTabsEffect("#show-and-tv-tabs");
	    idTabsEffect("#forum-and-blog-tabs");
	    idTabsEffect("#special-and-interactive-tabs");
	    idTabsEffect("#q-a-hot-top");
	    idTabsEffectClick("#expert-tabs");

	    idTabsEffectClick("#expert-tabs1");
	    idTabsEffectClick("#expert-tabs2");

	    dlMouseover("#hot-top5-tab1");
	    dlMouseover("#hot-top5-tab2");
	    dlMouseover("#hot-top5-tab3");
	    dlMouseover("#hot-top5-tab4");

	    dlMouseover("#special-and-interactive-tab1");
	    dlMouseover("#special-and-interactive-tab2");

	    $("#show-and-tv-jCarouselLite1").jCarouselLite({
			btnNext:"#show-and-tv-slide-next1",
			btnPrev:"#show-and-tv-slide-prev1",
			speed:800,
			visible:2
	    });

	    $("#show-and-tv-tab2-title").mouseover( function(){
		if( showtv_index == 1 ) {
		    $("#show-and-tv-jCarouselLite2").jCarouselLite({
			    btnNext:"#show-and-tv-slide-next2",
			    btnPrev:"#show-and-tv-slide-prev2",
			    speed:800,
			    visible:2,
			    start:0
		    });
		}
		showtv_index++;
	    });
	    /* For sub menu start */ 
	    $("#menu-bottom-block>div.current-sub-menu").css("display","block");
	    $("#menu-top-block li a").each(function(i){
			    	$(this).mouseover(function(){
					$("a.current-hover","#menu-top-block").removeClass("current-hover");
					if(!$(this).hasClass("current")) $(this).addClass("current-hover");
					$("#menu-bottom-block>div").each(function(ii){
							if(ii==i) $(this).css("display","block");
							else $(this).css("display","none");
						});
					});
				});
    	   $("#menu").mouseleave(function(){
				$("a.current-hover","#menu-top-block").removeClass("current-hover");
				$("#menu-bottom-block>div").each(function(ii){
						if($(this).hasClass("current-sub-menu")){
							$(this).css("display","block");
						}else{
							$(this).css("display","none");
						}
					});
				});
	   /* for sub menu End */

	    $("#realityshow-roll-jCarouselLite").jCarouselLite({
			btnNext:"#realityshow-slide-next",
			btnPrev:"#realityshow-slide-prev",
			speed:800,
			visible:6
	    });

	    $("#realityshow-small-img").mouseover(function(){
		$("#realityshow-intro-mouseover").show();
		$("#realityshow-intro").hide();
	    });

	    $("#realityshow-small-img").mouseout(function(){
		$("#realityshow-intro-mouseover").hide();
		$("#realityshow-intro").show();
	    });

	    $("#txt-keyword").focus(function(){
	        $(this).attr("value","");
	    });

	    $("#txt-keyword").blur(function(){
	        $(this).attr("value","关键字搜索");
	    });

	    $(".qa-final-list").each(function(i,n){
		var list_left_block = $(this).find(".qa-final-list-l");
		var list_right_block = $(this).find(".qa-final-list-r");

		setSameHeight(list_left_block,list_right_block);
	    });

	    setSameHeight("#centercol","#rightcol");

	    /******************
	      * End By Zengrong 
	    * ****************/
	});

        function setSameHeight(leftblock,rightblock){
	   var left_height = parseInt($(leftblock).attr("offsetHeight"))-2;
	   var right_height = parseInt($(rightblock).attr("offsetHeight"))-2; 

	   var arVersion = navigator.appVersion.split("MSIE");
	   var version = parseFloat(arVersion[1]);
	   var vAttr="height";
	   if(version==7) vAttr="min-height";
	   if( left_height < right_height ){
		 if(rightblock!="#rightcol")
		 	$(leftblock).css(vAttr,right_height+"px");
	    }else{
		 if(rightblock!="#rightcol")
		 	$(rightblock).css(vAttr,left_height+"px");
		 else{
			$(rightblock).css("border-left","none");
		 	$(".content-container:first").css("border-right","solid 1px #d1d1d1");
		 }
	    }
	}

	function dlMouseover(parentObj){
	    var dt=$(parentObj+" dt");
	    $(parentObj+" dd").hide();
	    $(parentObj+" dt:first").hide();
	    $(parentObj+" dd:first").show();
	    $.each(dt,function(i,n){
	        $(n).mouseover(function(){
	            $(parentObj+" dt").show();
		    $(parentObj+" dd").hide();
		    $(this).next().show();
		    $(this).hide();
	        });
	    });
	}

	//idTabs
	function idTabsEffect( parentObj ) { 
	    $(parentObj+" ul li a").each( function(){
		$(this).click(function(e){
		    commonFn.stopDefault(e);
	    	});
	    });

	    try {
	        $(parentObj+" ul").idTabs("!mouseover");
	    }
	    catch (e) {}
	}

	//idTabs Click
        function idTabsEffectClick( parentObj ) { 
	    $(parentObj+" ul li a").each( function(){
	        $(this).click(function(e){
		    commonFn.stopDefault(e);
	    });
	});

	try {
	    $(parentObj+" ul").idTabs();
	}
	catch (e) {}
     }

})(jQuery);


