// JavaScript Document
function EmbedVideo(url, width, height)
{
	document.write("<object width=\"" + width + "\" height=\"" + height + "\"><param name=\"movie\" value=\"" + url + "\"></param><param name=\"allowFullScreen\" value=\"true\"></param><param name=\"allowscriptaccess\" value=\"always\"></param><embed src=\"" + url + "\" type=\"application/x-shockwave-flash\" allowscriptaccess=\"always\" allowfullscreen=\"true\" width=\"" + width + "\" height=\"" + height + "\"></embed></object>");
}
function SwitchTab(tab, id)
{
	var query = "tab=" + tab;
	var links = document.getElementById(id + "tabs").getElementsByTagName("a");
	document.getElementById('loadingimg').style.display = "block";
	for (var i=0; i<links.length; i++)
	{
		links[i].className = "";
	}
	document.getElementById(tab).className = "down";
	ajaxFunction(query, "switch_tab.php", "TabChange(response, '" + id + "')");
}
function TabChange(response, id)
{
	document.getElementById(id).innerHTML = response;
	document.getElementById('loadingimg').style.display = "none";
}
function ToggleComments(lnk)
{
	var cbox = document.getElementById("commentsbox");
	if (cbox.style.display == "none")
	{
		cbox.style.display = "block";
		lnk.innerHTML = "Hide Comments";
	}
	else
	{
		cbox.style.display = "none";
		lnk.innerHTML = "Show Comments";
	}
}
function ajaxFunction(query, script, func)
{
	var ajaxRequest;
	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("An error has occurred");
				return false;
			}
		}
	}
	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
		if (ajaxRequest.readyState == 4){
			var response = ajaxRequest.responseText;
			eval(func);
		}
	}
	
	ajaxRequest.open("POST", "scripts/" + script, true);
	ajaxRequest.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	ajaxRequest.setRequestHeader("Content-Length", query.length);
	ajaxRequest.send(query);
}