$(function()
{
	//检查是否登录
	if($("#bookstaus").length>0)
	{
		$.ajax(
		{
			type:"post",
			cache:false,
			url:webroot+"plug/book.asp?act=islogin",
			error:function(){},
			success:function(_)
			{
				$("#bookstaus").html(_);
			}
		});
	}
})
$(function()
{
	$(".form_book").validator(
	{
		stopOnError:true,
		theme:'yellow_right_effect',
		ignore:':hidden',
		valid:function(form)
		{
			$.fn.tips({type:'loading',content:'数据提交中'});
			$.ajax(
			{
				url:webroot+"plug/book.asp?act=add",
				type:"post",
				data:$(form).serialize(),
				success:function(data){
					data=jQuery.parseJSON(data);
					if(data.status!="y"){$.fn.tips({content:data.info});}
					if(data.status=="y")
					{
						var info=data.info.substring(1);
						$.fn.tips({type:"ok",content:info});
						$(".form_book")[0].reset();
						if(data.info.substring(0,1)==2){
							if (webmode=="2"){
								setTimeout(function(){location.href = webroot + 'plug/book.html';},1500)
							}else{
								setTimeout(function(){location.href = '?';},1500)
							}
						}
					}
				}
			});
		}
	});
	//
})
