﻿/* index */
$(function(){
	$(".searchBox input:text").hover(function(){
			if($(this).val() == "搜索"){
				$(this).val("");
			}
			$(this).select();
			$(this).addClass("foc");
		},
		function(){
			if($(this).val() == ""){
				$(this).val("搜索");
			}
			$(this).blur();
			$(this).removeClass("foc");
		}
	)
})

/* cityLabel */
$(function(){
	$("#cityLayout").focus(function(){
		$(".cityLabel").fadeIn("fast");						
	})
	$(".cityLabel .close").click(function(){
		$(".cityLabel").fadeOut("fast");
		return false;
	})
})
/*sideNav*/
$(document).ready(function(){
	$(".sideNav .item").each(function(e){
		if($(this).find(".subNav")!= null)
		{
			$(this).click(function(){
				$(".sideNav li").removeClass("hover"); 
				$(this).addClass("hover");
				$(this).parent().find(".subNav").hide();
				$(this).find(".subNav").fadeIn("fast");
			});	
		}
	})	   
})
/* tabs */
$(document).ready(function(){	
	$(".tab_menu").each(function(i){		
		$(this).find("li").each(function(j){		
				$(this).click(function(e){				
				$(".tab_content:eq("+i.toString()+") .con").css("display","none");
				$(".tab_content:eq("+i.toString()+") .con:eq("+j.toString()+")").fadeIn(0);
				$(this).parent().find("li").removeClass("hover");
				$(this).addClass("hover");	
				if (e&&e.preventDefault ){
					e.preventDefault();
				}else{
					window.event.returnValue = false;
				}
				return false;
			});		
		});		
	});
	$("#tab_menu1 li").each(function(i){
		$(this).mouseover(function(e){
			$("#tab_menu1 li[class='active']").removeClass("active");
			$("#tab_content1 .con[class*='active']").removeClass("active");
			$(this).addClass("active");
			$("#tab_content1 .con:nth-child("+(i+1)+")").addClass("active");
			if (e&&e.preventDefault ){
				e.preventDefault();
			}else{
				window.event.returnValue = false;
			}
			return false;
		});
	});
	$("#tab_menu2 li").each(function(i){
		$(this).mouseover(function(e){
			$("#tab_menu2 li[class='active']").removeClass("active");
			$("#tab_content1 .con[class*='active']").removeClass("active");
			$(this).addClass("active");
			$("#tab_content1 .con:nth-child("+(i+6)+")").addClass("active");
			if (e&&e.preventDefault ){
				e.preventDefault();
			}else{
				window.event.returnValue = false;
			}
			return false;
		});
	});
	$(".tab_menu_inner").each(function(i){		
		$(this).find("li").each(function(j){		
				$(this).click(function(e){				
				$(".tab_content_inner:eq("+i.toString()+") .con_inner").css("display","none");
				$(".tab_content_inner:eq("+i.toString()+") .con_inner:eq("+j.toString()+")").fadeIn(0);
				$(this).parent().find("li").removeClass("on");
				$(this).addClass("on");	
				if (e&&e.preventDefault ){
					e.preventDefault();
				}else{
					window.event.returnValue = false;
				}
				return false;
			});		
		});		
	});
	$("#tip .tip").hover(
		function(){ $(this).addClass("active")},
		function(){ $(this).removeClass("active")}
	);
});
/* rooling */
var playing = true;
var playIndex = 0;
$(function(){
	var cont = $(".box1 .imgBox img").length-1;
	$("#rollingBox .ad_num li").each(function(j){
		$(this).hover(function(){
				$("#rollingBox .box1 .imgBox a img").css("display","none");
				$("#rollingBox .box1 .imgBox a img:eq("+j+")").fadeIn("slow");	
				$("#rollingBox ul.ad_num li").removeClass("active");
				$(this).addClass("active");
				playing = false;
				return false;
			},
			function(){
				playIndex = j ;
				playing = true;
				return false;
			}
		)							   
	})	
	$("#rollingBox .box1 .imgBox img").mouseover(function(){
		playing = false;
		clearTimeout("play()")
	})
	$("#rollingBox .box1 .imgBox img").each(function(k){	
		$(this).mouseout(function(){
			playIndex = k ;
			playing = true;
		});
	});
})
setTimeout("play()",5000);	
function play()
{
	var cont = $(".box1 .imgBox img").length;
	if(playing == true){
		playIndex++;
		if(playIndex>=cont) 
		{
			playIndex=0;
			$("#rollingBox .box1 .imgBox a img").css("display","none");
			$("#rollingBox .box1 .imgBox a img:eq("+playIndex+")").fadeIn("slow");	
		}
		else
		{
			$("#rollingBox .box1 .imgBox a img").css("display","none");
			$("#rollingBox .box1 .imgBox a img:eq("+playIndex+")").fadeIn("slow");	
		}
		$("#rollingBox ul.ad_num li").removeClass("active");
		$("#rollingBox ul.ad_num li:eq("+playIndex.toString()+")").addClass("active");
		
	}		
	setTimeout("play()",5000);	
}

$(document).ready(function(){
	$("#p-boxs .p-box").hover(
		function(){
			$(this).addClass('box-hover');
		},
		function(){
			$(this).removeClass('box-hover');
		}
	);
});
