var xmlHttp;
var tscat;
var tscate;
var site_url="http://www.bestestsports.com/";
var redirecturl="";
var killide;
var killimg;
var killimgid;
//##################################
	function useralreadyexist(id,name,value)
	{ 
		
		tscat=id;
		if(name!='verify_password')
		{
		xmlHttp=GetXmlHttpObject();
		if (xmlHttp==null)
		{
			alert ("Browser does not support HTTP Request")
			return
		}
		var url="user_exist.php?"+name+"="+value;
		xmlHttp.onreadystatechange=stateuseralreadyexist
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
		}
	}	
	
	
	function stateuseralreadyexist() 
	{ 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{ 
			
		 document.getElementById(tscat).innerHTML=xmlHttp.responseText;
		} 
	}
	//###################################Suresh#################################################################
	function showcountry(id)
	{ 
		
		tscat=id;
		
		xmlHttp=GetXmlHttpObject();
		if (xmlHttp==null)
		{
			alert ("Browser does not support HTTP Request")
			return
		}
		var url="showcountry.php";
		xmlHttp.onreadystatechange=stateshowcountry
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
		
	}	
	
	
	function stateshowcountry() 
	{ 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{ 
			
		 document.getElementById(tscat).innerHTML=xmlHttp.responseText;
		} 
	}
	/////////////////////////////////////////////////////////////////////////////////////////////////
	
	//###################################Suresh#############################################################
	function showforumcountry(id)
	{ 
		tscat=id;
		xmlHttp=GetXmlHttpObject();
		if (xmlHttp==null)
		{
			alert ("Browser does not support HTTP Request")
			return
		}
		var url="showforumcountry.php";
		xmlHttp.onreadystatechange=stateshowforumcountry
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
		
	}	
	
	
	function stateshowforumcountry() 
	{ 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{ 
			
		 document.getElementById(tscat).innerHTML=xmlHttp.responseText;
		} 
	}
	/////////////////////////////////////////////////////h///////////////////////////////////////////
	function editdesc_state(id,exam_id,state_id)
	{ 
		tscat=id;
		document.getElementById(id).innerHTML="<img src='images/load.gif' height='15' width='15'> <b>Loading ...<b> ";
		xmlHttp=GetXmlHttpObject();
		if (xmlHttp==null)
		{
			alert ("Browser does not support HTTP Request")
			return
		}
		var url="exams_state.php?exam_id="+exam_id+"&state_id="+state_id;
		xmlHttp.onreadystatechange=stateeditdesc_state
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
		
	}	
	
	
	function stateeditdesc_state() 
	{ 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{ 
			
		 document.getElementById(tscat).innerHTML=xmlHttp.responseText;
		} 
	}

	
	function upload_mem_photo()
	{ 
	   document.getElementById("Layer1").innerHTML="<img src='images/load.gif' height='20' width='20'> <b>Loading ...<b> ";
	   	xmlHttp=GetXmlHttpObject()
		if (xmlHttp==null)
		{
			alert ("Browser does not support HTTP Request")
			return
		}		
		
		var url="upload_mem_photo.php";
		xmlHttp.onreadystatechange=statetmem_photo
		xmlHttp.open("GET",url,true)
		xmlHttp.send(null)
	}	
	
	function statetmem_photo() 
	{ 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{ 
		  document.getElementById("Layer1").innerHTML=xmlHttp.responseText;
		} 
	}
	
 
	//--------------------------------------function by for add to favorite------------------------------------------
	
	function add_to_fav(id)
		{ 
		
		xmlHttp=GetXmlHttpObject()
		if (xmlHttp==null)
		{
		alert ("Browser does not support HTTP Request")
		return
		}
		var url="addtofav.php?sport_id="+id;		
		xmlHttp.onreadystatechange=favChanged 
		xmlHttp.open("GET",url,true)
		xmlHttp.send(null)
		}
		function favChanged() 
		{ 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{ 
		alert(xmlHttp.responseText); 
		} 
		}

		
		function removeMyfav(type_id,cat_type)
		{ 
		
		var response = window.confirm("Do you want to remove it from your favorite list?");
		
     	if (response) {
        xmlHttp=GetXmlHttpObject();
		
		if (xmlHttp==null)
		{
		alert ("Browser does not support HTTP Request")
		return
		}
		
		var url=site_url+"remove_favorite.php?sid="+type_id+"&cat_type="+cat_type;
		
		xmlHttp.onreadystatechange=favremove
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
		
		//window.location.href='notes.php?myfav=abc';
     }
	   else {
			  return false;
		 }
		
		}
		
		
		
		
		function favremove() 
		{ 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{ 
		alert(xmlHttp.responseText);
		window.location.href=site_url+"myaccount/";
		} 
		}
			
	///-------------------------------------------end of-----------------------------------------------------------
	//---------------------------------------------------functionby suresh----------------------------------------
	function InviteFriend_s(url,file1,user,pass)
	{ 
	   document.getElementById("showres").innerHTML="<img src='images/load.gif' height='20' width='20'> <b>Loading ...<b> ";
	   	xmlHttp=GetXmlHttpObject()
		if (xmlHttp==null)
		{
			alert ("Browser does not support HTTP Request")
			return
		}		
		
		var url="import/popup.php?url="+url+","+file1+","+user+","+pass;
		xmlHttp.onreadystatechange=statetmem_photo
		xmlHttp.open("GET",url,true)
		xmlHttp.send(null)
	}	
	
	function statetmem_photo() 
	{ 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{ 
		  document.getElementById("showres").innerHTML=xmlHttp.responseText;
		} 
	}
	
	//-------------------------------------------------------end--------------------------------------------------

	//-------------------------------------------------function by suresh for rating-----------------------------
	function rating_all(done,id,type)
	{ 
	   
	   	xmlHttp=GetXmlHttpObject()
		if (xmlHttp==null)
		{
			alert ("Browser does not support HTTP Request")
			return
		}		
		
		var url="rating.php?done="+done+"&type_id="+id+"&type="+type;
		xmlHttp.onreadystatechange=statetrating_all
		xmlHttp.open("GET",url,true)
		xmlHttp.send(null)
	}	
	
	function statetrating_all() 
	{ 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{ 
		$msg=xmlHttp.responseText;
		if($msg)
		{
		alert("You have rated sucessfully");	
		window.location.href=$msg;
		}
		} 
	}
	function hitit(id,sportid,page_index)
	{
		
		tscat=id;
		
	   document.getElementById(tscat).innerHTML="<img src='images/load.gif' height='20' width='20'>";
	   	xmlHttp=GetXmlHttpObject()
		if (xmlHttp==null)
		{
			alert ("Browser does not support HTTP Request")
			return
		}		
		
		var url=site_url+"hitcounter.php?sportid="+sportid+"&page_index="+page_index+"&hitlink="+tscat;
		xmlHttp.onreadystatechange=statehitit1
		xmlHttp.open("GET",url,true)
		xmlHttp.send(null)
	}
	function statehitit1() 
	{ 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{ 
				var str=	xmlHttp.responseText.indexOf("killlink for"); 
				var str1=xmlHttp.responseText.substr(str)
				
				var str2=str1.replace("killlink for","");
				
			
				var rat=xmlHttp.responseText.replace("killlink for","");
				var rat1=rat.replace("Kill it","");
				
			document.getElementById(tscat).innerHTML=rat1;
			
		} 
	}
	//-------------------------------------------------------end--------------------------------------------------
	//......................................................function by suresh....................................
	function hititprofile(id,sportid,page_index,redirecturl)
	{
		
		tscat=id;
		
	   document.getElementById(tscat).innerHTML="<img src='images/load.gif' height='20' width='20'>";
	   	xmlHttp=GetXmlHttpObject()
		if (xmlHttp==null)
		{
			alert ("Browser does not support HTTP Request")
			return
		}		
		
		var url=site_url+"hitcounter.php?sportid="+sportid+"&redirecturl="+redirecturl+"&page_index="+page_index;
		xmlHttp.onreadystatechange=statehititprofile
		xmlHttp.open("GET",url,true)
		xmlHttp.send(null)
	}
	function statehititprofile() 
	{ 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{ 
		  $msg=xmlHttp.responseText;
			var str=	xmlHttp.responseText.indexOf("killlink for"); 
				var str1=xmlHttp.responseText.substr(str)
				var str2=str1.replace("killlink for","");
				var rat=xmlHttp.responseText.replace("killlink for","");
				var rat1=rat.replace("Kill it","");
			document.getElementById(tscat).innerHTML=rat1;
		} 
	}
	
	//..........................................................end...............................................
	//------------------------------------------------------------------------------------------------------------
		function killit(id,killid,sportid,page_index,type)
	{
		tscat=id;
		killide=killid;
		killimg="kill"+killid.substr(4)+1;
		
	

	   document.getElementById(tscat).innerHTML="<img src='images/load.gif' height='20' width='20'>";
	   	xmlHttp=GetXmlHttpObject()
		if (xmlHttp==null)
		{
			alert ("Browser does not support HTTP Request")
			return
		}		
		
		var url="hitcounter.php?sportid="+sportid+"&page_index="+page_index+"&type="+type+"&hitlink="+tscat;
		xmlHttp.onreadystatechange=statehititkill
		xmlHttp.open("GET",url,true)
		xmlHttp.send(null)
	}
	function statehititkill() 
	{ 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{ 
		 
		 var str=	xmlHttp.responseText.indexOf("killlink for"); 
		 var str1=xmlHttp.responseText.substr(str)
			var str2=str1.replace("killlink for","");
			var str3=str2.substr(0,str2.length-12)
			var rat=xmlHttp.responseText.replace("killlink for","");
				var rat1=rat.replace("Kill it","");
			document.getElementById(tscat).innerHTML=rat1;
			document.getElementById(killimg).innerHTML=str3+'<img src="'+site_url+'images/kill-it-icon.jpg" width="14" height="14" border="0" /></a>';
			
			document.getElementById(killide).innerHTML=str2;
			
			
		} 
	}
	//******************************************************
	
		function del_photo(id)
		{ 
	
		var response = window.confirm("Do you want to remove the photo?");
     if (response) {
		xmlHttp=GetXmlHttpObject()
		if (xmlHttp==null)
		{
		alert ("Browser does not support HTTP Request")
		return
		}
		
		var url="del_photo.php?photo_id="+id;
		xmlHttp.onreadystatechange=submitdel_photo;
		xmlHttp.open("GET",url,true)
		xmlHttp.send(null)
	 }
		 else {
			 	return false;
			 }
	 
		}
		
		function submitdel_photo() 
		{ 
			if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
			{ 
			alert(xmlHttp.responseText);
			var spath=document.getElementById('sitepath').value;
			window.location.href=spath+'myphoto/';
			} 
			
		}
	
	//*****************************************
	//.......................................function by ....................................................
		
		function add_as_friend(id)
		{ 
			tscat=id;
			xmlHttp=GetXmlHttpObject()
			if (xmlHttp==null)
				{
				alert ("Browser does not support HTTP Request")
				return
				}
			var url=site_url+"addasfriend.php?frnd_id="+id;		
		
			xmlHttp.onreadystatechange=statefavChanged 
			xmlHttp.open("GET",url,true)
			xmlHttp.send(null);
		
		}
		
		function statefavChanged() 
			{ 
			if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
				{ 
					alert(xmlHttp.responseText); 
					window.location.href=site_url+"myprofile/"+tscat+"/";
				} 
			}
		
	//............................................end..............................................................
	
	function changemysetting(fname,fval)
		{ 
	
		var response = window.confirm("Do you want to update the setting?");
      	if (response) {
		xmlHttp=GetXmlHttpObject()
		if (xmlHttp==null)
		{
		alert ("Browser does not support HTTP Request")
		return
		}
		
		var url=site_url+"save_mysettings.php?fname="+fname+"&fval="+fval;
		xmlHttp.onreadystatechange=changesetting;
		xmlHttp.open("GET",url,true)
		xmlHttp.send(null)
	 }
		 else {
			 	return false;
			 }
	 
		}
		
		function changesetting() 
		{ 
			if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
			{ 
			alert(xmlHttp.responseText);
			window.location.href=site_url+'mysettings/';
			} 
			
		}
	//............................................................................................................
	
		function removeprofilecomment(type_id,cat_type)
		{ 
		
		var response = window.confirm("Do you want to remove all comments?");
		
     	if (response) {
        xmlHttp=GetXmlHttpObject();
		
		if (xmlHttp==null)
		{
		alert ("Browser does not support HTTP Request")
		return
		}
		
		var url=site_url+"delete_profile_comment.php?member_id="+type_id+"&cat_type="+cat_type;
		
		xmlHttp.onreadystatechange=profilecomment
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
		
		//window.location.href='notes.php?myfav=abc';
     }
	   else {
			  return false;
		 }
		
		}
		
		
		
		
		function profilecomment() 
		{ 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{ 
		alert(xmlHttp.responseText);
		window.location.href=site_url+"myprofile/";
		} 
		}
		
			function removephotocomment(type_id)
		{ 
		tscat=type_id
		var response = window.confirm("Do you want to remove all comments?");
		
     	if (response) {
        xmlHttp=GetXmlHttpObject();
		
		if (xmlHttp==null)
		{
		alert ("Browser does not support HTTP Request")
		return
		}
		
		var url=site_url+"delete_photo_comment.php?photoid="+type_id;
		
		xmlHttp.onreadystatechange=photocomment
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
		
		//window.location.href='notes.php?myfav=abc';
     }
	   else {
			  return false;
		 }
		
		}
		
		
		
		
		function photocomment() 
		{ 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{ 
		alert(xmlHttp.responseText);
		window.location.href=site_url+"photodetail/"+tscat+"/";
		} 
		}
		
		
			function removeblogcomment(type_id)
		{ 
		tscat=type_id
		var response = window.confirm("Do you want to remove all comments?");
		
     	if (response) {
        xmlHttp=GetXmlHttpObject();
		
		if (xmlHttp==null)
		{
		alert ("Browser does not support HTTP Request")
		return
		}
		
		var url=site_url+"delete_blog_comment.php?blogid="+type_id;
		
		xmlHttp.onreadystatechange=blogcomment
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
		
		//window.location.href='notes.php?myfav=abc';
     }
	   else {
			  return false;
		 }
		
		}
		
		
		
		
		function blogcomment() 
		{ 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{ 
		alert(xmlHttp.responseText);
		window.location.href=site_url+"blog/detail/"+tscat+"/";
		} 
		}


	function removesportcomment(sport_id,type_id)
		{ 
		tscat=type_id
		tscate=sport_id
		var response = window.confirm("Do you want to remove this comments?");
		
     	if (response) {
        xmlHttp=GetXmlHttpObject();
		
		if (xmlHttp==null)
		{
		alert ("Browser does not support HTTP Request")
		return
		}
		
		var url=site_url+"delete_sport_comment.php?comment_id="+type_id;
		
		xmlHttp.onreadystatechange=sportcomment
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
		
		//window.location.href='notes.php?myfav=abc';
     }
	   else {
			  return false;
		 }
		
		}
		
		
		
		
		function sportcomment() 
		{ 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{ 
		alert(xmlHttp.responseText);
		window.location.href=site_url+"comments/news/"+tscate+"/";
		} 
		}


	function removeprofilecommentone(comment_id,type_id,cat_type)
		{ 
		
		tscat=type_id
		tecate=cat_type
		var response = window.confirm("Do you want to remove this comment?");
		
     	if (response) {
        xmlHttp=GetXmlHttpObject();
		
		if (xmlHttp==null)
		{
		alert ("Browser does not support HTTP Request")
		return
		}
		
		var url=site_url+"delete_profile_comment_one.php?comment_id="+comment_id+"&member_id="+type_id+"&cat_type="+cat_type;
		
		xmlHttp.onreadystatechange=profilecommentone
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
		
		//window.location.href='notes.php?myfav=abc';
     }
	   else {
			  return false;
		 }
		
		}
		
		
		
		
		function profilecommentone() 
		{ 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{ 
		alert(xmlHttp.responseText);
		window.location.href=site_url+"myprofile/"+tscat+"/";
		} 
		}
		
		
			function removeblogcommentone(comment_id,type_id)
		{ 
		tscat=type_id
		var response = window.confirm("Do you want to remove this comment?");
		
     	if (response) {
        xmlHttp=GetXmlHttpObject();
		
		if (xmlHttp==null)
		{
		alert ("Browser does not support HTTP Request")
		return
		}
		
		var url=site_url+"delete_blog_comment_one.php?comment_id="+comment_id;
		
		xmlHttp.onreadystatechange=blogcommentone
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
		
		//window.location.href='notes.php?myfav=abc';
     }
	   else {
			  return false;
		 }
		
		}
		
		
		
		
		function blogcommentone() 
		{ 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{ 
		alert(xmlHttp.responseText);
		window.location.href=site_url+"blog/detail/"+tscat+"/";
		} 
		}
		
		
			function removephotocommentone(comment_id,type_id)
		{ 
		tscat=type_id
		var response = window.confirm("Do you want to remove this comment?");
		
     	if (response) {
        xmlHttp=GetXmlHttpObject();
		
		if (xmlHttp==null)
		{
		alert ("Browser does not support HTTP Request")
		return
		}
		
		var url=site_url+"delete_photo_comment_one.php?comment_id="+comment_id;
		
		xmlHttp.onreadystatechange=photocommentone
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
		
		//window.location.href='notes.php?myfav=abc';
     }
	   else {
			  return false;
		 }
		
		}
		
		
		
		
		function photocommentone() 
		{ 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{ 
		alert(xmlHttp.responseText);
		window.location.href=site_url+"photodetail/"+tscat+"/";
		} 
		}
		

	//-------------------------------------------------------------------------------------------------------------
    function GetXmlHttpObject()
	{ 
	var objXMLHttp=null
	if (window.XMLHttpRequest)
	{
	objXMLHttp=new XMLHttpRequest()
	}
	else if (window.ActiveXObject)
	{
		try {
		objXMLHttp = new ActiveXObject("Msxml2.XMLHTTP")
		} 
		catch (e){
		try{
		objXMLHttp = new ActiveXObject("Microsoft.XMLHTTP")
		}
		catch (e){}
		}
	}
	return objXMLHttp
	}
	
	
