/****************************************
Name: Page.js
Author: TsoLong
Email: tsolong@126.com
WebSite: http://www.tsolong.com/
Create Date: 2009-03-17
Description:
	页面脚本
****************************************/
	
function Search_Global(){
	var key = $('wel').value;
	new ajax({
        url: "/search/?action=getsearch&key=" + val,
        onLoading: function(){
        },
        onSuccess: function(o){
            
        }
    })
}

function getCookie(Name) 
{ 
    var search = Name + "=" 
    if(document.cookie.length > 0) 
    { 
        offset = document.cookie.indexOf(search) 
        if(offset != -1) 
        { 
            offset += search.length 
            end = document.cookie.indexOf("&", offset) 
            if(end == -1) end = document.cookie.length 
            return unescape(document.cookie.substring(offset, end)) 
        } 
        else return "" 
    } 
	else return "";
} 



/******************会员操作***********************/
function Comment(){
	
	var UserName= $("UserName");
	var Password= $("Password");
	var loginForm= $("loginForm");
	disabledElement(loginForm,false);
	
	if (UserName.value == "") {
		new win({
			title: "系统提示",
			msg: "请输入您的用户名",
			closeEvent: function(){
				disabledElement(loginForm,true);
				UserName.focus();
			}
		})
	}
	else if (Password.value == "") {
		new win({
			title: "系统提示",
			msg: "请输入您的密码",
			closeEvent: function(){
				disabledElement(loginForm,true);
				Password.focus();
			}
		})
	}
	else {		
		new ajax({
			method: "post",
			url: "?action=comment",
			formElement: $("loginForm"),
			onLoading:function(){
				loading({
					content: "评论提交中..."
				})
			},
			onSuccess: function(o){
				var result = o.responseText;
				if (result != "10")
					loading.close();
				if (result == "1") {
					new win({
						type: 4,
						title: "系统提示 -- 登录失败",
						msg: "您输入的用户名或密码格式不正确，请输入正确的用户名和密码",
						closeEvent: function(){
							disabledElement(loginForm,true);
							UserName.focus();
							UserName.select();
						}
					})
				}
				else if (result == "10") {
					setTimeout(function(){
						loading({
							content: "登录成功,页面自动跳转中,请稍等..."
						})
					}, 500)
					setTimeout(function(){
						location.href = "index.aspx";
					}, 1500)
				}
			},
			onError: function(){
				loading.close();
				new win({
					type: 4,
					title: "系统提示",
					msg: "请求服务器出错,请与网站管理员联系",
					closeEvent: function(){
						disabledElement(loginForm, true);
					}
				})
			}
		})
	}
	return false;
}
/*****************************************/


//更换验证码图片事件
var changeValidateImage = function(){
	var ValidateImage = $("ValidateImage");
	addEvent(ValidateImage, "click", function(){
		setAttr(ValidateImage, "src", "ValidateImage.aspx?num=" + new Date().getTime());
		$("ValidateCode").value="";
		$("ValidateCode").focus();
	})
}




