$(document).ready(function(){
	/*Color de fondo*/
	var colorin = '';
	$('a.cambiacolor').hover(function(){
		$('a.cambiacolor').parent().stop().animate({width:10},250);
		$(this).parent().stop().animate({width:60},250);
	},function(){
		$('a.cambiacolor').parent().stop().animate({width:15},150);
	});
	$('a.cambiacolor').live('click',function(){
		colorin = $(this).attr('rel');
		$.getJSON('js/api_cambiarColorUsr.php',{color:colorin});
		$('html').stop().animate({backgroundColor:colorin},500);
		$('body').stop().animate({backgroundColor:colorin},500);
		$('#body_wrapper').stop().animate({backgroundColor:colorin},500);
		$('p.piepag').stop().animate({color:colorin},500);
		$('.color').stop().animate({color:colorin},500);
		return false;
	});
	$('a.cambiacolor').each(function(){
		$(this).css({backgroundColor: $(this).attr('rel')});
	});
	/*Color de fondo*/
	/*Wombas*/
	$("#body").prepend(
		'<div class="wombas_adorno" id="wombas_adorno_1">\
			<img src="img/CBK_scrolla'+ ( Math.ceil( Math.random() * 4 ) ) +'.png" />\
		</div>\
		<div class="wombas_adorno" id="wombas_adorno_2">\
			<img src="img/CBK_scrollb'+ ( Math.ceil( Math.random() * 4 ) ) +'.png" />\
		</div>');
	var altura_header = $("#header_wrapper").height();
	var altura_total = $(document).height();
	var altura_ventana = $(window).height();
	var altura_body = $("#body").height() - $("#wombas_adorno_2").height();
	var scroll_w = $(window).scrollTop();
	$(".wombas_adorno").css({top:altura_header});
	$.acomodarWombas=function(){
		var scroll_max = altura_total - altura_ventana 
		scroll_max = (scroll_max > 0)?scroll_max:0.5;
		var percent = scroll_w / (scroll_max );
		var ir = altura_header + altura_body *  percent ;
		var dir_rand = (percent<0.5)? 1 : -1;
		$("#wombas_adorno_1").stop().animate({top:ir + ( Math.random() * 150 * dir_rand ), easing: 'easeOutCubic'}, 1200 );
		$("#wombas_adorno_2").stop().animate({top:ir + ( Math.random() * 150 * dir_rand ), easing: 'easeOutCubic'}, 1200 );
	}
	$(window).scroll(function(){/*
		scroll_w = $(window).scrollTop();
		$.acomodarWombas();*/
		altura_total = $(document).height();
		altura_ventana = $(window).height();
		altura_body = $("#body").height() - $("#wombas_adorno_2").height() ;
		scroll_w = $(window).scrollTop();
		$.acomodarWombas();
	}); 
	$(window).resize(function(){
		altura_total = $(document).height();
		altura_ventana = $(window).height();
		altura_body = $("#body").height() - $("#wombas_adorno_2").height() ;
		scroll_w = $(window).scrollTop();
		$.acomodarWombas();
	});
	$(document).resize(function(){
		altura_total = $(document).height();
		altura_ventana = $(window).height();
		altura_body = $("#body").height() - $("#wombas_adorno_2").height() ;
		scroll_w = $(window).scrollTop();
		$.acomodarWombas();
	});
	$.acomodarWombas();
	/*Wombas*/
	
	/*Esquinas redondeadas*/
	if (!$.browser.msie) {
		$.jcorners("#body_wrapper",{radius:10});
		$.jcorners("#body",{radius:8});
	}
	/*Esquinas redondeadas*/
});
