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 showLogin2()
{
	var chkcookie = get_cookie ( "mb_id" );

	if(chkcookie!=null){
		var username = get_cookie ( "mb_username" );
		document.getElementById('showlogin').innerHTML = '<div style="width:960px;float:left;"><div style="width:730px;float:left;text-align:right;"><a href="/refill.php" title=""><img src="/images/buttons_v4/recharge2.png" width="170" height="32" alt="" border="0"/></a> <a href="/inform_transfer.php" title=""><img src="/images/buttons_v4/report-transfer.png" width="170" height="32" alt="" border="0"/> </a></div><div style="float:left;text-align:right;margin-right:5px;width:220px;">สวัสดี คุณ : <span style="font-weight:bold;">'+username+'</span> <a href="/memberprofile.php" title="ข้อมูล สมาชิก">ดูข้อมูลสมาชิก</a><br/> <a href="/editprofile.php" title="แก้ไขข้อมูลสมาชิก">แก้ไขข้อมูลสมาชิก</a> <a href="/logout.php"  title="ออกจากระบบ">ออกจากระบบ</a></div></div>';
	} else {
		document.getElementById('showlogin').innerHTML = '<a href="/refill.php" title=""><img src="/images/buttons_v4/recharge2.png" width="170" height="32" alt=""  border="0"/></a> <a href="/inform_transfer.php" title=""><img src="/images/buttons_v4/report-transfer.png" width="170" height="32" alt="" border="0" /></a> <a href="/memberlogin.php" title="เข้าระบบ Horoworld"><img src="/images/buttons_v4/login.png" alt="เข้าระบบ Horoworld" border="0" width="110" height="32"  /></a> <a href="/register.php" title="สมัครสมาชิกฟรี"><img src="/images/buttons_v4/free-regis.png" alt="สมัครสมาชิกฟรี" width="170" height="32" border="0"/></a>';
	}


}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
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_new.php";
	obj.method = "POST"
	obj.addParam("login",'login');
	obj.function_name = "testdata3('fake')"; 
	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;
	}
} 
