$(document).ready(function(){
	//限制图片
	$(".news_cont img").each(function(i,n){
		var w = $(this).width();
		if(w > 725) {
			h = 725/w* $(this).height();
			$(this).attr({width:725,height:h});
		}
		//alert(w);
	});
	
	$(".product_cont img").each(function(i,n){
		var w = $(this).width();
		if(w > 725) {
			h = 725/w* $(this).height();
			$(this).attr({width:725,height:h});
		}
		//alert(w);
	});
		//留言
	$("#submit").click(function(){
		var title=$("input[name=title]").val();
		var content=$("textarea[name=content]").val();
		var code =$("input[name=code]").val(); 
		if(title==''){
			alert('留言主题不能为空！');
			$("input[name=title]").focus();
			return;
		}if(content==''){
			alert('留言内容不能为空！');
			$("input[name=content]").focus();
			return;
		}if(code==''){
			alert('验证码不能为空！');
			$("input[name=code]").focus();
			return;
		}
		var data = {title:title,content:content,code:code,cmd:'liu'};
		 	$.ajax({
		 		type:'POST',
		 		data:data,
		 		dataType:'text',
		 		url:"/ajax.php",
		 		success:function(msg){
		 			if(msg == '0'){
		 				alert("留言成功！");
		 				document.liu_frm.reset();
		 				return;
		 			}else if(msg=='1'){
		 				alert("验证码错误！");
		 				return;
		 			}else if(msg=='2'){
		 				alert("输入内容不能为空或不要输入HTML代码！");
		 				return;
		 			}
		 			else{
		 				alert("留言失败！");
		 				return;	
		 			}
		 		}
		 	})
	});
	//首页滚动
	 if($(".index_productPic").length == 1){
 		setInterval('move()', 4000);
 	}
})

function move(){
var top = parseInt($(".move").css('top'))-19;
$(".move").animate({top:top},1000,function(){
var h = $(".move").height()/2;
if(top+h<=0){
$(".move").css("top",top+h);
}
 });
}
 
