//create ajax object
function create_ajax() {
	var xml_http=false;
	try {
		xml_http = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
		try {
			xml_http = new ActiveXObject("Microsoft.XMLHTTP");
		} catch (E) {
			xml_http = false;
		}
	}
	if (!xml_http && typeof XMLHttpRequest!='undefined') {
		xml_http = new XMLHttpRequest();
	}
	return xml_http;
}


//refresh the header
function refresh_header() {
	xml_http = create_ajax();
	if (xml_http) {
		url = encodeURI("./header_nav.php");
		xml_http.open("GET",url,true);
		xml_http.onreadystatechange=function() {
			if (xml_http.readyState == 4) {
				document.getElementById('h').innerHTML = xml_http.responseText;
			}
		}
		xml_http.send(null);
	}
}


//login. wildly secure.
function login(u_name,password) {
	xml_http = create_ajax();
	if (xml_http) {
		url = encodeURI("./do_stuff.php?do_login=1&u_name="+u_name+"&password="+password);
		xml_http.open("GET",url,true);
		xml_http.onreadystatechange=function() {
			if (xml_http.readyState == 4) {
				document.getElementById('stuff').innerHTML = xml_http.responseText;
				refresh_header();
			}
		}
		xml_http.send(null);
	}
}


//load a player
function refresh_player(theme_id) {
	xml_http = create_ajax();
	if (xml_http) {
		url = encodeURI("./playlist.php?theme="+theme_id);
		xml_http.open("GET",url,true);
		xml_http.onreadystatechange=function() {
			if (xml_http.readyState == 4) {
				document.getElementById('player_container').innerHTML = xml_http.responseText;
			}
		}
		xml_http.send(null);
	}
}
