// JavaScript Document
function MM_jumpMenu(targ,selObj,restore){ 
  show_city(selObj.options[selObj.selectedIndex].value);
  if (restore) selObj.selectedIndex=0;
}
function MM_jumpMenu_state_posting(targ,selObj,restore){ 
  show_city(selObj.options[selObj.selectedIndex].value);
  if (restore) selObj.selectedIndex=0;
}
function MM_jumpMenu1(targ,selObj,restore){ 
  show_gym(selObj.options[selObj.selectedIndex].value);
  if (restore) selObj.selectedIndex=0;
}
//for Searching thead on state name
function MM_jumpMenu_search(targ,selObj,restore){ 
  show_search_city(selObj.options[selObj.selectedIndex].value);
  if (restore) selObj.selectedIndex=0;
}
function MM_jumpMenu_search_city(targ,selObj,restore){ 
   dropdown_search_city_data(selObj.options[selObj.selectedIndex].value);
   //window.location="search.result.php?state="+statename+"&city="+selObj.options[selObj.selectedIndex].value;
  if (restore) selObj.selectedIndex=0;
}
//function for hide and show
function toggle()
{
	for(var i=0;i<arguments.length;i++)
	{
		var element=ge(arguments[i]);
		element.style.display=(element.style.display=='block'||element.style.display=='')?'none':'block';
	}
	return false;
}
function ge()
{
	var ea;
	for(var i=0;i<arguments.length;i++)
	{
		var e=arguments[i];
		if(typeof e=='string')
			e=document.getElementById(e);
		if(arguments.length==1)
			return e;
		if(!ea)
		ea=new Array();
		ea[ea.length]=e;
	}
return ea;
}
var xmlHttp;
var str;
//for showing City Name 
function show_city(value)
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
	alert ("Browser does not support HTTP Request")
	return
	} 
	var url="city.php?statename=" + value;
	xmlHttp.onreadystatechange=stateChanged10
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}
function stateChanged10() 
{ 
    active_city="city_id"
	if (xmlHttp.readyState==1 || xmlHttp.readyState=="loading")
	{ 
		document.getElementById(active_city).innerHTML="Processing...."
	} 
	
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		document.getElementById(active_city).innerHTML=xmlHttp.responseText
	} 
} 
function show_search_city(value)
{
	state=value;
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
	alert ("Browser does not support HTTP Request")
	return
	} 
	var url="search_city.php?statename=" + value;
	xmlHttp.onreadystatechange=stateChanged11
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}
function stateChanged11() 
{ 
    //alert(state);
    active_city="search_id_city"
	if (xmlHttp.readyState==1 || xmlHttp.readyState=="loading")
	{ 
		//document.getElementById(active_city).innerHTML="Loading...."
	} 
	
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		document.getElementById(active_city).innerHTML=xmlHttp.responseText
		dropdown_search_city(state);
	} 
}
//for showing Data In mid table by selected left state 
function dropdown_search_city(value)
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
	alert ("Browser does not support HTTP Request")
	return
	} 
	var url="dropdownstate_search.php?statename=" + value;
	xmlHttp.onreadystatechange=stateChanged1 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}
function stateChanged1() 
{ 
    active="container"
	if (xmlHttp.readyState==1 || xmlHttp.readyState=="loading")
	{ 
		//document.getElementById(active).innerHTML="Loading...."
	} 
	
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		document.getElementById(active).innerHTML=xmlHttp.responseText
	} 
} 
//for showing Data In mid table by selected left city 
function dropdown_search_city_data(value)
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
	alert ("Browser does not support HTTP Request")
	return
	} 
	var url="dropdowncity_search.php?cityname=" + value;
	xmlHttp.onreadystatechange=stateChanged13 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}
function stateChanged13() 
{ 
    active="container"
	if (xmlHttp.readyState==1 || xmlHttp.readyState=="loading")
	{ 
		//document.getElementById(active).innerHTML="Loading...."
	} 
	
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		document.getElementById(active).innerHTML=xmlHttp.responseText
	} 
} 
/* Function for Posting*/
////////////////////////////////////////////////////////////////////////////////
function post_thread(str1,str2,str3,str4,str5,str6)
{
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 

	var url = "posting.php";
	var params = "title=" + str1 + "&state=" + str2 + "&city=" + str3 + "&gym=" + str4 + "&message=" + str5 + "&tags=" + str6;
	
	xmlHttp.open("POST", url, true);
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", params.length);
	xmlHttp.setRequestHeader("Connection", "close");
	xmlHttp.send(params);
	alert('Your juice has been posted');
}

/* Function for Posting Ends here*/

/* Function for Reply start here*/
function post_reply(str1,str2)
{
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	var url = "posting_reply.php";
	var params = "titleid=" + str1 + "&reply=" + str2 ;
	
	//xmlHttp.onreadystatechange=stateChanged2
	xmlHttp.open("POST", url, true);
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", params.length);
	xmlHttp.setRequestHeader("Connection", "close");
	xmlHttp.send(params);
	alert('Your reply has been posted');
	
	replycount(str1); //changing reply counting
	
    show_subreply(str1) 
	
}
/* Function for Reply ends here*/

/* Function for 2 level Reply start here*/
function post_reply_2level(str1,str2,str3)
{
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	var url = "posting_reply_2level.php";
	var params = "titleid=" + str1 + "&reply=" + str2 ;
	
	//xmlHttp.onreadystatechange=stateChanged2
	xmlHttp.open("POST", url, true);
	xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlHttp.setRequestHeader("Content-length", params.length);
	xmlHttp.setRequestHeader("Connection", "close");
	xmlHttp.send(params);
	alert('Reply Inserted Successfully');
	
    show_subreply_2level(str1)
}
/* Function for 2 level Reply ends here*/
////////////////////////////////////////////////////////////////////////////////
/* Function for Rating Start here*/
function Rate_title(titleid,value,bg)
{
	//alert(bg);
	var r_ponit=value;
	active="vote-rating-"+titleid
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	}
	
	var url = "rate.php?sid=" + Math.random() + "&titleid=" + titleid + "&value=" + r_ponit+"&clr="+bg;
	xmlHttp.onreadystatechange=stateChanged3
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}
function stateChanged3() 
{ 
	if (xmlHttp.readyState==1 || xmlHttp.readyState=="loading")
	{ 
		//document.getElementById(active).innerHTML=""
	} 
	
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		document.getElementById(active).innerHTML=xmlHttp.responseText
	} 
}
/* Function for Rating Ends here*/
////////////////////////////////////////////////////////////////////////////////
/* Function for Viewcount Start here*/
function viewcount(titleid)
{
	active="view-count-"+titleid
	showtableid="detail-view-"+titleid
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	}
	
	var url = "viewcount.php?sid=" + Math.random() + "&titleid=" + titleid ;
	xmlHttp.onreadystatechange=stateChanged4
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}
function stateChanged4() 
{ 
	if (xmlHttp.readyState==1 || xmlHttp.readyState=="loading")
	{ 
		//document.getElementById(active).innerHTML=""
	} 
	
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		document.getElementById(active).innerHTML=xmlHttp.responseText
		toggle(showtableid);	
	} 
}
/* Function for Viewcount Ends here*/

/* Function for Reply Count Start here*/
function replycount(titleid)
{
	active="reply-count-"+titleid
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	}
	
	var url = "replycount.php?sid=" + Math.random() + "&titleid=" + titleid ;
	xmlHttp.onreadystatechange=stateChanged5
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}
function stateChanged5() 
{ 
	if (xmlHttp.readyState==1 || xmlHttp.readyState=="loading")
	{ 
		//document.getElementById(active).innerHTML="Loading.........."
	} 
	
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		document.getElementById(active).innerHTML=xmlHttp.responseText
	} 
}
/* Function for Reply Count Ends here*/

/* Function for Sub Reply Listing Start here*/
function show_subreply(titleid)
{
	active="reply-1_level-"+titleid;
	formid="#reply-"+titleid;
	imageid=titleid;
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	}
	
	var url = "includes/subreply.php?sid=" + Math.random() + "&replyid=" + titleid ;
	xmlHttp.onreadystatechange=stateChanged6
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}
function stateChanged6() 
{ 
	if (xmlHttp.readyState==1 || xmlHttp.readyState=="loading")
	{ 
		//document.getElementById(active).innerHTML=""
	} 
	
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		document.getElementById(active).innerHTML=xmlHttp.responseText
		$(formid).hide();
		show(active);
		reply_image_change(imageid);
		
	} 
}
/* Function for Sub Reply Listing Ends here*/

/* Function for Sub Reply 2 level Listing Start here*/
function show_subreply_2level(titleid)
{
	active="reply-2_level-"+titleid;
	imageid=titleid;
	
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	}
	
	var url = "includes/reply_2level.php?sid=" + Math.random() + "&replyid=" + titleid ;
	xmlHttp.onreadystatechange=stateChanged7
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
	
}
function stateChanged7() 
{ 
	if (xmlHttp.readyState==1 || xmlHttp.readyState=="loading")
	{ 
		//document.getElementById(active).innerHTML=""
	} 
	
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		document.getElementById(active).innerHTML=xmlHttp.responseText
		reply_image_change(imageid)
	} 
}
/* Function for Sub Reply 2 level Listing Ends here*/

/* Function for Reply Image Change Start here*/
function reply_image_change(titleid)
{
	active="reply-image-id-"+titleid;
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	}
	
	var url = "reply_image.php?sid=" + Math.random() + "&replyid=" + titleid ;
	xmlHttp.onreadystatechange=stateChanged8
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}
function stateChanged8() 
{ 
	if (xmlHttp.readyState==1 || xmlHttp.readyState=="loading")
	{ 
		//document.getElementById(active).innerHTML=""
	} 
	
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
		document.getElementById(active).innerHTML=xmlHttp.responseText
	} 
}
/* Function for Reply Image Change Ends here*/

////////////////////////////////////////////////////////////////////////////////
function GetXmlHttpObject(handler)
{ 
var objXMLHttp=null
if (window.XMLHttpRequest)
{
objXMLHttp=new XMLHttpRequest()
}
else if (window.ActiveXObject)
{
objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
}
return objXMLHttp
}