/*============================================================
Scale images to fit content area.
	Using max-width should be enough, but of course, there's IE. 
============================================================*/

$(document).ready(function() {

	// Max width to allow
	var max_width = 470;
	
	$('.coupon').find('img').each(function(){
		var width = $(this).width();
		var height = $(this).height();
		if(width > max_width) {
			var ratio = (height / width);
			var new_width = max_width;
			var new_height = (new_width * ratio);
			
			// Shrink it
			$(this).height(new_height).width(new_width);				
		}
	});
	
});





/* =============================================== */

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}



//EMAIL VALIDATION (USED IN FORM VALIDATION)
function isValidEmail(str) {
	//returns TRUE if valid, false if not
	return (str.indexOf(".") > 2) && (str.indexOf("@") > 0); 
	
}


//FORM VALIDATION
function validateContactForm(form) {
  	  	
	if (form.name.value == "") {
		alert('Please enter your name');
		return false 
	}
	
	else if (!isValidEmail(form.email.value)) {
		alert('Please enter a valid email address');
		return false 
	}	
	
	else {
		return true
	}

}
  
function validateContestForm(form) {
	
	if (form.name.value == "") {
		alert('Please enter your name');
		return false 
	}
		
	else if (!isValidEmail(form.email.value)) {
		alert('Please enter a valid email address');
		return false 
	}	
	
	else if (form.phone.value == "") {
		alert('Please enter your phone number');
		return false 
	}
	
	else if (form.city.value == "") {
		alert('Please enter your city');
		return false 
	}
	
	else {
		return true
	}

}