﻿/*
author:char
date:2009.12.1
*/
String.prototype.Trim = function()
{ 
    return this.replace(/(^\s*)|(\s*$)/g,""); 
}
if(typeof $ =="undefined"){
var $=function(id){
    return document.getElementById(id);
}
}
var default_words="红扣子";
function i_search(){
    this.words=$("s_w");
    this.type=$("s_t");
    this.btn=$("s_b");
    this.words.value=default_words;
    this.tus=new Array("","/hzp","/fz","/jia","/tv","/cx","/rh","/xs","/xqt","/lp");
    this.words.onfocus=function(){
        this.style.color="black";
        if(this.value==default_words)this.value="";
        else this.select();
    }
    this.btn.onclick=new Function("i_s.search()");
    this.search=function(){
        var w=this.words.value.Trim();
        var t=this.type.value;
        if(w.length<=0){
            if(t==0)alert("请输入关键字或选择类别");
            else location.href=this.tus[t];
        }else{
            if(t==0) location.href="/search?key="+escape(w);
            else location.href="/search?ty="+t+"&key="+escape(w);
        }
    }
}
function memberToLogin(){
    location.href="/login?u="+escape(location.href);
}
function memberExit(){
    if(!confirm("您确定登出帐号吗?"))return;
    if(WebAjaxAction.memberExit().error==null){
        if($("Top1_lik_log")!=null&&$("Top1_lik_reg")!=null){
            $("Top1_lik_log").href="/login.html";
            $("Top1_lik_log").onclick=function(){
                memberToLogin();
                return false;
            }
            $("Top1_lik_log").innerHTML="用户登录";
            $("Top1_lik_reg").href="/register.html";
            $("Top1_lik_reg").innerHTML="快速注册";
            $("Top1_lik_reg").onclick=null;
            alert("已安全退出!");
        }else{
            location.href=location.href;
        }
    }else{
        alert("系统繁忙!请稍候再试!");
    }
}
var i_s=new i_search();
window.document.onkeydown=function(){
	if(event.keyCode==13) 
	{
		var e=event.srcElement;
		if(e!=null&&(e.id=="s_w"||e.id=="s_t"||e.id=="s_b")){
			$("s_b").click();
		}else if(e!=null&&(e.id=="txtName"||e.id=="txtPass"||e.id=="txtCode"||e.id=="txtRpass"||e.id=="txtEmail"||e.id=="chkAgree")){
		    if($("btnSave")!=null){$("btnSave").click();}
		}
		return false;
	}
}