function hSearchKeyword(){

    var kw = document.getElementById("hKword").value;
  
    if(kw!=""){
        var theIndex;
        kw = kw.substr(kw.search("[^ ]"));theIndex = kw.search(" $");
        while (theIndex != -1){
            kw = kw.substring(0, theIndex);theIndex = kw.search(" $");
        }
        document.getElementById("hKword").value = kw;
        if (document.getElementById("hKword").value == "地名、酒店名、攻略關鍵詞"||document.getElementById("hKword").value ==""){
            document.getElementById("hKword").value="";
        }
        else{
            document.getElementById("hKword").value = document.getElementById("hKword").value.replace(/(^\s*)|(\s*$)/g,"");
            if(document.getElementById("Kword")) document.getElementById("Kword").value = document.getElementById("hKword").value;
           
                // add by hcdu 2010-11-12 fast
                document.forms[0].action="/destguides/search.aspx?q="+document.getElementById("hKword").value;   
                        window.location.href="/destguides/search.aspx?q="+document.getElementById("hKword").value;
                    
        }  
    }  
}
//2010-11-19  add by hcdu fast  begin
function hSearchfastKeyword(){

    var kw = document.getElementById("txtfastsearch").value;
  
    if(kw!=""){
        var theIndex;
        kw = kw.substr(kw.search("[^ ]"));theIndex = kw.search(" $");
        while (theIndex != -1){
            kw = kw.substring(0, theIndex);theIndex = kw.search(" $");
        }
        document.getElementById("txtfastsearch").value = kw;
        if (document.getElementById("txtfastsearch").value == "地名、酒店名、景點名、攻略關鍵詞等"||document.getElementById("txtfastsearch").value ==""){
            document.getElementById("txtfastsearch").value="";
        }
        else{
            document.getElementById("txtfastsearch").value = document.getElementById("txtfastsearch").value.replace(/(^\s*)|(\s*$)/g,"");
            if(document.getElementById("txtfastsearch")) document.getElementById("txtfastsearch").value = document.getElementById("txtfastsearch").value;
           
           
                  document.forms[0].action="/destguides/search.aspx?q="+document.getElementById("txtfastsearch").value;   
                  window.location.href="/destguides/search.aspx?q="+document.getElementById("txtfastsearch").value;
                    
              
        }  
    }  
}
function hsetfastEnterfunc()
{
    if(document.getElementById("txtfastsearch").value=='地名、酒店名、景點名、攻略關鍵詞等'){
        document.getElementById("txtfastsearch").value='';
        document.getElementById("txtfastsearch").style.color = '#2c2c2c';
        
    }else{
        document.getElementById("txtfastsearch").style.color = '#2c2c2c';
    }
}

function hclearfastEnterfunc()
{
    if(document.getElementById("txtfastsearch").value==''){
        document.getElementById("txtfastsearch").value='地名、酒店名、景點名、攻略關鍵詞等';
        document.getElementById("txtfastsearch").style.color = '#aaa';
    }
    
}
//end 
function hsetEnterfunc()
{
    if(document.getElementById("hKword").value=='地名、酒店名、攻略關鍵詞'){
        document.getElementById("hKword").value='';
        document.getElementById("hKword").style.color = '#2c2c2c';
    }
    else
    {
       document.getElementById("hKword").style.color = '#2c2c2c';
    }
}

function hclearEnterfunc()
{
    if(document.getElementById("hKword").value==''){
        document.getElementById("hKword").value='地名、酒店名、攻略關鍵詞';
        document.getElementById("hKword").style.color = '#999';
    }
    //document.onkeydown = "";
}
(function(object,type, handler) {
    if (object.attachEvent) {
        object.attachEvent("on" + type, handler);
    }
    else if (object.addEventListener) {
        object.addEventListener(type, handler, false);
    }
    else {
        object[type] = handler;
    }
})(document,"keydown",function(e){
    var e = e ? e : event;
    if(13 == e.keyCode){
        if(e.srcElement) e.target = e.srcElement;
     
        if("object" == typeof e.target && "input" == e.target.tagName.toLowerCase() && "hKword" == e.target.id)
        {
            if("" != e.target.value.replace(/(^\s*)|(\s*$)/g,"")){hSearchKeyword();}
        }
        // add by hcdu 2010-11-19
        
        if("object" == typeof e.target && "input" == e.target.tagName.toLowerCase() && "txtfastsearch" == e.target.id)
        {
      
            if("" != e.target.value.replace(/(^\s*)|(\s*$)/g,"")){hSearchfastKeyword();}
        }
    }
});

function showRegisterInfor(){
	var e = arguments[0] ? arguments[0] : window.event;
    var tag = e.target ? e.target : e.srcElement;
	document.getElementById('register_infor_uplayer').style.display = 'block';
	document.getElementById('head_register_infor').className = 'head_register_down';
	document.getElementById('register_infor_uplayer').style.top = tag.offsetTop + tag.offsetHeight - 1 + 'px';
	document.getElementById('register_infor_uplayer').style.left = tag.offsetLeft + 'px';
}
function hideRegisterInfor(){
	document.getElementById('register_infor_uplayer').style.display = 'none';
	document.getElementById('head_register_infor').className = 'head_register_infor';
}
