/**
 * Validate the registration form
 *@return boolean
 */
function validateRegistration () {
	f = document.forms.registration;
	if ( !f ) return false;
	var message = "";
	var valid = true;
	if ( f.password.value != f.password2.value || f.password.value == "" ) {
		message += "<li>Please type in your password and confirmation password.</li>";
		valid = false;
	}
	if ( f.username.value == "" ) {
		message += "<li>Please type in your desired username.</li>";
		valid = false;
	}
	if ( valid ) return true;
	document.getElementById("registrationError").innerHTML = "Sorry, we can't accept your registration until you complete the form.  Please check the following:<ol>"+message+"</ol>";
	return valid;
}


/**
 * We only want to show one "Buy Now" button at a time
 * @param string name
 */
function showPaymentButton () {
	if ( document.getElementById("paymentGoogle").checked ) {
		document.getElementById("buyNowPayPal").style.display = "none";
		document.getElementById("buyNowGoogle").style.display = "";
	} else {
		document.getElementById("buyNowGoogle").style.display = "none";
		document.getElementById("buyNowPayPal").style.display = "";
	}
}


/**
 * Load a YouTube video into the player
 */
function loadVideo ( videoID, title, description, rating ) {
	var e = document.getElementById("video");
	var t = document.getElementById("videoTitle");
	var d = document.getElementById("videoDescription");
	var o = document.getElementById("videoObject");
	if ( !e ) return false;
	
	t.innerHTML = title;
	d.innerHTML = description;
	o.innerHTML =
		'<object width="425" height="355">'+
		'	<param name="movie" value="http://www.youtube.com/v/'+videoID+'&autoplay=1"></param>'+
		'	<param name="wmode" value="transparent"></param>'+
		'	<param name="play" value="true"></param>'+	
		'	<embed src="http://www.youtube.com/v/'+videoID+'&autoplay=1" type="application/x-shockwave-flash" wmode="transparent" width="425" height="355" play="true" loop="false"></embed>'+
		'</object>';
	
	if ( document.getElementById("videoStar1") ) {  // set the star rating
		if ( Math.round(rating) >= 1 ) document.getElementById("videoStar1").src = "images/star.png";
		if ( Math.round(rating) >= 2 ) document.getElementById("videoStar2").src = "images/star.png";
		if ( Math.round(rating) >= 3 ) document.getElementById("videoStar3").src = "images/star.png";
		if ( Math.round(rating) >= 4 ) document.getElementById("videoStar4").src = "images/star.png";
		if ( Math.round(rating) >= 5 ) document.getElementById("videoStar5").src = "images/star.png";
	}
	
	if ( document.forms.video ) {  // only if the form is present
		document.forms.video.rating.value = rating;
		document.forms.video.videoID.value = videoID;
	}
	
	e.style.visibility = "visible";
}





function closeVideo () {
	var e = document.getElementById("video");
	var o = document.getElementById("videoObject");
	if ( !e ) return false;
	e.style.visibility = "hidden";
	o.innerHTML = '';
}

function starHot ( star ) {
	for ( var i=1; i<=star; i++ ) document.getElementById("videoStar"+i).src = "images/star-hot.png";
}
function starCold ( star ) {
	for ( var i=1; i<=5; i++ ) {
		if ( i > document.forms.video.rating.value ) document.getElementById("videoStar"+i).src = "images/star-cold.png";
		else document.getElementById("videoStar"+i).src = "images/star.png";
	}
}
function starRate ( score ) {
	document.forms.video.rating.value = score;
	starCold(score);
}