// JavaScript Document

// check the form for errors------------------------------------------------------------
function MM_validateReviewForm() { //v4.0
var i,p,q,nm,enquiry='',test,num,min,max,errors='', args=MM_validateForm.arguments;


//test reviewer name

if(document.form1.ReviewerName.value=="") {
	enquiry+='a';
	document.getElementById('DIVReviewerName').style.visibility='visible';
	}
	else 
	{ 
	
		document.getElementById('DIVReviewerName').style.visibility='hidden';
	}

//test Looks

if (document.form1.Looks.value=="Choose") {
	enquiry+='a';
	document.getElementById('DIVLooks').style.visibility='visible';
	}
	else { 
	
	document.getElementById('DIVLooks').style.visibility='hidden';
	}

//test Functions

if (document.form1.Functions.value=="Choose") {
	enquiry+='a';
	document.getElementById('DIVFunctions').style.visibility='visible';
	}
	else { 
	
	document.getElementById('DIVFunctions').style.visibility='hidden';
	}

//test Usability

if (document.form1.Usability.value=="Choose") {
	enquiry+='a';
	document.getElementById('DIVUsability').style.visibility='visible';
	}
	else { 
	
	document.getElementById('DIVUsability').style.visibility='hidden';
	}

//test Price

if (document.form1.Price.value=="Choose") {
	enquiry+='a';
	document.getElementById('DIVPrice').style.visibility='visible';
	}
	else { 
	
	document.getElementById('DIVPrice').style.visibility='hidden';
	}


// test SizeAndWeight

if (document.form1.SizeAndWeight.value=="Choose") {
	enquiry+='a';
	document.getElementById('DIVSizeAndWeight').style.visibility='visible';
	}
	else { 
	
	document.getElementById('DIVSizeAndWeight').style.visibility='hidden';
	}


// test BuildQuality

if (document.form1.BuildQuality.value=="Choose") {
	enquiry+='a';
	document.getElementById('DIVBuildQuality').style.visibility='visible';
	}
	else { 
	
	document.getElementById('DIVBuildQuality').style.visibility='hidden';
	}


// ReviewerComments

if (document.form1.ReviewerComments.value=="") {
	enquiry+='a';
	document.getElementById('DIVReviewerComments').style.visibility='visible';
	}
	else { 
	
	document.getElementById('DIVReviewerComments').style.visibility='hidden';
	}

// look for http

var myRegExp = /http/;
var string1 = document.form1.ReviewerComments.value;
var matchPos1 = string1.search(myRegExp);

if(matchPos1 != -1){
	//document.write("There was a match at position " + matchPos1); 
	enquiry+='a';}
else{
	document.getElementById('DIVReviewerComments').style.visibility='hidden';
	}



//calculate errors and add to msg box-------------------------------
if (enquiry)errors += 'Review Submission\n';
// show msg box		
if (errors){
 alert('PLEASE ENTER THE MISSING INFORMATION\n');

//if now errors then submit the form
  }else{
		
		// calculate overall score
		var avg, part2, part3, part4, part5, part6, part7;
		part2 = document.form1.Looks.value / 1;
		part3 = document.form1.Functions.value / 1;
		part4 = document.form1.Usability.value /1;
		part5 = document.form1.Price.value /1;
		part6 = document.form1.SizeAndWeight.value /1;
		part7 = document.form1.BuildQuality.value /1;
		
		avg = part2 + part3 + part4 + part5 + part6 + part7;
		avg = avg / 6;
		avg = Math.round(avg);
		document.form1.OveralScore.value = avg;
		//alert(document.form1.OveralScore.value);
		
		// submit the form
		document.form1.Button.value = 'Thank You...' ;
		document.form1.submit();
 	 	}		
		

 document.MM_returnValue = (errors == '');
 }

