$(document).ready(function () {

	lastBlock = $("#a1");
	maxWidth = 255;
	minWidth = 31;

	$("ul.menu li div").hover(
	function(){
		$(lastBlock).animate({width: minWidth+"px"}, { queue:false, duration:400 });
		$(this).animate({width: maxWidth+"px"}, { queue:false, duration:400});
		currentBlock = this;
		lastBlock = this;
	}
	);


	$(".noticias").jCarouselLite({
		vertical: true,
		hoverPause:true,
		visible: 5,
		auto:3500,
		speed:1000
	});

	enlacesInternos();

	//	$(".interno:first").click();
	$(".principal").click();


	$('.galeria a').lightBox({	imageBtnClose: 'imagenes/ligthbox/lightbox-cerrar.gif',
	imageBtnPrev: 'imagenes/ligthbox/lightbox-anterior.gif',
	imageBtnNext: 'imagenes/ligthbox/lightbox-siguiente.gif',
	txtImage: 'Im&aacute;gen',	txtOf: 'de'});

	$('#imagen a').lightBox({	imageBtnClose: 'imagenes/ligthbox/lightbox-cerrar.gif',
	imageBtnPrev: 'imagenes/ligthbox/lightbox-anterior.gif',
	imageBtnNext: 'imagenes/ligthbox/lightbox-siguiente.gif',
	txtImage: 'Im&aacute;gen',	txtOf: 'de'});

	// formularios marcados
	$(".marcados").focus(function() {
		$(this).parent().addClass("curFocus")
	});
	$(".marcados").blur(function() {
		$(this).parent().removeClass("curFocus")
	});
	// Validacion y Envio del form
	/*
	$('.panel').animate({
	height: 'show',
	opacity: 'show'
	}, 2000, function() {
	// Animation complete.
	});

	*/

	//	var seccion = <?php echo $seccion; ?>;
	var seccion = getUrlVars()['sec']
	if (seccion == "" || !(seccion)) {
		seccion = 0;
	}
	$('.enlaces_menus').each(function(){
		var texto = "<div>( ";
		var pasa = false;
		var numero = 0;
		var actual = this;
		$('.enlaces_menus').each(function(){
			numero+=1;
			if (! ($(actual).hasClass('_tipo'+numero))) {
				if (pasa) {	texto += " - "};
				texto +='<a href="javascript:enlace('+numero+');">' + $(".tipo"+numero).html() + '</a>';
				pasa = true;
			}
		});
		texto +=" )</div>"
		$(this).html(texto)
	});
	if (seccion!= 0) {
		enlace(seccion)
	}


});

function enlace(id){
	$.scrollTo(".tipo"+id,1500)
}

function generarRealPerson(){
	$('#real').realperson({regenerate: 'Regenerar',includeNumbers: true,length: 6});

}
function getUrlVars() {
	var vars = {};
	var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
		vars[key] = value;
	});
	return vars;
}

function enlacesInternos(){
	$(".interno").each(function(){
		var href = $(this).attr("href");
		$(this).attr({ href: "javascript:void(0);"});
		$(this).click(function(){
			$("#box").load(href, function() {
				$('html').animate( { scrollTop: 0 }, 'fast' );
				$('#paseFotos').cycle({
					fx:    'curtainX,fade,scrollUp,shuffle',
					sync:   0,
					timeout: 8000,
					pause:1
				});

			});
		});
	});


}

function actualizarClick(Id){
	$.post("modulos/noticias/noticia_click.php", {'Id':escape(Id)})

}

