// JavaScript Document

function over(object) {
	document.getElementById(object).className = "over";
}

function out(object) {
	document.getElementById(object).className = "button";
}

function checkAddUser() {
	var add_username = document.myform.add_username;
	var add_password = document.myform.add_password;
	var add_fullname = document.myform.add_fullname;
	
	if (add_username.value == "") {
		alert("Please enter Username");
		add_username.focus();
		return false;
	}
	if (add_password.value == "") {
		alert("Please enter Password");
		add_password.focus();
		return false;
	}
	if (add_fullname.value == "") {
		alert("Please enter Full Name");
		add_fullname.focus();
		return false;
	}
	document.myform.action = "adduser.php";
	return true;
}

function checkPostPhoto() {
	var photocomment = document.myform.photocomment;
	
	if (photocomment.value == "") {
		alert("Please enter photo comment into the space provided");
		photocomment.focus();
		return false;
	}
	if (photocomment.value.indexOf('"') != -1) {
		alert('Please remove the quotation mark/s (") from the photo comment');
		photocomment.focus();
		return false;
	}
	
	document.myform.action = "postphoto_action.php";
	return true;
}

function checkPostNews() {
	var newstitle = document.myform.newstitle;
	var newscontent = document.myform.newscontent;
	
	if (newstitle.value == "") {
		alert("Please enter news title into the space provided");
		newstitle.focus();
		return false;
	}
	if (newstitle.value.indexOf('"') != -1) {
		alert('Please remove the quotation mark/s (") from the news title');
		newstitle.focus();
		return false;
	}
	if (newscontent.value == "") {
		alert("Please enter news content into the space provided");
		newscontent.focus();
		return false;
	}
	if (newscontent.value.indexOf('"') != -1) {
		alert('Please remove the quotation mark/s (") from the news content');
		newscontent.focus();
		return false;
	}
	
	document.myform.action = "postnews_action.php";
	return true;
}

function checkPostYouTube() {
	var youtubelink = document.myform.youtubelink;
	var youtubecomment = document.myform.youtubecomment;
	
	if (youtubelink.value == "") {
		alert("Please paste the YouTube link into the space provided");
		youtubelink.focus();
		return false;
	}
	if (youtubelink.value.indexOf("'") != -1) {
		alert("Please remove the apostrophe mark/s (') from the YouTube link");
		youtubelink.focus();
		return false;
	}
	if (youtubecomment.value == "") {
		alert("Please enter comments relating to the video into the space provided");
		youtubecomment.focus();
		return false;
	}
	if (youtubecomment.value.indexOf('"') != -1) {
		alert('Please remove the quotation mark/s (") from the YouTube comments');
		youtubecomment.focus();
		return false;
	}
	if (youtubecomment.value.indexOf("'") != -1) {
		alert("Please remove the apostrophe mark/s (') from the YouTube comments");
		youtubecomment.focus();
		return false;
	}
	
	document.myform.action = "postyoutube_action.php";
	return true;
}

function checkLogin() {
	var username = document.myform.username;
	var password = document.myform.password;
	
	if (username.value == "") {
		alert("Please enter Username");
		username.focus();
		return false;
	}
	if (password.value == "") {
		alert("Please enter Password");
		password.focus();
		return false;
	}
	
	document.myform.action = "validate.php";
	return true;
}

function checkForm() {
	var fullname = document.myform.fullname.value;
	var email = document.myform.email.value;
	var celltel = document.myform.celltel.value;
	var comments = document.myform.comments.value;
	
	if (fullname == "") {
		alert("Please enter your full name");
		document.myform.fullname.focus();
		return false;
	}
	if (email == "") {
		alert("Please enter your e-mail address");
		document.myform.email.focus();
		return false;
	}
	if (celltel == "") {
		alert("Please enter your cell / tel number");
		document.myform.celltel.focus();
		return false;
	}
	if (comments == "") {
		alert("Please enter your comments");
		document.myform.comments.focus();
		return false;
	}
	if (comments.indexOf("'") != -1) {
		alert("Please remove the apostrophe sign/s from your comments");
		document.myform.comments.focus();
		return false;
	}
	if (comments.indexOf('"') != -1) {
		alert("Please remove the quotation mark/s from your comments");
		document.myform.comments.focus();
		return false;
	}
	document.myform.action = "contactus.php";
	return true;
}