
function theaterSearch(theaterId, day) {
	document.getElementById('today').style.textDecoration="underline";
	document.getElementById('tomorrow').style.textDecoration="underline";
	document.getElementById('2days').style.textDecoration="underline";

	document.getElementById(day).style.textDecoration="none";
	
	loadData("/sp?p=/results/theater_showtimes&theaterId=" + theaterId + "&day="+day);
}

function movieSearch(movieId, day) {
	document.getElementById('today').style.textDecoration="underline";
	document.getElementById('tomorrow').style.textDecoration="underline";
	document.getElementById('2days').style.textDecoration="underline";
	document.getElementById(day).style.textDecoration="none";
	
	loadData("/sp?p=/results/movie_showtimes&movieId=" + movieId + "&day="+day);
	
}


function loadData(url) {
	try {
		// branch for native XMLHttpRequest object
    	if (window.XMLHttpRequest) {
	        xmlhttp = window.XMLHttpRequest?new XMLHttpRequest:'';
	        //alert('before processReqChange');
    	    xmlhttp.onreadystatechange = processReqChange;
        	xmlhttp.open("GET", url, true);
	        xmlhttp.send("");

    	// branch for IE/Windows ActiveX version
	    } else if (window.ActiveXObject) {
    	    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        	isIE = true;
	        if (xmlhttp) {
	    	    xmlhttp.onreadystatechange = processReqChange;
	        	xmlhttp.open("GET", url, true);
		        xmlhttp.send("");
	        }
    	}
	} catch (e) {
		alert('Sorry, your browser does not support this functionality');
	}
	
	return;
}

function processReqChange() {
	// if the readyState code is 4 (Completed)  
	// and http status is 200 (OK) we go ahead and get the responseText  
	// other readyState codes:  
	// 0=Uninitialised 1=Loading 2=Loaded 3=Interactive
	//alert(xmlhttp.readyState);

	//if (xmlhttp.readyState == 1) {
	//	document.getElementById("results").innerHTML = "<div style='padding:10px 0 10px 230px; text-align:left' >Searching...</div>";
	//}

    if (xmlhttp.readyState == 4) {
		try {
	    	if (xmlhttp.status == 200) {
	    		//alert("good");
				document.getElementById("results").innerHTML = xmlhttp.responseText;
			} else {
				//alert("bad");
				document.getElementById("results").innerHTML = "";
			}
		} catch (err) {
			//alert(err);
		}
    }
}
