// --- 選擇action ---
function checkaction(v){
if(v==0){
   document.formsearch.action="/SearchSpotByKeyword.php";
}else{
   document.formsearch.action="/SearchTravelByKeyword.php";
}
setCookie("SN",v);
}

// --- 菜單 ---
function drop_mouseover(pos){
	try{window.clearTimeout(timer);}catch(e){}
}

function drop_mouseout(pos){
 var posSel=document.getElementById(pos+"Sel").style.display;
 if(posSel=="block"){
	timer = setTimeout("drop_hide('"+pos+"')", 1000);
 }
}

function drop_hide(pos){
	document.getElementById(pos+"Sel").style.display="none";
}

function search_show(pos,searchType,href){
    document.getElementById(pos+"Sel").style.display="none";
    document.getElementById(pos+"Slected").innerHTML=href.innerHTML;
	setCookie("SV",href.innerHTML);
    try{window.clearTimeout(timer);}catch(e){}
    return false;
}

function submit_top_search_form(f,v){
	var v_obj = document.getElementById(v);
	if (v_obj.value == '' || v_obj.value =='搜尋 7,000+ 個旅遊景點')
	{
		f.action="/SearchSpot.php";
		f.submit();
		//document.location.href="/SearchSpot.php";
		return false;
	}else{
		f.submit();
	}

}

function submit_top_search_form_iframe(){

	if (document.formsearch.q.value == '')
		document.formsearch.action="/SearchSpot.php";
	else
		document.formsearch.action="/SearchSpotByKeyword.php";
	document.formsearch.submit();
}


//-- COOKIE --
function setCookie(name, value) 
{ 
var argv = setCookie.arguments; 
var argc = setCookie.arguments.length; 
var expires = (argc > 2) ? argv[2] : null; 
if(expires!=null) 
{
var LargeExpDate = new Date (); 
LargeExpDate.setTime(LargeExpDate.getTime() + (expires*1000*3600*24)); 
}
document.cookie = name + "=" + escape (value)+((expires == null) ? "" : ("; expires=" +LargeExpDate.toGMTString())); 
}


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 "" 
} 
} 


function submit_check(obj){
	if(obj.value == '搜尋 7,000+ 個旅遊景點'){
		obj.value = "";
	}
	//document.formsearch.q.value = "";
}