// This JavaScript allows you to connect via AJAX to another PHP script and retrive the information for seeing other tips without reloading the page.
// © 2008 RunescapeTips For use on RunescapeTips.net only.
// Written by Star Wars Fanatic
// Created April 8, 2008
// Last Edited April 8, 2008

// Browser Support Code
function get_tip ( tip_id )	{
	var ajaxRequest ;	// The variable that makes Ajax possible!
	var url = "http://runescapetips.org/tips/get_tip.php?tip_id=" + tip_id
	
	// Browser detection code start.
	// Because there are different browsers that require different JavaScript code to create the AJAX object,
	// we have to rty several different statements before we can get the object made.
	try	{	// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest ( ) ;
	}
	catch ( e )	{	// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject ( "Msxml2.XMLHTTP" ) ;
		}
		catch ( e )	{
			try	{
				ajaxRequest = new ActiveXObject ( "Microsoft.XMLHTTP" ) ;
			}
			catch ( e )	{	// Their browser is too old to use AJAX.
				alert ( "Your browser is too old! Please update it to the latest version." ) ;
				return false ;
			}
		}
	}
	// Browser detection code end.
	
	// Create a function that will receive data sent from the server
	ajaxRequest . onreadystatechange = function ( )	{
		if ( ajaxRequest . readyState == 4 )	{
			
			var tip = document . getElementById ( 'tip' ) ;	// This will get the tip id and point it to the correct place.
			tip . innerHTML = ajaxRequest . responseText ;	// This displays the tip info in the spot!
			
		}
	}
	ajaxRequest . open ( "GET" , url , true ) ;
	ajaxRequest . send ( null ) ; 
	
	
}