$(function(){
	
	//按钮1
	$(".h_ban_a").hover(function(){		 
		$(this).css("background-position","0 0");
	},function(){		 
		$(this).css("background-position","0 -31px");
	})
	
	//按钮2
	$(".h_ban_b").hover(function(){		 
		$(this).css("background-position","134px 0");
	},function(){		 
		$(this).css("background-position","134px -31px");
	})
	
	//列表图片状态
	$(".pic_class").hover(function(){//产品目录
		$(this).addClass("on");						
	},function(){
		$(this).removeClass("on");
	});
	
	$(".pic_list span").hover(function(){//产品列表
		$(this).addClass("on");						
	},function(){
		$(this).removeClass("on");
	});
	
	$(".in_pic span").hover(function(){//主页产品推荐
		$(this).addClass("on");						
	},function(){
		$(this).removeClass("on");
	});
	
	$(".in_pro_1 span").hover(function(){//主页产品状态
		$(this).addClass("on");						
	},function(){
		$(this).removeClass("on");
	});
	
	$(".in_pro_2 span").hover(function(){//主页产品状态
		$(this).addClass("on");						
	},function(){
		$(this).removeClass("on");
	});
		
	//输入框
	$(".text").focus(function(){
		$(this).addClass("text_on");						
	});
	$(".text").blur(function(){
		$(this).removeClass("text_on");
	});
	
	//输入框
	$(".ban").hover(function(){
		$(this).addClass("ban_on");						
	},function(){
		$(this).removeClass("ban_on");
	});
	
	//产品分类状态
	$(".m_class li").hover(function(){
		$(this).addClass("mon");						
	},function(){
		$(this).removeClass("mon");
	});
	
	//产品详细菜单
	$(".view_pic_menu li span:first").addClass("on");
	$(".view_pic_show table:not(:first)").hide();
	$(".view_pic_menu li span").each(function(index) {
			$(this).hover(
			function() {
					$(".view_pic_menu li span.on").removeClass("on");
					$(this).addClass("on");
					$(".view_pic_show > table:visible").hide();
					$(".view_pic_show table:eq(" + index + ")").show();
			});
	});
	
	loadPage("car_cou", "/hzh/car/car_cou.asp");
	//loadPage("home_about", "home_about.asp");
	//loadPage("home_plist", "home_plist.asp");
	  
	$(".im_ban a").click(function(){
		$("#im_a").hide();
		$("#im_b").show();
		SetCookie("cook_im",1);
	});
	
	$("#im_b a").click(function(){
		$("#im_a").show();
		$("#im_b").hide();
		SetCookie("cook_im",0);
	});
	
	im_cookie();
}) 


//动态加载页面(id显示页面的容器组件ID,url欲加载页面网址)
function loadPage(id, url) { 
	$("#"+id).addClass("loader"); 
	//$("#"+id).append("<img src='../images/ico/loading.gif' height='18px'> 加载中..."); 
	$.ajax({ 
	type: "get", 
	url: url, 
	cache: false, 
	error: function() { $("#"+id).append("?");  }, 
	success: function(msg) { 
	$("#"+id).empty().append(msg); 
	$("#"+id).removeClass("loader"); 
	} 
	}); 
}

//js加载flash
function flash(ur,w,h){
	document.write('<object classid="clsid:D27CDB6E-AE6D-11CF-96B8-444553540000" id="obj1" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0" border="0" width="'+w+'" height="'+h+'">');
	document.write('<param name="movie" value="'+ur+'">');
	document.write('<param name="quality" value="high"> ');
	document.write('<param name="wmode" value="transparent"> ');
	document.write('<param name="menu" value="false"> ');
	document.write('<embed src="'+ur+'" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" name="obj1" width="'+w+'" height="'+h+'" quality="High" wmode="transparent">');
	document.write('</embed>');
	document.write('</object>');
}


//设置cookie.
function SetCookie(name,value){
	document.cookie=name+"="+escape(value)+";path=/";
}

//获取cookie
function getCookie(name) {
	var strCookie = document.cookie;
	var arrCookie = strCookie.split("; ");
	for (var i = 0; i < arrCookie.length; i++) {
			var arr = arrCookie[i].split("=");
			if (arr[0] == name) return arr[1];
	}
	return "";
}

//判断cookie
var cook_im = getCookie("cook_im")//聊天层状态
	function im_cookie() {
	//判断状态
	if (cook_im == 1) { //如果为1就是已展开
		$("#im_a").hide();
		$("#im_b").show();
    } else {
		$("#im_a").show();
		$("#im_b").hide();
    }
}

function chk_buy() {
	if(document.buy.num.value==''){
		alert('请填写购买数量');
		document.buy.num.focus();
		return false;
	}
	if(isNaN(document.buy.num.value)){
		alert('请填写数字');
		document.buy.num.focus();
		return false;
	}
}
function chk_buy2() {
	if(document.buy2.addname.value==''){
		alert('请填写收货人');
		document.buy2.addname.focus();
		return false;
	}
	if(document.buy2.addname.value.length<2){
		alert('收货人不得少2个字哦');
		document.buy2.addname.focus();
		return false;
	}
	if(document.buy2.address.value==''){
		alert('请填写收货地址');
		document.buy2.address.focus();
		return false;
	}
	if(document.buy2.address.value.length<10){
		alert('收货地址最少10个字哦');
		document.buy2.address.focus();
		return false;
	}
	if(document.buy2.way.value==''){
		alert('请填写联系电话');
		document.buy2.way.focus();
		return false;
	}
	if(document.buy2.way.value.length<5) {
		alert("电话号码最少5位以上哦");
		document.buy2.way.focus();
		return false;
  }
	if(isNaN(document.buy2.way.value)){
		alert('电话号码不正确哦');
		document.buy2.way.focus();
		return false;
	}
	//邮箱
	var myreg = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
	if(!myreg.test(document.buy2.email.value)){
		alert('邮箱不正确哦');
		document.buy2.email.focus();
		return false;
	}

}

