function showDetails(eventID)
{
		CreateRequest();
		var URL = "eventDetails.php";
		request.open("POST", URL, true);
		request.onreadystatechange = showEventDetails;
		request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		request.send("eventID="+escape(eventID));
}
function showEventDetails()
{
	if (request.readyState == 4) {
	if (request.status == 200) {
	var str = request.responseText;
	//alert(str);
	document.getElementById("searchResultDiv").style.display = 'none';
	document.getElementById("viewImageDiv").innerHTML=str; 
	document.getElementById("viewImageDiv").style.display = 'block';      
	}
	else {
	alert('Error While Getting Data From Server. \nStatus is:' + request.status);
	}
	}
}
function showPrev()
{
	document.getElementById("searchResultDiv").style.display = 'block';
	document.getElementById("viewImageDiv").style.display = 'none';
}
function search()
{
		var searchKey=document.getElementById('searchKey').value;
		CreateRequest();
		var URL = "search.php";
		request.open("POST", URL, true);
		request.onreadystatechange = showSearchResults;
		request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		request.send("searchKey="+escape(searchKey));
		document.getElementById("searchResultDiv").innerHTML = "<span style='align:center;padding-left:10px;'><img src='loader.gif' alt='Please wait...' border='0'/>please wait....</span>";
}
function showSearchResults()
{
	if (request.readyState == 4) {
	if (request.status == 200) {
	var str = request.responseText;
	//alert(str);
	document.getElementById("searchResultDiv").innerHTML=str; 
	stickytooltip.init("*[data-tooltip]", "mystickytooltip")   
	}
	else {
	alert('Error While Getting Data From Server. \nStatus is:' + request.status);
	}
	}
}
function moreInfo(eventID)
{
	//alert(eventID);
	CreateRequest();
	var URL = "moreEventInfo.php";
	request.open("POST", URL, true);
	request.onreadystatechange = showMoreInfo;
	request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	request.send("eventID="+escape(eventID));
}
function showMoreInfo()
{
	if (request.readyState == 4) {
	if (request.status == 200) {
	var str = request.responseText;
	//alert(str);
	document.getElementById("moreinfo").innerHTML=str;    
	}
	else {
	alert('Error While Getting Data From Server. \nStatus is:' + request.status);
	}
	}
}
function addToList(eventID)
{
	CreateRequest();
	var URL = "addToMyPartyList.php";
	request.open("POST", URL, true);
	request.onreadystatechange = addToMyPartyList;
	request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	request.send("eventID="+escape(eventID));
}
function addToMyPartyList()
{
	if (request.readyState == 4) {
	if (request.status == 200) {
	var str = request.responseText;
	str.split("<");
	//alert(str[0]);
	if(str[0]=='0')
	window.location="login.php?msg=<font color='red'>You need to login first before adding an event into myList !</font>";
	if(str[0]=='1')
	window.location="showMyPartyDetails.php?msg=Added Sucessfully";
	if(str[0]=='2')
	window.location="showMyPartyDetails.php?msg=<BLINK><font color='red'>Already Added</font></BLINK>"
	//document.getElementById("addmessage").innerHTML=str;    
	}
	else {
	alert('Error While Getting Data From Server. \nStatus is:' + request.status);
	}
	}
}	
function removeFromList(favourite_id)
{
	var answer = confirm ("Are you sure you want to Remove it from MyPartyList?")
	if (answer)
	{
	CreateRequest();
	var URL = "removeFromMyPartyList.php";
	request.open("POST", URL, true);
	request.onreadystatechange = removeFromMyPartyList;
	request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	request.send("favourite_id="+escape(favourite_id));
	}
}
function removeFromMyPartyList()
{
	if (request.readyState == 4) {
	if (request.status == 200) {
	var str = request.responseText;
	str.split("<");
	//alert(str);
	if(str[0]=='0')
	window.location="login.php?msg=<font color='red'>You need to login first before adding an event into myList !</font>";
	if(str[0]=='1')
	window.location="showMyPartyDetails.php?msg=Removed Sucessfully";
	//document.getElementById("addmessage").innerHTML=str;    
	}
	else {
	alert('Error While Getting Data From Server. \nStatus is:' + request.status);
	}
	}
}
