function ShowNewImage(divID, imageid) {
	if (XMLHttpRequestObject) {
		var obj = document.getElementById(divID);
		
		if (imageid == '') {
			alert("Image Error - Could not load image.");
			return false;
		} else {
			// Must tell it that we are opening it in POST format
			XMLHttpRequestObject.open("POST", "/users.php?do=shownewimage", true);
			// Also tell if which content-type
			XMLHttpRequestObject.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			
			// Create a null function
			XMLHttpRequestObject.onreadystatechange = function() {
				// Check to make sure download is 100% ready
				// 200 to make sure download is ready
				if (XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200) {
					obj.innerHTML = XMLHttpRequestObject.responseText;
				}	
			}
			
			XMLHttpRequestObject.send("imageid=" + encodeURI(imageid));
		}
	}
}



function LogoutNow() {
	if (XMLHttpRequestObject) {
		DisplayWin("OpenLogout", "400");
		obj = document.getElementById("OpenLogout");
	
		// Must tell it that we are opening it in POST format
		XMLHttpRequestObject.open("POST", "/users.php?do=showlogout", true);
		// Also tell if which content-type
		XMLHttpRequestObject.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		
		// Create a null function
		XMLHttpRequestObject.onreadystatechange = function() {
			// Check to make sure download is 100% ready
			// 200 to make sure download is ready
			if (XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200) {
				obj.innerHTML = XMLHttpRequestObject.responseText;
			}	
		}
		
		XMLHttpRequestObject.send(null);
	}
}

function LoginNow() {
	if (XMLHttpRequestObject) {
		DisplayWin("OpenLogin", "400");
		obj = document.getElementById("OpenLogin");
	
		// Must tell it that we are opening it in POST format
		XMLHttpRequestObject.open("POST", "/users.php?do=showlogin", true);
		// Also tell if which content-type
		XMLHttpRequestObject.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		
		// Create a null function
		XMLHttpRequestObject.onreadystatechange = function() {
			// Check to make sure download is 100% ready
			// 200 to make sure download is ready
			if (XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200) {
				obj.innerHTML = XMLHttpRequestObject.responseText;
			}	
		}
		
		XMLHttpRequestObject.send(null);
	}
}

function RegisterNow() {
	if (XMLHttpRequestObject) {
		DisplayWin("OpenRegister", "500");
		obj = document.getElementById("OpenRegister");
	
		// Must tell it that we are opening it in POST format
		XMLHttpRequestObject.open("POST", "/users.php?do=showregister", true);
		// Also tell if which content-type
		XMLHttpRequestObject.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		
		// Create a null function
		XMLHttpRequestObject.onreadystatechange = function() {
			// Check to make sure download is 100% ready
			// 200 to make sure download is ready
			if (XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200) {
				obj.innerHTML = XMLHttpRequestObject.responseText;
			}	
		}
		
		XMLHttpRequestObject.send(null);
	}
}

// add to favs
function addtofav(divID, movieid) {
	if (XMLHttpRequestObject) {
		var obj = document.getElementById(divID);

		// Must tell it that we are opening it in POST format
		XMLHttpRequestObject.open("POST", "/user.php?do=addtofav", true);
		// Also tell if which content-type
		XMLHttpRequestObject.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		
		// Create a null function
		XMLHttpRequestObject.onreadystatechange = function() {
			// Check to make sure download is 100% ready
			// 200 to make sure download is ready
			if (XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200) {
				// Respond with error code / response in divid
				obj.innerHTML = "Completed";

			}	
		}
		
		XMLHttpRequestObject.send("movieid=" + encodeURI(movieid));
	}
}

function addaffiliate() {
	var title = document.getElementById("name").value;
	var image = document.getElementById("image").value;
	var url = document.getElementById("url").value;
	
	if (title == '' || image == '' || url == '') {
		alert("Please enter all fields.");
		return false;
	} else {
		return true;
	}
}

function StartVOTD(divID) {
	if (XMLHttpRequestObject) {
		var obj = document.getElementById(divID);

		// Must tell it that we are opening it in POST format
		XMLHttpRequestObject.open("POST", "/movies.php?do=votd", true);
		// Also tell if which content-type
		XMLHttpRequestObject.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		
		// Create a null function
		XMLHttpRequestObject.onreadystatechange = function() {
			// Check to make sure download is 100% ready
			// 200 to make sure download is ready
			if (XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200) {
				// Respond with error code / response in divid
				obj.innerHTML = XMLHttpRequestObject.responseText;;

			}	
		}
		
		XMLHttpRequestObject.send(null);
	}
}
