function adjustImageProperties(image, width, stretchToFit){
	
	//by default the content should stretch to fit the 
	//desired container width
	if(stretchToFit == null) {
		stretchToFit = true;
	}
	
	var curImgWidth = $(image).width();
	var curImgHeight = $(image).height();
	var imgAdjustmentRatio;
	var newImgHeight;
	if (curImgWidth > width) {
		
		imgAdjustmentRatio = 1 - ((curImgWidth - width) / curImgWidth);
		newImgHeight = curImgHeight * imgAdjustmentRatio;
		
		$(image).width(width);
		$(image).height(newImgHeight);
		
	} else if (curImgWidth < width && stretchToFit) {	
		
		imgAdjustmentRatio = 1 + ((width - curImgWidth) / width);
		newImgHeight = curImgHeight * imgAdjustmentRatio;
		
		$(image).width(width);
		$(image).height(newImgHeight);
		
	}

}
function getNewsletterSrc(id) {
	return 'delta_delta_datas/' + id;
}
function setCurrentNewsletter(){
	var newsletterSrc = getNewsletterSrc($('#newsletterSelect :selected').attr('id'));
	$('iframe#newsletter').attr('src', newsletterSrc);
}
function getCompositeSrc(id) {
	return 'composites/' + id;
}
function setCurrentComposite(){
	var compositeSrc = getCompositeSrc($('#compositeSelect :selected').attr('id'));
	$('#composite').attr('src', compositeSrc);
}
$(function(){
	//initialize top nav
	$("#topNav ul").superfish({firstOnClick: true});
	
	//load all tabbed functionality
	$('.tabContent:first').show();
	$('.tab:first').addClass('active');
	$('.tab a').click(function(){
		//hide all tabs
		$('.tabContent').hide();
		
		//reset active tab
		$('.tab').removeClass('active');
		$(this).parent().addClass('active');
		
		//display active tab
		var tabInd = $('#sTabs li, #tabs li').index($(this).parent());
		$('.tabContent:eq(' + tabInd + ')').show();
	});
	
	//bind change events to delta delta datas
	$('#newsletterSelect').change(function(){
		setCurrentNewsletter();
	});

	//bind change events to composites
	$('#compositeSelect').change(function(){
		setCurrentComposite();
	});	

});


