// JavaScript Document

//Use this to set the date to which the timer counts down to

//Edit line 23. Input your desired date using the format below:
//
// 		newYear = new Date(yyyy, 00 - 1, dd, hh, mm, ss);
//
// where yyyy = year, oo = month (e.g. Sep = 09), dd = day, hh = hour (e.g. 5pm = 17), mm = min and ss = seconds
//
// for example, July 12th, 2012, at 18:43pm would be written as below:
//
// 		newYear = new Date(2012, 07 - 1, 12, 18, 43, 00);
	
	//modify line 23 below to use your own launch date, following the instructions above:

function moveDiv(div2){
    var div = $('div.'+div2),ul = $('ul.'+div2),ulPadding = 15;
    var divWidth = div.width();
    //console.log("widht:"+divWidth);
    div.css({overflow: 'hidden'});
    var lastLi = ul.find('li:last-child');
    div.mousemove(function(e){
    	var ulWidth = lastLi[0].offsetLeft + lastLi.outerWidth() + ulPadding;
    	var left = (e.pageX - div.offset().left) * (ulWidth-divWidth) / divWidth;
    	//console.log("widht:"+ulWidth+", Left:"+left);
      div.scrollLeft(left);
    });	
}

$(document).ready(function(){
	var newYear = new Date(); 
	newYear = new Date(2011, 3-1, 5, 11, 00, 00);
	$('#months p').countdown({
		until: newYear, 
		format: 'yODHMS',
		layout: '{on}'
	});
	$('#days p').countdown({
		until: newYear, 
		format: 'ODHMS',
		layout: '{dn}'
	});
	$('#hours p').countdown({
		until: newYear, 
		format: 'ODHMS',
		layout: '{hn}'
	});
	$('#minutes p').countdown({
		until: newYear, 
		format: 'ODHMS',
		layout: '{mn}'
	});
	$('#seconds p').countdown({
		until: newYear, 
		format: 'ODHMS',
		layout: '{sn}'
	});

	$(".popup").fancybox({
		'scrolling'		: 'no',
		'centerOnScroll':true,
		'width'				: 556,
		'padding'			: 0,
		'height'			: 900,
		'autoScale'			: false,
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'type'				: 'iframe'
		
	});

	$('.scroll').jScrollPane({
		verticalDragMinHeight: 10,
		verticalDragMaxHeight: 10,
		horizontalDragMinWidth: 10,
		horizontalDragMaxWidth: 10
	}
);

	$(".tweet").tweet({
        username: "FMLUCHALIBRE",
        join_text: "auto",
        avatar_size: 32,
        count: 4,
        auto_join_text_default: "Dijimos",
        auto_join_text_ed: "Nosotros",
        auto_join_text_ing: "Nosotros estábamos",
        auto_join_text_reply: "Le contestamos a",
        auto_join_text_url: "Estábamos checando",
        loading_text: "Cargando tweets..."

    });	
	
	moveDiv("sc_menu0");
	moveDiv("sc_menu1");
	moveDiv("sc_menu2");
	
	moveDiv("sc_menu4");
	
	if($("#notMotion").length){
		$("#notMotion").css("overflow","hidden");
		$(".listNotHome a").click(function(e){
			var url=$(this).attr("href");
			var countLi=$("#notMotion li").length;
			url = url.replace(/^.*=/, '');
			var posWidth=(countLi-url)*$("#notMotion").width();
			
			$("#notMotion").animate({scrollLeft:posWidth},1000);
			return false;
		});
	}
});

