// JavaScript Document
function checklogin() 
{ 
	if ((document.getElementById("user-login-username")==null) || (document.getElementById("user-login-username").value.length == 0)) {
		alert("Please enter a username");
		document.getElementById("user-login-username").focus();
		document.getElementById("user-login-username").style.backgroundColor = '#ffffcc';	
		return false;
	}
	if ((document.getElementById("user-login-userpassword")==null) || (document.getElementById("user-login-userpassword").value.length == 0)) {
		alert("Please enter your password");
		document.getElementById("user-login-userpassword").focus();
		document.getElementById("user-login-userpassword").style.backgroundColor = '#ffffcc';	
		return false;
	}
	
	document.getElementById("user-login-form").submit();
} 

function checkjoin()	{
	$username 		= document.getElementById("user-add-username");
	$useremail 		= document.getElementById("user-add-useremail").value;
	$userpassword1 	= document.getElementById("user-add-userpassword1").value;
	$userpassword2 	= document.getElementById("user-add-userpassword2").value;
	
/***** Check for NULL values *****/
	if ((document.getElementById("user-add-username")==null) || (document.getElementById("user-add-username").value.length == 0)) {
		alert("Please enter a username");
		document.getElementById("user-add-username").focus();
		document.getElementById("user-add-username").style.backgroundColor = '#ffffcc';	
		return false;
	}
	if ((document.getElementById("user-add-useremail")==null) || (document.getElementById("user-add-useremail").value.length == 0)) {
		alert("Please enter your email address");
		document.getElementById("user-add-useremail").focus();
		document.getElementById("user-add-useremail").style.backgroundColor = '#ffffcc';	
		return false;
	}
	if ((document.getElementById("user-add-userpassword1")==null) || (document.getElementById("user-add-userpassword1").value.length == 0)) {
		alert("Please enter a password");
		document.getElementById("user-add-userpassword1").focus();
		document.getElementById("user-add-userpassword1").style.backgroundColor = '#ffffcc';	
		return false;
	}
	if ((document.getElementById("user-add-userpassword2")==null) || (document.getElementById("user-add-userpassword2").value.length == 0)) {
		alert("Please retype your password");
		document.getElementById("user-add-userpassword2").focus();
		document.getElementById("user-add-userpassword2").style.backgroundColor = '#ffffcc';	
		return false;
	}
	
/***** Check for username length values *****/
	if ((document.getElementById("user-add-username").value.length < 4) || (document.getElementById("user-add-username").value.length > 15)) {
		alert("Username must be between 4 and 15 characters in length");
		document.getElementById("user-add-username").focus();
		document.getElementById("user-add-username").style.backgroundColor = '#ffffcc';	
		return false;
	}
	
/***** Check for password match *****/
	if ((document.getElementById("user-add-userpassword1").value) != (document.getElementById("user-add-userpassword2").value)) {
		alert("Passwords do not match");
		document.getElementById("user-add-userpassword1").focus();
		document.getElementById("user-add-userpassword1").style.backgroundColor = '#ffffcc';	
		document.getElementById("user-add-userpassword2").style.backgroundColor = '#ffffcc';	
		return false;
	}
	
/***** Check for password length values *****/
	if ((document.getElementById("user-add-userpassword1").value.length < 4) || (document.getElementById("user-add-userpassword1").value.length > 15)) {
		alert("Password must be between 6 and 15 characters in length");
		document.getElementById("user-add-userpassword1").focus();
		document.getElementById("user-add-userpassword1").style.backgroundColor = '#ffffcc';	
		return false;
	}
//alert($useremail.indexOf("."));
//alert($useremail.indexOf("@"));

/***** Check for valid email address *****/
	if (($useremail.indexOf(".") < 1) && ($useremail.indexOf("@") < 1)) {
		alert("Please enter a valid email address");
		document.getElementById("user-add-useremail").focus();
		document.getElementById("user-add-useremail").style.backgroundColor = '#ffffcc';	
		return false;
	}

document.getElementById("user-add-form").submit();
}
	

function showdetails(showID, pageID) 
{ 
	if (pageID == 0) pageUrl = "/content/shows-details.php?showID="+showID;
	if (pageID == 1) pageUrl = "/content/shows-add.php?showID="+showID;
	if (pageID == 2) pageUrl = "/content/users/users-add.php";
	if (pageID == 3) pageUrl = "/content/users/users-login.php";
	if (pageID == 4) pageUrl = "/content/shows-add.php";

	try 
	{
		showdetails_xmlhttp = window.XMLHttpRequest?new XMLHttpRequest(): new ActiveXObject("Msxml2.XMLHTTP"); 
	} 
	
	catch (e) 
	{ 
		// browser doesn't support ajax. handle however you want  
	} 
	
	showdetails_xmlhttp.onreadystatechange = showdetails_triggered; 
	showdetails_xmlhttp.open("GET", pageUrl); 
	showdetails_xmlhttp.send(null);
} 

function showdetails_triggered() 
{ 
	if ((showdetails_xmlhttp.readyState == 4) && (showdetails_xmlhttp.status == 200)) 
	{
		document.getElementById("show-details-wrapper").innerHTML = showdetails_xmlhttp.responseText;
		document.getElementById("show-details-wrapper").style.display = 'block';
		document.getElementById("inner-wrapper").style.opacity = .4;
		document.getElementById("inner-wrapper").style.MozOpacity = .4;
		document.getElementById("inner-wrapper").style.KhtmlOpacity = .4;
		document.getElementById("header").style.opacity = .4;
		document.getElementById("header").style.MozOpacity = .4;
		document.getElementById("header").style.KhtmlOpacity = .4;
		document.getElementById("footer").style.opacity = .4;
		document.getElementById("footer").style.MozOpacity = .4;
		document.getElementById("footer").style.KhtmlOpacity = .4;
		//document.getElementById("inner-wrapper").style.filter =  "alpha(opacity='40')";
	}
}

function hidedetails()
{
	document.getElementById("inner-wrapper").style.opacity = 1;
	document.getElementById("inner-wrapper").style.MozOpacity = 1;
	document.getElementById("inner-wrapper").style.KhtmlOpacity = 1;
	document.getElementById("header").style.opacity = 1;
	document.getElementById("header").style.MozOpacity = 1;
	document.getElementById("header").style.KhtmlOpacity = 1;
	document.getElementById("footer").style.opacity = 1;
	document.getElementById("footer").style.MozOpacity = 1;
	document.getElementById("footer").style.KhtmlOpacity = 1;
	//document.getElementById("inner-wrapper").style.filter =  "alpha(opacity='100')";
	document.getElementById("show-details-wrapper").style.display = 'none';

}

function addFav(showID, userID) 
{ 
	status = document.getElementById("favorite"+showID).title ;

	if (status == "My Favorite") {
			checked = 0;
			document.getElementById("favorite"+showID).src = "/images/award_star_gold-bw.png";
			document.getElementById("favorite"+showID).title = "Add to Favorites";
		} else {
			checked = 1;
			document.getElementById("favorite"+showID).src = "/images/award_star_gold.png";
			document.getElementById("favorite"+showID).title = "My Favorite";
	}
	
	url = "/content/fav-add.php?showID="+showID+"&userID="+userID+"&checked="+checked;
	
	try 
	{
		addfav_xmlhttp = window.XMLHttpRequest?new XMLHttpRequest(): new ActiveXObject("Msxml2.XMLHTTP"); 
	} 
	
	catch (e) 
	{ 
		// browser doesn't support ajax. handle however you want  
	} 
	
	addfav_xmlhttp.onreadystatechange = addfav_triggered; 
	addfav_xmlhttp.open("GET", url); 
	addfav_xmlhttp.send(null);	
}

function addfav_triggered() {

	if ((addfav_xmlhttp.readyState == 4) && (addfav_xmlhttp.status == 200)) 
	{
	}	
}

function rateshow(starID, userID, showID)	{
	
	ratingurl = "/content/rating-add.php?showID="+showID+"&userID="+userID+"&starID="+starID;	

	try 
	{
		rateshow_xmlhttp = window.XMLHttpRequest?new XMLHttpRequest(): new ActiveXObject("Msxml2.XMLHTTP"); 
	} 
	catch (e) 
	{ 
		// browser doesn't support ajax. handle however you want  
	} 
	
	rateshow_xmlhttp.onreadystatechange = function rateshow_triggered () {
		if ((rateshow_xmlhttp.readyState == 4) && (rateshow_xmlhttp.status == 200)) 
		{
			if (starID == "star1") {
				document.getElementById("star1").style.opacity = 1;
				document.getElementById("star1").style.MozOpacity = 1;
				document.getElementById("star1").style.KhtmlOpacity = 1;
				document.getElementById("star1").style.filter =  "alpha(opacity='100')";
				document.getElementById("star2").style.opacity = .2;
				document.getElementById("star2").style.MozOpacity = .2;
				document.getElementById("star2").style.KhtmlOpacity = .2;
				document.getElementById("star2").style.filter =  "alpha(opacity='20')";
				document.getElementById("star3").style.opacity = .2;
				document.getElementById("star3").style.MozOpacity = .2;
				document.getElementById("star3").style.KhtmlOpacity = .2;
				document.getElementById("star3").style.filter =  "alpha(opacity='20')";
				document.getElementById("star4").style.opacity = .2;
				document.getElementById("star4").style.MozOpacity = .2;
				document.getElementById("star4").style.KhtmlOpacity = .2;
				document.getElementById("star4").style.filter =  "alpha(opacity='20')";
				document.getElementById("star5").style.opacity = .2;
				document.getElementById("star5").style.MozOpacity = .2;
				document.getElementById("star5").style.KhtmlOpacity = .2;
				document.getElementById("star5").style.filter =  "alpha(opacity='20')";
			}
			if (starID == "star2") {
				document.getElementById("star1").style.opacity = 1;
				document.getElementById("star1").style.MozOpacity = 1;
				document.getElementById("star1").style.KhtmlOpacity = 1;
				document.getElementById("star1").style.filter =  "alpha(opacity='100')";
				document.getElementById("star2").style.opacity = 1;
				document.getElementById("star2").style.MozOpacity = 1;
				document.getElementById("star2").style.KhtmlOpacity = 1;
				document.getElementById("star2").style.filter =  "alpha(opacity='100')";
				document.getElementById("star3").style.opacity = .2;
				document.getElementById("star3").style.MozOpacity = .2;
				document.getElementById("star3").style.KhtmlOpacity = .2;
				document.getElementById("star3").style.filter =  "alpha(opacity='20')";
				document.getElementById("star4").style.opacity = .2;
				document.getElementById("star4").style.MozOpacity = .2;
				document.getElementById("star4").style.KhtmlOpacity = .2;
				document.getElementById("star4").style.filter =  "alpha(opacity='20')";
				document.getElementById("star5").style.opacity = .2;
				document.getElementById("star5").style.MozOpacity = .2;
				document.getElementById("star5").style.KhtmlOpacity = .2;
				document.getElementById("star5").style.filter =  "alpha(opacity='20')";
			}
			if (starID == "star3") {
				document.getElementById("star1").style.opacity = 1;
				document.getElementById("star1").style.MozOpacity = 1;
				document.getElementById("star1").style.KhtmlOpacity = 1;
				document.getElementById("star1").style.filter =  "alpha(opacity='100')";
				document.getElementById("star2").style.opacity = 1;
				document.getElementById("star2").style.MozOpacity = 1;
				document.getElementById("star2").style.KhtmlOpacity = 1;
				document.getElementById("star2").style.filter =  "alpha(opacity='100')";
				document.getElementById("star3").style.opacity = 1;
				document.getElementById("star3").style.MozOpacity = 1;
				document.getElementById("star3").style.KhtmlOpacity = 1;
				document.getElementById("star3").style.filter =  "alpha(opacity='100')";
				document.getElementById("star4").style.opacity = .2;
				document.getElementById("star4").style.MozOpacity = .2;
				document.getElementById("star4").style.KhtmlOpacity = .2;
				document.getElementById("star4").style.filter =  "alpha(opacity='20')";
				document.getElementById("star5").style.opacity = .2;
				document.getElementById("star5").style.MozOpacity = .2;
				document.getElementById("star5").style.KhtmlOpacity = .2;
				document.getElementById("star5").style.filter =  "alpha(opacity='20')";
			}
			if (starID == "star4") {
				document.getElementById("star1").style.opacity = 1;
				document.getElementById("star1").style.MozOpacity = 1;
				document.getElementById("star1").style.KhtmlOpacity = 1;
				document.getElementById("star1").style.filter =  "alpha(opacity='100')";
				document.getElementById("star2").style.opacity = 1;
				document.getElementById("star2").style.MozOpacity = 1;
				document.getElementById("star2").style.KhtmlOpacity = 1;
				document.getElementById("star2").style.filter =  "alpha(opacity='100')";
				document.getElementById("star3").style.opacity = 1;
				document.getElementById("star3").style.MozOpacity = 1;
				document.getElementById("star3").style.KhtmlOpacity = 1;
				document.getElementById("star3").style.filter =  "alpha(opacity='100')";
				document.getElementById("star4").style.opacity = 1;
				document.getElementById("star4").style.MozOpacity = 1;
				document.getElementById("star4").style.KhtmlOpacity = 1;
				document.getElementById("star4").style.filter =  "alpha(opacity='100')";
				document.getElementById("star5").style.opacity = .2;
				document.getElementById("star5").style.MozOpacity = .2;
				document.getElementById("star5").style.KhtmlOpacity = .2;
				document.getElementById("star5").style.filter =  "alpha(opacity='20')";
			}
			if (starID == "star5") {
				document.getElementById("star1").style.opacity = 1;
				document.getElementById("star1").style.MozOpacity = 1;
				document.getElementById("star1").style.KhtmlOpacity = 1;
				document.getElementById("star1").style.filter =  "alpha(opacity='100')";
				document.getElementById("star2").style.opacity = 1;
				document.getElementById("star2").style.MozOpacity = 1;
				document.getElementById("star2").style.KhtmlOpacity = 1;
				document.getElementById("star2").style.filter =  "alpha(opacity='100')";
				document.getElementById("star3").style.opacity = 1;
				document.getElementById("star3").style.MozOpacity = 1;
				document.getElementById("star3").style.KhtmlOpacity = 1;
				document.getElementById("star3").style.filter =  "alpha(opacity='100')";
				document.getElementById("star4").style.opacity = 1;
				document.getElementById("star4").style.MozOpacity = 1;
				document.getElementById("star4").style.KhtmlOpacity = 1;
				document.getElementById("star4").style.filter =  "alpha(opacity='100')";
				document.getElementById("star5").style.opacity = 1;
				document.getElementById("star5").style.MozOpacity = 1;
				document.getElementById("star5").style.KhtmlOpacity = 1;
				document.getElementById("star5").style.filter =  "alpha(opacity='100')";
			}
		}
	}
	rateshow_xmlhttp.open("GET", ratingurl); 
	rateshow_xmlhttp.send(null);	
}


function setrating(level)	{
	if (level == "1") {
		document.getElementById("star1").style.opacity = 1;
		document.getElementById("star1").style.MozOpacity = 1;
		document.getElementById("star1").style.KhtmlOpacity = 1;
		document.getElementById("star1").style.filter =  "alpha(opacity='100')";
		document.getElementById("star2").style.opacity = .2;
		document.getElementById("star2").style.MozOpacity = .2;
		document.getElementById("star2").style.KhtmlOpacity = .2;
		document.getElementById("star2").style.filter =  "alpha(opacity='20')";
		document.getElementById("star3").style.opacity = .2;
		document.getElementById("star3").style.MozOpacity = .2;
		document.getElementById("star3").style.KhtmlOpacity = .2;
		document.getElementById("star3").style.filter =  "alpha(opacity='20')";
		document.getElementById("star4").style.opacity = .2;
		document.getElementById("star4").style.MozOpacity = .2;
		document.getElementById("star4").style.KhtmlOpacity = .2;
		document.getElementById("star4").style.filter =  "alpha(opacity='20')";
		document.getElementById("star5").style.opacity = .2;
		document.getElementById("star5").style.MozOpacity = .2;
		document.getElementById("star5").style.KhtmlOpacity = .2;
		document.getElementById("star5").style.filter =  "alpha(opacity='20')";
	}
	if (level == "2") {
		document.getElementById("star1").style.opacity = 1;
		document.getElementById("star1").style.MozOpacity = 1;
		document.getElementById("star1").style.KhtmlOpacity = 1;
		document.getElementById("star1").style.filter =  "alpha(opacity='100')";
		document.getElementById("star2").style.opacity = 1;
		document.getElementById("star2").style.MozOpacity = 1;
		document.getElementById("star2").style.KhtmlOpacity = 1;
		document.getElementById("star2").style.filter =  "alpha(opacity='100')";
		document.getElementById("star3").style.opacity = .2;
		document.getElementById("star3").style.MozOpacity = .2;
		document.getElementById("star3").style.KhtmlOpacity = .2;
		document.getElementById("star3").style.filter =  "alpha(opacity='20')";
		document.getElementById("star4").style.opacity = .2;
		document.getElementById("star4").style.MozOpacity = .2;
		document.getElementById("star4").style.KhtmlOpacity = .2;
		document.getElementById("star4").style.filter =  "alpha(opacity='20')";
		document.getElementById("star5").style.opacity = .2;
		document.getElementById("star5").style.MozOpacity = .2;
		document.getElementById("star5").style.KhtmlOpacity = .2;
		document.getElementById("star5").style.filter =  "alpha(opacity='20')";
	}
	if (level == "3") {
		document.getElementById("star1").style.opacity = 1;
		document.getElementById("star1").style.MozOpacity = 1;
		document.getElementById("star1").style.KhtmlOpacity = 1;
		document.getElementById("star1").style.filter =  "alpha(opacity='100')";
		document.getElementById("star2").style.opacity = 1;
		document.getElementById("star2").style.MozOpacity = 1;
		document.getElementById("star2").style.KhtmlOpacity = 1;
		document.getElementById("star2").style.filter =  "alpha(opacity='100')";
		document.getElementById("star3").style.opacity = 1;
		document.getElementById("star3").style.MozOpacity = 1;
		document.getElementById("star3").style.KhtmlOpacity = 1;
		document.getElementById("star3").style.filter =  "alpha(opacity='100')";
		document.getElementById("star4").style.opacity = .2;
		document.getElementById("star4").style.MozOpacity = .2;
		document.getElementById("star4").style.KhtmlOpacity = .2;
		document.getElementById("star4").style.filter =  "alpha(opacity='20')";
		document.getElementById("star5").style.opacity = .2;
		document.getElementById("star5").style.MozOpacity = .2;
		document.getElementById("star5").style.KhtmlOpacity = .2;
		document.getElementById("star5").style.filter =  "alpha(opacity='20')";
	}
	if (level == "4") {
		document.getElementById("star1").style.opacity = 1;
		document.getElementById("star1").style.MozOpacity = 1;
		document.getElementById("star1").style.KhtmlOpacity = 1;
		document.getElementById("star1").style.filter =  "alpha(opacity='100')";
		document.getElementById("star2").style.opacity = 1;
		document.getElementById("star2").style.MozOpacity = 1;
		document.getElementById("star2").style.KhtmlOpacity = 1;
		document.getElementById("star2").style.filter =  "alpha(opacity='100')";
		document.getElementById("star3").style.opacity = 1;
		document.getElementById("star3").style.MozOpacity = 1;
		document.getElementById("star3").style.KhtmlOpacity = 1;
		document.getElementById("star3").style.filter =  "alpha(opacity='100')";
		document.getElementById("star4").style.opacity = 1;
		document.getElementById("star4").style.MozOpacity = 1;
		document.getElementById("star4").style.KhtmlOpacity = 1;
		document.getElementById("star4").style.filter =  "alpha(opacity='100')";
		document.getElementById("star5").style.opacity = .2;
		document.getElementById("star5").style.MozOpacity = .2;
		document.getElementById("star5").style.KhtmlOpacity = .2;
		document.getElementById("star5").style.filter =  "alpha(opacity='20')";
	}
	if (level == "5") {
		document.getElementById("star1").style.opacity = 1;
		document.getElementById("star1").style.MozOpacity = 1;
		document.getElementById("star1").style.KhtmlOpacity = 1;
		document.getElementById("star1").style.filter =  "alpha(opacity='100')";
		document.getElementById("star2").style.opacity = 1;
		document.getElementById("star2").style.MozOpacity = 1;
		document.getElementById("star2").style.KhtmlOpacity = 1;
		document.getElementById("star2").style.filter =  "alpha(opacity='100')";
		document.getElementById("star3").style.opacity = 1;
		document.getElementById("star3").style.MozOpacity = 1;
		document.getElementById("star3").style.KhtmlOpacity = 1;
		document.getElementById("star3").style.filter =  "alpha(opacity='100')";
		document.getElementById("star4").style.opacity = 1;
		document.getElementById("star4").style.MozOpacity = 1;
		document.getElementById("star4").style.KhtmlOpacity = 1;
		document.getElementById("star4").style.filter =  "alpha(opacity='100')";
		document.getElementById("star5").style.opacity = 1;
		document.getElementById("star5").style.MozOpacity = 1;
		document.getElementById("star5").style.KhtmlOpacity = 1;
		document.getElementById("star5").style.filter =  "alpha(opacity='100')";
	}
}


function RSSPref(userID, pref) 
{ 
	url = "/content/myaccount/rsspref.php?userID="+userID+"&pref="+pref;
	
	try 
	{
		RSSPref_xmlhttp = window.XMLHttpRequest?new XMLHttpRequest(): new ActiveXObject("Msxml2.XMLHTTP"); 
	} 
	
	catch (e) 
	{ 
		// browser doesn't support ajax. handle however you want  
	} 
	RSSPref_xmlhttp.open("GET", url); 
	RSSPref_xmlhttp.send(null);	
}

