$('document').ready(function(){
	
	//	A la funcion le paso, el boton del evento y el menu a desplegar.
	//	+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
	function menuToggle(boton,contMenu){
	
		$('.menuPpl a').click(function(){
		
			$('.menuPpl ul').css("display","none")
		
		})
		
		
		
		$(boton).click(function(e){
			
			e.preventDefault(); 
			e.returnValue=false;
			
			 $(contMenu).slideToggle("fast");

		})
	}
	
	if($('#idProducto')){
		
		$('#idProducto').change(function(){
			
			idProducto = $(this).val();
			$('#buscaProd').submit();
			
		})
	}

	
	
	//	Ejecuto función que despliega menus
	menuToggle('#btProds',		".menuSec.menuProd");
	menuToggle('#btAcerca',		".menuSec.menuAcerca");
	menuToggle('#btPublis',		".menuSec.menuPubl");
	menuToggle('#btNovs',		".menuSec.menuNovs");
	menuToggle('#btInfo',		".menuSec.menuInfo");

	//	Valido formulario de contacto
	//	++++++++++++++++++++++++++++++++
	$('#btEnviar').click(function(e){

			e.preventDefault(); 
			e.returnValue=false;
			
			error = "";
			$('.error').css("display","none")
			
			contacto		=	$('#contacto').val();
			email		=	$('#email').val();
			consulta	=	$('#consulta').val();
			
			if(contacto == ""){
			
				error += "Debe completar su nombre.<br />";
			}
			
			if(email == "")	{	
				
				error += "Debe completar su mail.<br />";	
			} else {
				
				if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(email))){	error += "El formato de su e-mail es incorrecto.<br />";	}
			
			}
			
			if(consulta == ""){
			
				error += "Debe completar su consulta<br />";
			}
			
			
			if(error != ""){
				
				$('.error').html(error)
				$('.error').fadeTo('slow', 1);
				
			}else{
				
				
				$('#formConsulta').submit();
			}
	});
	
	//	Lightbox
	//	++++++++++++++++
	$(function() {
		$('.imagen a').lightBox({
								
			overlayOpacity:	 0.6,
			overlayBgColor: '#000',
			imageLoading: 	'images/imgLightbox/lightbox-ico-loading.gif',
			imageBtnClose: 	'images/imgLightbox/lightbox-btn-close.gif',
			imageBtnPrev: 	'images/imgLightbox/lightbox-btn-prev.gif',
			imageBtnNext: 	'images/imgLightbox/lightbox-btn-next.gif',
			txtImage: 		'Imágen',
			txtOf:			 'de'
			
		});
	 });
	
	

	
	
});	

function togMenu(menu){
	
	
	
		 $(menu).slideToggle("fast");


}

function mycarousel_initCallback(carousel)
{
    // Disable autoscrolling if the user clicks the prev or next button.
    carousel.buttonNext.bind('click', function() {
        carousel.startAuto(0);
    });

    carousel.buttonPrev.bind('click', function() {
        carousel.startAuto(0);
    });

    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
};

