/*************************************************************************************************************************
Copyright - Stephen D. Miller, TexasTailchaser.com 

The content on the TexasTailchaser.com and all web pages therin, including without limitation, the text, software, scripts, 
graphics, photos, sounds, videos, interactive features and the like ("Content") and the trademarks, service marks and logos 
contained therein ("Marks"), are owned by or licensed to TexasTailchaser.com, subject to copyright and other 
intellectual property rights under United States and foreign laws and international conventions. Content on the Website is provided 
to you AS IS for your information and personal use only and may not be used, copied, reproduced, distributed, transmitted, broadcast, 
displayed, sold, licensed, or otherwise exploited for any other purposes whatsoever without the prior written consent of Stephen D.Miller, TexasTailchaser.com. 
TexasTailchaser.com reserves all rights not expressly granted in and to the Website and the Content. 

Any violations are not protected, recognized, permissable, classified, or permitted under "Fair Use" and "Public Domain" claims. 

In plain english, you are not allowed to copy or download ANY of the underlying code (HTML, CSS, Javascript, AJAX, etc) for ANY use whatsoever. 
Go write your own code!!!
***************************************************************************************************************************/

var status;
function loadChaseStatus() {
	if (window.XMLHttpRequest) { // code for Mozilla, Safari, ** And Now IE 7 **, etc 
        xmlhttp=new XMLHttpRequest();
        //xmlhttp = new ActiveXObject("MSXML2.XMLHTTP.4.0");
    } else if (window.ActiveXObject) { //IE 
        xmlhttp=new ActiveXObject('Microsoft.XMLHTTP');
    }
	if (typeof(xmlhttp)=='object') {
        xmlhttp.open('GET', 'http://texastailchaser.com/livechase/status.txt', false);
        //xmlhttp.onreadystatechange=processChaseStatus;
        xmlhttp.onreadystatechange=function(){};
        xmlhttp.send(null);
        status = xmlhttp.responseText;
        //alert(status);
        loadStatus();
    }
}

function loadStatus() {
obj = document.getElementById("chaseStatus");
	if(status == "gray") {
		obj.innerHTML = "No chase planned";
		obj.className = "csGray";
		changePlayerMessage("gray");
	}
	if(status == "green") {
		obj.innerHTML = "Chase Planned Today. (streaming video off)";
		obj.className = "csGreen";
		changePlayerMessage("green");
	}
	if(status == "yellow") {
		obj.innerHTML = "CHASING! On Road To Target Area!<br>Live streaming video pending.<br><i>(Next status: approaching storm)</i>.";
		obj.className = "csYellow";
		changePlayerMessage("yellow");
	}
	if(status == "orange") {
		obj.innerHTML = "CHASING! APPROACHING STORM!! <br>Video stream is LIVE!<br><i>(Next status: storm interception.)</i>";
		obj.className = "csOrange";
		changePlayerMessage("orange");
	}
	if(status == "red") {
		obj.innerHTML = "STORM INTERCEPT IN PROGRESS!!<br>VIDEO STREAM IS ACTIVE AND LIVE!";
		obj.className = "csRed";
		changePlayerMessage("red");
	}
	if(status == "white") {
		obj.innerHTML = "Chase has ended for the day.";
		obj.className = "csWhite";
		changePlayerMessage("white");
	}		
}



function processChaseStatus() {	
	if (xmlhttp.readyState == 4 || xmlhttp.readyState == 0) {		
		if (xmlhttp.status==200) {		
			//alert('3');
			status = xmlhttp.responseText;
			//alert(status);
			obj = document.getElementById("chaseStatus");
			if(status == "gray") {
				obj.innerHTML = "No chase planned";
				obj.className = "csGray";
			}
			if(status == "green") {
				obj.innerHTML = "Chase Planned Today.";
				obj.className = "csGreen";
			}
			if(status == "yellow") {
				obj.innerHTML = "Chase! On the Road!";
				obj.className = "csYellow";
			}
			if(status == "orange") {
				obj.innerHTML = "Chase! Approaching Storm! Video Streaming!";
				obj.className = "csOrange";
			}
			if(status == "red") {
				obj.innerHTML = "Chase! On The Storm! Video Streaming!";
				obj.className = "csRed";
			}		
				
		}else{
			alert("ERROR GETTING STATUS");
		}		
	}
}	