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

//
// Menu inicio
//
//
function menu_inicio_show(class_name){
	$("#menu-inicio-images div").each(function(){
		$(this).hide();
	});
	if(class_name){	
		$("#menu-inicio-images div."+class_name+"").show("fast",
			function(){
				menu_inicio_hide(class_name);
			}
		);
	}
}
//
function menu_inicio_hide(class_name){
	$("#menu-inicio-images div").each(function(){
		if ($(this).attr("class") != class_name){
			$(this).hide();
		}
	});
}

//
// Ruta - Menu
//
// la marca se calcula en la ruta
function menu_marca(id,clase){
	$("#mainmenu-"+id).addClass(clase);
}
//	

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

//
//formularios
//

// copia datos de grupo al de contacto
function formulario_visitas_copy(){
	cb = $("input[name='copy']");
	//
	tlf = $("input[name='Telefono']");
	ema = $("input[name='Email']");
	//
	tlf_c = $("input[name='Tlf_Contacto']");
	ema_c = $("input[name='Email_Contacto']");
	//
	if(cb.is(':checked')){
		tlf_c.val(tlf.val());	
		ema_c.val(ema.val());	
	}
	else {
		tlf_c.val(' ');
		ema_c.val(' ');
	}
}

//
// Carga de funciones para DOM
//
$(function(){
	// pngFix ie5 ie6
	$(document).pngFix({
		blankgif: 'include/images/blank.gif'
	});

	// menu
	//var css = ['parent-hover', 'child-hover1', 'child-hover2', 'child-hover3', 'child-hover4'];
	//$('#mainmenu').dropDownMenu({timer: 900, numberOfLevels: 2, levels: css});
	
	// toggle
	$("dl.toggle").each(function(){
		$(this).children("dt").click(function(){
			$(this).toggleClass("current");
			$(this).next("dd").toggleClass("current");
			$(this).next("dd").toggle(200);
		});
	});
	
	// colorbox
	$("a[rel*='colorbox'],a[rel*='lightbox']").colorbox({
		transition: 'elastic', 
		scalePhotos: false,
		speed: 500, 
		current: '{current}/{total}'
	});	
	
	// colorbox
	$("a.iframe[rel*='colorbox']").colorbox({width:'80%', height:'80%', iframe:true});

	// tabs
		//initialIndex: <?=intval($_REQUEST["tabs-{$name}-selected"])?>,
		//onBeforeClick: function(tab_index){
		//	$('#tabs-<?=$name?>-hidden').attr('value',tab_index);
		//},	
		
		//onClick: function(index){
			//document.location='#'+(index+1);
		//}
	/*
	$("ul.tabs").tabs("div.tabs-panes > div.pane", {
		api: true,
		effect: 'fade',
		//history: false,
	  	//event:'mouseover'
	});
	*/

	// tiptip
	//$(".menu-item").tipTip();	

	/*
	// 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: 10000,                    // 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)
	});
	*/

	// fancy thumb
	$("div.exposiciones a.thumbs").hover(
		function(){
			$(this).css({'z-index' : '10'});
			$(this).find('img').addClass("hover").stop().animate(
				{
					marginTop: '-100px',
					marginLeft: '-75px',
					top: '50%',
					left: '50%',
					width: '200px',
					height: '125px',
					padding: '5px'
				},
				200
			);
		},
		function(){
			$(this).css({'z-index' : '0'});
			$(this).find('img').removeClass("hover").stop().animate(
				{
					marginTop: '0',
					marginLeft: '0',
					top: '0',
					left: '0',
					width: '82px',
					height: '52px',
					padding: '0px'
				},
				400
			);
		}
	);

	/*
	// Z-INDEX correcciones
	// poner el MENU por encima del SLIDER
	$("#blqCarrusel .anythingSlider ul").css('z-index',1);
	$("#blqMenu .showhide div").css('z-index',10);		
	*/

	//
	// Menus horizontales
	//
	$("#MenusHorizontales .blqMenuHorizontal").each(function(){
		$(this).find("ul li").mouseover(function(){
			// marcar el current
			$(this).siblings('li').each(function(){
				$(this).removeClass('current');
				$(this).removeClass('over');
			});
			$(this).addClass('current');
			$(this).addClass('over');			
			$(this).siblings('li').each(function(){
				if(!$(this).hasClass('current')){
					$(this).find("li").removeClass('over');
				}
			});
			
		});
	});
	
	//
	// menu inicio
	//
	$("#menu-inicio-enlaces").mouseleave(
		function(){
			menu_inicio_show();
		}
	);
	$("#menu-inicio-enlaces a").mouseover(
		function(){
			menu_inicio_show(this.className)
		}
	).mouseout(
		function(){
			menu_inicio_show();
		}	
	);
		
});

/*
//
$(document).ready(function() {
  $("iframe.autoHeight").autoHeight();
});
*/
