function get_ajax_obj(){
	var ajaxRequest;  // The variable that makes Ajax possible!	
	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){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	return ajaxRequest;
}

function get_content(url){
    var ajaxRequest = get_ajax_obj();
	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		if(ajaxRequest.readyState == 4){
			var ajaxDisplay = document.getElementById('content');
			ajaxDisplay.innerHTML = ajaxRequest.responseText;
		}
		if(ajaxRequest.readyState == 3){
			var ajaxDisplay = document.getElementById('content');
			ajaxDisplay.innerHTML = '<h1>Loading .. .. ..</h1><br/><img src="/loading.gif"/>';
		}
		if(ajaxRequest.readyState == 2){
		    var ajaxDisplay = document.getElementById('content');
			ajaxDisplay.innerHTML = '<h1>Loading .. ..</h1><br/><img src="/loading.gif"/>';
		}
		if(ajaxRequest.readyState == 1){
		    var ajaxDisplay = document.getElementById('content');
			ajaxDisplay.innerHTML = '<h1>Loading ..</h1><br/><img src="/loading.gif"/>';
		}	
	}

	var queryString = "?url=" + url;
	ajaxRequest.open("GET", "http://freeflashgamezone.com/getcontent.php" + queryString, true);
	ajaxRequest.send(null); 
}

function SelectAll(id)
{
    document.getElementById(id).focus();
    document.getElementById(id).select();
}

function updatecode(form){
	var h = form.h.value;
	var w = form.w.value;
	var code = form.embed.value;
	code = code.replace(/width="[0-9]+"/ig,'width="'+w+'"');
	code = code.replace(/height="[0-9]+"/ig,'height="'+h+'"');
	form.embed.value = code;
	alert("Code Updated Please Copy");
	return false;
}

function add_relevant(currentid,targetid){
	if (window.XMLHttpRequest)
	{// code for IE7+, Firefox, Chrome, Opera, Safari
	xmlhttp=new XMLHttpRequest();
	}
	else
	{// code for IE6, IE5
	xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
    xmlhttp.onreadystatechange=function(){
   if (xmlhttp.readyState==4)
    {
	 //alert(xmlhttp.status);
     //alert(xmlhttp.responseText);
    }
    }
	xmlhttp.open("GET", "/functions1.php?func=relevant&cid="+currentid+"&tid="+targetid, false);
	xmlhttp.send(); 
}

function add_views(id){
	if (window.XMLHttpRequest)
	{// code for IE7+, Firefox, Chrome, Opera, Safari
	xmlhttp=new XMLHttpRequest();
	}
	else
	{// code for IE6, IE5
	xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	xmlhttp.open("GET", "/functions1.php?func=add_views&pid="+id);
	xmlhttp.send(); 
}

