//网站表单验证
$(function(){
	$.cookie("S")=="_" || $.cookie("S","_");
	$(document).delegate(":input",{focusout:function(){
		if($(this).attr("_default") && $(this).val()==""){
			$(this).val($(this).attr("_default"));
		}
		if($(this).is("[_type]")){
			var _errno = 0;
			if($(this).attr("_type") == "need" && ($(this).val() == "" || $(this).val() == "0")){
				_errno = 1;
			}else if($(this).attr("_type") == "title" && $(this).val().length < 2){
				_errno = 1;
			}else if($(this).attr("_type") == "email" && $(this).val().match(/@/) == null){
				_errno = 1;
			}else if($(this).attr("_type") == "username" && $(this).val().length < 2){
				_errno = 1;
			}else if($(this).attr("_type") == "telphone" && $(this).val().match(/^\d+$/) == null){
				_errno = 1;
			}else if($(this).attr("_type") == "mobile"   && $(this).val().match(/^1(3|5|8)\d{9}$/) == null){
				_errno = 1;
			}
			if(_errno!=0){
				if($(this).next().is("._error")){
					$(this).next().html($(this).attr("_error"));
				}else{
					$(this).after("<span class=_error style=color:red>"+$(this).attr("_error")+"</span>");
				}
				$(this).attr("_errno",1);
			}else{
				$(this).next().filter("._error").remove();
				$(this).attr("_errno",0);
			}
		}
	},focusin:function(){
		if($(this).val().indexOf("请输入") != -1 || $(this).val().indexOf("請輸入") != -1){
			$(this).attr("_default",$(this).val()).val("");
		}
	}}).delegate("form","submit",function(){
		$(":input",this).trigger("focusout");
		if($("input[_errno=1]").length>0){
			return false;
		}else{
			if($(unescape("%5Bname%3D_s%5D")).val("2010").length==0){
				$(unescape("%3Cinput%20type%3D%27hidden%27%20name%3D%27_s%27%20value%3D%272010%27/%3E")).appendTo(this);
			}
			return true;
		}
	});
});
