jQuery(document).ready(function() {

	// Slide "fade" del banner principal
		/*jQuery("#banner_slide").cycle( {
			fx : 'fade',
			speed : 1000,
			pager : '#nav_banner'
		});*/
		
		jQuery("#about_history_2010 > .scrollable1").scrollable({
			easing: "swing", 
			keyword: true, 
			items: ".items1", 
			circular: true, 
			next: ".next1", 
			prev: ".prev1", 
			speed: 400, 
			vertical: false
		}).autoscroll({
			autoplay: true, 
			interval: 15000, 
			autopause: true
		}).navigator({
			navi: ".navi1"
		});

		jQuery(".scrollable2").scrollable({
			easing: "swing", 
			keyword: true, 
			items: ".items2", 
			circular: true, 
			next: ".next2", 
			prev: ".prev2", 
			speed: 400, 
			vertical: false
		}).autoscroll({
			autoplay: true, 
			interval: 15000, 
			autopause: true
		}).navigator({
			navi: ".navi2"
		});

		jQuery("#nav_banner a").text("");

		// Alinea los patrocinadores en "altura"
		for (i = 0; i < jQuery("#patrocinadores li").length; i++) {

			ordenaPartocinadores(jQuery("#patrocinadores li").eq(i).children(
					"img"));
			jQuery("#patrocinadores li").eq(i).children("img").load(function() {
				ordenaPartocinadores(this);
			});
		}
		
		var browser = navigator.appName;
		var version = navigator.appVersion;
		if(
			(browser == 'Microsoft Internet Explorer') && 
			(
				(version.indexOf('MSIE 8.0') != -1) || 
				(version.indexOf('MSIE 7.0') != -1) || 
				(version.indexOf('MSIE 6.0') != -1)
			)
		){	
			jQuery(".ultimoTweet").html("<p>emprendedor_mx: ¡Siguenos en Twitter!</p>");
		}else{
			var tutwitter = "emprendedor_mx";
			var timeline = [];
			try{
				jQuery.getJSON("http://search.twitter.com/search.json?callback=?&rpp=5&q=from:"+ tutwitter, function(json,textStatus,xhr){
					timeline = json.results;
					if(timeline[0] != undefined){
						var lastTweet = timeline[0].text;
						var tweetTime = timeline[0].created_at;
						var tweetTime = relative_time(timeline[0].created_at);
						jQuery(".ultimoTweet").html(lastTweet);
						jQuery("#twittiempo").html(tweetTime);
					}else{
						throw('EmptyJSON');
						return false;
					}
				});
			}catch(e){
				jQuery(".ultimoTweet").html("<p>emprendedor_mx: ¡Siguenos en Twitter!</p>");
			}
		}
		
		var navegador = navigator.appName;
		
		if(navegador == 'Microsoft Internet Explorer'){
			jQuery('.crumbSeparator').before('</li>');
			jQuery('.crumbSeparator').css('margin-left', '15px');
		}

	});

// Método de alineación de los patrocinadores
function ordenaPartocinadores(el) {

	var alturaPatrocinador;
	var topPatrocinador;

	alturaPatrocinador = jQuery(el).height();
	topPatrocinador = 50 - (alturaPatrocinador / 2);
	jQuery(el).parent().css( {
		'position' : 'relative',
		'top' : topPatrocinador,
		'padding' : '0 20px 0'
	});
}

