var menuID;
var numberOfCheckbox=30;
var numberOfRadioButton=9;
var defaultAgeCriteria=5;
var radioButtonID=6;
function city(id)
{
menuID=id;
var checkboxID=new Array();
var j=0;
		for(var i=1; i<=numberOfCheckbox;i++)
		{
			if(document.getElementById("c"+i).checked== true)
			{
			checkboxID[j++]=document.getElementById("c"+i).value;
			}
		}
		for(var i=1; i<=numberOfRadioButton;i++)
		{
			if(document.getElementById("b"+i).checked== true)
			{
			radioButtonID=document.getElementById("b"+i).value;
			}
		}
		var coverPrice=document.getElementById("red-input").value;
		//alert(checkboxID);
		//alert(radioButtonID);
		//alert(coverPrice);
		CreateRequest();
		var URL = "sideMenuSearch.php";
		request.open("POST", URL, true);
		request.onreadystatechange = showCity;
		request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		request.send("cityID="+escape(id)+"&genereID="+escape(checkboxID)+"&agecriteriaID="+escape(radioButtonID)+"&coverPrice="+escape(coverPrice));
		document.getElementById("searchResultDiv").innerHTML = "<span style='align:center;padding-left:10px;'><img src='loader.gif' alt='Please wait...' border='0'/>please wait....</span>";
}

function showCity()
{
	if (request.readyState == 4) {
	if (request.status == 200) {
	var str = request.responseText;
	//alert(str);
	//document.getElementById("searchResultDiv").parentNode.removeChild(document.getElementById("searchResultDiv"));
	document.getElementById("searchResultDiv").innerHTML=str; 
	stickytooltip.init("*[data-tooltip]", "mystickytooltip")   
	searchResult(menuID);                 
	}
	else {
	alert('Error While Getting Data From Server. \nStatus is:' + request.status);
	}
	}
}

function searchResult(menuID)
{
var id=1;
//alert(menuID);
CreateRequest();
var URL = "try.php";
request.open("POST", URL, true);
request.onreadystatechange = showSearchResult;
request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
request.send("cityID="+escape(menuID));
}

function showSearchResult()
{
	if (request.readyState == 4) {
	if (request.status == 200) {
	var str = request.responseText;
	//alert(str);
	document.getElementById("dataDiv").innerHTML=str;           
	}
	else {
	alert('Error While Getting Data From Server. \nStatus is:' + request.status);
	}
	}
}
/* For CheckBox */

function selectedCheckbox()
{
	var checkboxID=new Array();
	var j=0;
	for(var i=1; i<=numberOfCheckbox;i++)
	{
		if(document.getElementById("c"+i).checked== true)
		{
		checkboxID[j++]=document.getElementById("c"+i).value;
		}
	}
	for(var i=1; i<=numberOfRadioButton;i++)
	{
		if(document.getElementById("b"+i).checked== true)
		{
		radioButtonID=document.getElementById("b"+i).value;
		}
	}
	var cityID=document.getElementById("cityID").value;
	var coverPrice=document.getElementById("red-input").value;
	//alert(checkboxID);
	//alert(radioButtonID);
	//alert(cityID);
	menuID=cityID;
	//alert(coverPrice);
	CreateRequest();
	var URL = "sideMenuSearch.php";
	request.open("POST", URL, true);
	request.onreadystatechange = showCity;
	request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	request.send("cityID="+escape(cityID)+"&genereID="+escape(checkboxID)+"&agecriteriaID="+escape(radioButtonID)+"&coverPrice="+escape(coverPrice));
	document.getElementById("searchResultDiv").innerHTML = "<span style='align:center;padding-left:10px;'><img src='loader.gif' alt='Please wait...' border='0'/>please wait....</span>";
}

function getDate(passYear,passMonth,passDate)
{
	//alert(passYear);
	passDate='0'+passDate;
	while (passDate.substr(0,1) == '0' && passDate.length>1) { passDate = passDate.substr(1,9999); }
	passMonth='0'+passMonth;
	while (passMonth.substr(0,1) == '0' && passMonth.length>1) { passMonth = passMonth.substr(1,9999); }
	if(passMonth<10)
	passMonth='0'+passMonth;
	//alert(passMonth);
	if(passDate<10)
	passDate='0'+passDate;
	//alert(passDate);
	var checkboxID=new Array();
	var j=0;
	for(var i=1; i<=numberOfCheckbox;i++)
	{
		if(document.getElementById("c"+i).checked== true)
		{
		checkboxID[j++]=document.getElementById("c"+i).value;
		}
	}
	for(var i=1; i<=numberOfRadioButton;i++)
	{
		if(document.getElementById("b"+i).checked== true)
		{
		radioButtonID=document.getElementById("b"+i).value;
		}
	}
	var cityID=document.getElementById("cityID").value;
	var coverPrice=document.getElementById("red-input").value;
	//alert(checkboxID);
	//alert(radioButtonID);
	//alert(cityID);
	menuID=cityID;
	//alert(coverPrice);
	CreateRequest();
	var URL = "sideMenuSearch.php";
	request.open("POST", URL, true);
	request.onreadystatechange = showCity;
	request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	request.send("cityID="+escape(cityID)+"&genereID="+escape(checkboxID)+"&agecriteriaID="+escape(radioButtonID)+"&coverPrice="+escape(coverPrice)+"&year="+escape(passYear)+"&month="+escape(passMonth)+"&date="+escape(passDate));
	document.getElementById("searchResultDiv").innerHTML = "<span style='align:center;padding-left:10px;'><img src='loader.gif' alt='Please wait...' border='0'/>please wait....</span>";
}

function pagination(PageNo)
{
	var checkboxID=new Array();
	var j=0;
	for(var i=1; i<=numberOfCheckbox;i++)
	{
		if(document.getElementById("c"+i).checked== true)
		{
		checkboxID[j++]=document.getElementById("c"+i).value;
		}
	}
	for(var i=1; i<=numberOfRadioButton;i++)
	{
		if(document.getElementById("b"+i).checked== true)
		{
		radioButtonID=document.getElementById("b"+i).value;
		}
	}
	var cityID=document.getElementById("cityID").value;
	var coverPrice=document.getElementById("red-input").value;
	//alert(PageNo);
	//alert(radioButtonID);
	//alert(cityID);
	menuID=cityID;
	//alert(coverPrice);
	CreateRequest();
	var URL = "sideMenuSearch.php";
	request.open("POST", URL, true);
	request.onreadystatechange = showCity;
	request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	request.send("cityID="+escape(cityID)+"&genereID="+escape(checkboxID)+"&agecriteriaID="+escape(radioButtonID)+"&coverPrice="+escape(coverPrice)+"&PageNo="+escape(PageNo));
	document.getElementById("searchResultDiv").innerHTML = "<span style='align:center;padding-left:10px;'><img src='loader.gif' alt='Please wait...' border='0'/>please wait....</span>";
}
