 // Update loop value

//Gets the browser specific XmlHttpRequest Object
function getXmlHttpRequestObject() {
    if (window.XMLHttpRequest) {
        return new XMLHttpRequest();
    } else if(window.ActiveXObject) {
        return new ActiveXObject("Microsoft.XMLHTTP");
    } else {
        alert("Your Browser does not support AJAX!\nIt's about time to upgrade don't you think?");
    }
}


//XmlHttpRequest object to get the auto suggest
//searchReq
var httpRequestObj = getXmlHttpRequestObject();
var tabName;

//0	The request is not initialized
//1	The request has been set up
//2	The request has been sent
//3	The request is in process
//4	The request is complete

function getContent(file)
{
    if (httpRequestObj.readyState == 4 || httpRequestObj.readyState == 0) 
	{
		tabName = file;
		
		//Get file which is stored in the relative include folder
        httpRequestObj.open("GET", "include/" + file, true);
		
		//Do not use () for the handler reference
        httpRequestObj.onreadystatechange = handleContentChange; 
		
		//Send GET... null becuase we did not send a POST
        httpRequestObj.send(null);	
    }        	
}


function handleContentChange()
{
	if (httpRequestObj.readyState == 4) 
	{
		// Get a reference to the content div
		var divContent = document.getElementById('contentWrapper');
		
		//Get response and fill the content div
		var str = httpRequestObj.responseText;
		divContent.innerHTML = str;
		
		resetTabs();
		
		var content = tabName.split('.');
		//alert(content[0]);
		//if (tabName[0] == 'specs.php')
		//{
			//alert("Wow");
			var tab = document.getElementById(content[0]);
			tab.className = "selected";
			
			//Get the current tab from the hidden field
			var currentTab = document.getElementById('currentTab')
			currentTab.value = content[0];
			//tab.style.color = 'black'; 
			//tab.style.backgroundColor = 'white';
			//tab.style.borderTopColor = 'green';
			//document.getElementById("myP").className = "myC"
		//}

    }
}

function resetTabs()
{
	
	var tab = document.getElementById('overview');
	tab.className = "";
	
	var tab = document.getElementById('resources');
	tab.className = "";
	
	var tab = document.getElementById('faq');
	tab.className = "";
	
	var tab = document.getElementById('accessories');
	tab.className = "";
	
	var tab = document.getElementById('specs');
	tab.className = "";
	
	tab = document.getElementById('purchase');
	tab.className = "";
	
	tab = document.getElementById('images');
	tab.className = "";
	
	tab = document.getElementById('advantages');
	tab.className = "";
	
	tab = document.getElementById('controllers');
	tab.className = "";

}


function showHide(faqId)
{
	//alert(faqId);
	var div = document.getElementById(faqId);
	div.style.display = (div.style.display=="block")?"none":"block";
	//div.display="block";
}

//function getCurrentTab()
//{
//	// Get a reference to the currentTab hidden textbox
//	var currentTab = document.getElementById('currentTab');
//	return(currentTab);	
//}

/*
//Called from setInterval every X seconds
function getLoopValue(username) {
	
    if (httpRequestObj.readyState == 4 || httpRequestObj.readyState == 0) {

		//Setup the object
        httpRequestObj.open("GET", "bll/getLoopValue.php?username=" + username, true);
		
		//Do not use () for the handler reference
        httpRequestObj.onreadystatechange = handleStateChange; 
		
		//Send GET... null becuase we did not send a POST
        httpRequestObj.send(null);	
    }        
}


//AJAX response handler
function handleStateChange() {
	
    if (httpRequestObj.readyState == 4) {
		// Get a reference to the the loop textbox
        var loop = document.getElementById('txtloop2');
		//var statusSpan = document.getElementById('spanStatus');
		var str = httpRequestObj.responseText.split("\n");
		loop.value = str[0];
		//statusSpan.innerText = str[1];
    }
}

function getInstrumentPanel() {
	
	if (httpRequestObj.readyState == 4 || httpRequestObj.readyState == 0) {

		//Ading the date and time to the querysting does nothing but make the 
		//URL unique so silly IE does not cache try to cache the URL.  Holly crap that was a 
		//pain in ass to figure out!  Thanks IE...
		var url = "../bll/getInstrumentPanel.php?id=iecachefix" + "&ms=" + new Date().getTime();

		//Setup the object
        httpRequestObj.open("GET", url, true);
		
		//Do not use () for the handler reference
        httpRequestObj.onreadystatechange = handleInstrumentChange; 
		
		//Send GET... null becuase we did not send a POST
        httpRequestObj.send(null);	
    } 
}

function handleInstrumentChange() {

    if (httpRequestObj.readyState == 4) {
		// Get a reference to the the loop textbox
        var divInstrumentPanel = document.getElementById('instrumentPanel');

		var str = httpRequestObj.responseText;
		divInstrumentPanel.innerHTML = str;

    }
}

//Button Commands
function executeMove(file) {
	//alert(file + " Test!");
	var httpRequest = getXmlHttpRequestObject();
	
	//The date time function is needed so silly IE does not cache the page.
	var url = "../bll/setMoveRequest.php?filename=" + file + "&ms=" + new Date().getTime();
	
	httpRequest.open("GET", url + file, true);	
	httpRequest.send(null);
	
	//if (httpRequest.readyState == 4 || httpRequest.readyState == 0) {}
	
	
}*/