$(document).ready(function()
{
	// Let's visualize HTML code
	if($('#dyncontent-sponsors textarea').length > 0)
	{
		$('#dyncontent-sponsors').html($('#dyncontent-sponsors textarea').text());
	}
	
	// rounded corners //
	$(".rounded").corner("round 8px").parent().css("padding", "2px").corner("round 10px");
	
	// vertical slider //
	var visible_height = $("#sponsor-logos" ).height();
	var total_height = $("#dyncontent-sponsors" ).height();
	var interval = 30;
	var offset = 0;
	$("#event-sponsors-buttons .nextPage" ).click(function(){
		if(total_height > visible_height)
		{
			if((0-offset) < (total_height-(interval*2)))
			{
				offset -= interval;
				$("#dyncontent-sponsors").animate({"marginTop": offset+"px"});
			}
		}
	})
	$("#event-sponsors-buttons .prevPage" ).click(function(){
		if(total_height > visible_height)
		{
			if(offset < 0)
			{
				offset += interval;
				$("#dyncontent-sponsors").animate({"marginTop": offset+"px"});
			}
		}
	})

	// Reset Dynamic Content Styles //
	$("#dyncontent-sponsors *").each(function()
	{
		this.className="";
		$(this).attr("style","");
	});
	$.each($('#dyncontent-sponsors img'), function(){
		var fakeImage = $('<img>').attr('src', $(this).attr('src'));
		var imageRatio = fakeImage.attr('width') / $(this).width();
		var newHeight = $(this).height() / imageRatio;
		$(this).css('height', newHeight);
	});
});