/**
* TWSAINT - TETRAWARE INFOGRAFICA S.C.A. 2010
* tetraware <tetraware@tetraware.net>
*/

$(function(){
	// toggle
	$("dl.toggle").each(function(){
		var $toogle_dt = $(this).children("dt");
		$toogle_dt.click(function(){
			$(this).toggleClass("current");
			$(this).next("dd").toggleClass("current");
			$(this).next("dd").toggle();
		});
		// crear otro boton para desplegar el toggle
		var rel_id	= $(this).attr('rel');
		var $rel	= $("#"+rel_id);
		if($rel){
			$rel.click(function(){
				$toogle_dt.click();
			});
		}
		
	});
	// colorbox
	$("a[rel*='colorbox'],a[rel*='lightbox']").colorbox({transition:'elastic', speed:500, current: '{current}/{total}'});
	$("a[rel*='colorbox-inline']").colorbox({inline:true, transition:'elastic', speed:500, current: '{current}/{total}', width: 660, height:400});
	$("a.iframe[rel*='colorbox']").colorbox({width:'60%', height:'60%', iframe:true});
	
	// tabs
	/*
	$("ul.tabs").tabs("div.tabs-panes > .pane", {
		api: true,
		effect: 'fade',
		history: true
	});
	*/
	$("#tabs[class!='notab']").tabs();
	
	// accord
	/*
	$("dl.acor").tabs("dl.acor dd", {
		tabs: 'dt',
		effect: 'slide',
		history: false,
		initialIndex: 0,
	});
	*/
 	$(".accordion").accordion({
 		autoHeight: false 
 	});/*header: 'div.acc-header'*/
	
	// anything alider
	$(".anythingSlider").anythingSlider({
		easing: "swing",			// Anything other than "linear" or "swing" requires the easing plugin
        autoPlay: true,				// This turns off the entire FUNCTIONALY, not just if it starts running or not
        startStopped: false,		// If autoPlay is on, this can force it to start stopped
        delay: 3000,				// How long between slide transitions in AutoPlay mode
        animationTime: 400,			// How long the slide transition takes
        hashTags: false,			// Should links change the hashtag in the URL?
        buildNavigation: false,		// If true, builds and list of anchor links to link to each slide
        pauseOnHover: true,			// If true, and autoPlay is enabled, the show will pause on hover
        startText: "Iniciar",		// Start text
        stopText: "Parar",			// Stop text
        navigationFormatter: null	// Details at the top of the file on this use (advanced use)
	});
	// simple over
	$(".showhide").mouseenter(function(){
			//$(this).find("div").show("slow");
			$(this).find("span").toggleClass("current");
			$(this).find("div").show();
		}
		).mouseleave(function(){
			//$(this).find("div").hide("slow");
			$(this).find("span").toggleClass("current");
			$(this).find("div").hide();
		});
	// cycle para home
	$("#blqCategoriasHome div ul.shuffle").each(function(){
		// asignar la animacion
		//cy  = new Object();
		new $(this).cycle({ 
			fx: 'shuffle',
			shuffle:{ top: 145, left:5},
			speed:500
		});
		$(this).cycle('pause');
		// control de la animacion
		$(this).parent('div').mouseenter(function(){
			$(this).children('ul.shuffle').cycle('resume');
			$(this).children('ul.shuffle').cycle('next');
		}).mousemove(function(){
			$(this).children('ul.shuffle').cycle('resume');
		}).mouseleave(function(){
			$(this).children('ul.shuffle').cycle('pause');
		});
	});
	
	// simple over mor images
	$(".more-images").mouseenter(function(){
			$(this).find("div.more-images-info").show("slow");
		}
		).mouseleave(function(){
			$(this).find("div.more-images-info").hide();
		});	
	
	// datepicker
	$(".datepicker").each(function(){
		at_mindate = $(this).attr('mindate'); 
		at_maxdate = $(this).attr('maxdate'); 
		at_dateformat = $(this).attr('dateformat');
		//
		new $(this).datepicker({
				minDate: at_mindate,
				maxDate: at_maxdate,
				dateFormat: at_dateformat
		});
	});
	
	// tooltip
	//$("a[title]").tooltip();	
	$(".tooltip").tooltip();	
	
	// fancy thumb
	$("div.thumb").hover(
		function(){
			$(this).css({'z-index' : '10'});
			$(this).find('img').addClass("hover").stop().animate(
				{
					marginTop: '-25px',
					marginLeft: '-25px',
					top: '50%',
					left: '50%',
					width: '150px',
					height: '150px'
				},
				200
			);
		},
		function(){
			$(this).css({'z-index' : '0'});
			$(this).find('img').removeClass("hover").stop().animate(
				{
					marginTop: '0',
					marginLeft: '0',
					top: '0',
					left: '0',
					width: '100px',
					height: '100px'
				},
				400
			);
		}
	);
	
	/*imprimir pot id*/
	$(".print-intinerary").click(function(){
			var rel = $(this).attr('href');
			rel_html = "<html>"
				+"<head>"
				+"<style>.noforprint, img {display:none;} dt {font-size:18pt;} .titulo {font-size:24pt;} li {list-style:none;}</style>"
				+"</head>"
				+"<body>" 
				+$(rel).html()
				+ "</body>"
				+"</html>";
			//
			var ventimp = window.open(' ','popimpr');
			ventimp.document.write(rel_html);
			ventimp.document.close();
			//ventimp.print();
			//ventimp.close();
			//
			return false;
	});
	/*
	// Vertical
	$("#vertical div a").hover(function(){
		$("img", this).stop().animate({top:"-130px"},{queue:false,duration:200});
	}, function() {
		$("img", this).stop().animate({top:"0px"},{queue:false,duration:200});
	});
	// Horizontal
	$("#horizontal div a").hover(function(){
		$("img", this).stop().animate({left:"-296px"},{queue:false,duration:200});
	}, function() {
		$("img", this).stop().animate({left:"0px"},{queue:false,duration:200});
	});
	*/	
});

function anythingslider_jump(idx){
	$('.anythingSlider').anythingSlider(idx);
}

/*
// cycle para feedbacks
$('ul.feedbacks-anim').cycle({ 
	fx: 'scrollUp',
	pause: 1
});
// slideshow
$('.slideshow').cycle({
	fx: 'fade' // choose your transition type, ex: fade, scrollUp, shuffle, etc...
});
$('.slideshow2').cycle({
	fx: 'fade',
	next: '#next', 
	prev: '#prev' 		
});
*/

