function submitThis(form){
	document.theform.action = "index.php";
	document.theform.submit();	
}

// changes button color so u know button does sumthin
function changeColor(e, color){
	var element = window.event? event.srcElement: e.target ; 
	if (element.tagName == "INPUT" && (element.type == "submit" || element.type == "button")){
		element.style.backgroundColor = color
	}
}

// reset the form. reset button wont do it on u subsequent visits where page is populated by POST vars
function resetForm(form){
	for(var i = 0; i < document.theform.length; i++) {
		var e = document.theform.elements[i];
		if( (e.type == "radio" || e.type == "checkbox") && e.checked == true){
			e.checked = false;
		}				
	}
	document.theform.action = "index.php";
	document.theform.submit();		
}

function printView(arg) {				
	my_window = window.open('',"newWin","width=750px,height=775px,left=25,top=25,titlebar=no,status=no,menubar=yes,toolbar=no,scrollbars=yes,resizeable=yes");
	var out = my_window.document;
	
	out.open();
  	out.write('<html><head><title>VerticalScope</title>');
	out.write('<link rel="stylesheet" href="crs.css" type="text/css"></head>');
  	out.write('<body onLoad="window.focus()">');
  	out.write('<table class="print_tbl" cellpadding="0" cellspacing="0" width="100%">');
	if(arg){
		out.write('<tr><td class="print_tbl_td" align="left" valign="top">');
		out.write(arg);
		out.write('</td></tr>');
	}  		
  	out.write('</table></body></html>');
  	out.close();
}

function validateEmail(form){
	var sender_name = document.emailform.sender_name.value;
	var sender_email = document.emailform.sender_email.value;
	var recipient_email = document.emailform.recipient_email.value;
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if(!sender_name){
		alert('Please input your name.');
		document.emailform.sender_name.select();
		return false;
	}	
	if(!filter.test(sender_email)){
		alert('Your email address is invalid.');
		document.emailform.sender_email.select();
		return false;
	}	
	if(!filter.test(recipient_email)){
		alert('Email recipient address is invalid.');
		document.emailform.recipient_email.select();
		return false;
	}	
	return true;
}

function validateComparisonForm(form){
	var one = document.compForm.TrimId_one.selectedIndex;
	var TrimId_one = document.compForm.TrimId_one.options[one].value;
	var two = document.compForm.TrimId_two.selectedIndex;
	var TrimId_two = document.compForm.TrimId_two.options[two].value;
	// if both are FALSE return false
	if(TrimId_one == "FALSE" && TrimId_two == "FALSE"){
		alert('Please select at least one Model to compare with.');
		document.compForm.TrimId_one.focus();
		return false;
	}
	return true;
}


function popitup(url) {
	newwindow=window.open(url,'name','height=712,width=876');
	if (window.focus) {newwindow.focus()}
	return false;
}

function mark_review(id,score){
		currentTime = new Date();
		
 		$.get("/specs/ajax.php",
 			{
 				ajax_action:"mark_a_review",
 				rid:id,
 				s:score,
 				rand:" "+currentTime
 			},
 			function(j){
	   				$('div#trim_review_'+id+' div.thumb_up').html(j);
 			}
 		);
}



