// JavaScript Document



var xmlHttp;



function GetXmlHttpObject()

{

	var xmlHttp=null;

	try

	{

		// Firefox, Opera 8.0+, Safari

		xmlHttp=new XMLHttpRequest();

	}

	catch (e)

	{

	//Internet Explorer

		try

		{

			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");

		}

		catch (e)

		{

			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");

		}

	}

	return xmlHttp;

}



function loadgamecomments(str,limitstart)

{

	var base_url = document.getElementById('base_url').value;

	

	document.getElementById('game_comments').innerHTML='<div style="clear:both; padding-top:160px; height:160px;" align="center"><img src="'+base_url+'images/loading.gif"></div>';



	xmlHttp=GetXmlHttpObject();



	if (xmlHttp==null)

	{

		alert ("Browser does not support HTTP Request");



		return;

	}



	var url=base_url+"ajaxfunctions.php";



	url=url+"?page=loadgamecomments&str="+str+"&limitstart="+limitstart;



	url=url+"&sid="+Math.random();



	xmlHttp.onreadystatechange=stateChanged4;



	xmlHttp.open("GET",url,true);



	xmlHttp.send(null);

}



function stateChanged4() 

{ 

	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")

	{ 

		document.getElementById("game_comments").innerHTML=xmlHttp.responseText;

	} 

}



function check_commentform()

{

	if(document.getElementById('newcomment').value == "" || document.getElementById('newcomment').value == "Enter text here")

	{

		alert("Please Enter Comment");

		document.getElementById('newcomment').focus();

		return false;

	}

	else

		return true;

}



function loadfavorites(str,limitstart)

{

	

	var base_url = document.getElementById('base_url').value;



	document.getElementById('user_favorites').innerHTML='<div style="clear:both; padding-top:50px; height:52px;" align="center"><img src="'+base_url+'images/loading.gif"></div>';

	xmlHttp=GetXmlHttpObject();

	if (xmlHttp==null)

	{

		alert ("Browser does not support HTTP Request");

		return;

	}



	var url= base_url+"ajaxfunctions.php";



	url=url+"?page=loadfavorites&str="+str+"&limitstart="+limitstart;



	url=url+"&sid="+Math.random();



	xmlHttp.onreadystatechange=stateChanged2;



	xmlHttp.open("GET",url,true);



	xmlHttp.send(null);

}





function stateChanged2() 

{ 

	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")

	{ 

		document.getElementById("user_favorites").innerHTML=xmlHttp.responseText;
		
		$(document).ready(function() {
		
			//Select all anchor tag with rel set to tooltip
			$('a[rel=tooltip]').mouseover(function(e) {
				
				//Grab the title attribute's value and assign it to a variable
				var tip = $(this).attr('title');	
				
				//Remove the title attribute's to avoid the native tooltip from the browser
				$(this).attr('title','');
				
				//Append the tooltip template and its value
				$(this).append('<div id="tooltip"><div class="tipHeader"></div><div class="tipBody">' + tip + '</div><div class="tipFooter"></div></div>');		
						
				//Show the tooltip with faceIn effect
				$('#tooltip').fadeIn('500');
				$('#tooltip').fadeTo('10',0.9);
				
			}).mousemove(function(e) {
			
				//Keep changing the X and Y axis for the tooltip, thus, the tooltip move along with the mouse
				$('#tooltip').css('top', e.pageY + 10 );
				$('#tooltip').css('left', e.pageX + 20 );
				
			}).mouseout(function() {
			
				//Put back the title attribute's value
				$(this).attr('title',$('.tipBody').html());
			
				//Remove the appended tooltip template
				$(this).children('div#tooltip').remove();
				
			});
		
		});

	}

}

function loadfavorites_sidebar(str,limitstart)

{

	

	var base_url = document.getElementById('base_url').value;



	document.getElementById('user_favorites_sidebar').innerHTML='<div style="clear:both; padding-top:50px; height:52px;" align="center"><img src="'+base_url+'images/loading.gif"></div>';

	xmlHttp=GetXmlHttpObject();

	if (xmlHttp==null)

	{

		alert ("Browser does not support HTTP Request");

		return;

	}



	var url= base_url+"ajaxfunctions.php";



	url=url+"?page=loadfavorites_sidebar&str="+str+"&limitstart="+limitstart;



	url=url+"&sid="+Math.random();



	xmlHttp.onreadystatechange=stateChanged12;



	xmlHttp.open("GET",url,true);



	xmlHttp.send(null);

}





function stateChanged12() 

{ 

	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")

	{ 

		document.getElementById("user_favorites_sidebar").innerHTML=xmlHttp.responseText;
		
		$(document).ready(function() {
		
			//Select all anchor tag with rel set to tooltip
			$('a[rel=tooltip]').mouseover(function(e) {
				
				//Grab the title attribute's value and assign it to a variable
				var tip = $(this).attr('title');	
				
				//Remove the title attribute's to avoid the native tooltip from the browser
				$(this).attr('title','');
				
				//Append the tooltip template and its value
				$(this).append('<div id="tooltip"><div class="tipHeader"></div><div class="tipBody">' + tip + '</div><div class="tipFooter"></div></div>');		
						
				//Show the tooltip with faceIn effect
				$('#tooltip').fadeIn('500');
				$('#tooltip').fadeTo('10',0.9);
				
			}).mousemove(function(e) {
			
				//Keep changing the X and Y axis for the tooltip, thus, the tooltip move along with the mouse
				$('#tooltip').css('top', e.pageY + 10 );
				$('#tooltip').css('left', e.pageX + 20 );
				
			}).mouseout(function() {
			
				//Put back the title attribute's value
				$(this).attr('title',$('.tipBody').html());
			
				//Remove the appended tooltip template
				$(this).children('div#tooltip').remove();
				
			});
		
		});

	}

}



function loadfriends(str,limitstart)



{

	var base_url = document.getElementById('base_url').value;



	document.getElementById('user_friends').innerHTML='<div style="clear:both; padding-top:55px; height:56px;" align="center"><img src="'+base_url+'images/loading.gif"></div>';



	xmlHttp=GetXmlHttpObject();



	if (xmlHttp==null)



	{



		alert ("Browser does not support HTTP Request");



		return;



	}



	var url=base_url+"ajaxfunctions.php";



	url=url+"?page=loadfriends&str="+str+"&limitstart="+limitstart;

	

	url=url+"&sid="+Math.random();



	xmlHttp.onreadystatechange=stateChanged3;



	xmlHttp.open("GET",url,true);



	xmlHttp.send(null);



}







function stateChanged3() 



{ 



	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")



	{ 



		document.getElementById("user_friends").innerHTML=xmlHttp.responseText;



	} 



}



function loadusercomments(str,limitstart)

{

	var base_url = document.getElementById('base_url').value;

	

	document.getElementById('user_comments').innerHTML='<div style="clear:both; padding-top:160px; height:160px;" align="center"><img src="'+base_url+'images/loading.gif"></div>';

	xmlHttp=GetXmlHttpObject();

	if (xmlHttp==null)

	{

		alert ("Browser does not support HTTP Request");

		return;

	}

	

	var url= base_url+"ajaxfunctions.php";



	url=url+"?page=loadusercomments&str="+str+"&limitstart="+limitstart;



	url=url+"&sid="+Math.random();



	xmlHttp.onreadystatechange=stateChanged5;



	xmlHttp.open("GET",url,true);



	xmlHttp.send(null);

}



function stateChanged5() 

{ 

	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")

	{ 

		document.getElementById("user_comments").innerHTML=xmlHttp.responseText;

	} 

}



function showresult(type,limitstart)

{

	if(type == 0)

		alert("Please select a sort by type");

	else

	{

		var base_url = document.getElementById('base_url').value;
		
		var catid = document.getElementById('bcatid').value;

	

		document.getElementById('bcontent').innerHTML='<div style="clear:both; padding-top:160px; height:160px;" align="center"><img src="'+base_url+'images/loading.gif"></div>';

		

		xmlHttp=GetXmlHttpObject();

		

		if (xmlHttp==null)

		{

			alert ("Browser does not support HTTP Request");

			return;

		}

		

		var url= base_url+"ajaxfunctions.php";

	

		url=url+"?page=showorderby&str="+type+"&limitstart="+limitstart+"&catid="+catid;



		url=url+"&sid="+Math.random();

	

		xmlHttp.onreadystatechange=stateChanged6;

	

		xmlHttp.open("GET",url,true);

	

		xmlHttp.send(null);

	}

}



function stateChanged6() 

{ 

	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")

	{ 

		document.getElementById("bcontent").innerHTML=xmlHttp.responseText;

	} 

}



function show_games(value)

{

	var base_url = document.getElementById('base_url').value;

	

	xmlHttp=GetXmlHttpObject();

	if (xmlHttp==null)

	{

		alert ("Browser does not support HTTP Request");

		return;

	}

	

	var url= base_url+"ajaxfunctions.php";



	url=url+"?page=show_games&str="+value;



	url=url+"&sid="+Math.random();



	xmlHttp.onreadystatechange=stateChanged7;



	xmlHttp.open("GET",url,true);



	xmlHttp.send(null);

}



function stateChanged7() 

{ 

	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")

	{ 

		document.getElementById("topsrch_list").style.display = "block";

		document.getElementById("topsrch_list").innerHTML=xmlHttp.responseText;

	} 

}
