  function checklogin(){
	  if($("#username").val().length<1){
		   alert("请输入用户名");
		   $("#username").focus();
		   return false;
	  }
	   if($("#password").val().length<1){
		   alert("请输入密码");
		   $("#password").focus();
		   return false;
	  }
	}
	
	function checkcontent(){
		 if($("#textarea").val().length<1){
		   alert("请输入留言内容");
		   $("#textarea").focus();
		   return false;
	     }
		  if($("#textarea").val().length>400){
		   alert("最多只能输入字");
		   $("#textarea").focus();
		   return false;
	     }
	}
	
	function  getcontent(id){
		  $.ajax({
			  type:"get",
			  url:"ajax_con.php",
			  data:"id="+id,
			  error:function(){$("#city_a1").html("获取信息失败");},
			  success:function(data){
				  $("#city_a1").hide();
				  $("#city_a1").html(data);
				 
				  $("#city_a2").fadeOut("fast",function(){
						$("#city_a1").fadeIn("slow");							 
					});  
			  }
		 });
	  
	  }
	  
  function getSelectVal(){ 
    $.getJSON("/_city_server.php",{bigname:$("#bigname").val()},function(json){ 
        var smallname = $("#smallname"); 
        $("option",smallname).remove(); //清空原有的选项 
        $.each(json,function(index,array){ 
            var option = "<option value='"+array['id']+"'>"+array['title']+"</option>"; 
            smallname.append(option); 
        }); 
    }); 
} 

function ImgAuto(i, MaxW, MaxH) {
    var o = new Image();
    o.src = i.src;
    var w = o.width;
    var h = o.height;
    var t;
    if (w > MaxW) {
        t = MaxW
    } else {
        t = w
    }
    if ((h * t / w) > MaxH) {
        i.height = MaxH;
        i.width = MaxH / h * w
    } else {
        i.width = t;
        i.height = t / w * h
    }
}

$(document).ready(function(){
  $('a[href^=#]').each (function(){
		var hash = this.hash;
		if(hash.length > 1 && !this['rel']){
			$(this).click(function() {
				smoothScroll(hash);
				return false;
			})
		}
	});

 });



function smoothScroll(hash) {
	var target = $(hash).offset().top;

	$(($.browser.safari) ? 'body' : 'html')
		.animate({scrollTop: target >= 15 ? target - 15 : target}, 600, 'swing', function(){$(this).unbind("mousewheel DOMMouseScroll");})
		.bind("mousewheel DOMMouseScroll",function(){
			$(this).queue([]).stop();
			$(this).unbind("mousewheel DOMMouseScroll");
		})
}

function checkMobile(){
	var sMobile = document.mobileform.mobile.value
	if(!(/^1[3|4|5|8][0-9]\d{4,8}$/.test(sMobile))){
		alert("不是完整的11位手机号或者正确的手机号前七位");
		document.mobileform.mobile.focus();
		return false;
	}
}

