﻿function rating(num, setnum) {

	var s = num.id.replace(setnum + "_", '');
	
	for (i = 1; i <= 5; i++ ){		
		if (i <= s) {
			document.getElementById(setnum + "_" + i).className = "on";
		} else {
			document.getElementById(setnum + "_" + i).className = "";
		}
	}
	
}

function rolloff(me, setnum) {

	var current = document.getElementById(setnum + "_rating").value;
	

	for (i = 1; i <= 5; i++) {
		if (i <= current) {
			document.getElementById(setnum + "_" + i).className = "on";
		} else {
			document.getElementById(setnum + "_" + i).className = "";
		}
	}

}

function rateIt(me, setnum){

	var s = me.id.replace(setnum + "_", '');
	document.getElementById(setnum + "_rating").value = s;	
	rolloff(me, setnum);

}

function CheckRating(button) {
	var emailadd=jQuery("input[name='email']").val();
	if(jQuery("input[name='author']").val()=='') {
		alert("Name cannot be empty");
		return false;
	}
	if(jQuery("input[name='email']").val()=='') {
		alert("Email cannot be empty");
		return false;
	}
	if(!isValidEmailAddress(emailadd))
	 {
	 	alert("Please enter valid email only");
		return false;
	}
	
	
	if(jQuery("input[name='1_rating']").val()==0) {
		alert("please rate Overall Rating");
		return false;
	}
	if(jQuery("input[name='2_rating']").val()==0) {
		alert("please rate Features");
		return false;
	}
	if(jQuery("input[name='3_rating']").val()==0) {
		alert("please rate Support");
		return false;
	}
	if(jQuery("input[name='4_rating']").val()==0) {
		alert("please rate Value");
		return false;
	} else {
		return true;
	}

   
}


function isValidEmailAddress(emailAddress) {
	var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
	return pattern.test(emailAddress);
}