/*
This function will look at all images and embedded videos on the page 
and resize them down to a certain width. It adjusts the height accordingly.
Code by James Pfleiderer, pro2go Designs.
http://www.p2gdesigns.com
*/

$(document).ready(function(){
	var img_width;
	var img_height;
	var new_height;
	var new_width = 715; //This is the max width an image can be.
	$("img").each(function(index) {
		img_width = $(this).width();
		img_height = $(this).height();
		
		if(img_width > new_width){
			new_height = (img_height * new_width) / img_width;
			new_height = Math.round(new_height);
			$(this).width(new_width);
			$(this).height(new_height);
		}//END IF (img_width > new_width)
	});//END each
	
	$("object").each(function(index) {
		img_width = $(this).attr("width");
		img_height = $(this).attr("height");
		
		if(img_width > new_width){
			new_height = (img_height * new_width) / img_width;
			new_height = Math.round(new_height);
			$(this).attr("width",new_width);
			$(this).attr("height",new_height);
		}//END IF (img_width > new_width)
	});//END each
	
	$("embed").each(function(index) {
		img_width = $(this).attr("width");
		img_height = $(this).attr("height");
		
		if(img_width > new_width){
			new_height = (img_height * new_width) / img_width;
			new_height = Math.round(new_height);
			$(this).attr("width",new_width);
			$(this).attr("height",new_height);
		}//END IF (img_width > new_width)
	});//END each
	
 });
