$(document).ready(function(){
	
	var h = $(window).height();
	
	$('img').removeAttr("width").removeAttr("height");	
	$('.wp-caption').removeAttr("width");	
	$('#s_presentationcloud, #s_index-nonHome').hide();
	$('#s_presentation-title, #s_main-index').css({'color':'silver'});
	$('#s_indexes').height(h-150+'px');
	$('img').css({'border':'none'});
	$('.gallery-item').css({'margin':'0'});
	
	$('#s_index-menu').toggle(
		function(){ 
			$('#s_tagcloud').hide()
			$('#s_directory-title').css({'color':'silver'});
			$('#s_presentationcloud').show();
			$('#s_presentation-title').css({'color':'black'});
		},
		function(){ 
			$('#s_tagcloud').show().show().find('h3').css({'color':'black'});
			$('#s_directory-title').css({'color':'black'});
			$('#s_presentationcloud').hide().find('h3').css({'color':'silver'});
			$('#s_presentation-title').css({'color':'silver'});
		}
	);
	
	$('#s_main-index').toggle(
		function(){ 
			$('#s_index-nonHome').show();
			$('#s_main-index').css({'color':'black'});
		},
		function(){ 
			$('#s_index-nonHome').hide();
			$('#s_main-index').css({'color':'silver'});
		}
	);
		
	var obj = $('object');
	
	for(var i = 0; i < obj.length; i++)
	{
		var tw = $(obj[i]).attr('width');
		var th = $(obj[i]).attr('height');
		var ratio =	th/tw;
		var nh = Math.floor(390 * ratio);
		
		$(obj[i]).attr('width', '390px').attr('height', nh+'px');
	}
	
	var emb = $('embed');
	
	for(var i = 0; i < emb.length; i++)
	{
			var tw = $(emb[i]).attr('width');
			var th = $(emb[i]).attr('height');
			var ratio =	th/tw;
			var nh = Math.floor(390 * ratio);

			$(emb[i]).attr('width', '390px').attr('height', nh+'px');
	}
});
