var chkcookie = get_cookie ( "mb_id" );
var d=new Date();

var obj = new clsAjax();
function testajax(){
obj.create();
obj.url = "get.php";
obj.method = "POST"
obj.addParam("txt", document.form1.data.value);
obj.function_name = "testdata()"; 
obj.send();
}
function get_cookie ( cookie_name )
{
  var results = document.cookie.match ( '(^|;) ?' + cookie_name + '=([^;]*)(;|$)' );

  if ( results )
    return ( unescape ( results[2] ) );
  else
    return null;
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function testdata(showresponse)
{
	document.getElementById(showresponse).innerHTML = obj.responseText;
	if(showresponse=='webcamdoc')
	{
		setTimeout('getDoctorWebcam()',20000);
	} 
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function testdata2(showresponse)
{
	document.getElementById(showresponse).innerHTML = obj.responseText;
	if((obj.responseText!='')&&(showresponse=='showhorotoday'))
	{
		getDoctorWebcam();
	}
	else if((obj.responseText!='')&&(showresponse=='showlogin'))
	{		
		if(chkcookie!=null){
			horomember(chkcookie);
		} else {
			horotoday();
		}
	}
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function testdata3(showresponse)
{
	document.getElementById(showresponse).innerHTML = obj.responseText;
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


function bookmarksite(title,url){
if (window.sidebar) // firefox
	window.sidebar.addPanel(title, url, "");
else if(window.opera && window.print){ // opera
	var elem = document.createElement('a');
	elem.setAttribute('href',url);
	elem.setAttribute('title',title);
	elem.setAttribute('rel','sidebar');
	elem.click();
} 
else if(document.all)// ie
	window.external.AddFavorite(url, title);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

/*var OnLoad = 'showLogin()';
window.onload = function() {eval(OnLoad);};*/
function showLogin()
{
	obj.create();
	obj.url = "/includes/horohead_login.php";
	obj.method = "POST"
	obj.addParam("login",'login');
	obj.function_name = "testdata3('showlogin')"; 
	var xxx=obj.send();
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

function showBanner()
{
	obj.create();
	obj.url = "/includes/horohead_banner.php";
	obj.method = "POST"
	obj.addParam("login",'login');
	obj.function_name = "testdata3('showbanner')"; 
	var xxx=obj.send();
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

 function chksearch_xx(form)
{
	if(document.fSearch_xx.key.value=="")
	{
		alert('กรุณาใส่ข้อความค้นหา ก่อนค่ะ');
		document.fSearch_xx.key.focus();
		return false;
	} else{
		location.href='/search.php?key='+document.fSearch_xx.key.value+'&subcat='+document.fSearch_xx.subcat.value;
		return true;
	}
} 