﻿function trim(str,chars){
	return ltrim(rtrim(str,chars),chars);
}
function ltrim(str,chars){
	chars=chars || "\\s";
	return str.replace(new RegExp("^["+chars+"]+","g"),"");
}

function rtrim(str,chars){
	chars=chars || "\\s";
	return str.replace(new RegExp("["+chars+"]+$","g"),"");
}

function _startSearch(){
	var k=document.getElementById('keyword').value;
	if(trim(k," ")!=''){
		alert('start search for: '+k);
	}
}
function show_boxa(){
	document.getElementById('idvSearchBox2').style.visibility='visible';
	document.getElementById('idvSearchBox2').style.left='25px';
	document.getElementById('idvSearchBox2').style.zIndex='5000';
	//alert('idvSearchBox height:'+document.getElementById('idvSearchBox').style.height);
}
function closesa(){
	document.getElementById('idvSearchBox2').style.visibility='hidden';	
	document.getElementById('idvSearchBox2').style.left='425px';
	document.getElementById('idvSearchBox2').style.zIndex='0';
}
function show_boxa2(){
	document.getElementById('idvSearchBox').style.display='block';
}
function closesa2(){
	document.getElementById('idvSearchBox').style.display='none';
}
function show_boxa3(){
	document.getElementById('idvSearchBox2').style.visibility='visible';
	document.getElementById('idvSearchBox2').style.left='0';
	document.getElementById('idvSearchBox2').style.zIndex='5000';
}
function closesa3(){
	document.getElementById('idvSearchBox2').style.visibility='hidden';	
	document.getElementById('idvSearchBox2').style.left='-999px';
	document.getElementById('idvSearchBox2').style.zIndex='0';
}
function checksubmit(){
	if(document.getElementById('keyword').value != ''){
		document.getElementById('search_form').submit();
		return true;
	}
	else{
		alert('กรุณาใส่ค่า keyword');
		return false;
	}
}
function checksubmitAdvance(){
	if(document.getElementById('keyword2').value != ''){
		document.getElementById('ad_search_form').submit();
		return true;
	}
	else{
		alert('กรุณาใส่ค่า keyword');
		return false;
	}
}
