/*
 * FILENAME: testimonials.js
 * AUTHOR: Ashley Barrett (ashley.barrett@rgroup.co.uk)
 * CREATED: 12/09/2009
 * COMMENTS: The .js file to handle the js for the testimonials page
 * */

$(function(){

	var max = 200;
	var allowedExt = "jpg,jpeg,gif,png, ,";
	/*$(".num").hide();*/
	
	$('input.star').rating();
	
	$("#custTestimonialsIntro .add .clickStars span, #custTestimonialsIntro .add .clickStars p").css("visibility","visible");
	
	
	$("form #newReviewSubmit").click(function(){
		var filename = $("#fileUpload").val();
		
		var splitted = filename.split('.');

		var len = (splitted.length) - 1;
		
		if(allowedExt.indexOf(splitted[len])){
			//ERROR HERE
			alert("Your photo was not recognised as a valid image (.jpg, .gif or .png)");
			$("#fileUpload").val("");
			return false;
		}
		

	});	
	
	/*$.fn.setCharLeft = function(name){
		var len = $(name).val().length;
		var left = max - len;
		$("#charLeft").text(left);
		if(len >= max){
			alert("Maximum comment length reached.");
		}
	}
		
	$("textarea[name=text]").keyup(function(){
		$("html").setCharLeft(this);
	});

	$("html").setCharLeft("textarea[name=text]");*/
	
});

	
		
