// Rate Over
function rate_over(id, directory) {
	for (i=1; i<=5; i++)
		document.getElementById("rate"+i).src=directory+(i<=id?"/rating.gif":"/rating-q0.gif");
}
// Rete Out
function rate_out(rate, directory) {
	for (i=1; i<=5; i++) {
		if (rate < i-0.75) no = 0;
		else if (rate < i-0.5) no = 1;
		else if (rate < i-0.25) no = 2;
		else if (rate < i) no = 3;
		else no = 4;
		document.getElementById("rate"+i).src=directory+"/rating-q"+no+".gif";
	}
}
// Ajax
function setdata(url, target) {
	var http;
	if (window.ActiveXObject) {
		http = new ActiveXObject("Microsoft.XMLHTTP");
	} else if (window.XMLHttpRequest) {
		http = new XMLHttpRequest();
	} else {
		alert("Your browser don't support Ajax.");
	}
	http.onreadystatechange = statechange;
	http.open("GET", url, true);
	http.send(null);
	function statechange() {
		if (http.readyState == 1) {
			//document.getElementById(target).innerHTML = '<span class="loading">Loading...</span>';
		} else if (http.readyState == 4) {
			if (http.status == 200) {
				document.getElementById(target).innerHTML = http.responseText;
			} else {
				alert("There was a problem retrieving the XML data:\n" + http.statusText);
			}
		}
	}
}
// Check Mail
function check_mail(email) {
	var filter = /^[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}$/i;
	if (!filter.test(email))
		return false;
	return true;
}
// Guestbook Validation
function guestbook_validation(form) {
	if (form.name.value == "") {
		alert("Invalid Name.");
		form.name.focus();
		return false;
	} else if (form.email.value != "" && !check_mail(form.email.value)) {
		alert("Invalid Email.");
		form.email.focus();
		return false;
	} else if (form.comment.value == "") {
		alert("Invalid Comment.");
		form.comment.focus();
		return false;
	} else if (form.captcha.value == "") {
		alert("Invalid Captcha.");
		form.captcha.focus();
		return false;
	}
	return true;
}
// ContactUs Validation
function contactus_validation(form) {
	if (form.name.value == "") {
		alert("Invalid Name.");
		form.name.focus();
		return false;
	} else if (!check_mail(form.email.value)) {
		alert("Invalid Email.");
		form.email.focus();
		return false;
	} else if (form.subject.value == "") {
		alert("Invalid Subject.");
		form.subject.focus();
		return false;
	} else if (form.message.value == "") {
		alert("Invalid Message.");
		form.message.focus();
		return false;
	} else if (form.captcha.value == "") {
		alert("Invalid Captcha.");
		form.captcha.focus();
		return false;
	}
	return true;
}
// Comment Validation
function comment_validation(form) {
	if (form.name.value == "") {
		alert("Invalid Name.");
		form.name.focus();
		return false;
	} else if (form.email.value != "" && !check_mail(form.email.value)) {
		alert("Invalid Email.");
		form.email.focus();
		return false;
	} else if (form.comment.value == "") {
		alert("Invalid Comment.");
		form.comment.focus();
		return false;
	} else if (form.captcha.value == "") {
		alert("Invalid Captcha.");
		form.captcha.focus();
		return false;
	}
	return true;
}