$(document).ready(function(){

// general para scroll
	$(".rest-pres").html($("#tcon1").html());
// scroll slider
	var ig=$(".rest-pres").height()-$(".rest-pres").parent("div").height();
	if(typeof(legal)=='undefined')
		ig=ig*1.09;
	else
		ig=ig*1.15;
	if(ig>0){$("#drag").slider({minValue:0,maxValue:ig, slide: function (event, ui) {$(".rest-pres").css("top", (ui.value*-1)+"px");}});}

// Efecto pestanyas menuPrincipal
	q=document.location.toString().split('/');
	q=q[q.length-1].split('?');
	if(q[0]!=''&&q[0].indexOf('index.php'==-1)){
		$("#menuPrincipal a[href='"+q[0]+"']").addClass('select');
	}else{
		$("#menuPrincipal a:first").addClass('select');
	}
	
	$('.catalogo li a').click(function(){
		c=0;
		h=$(".rest-pres dd").height();
		hh=$(".rest-pres dt").height();
		pos=$('.catalogo li a').index(this);
		tmp=$('#tcon1 dt').eq(pos).prev();
		if($('#tcon1 dd').index(tmp)!=-1){c=h*$('#tcon1 dd').index(tmp)+(hh*(pos+1));}
		$('#drag').slider("moveTo", c); 
		c=c*-1;
		$('.rest-pres').animate({top:c+'px'},300);		
	});

// Rollover
	$('.marginRotula a').click(function(){
		a=$('.marginRotula a').index(this);
		$('.containerImg img:visible').fadeOut(200);
		$('.containerImg img').eq(a).fadeIn(200);
		return false;
	});

// impresion click
	$('.left ul a').click(function(){
		a=$(this).attr('href');
		$('#imagenFondo').fadeOut(200,function(){
			$('#imagenFondo').html('<li style="position:absolute;display:list-item;"><img src="'+a+'" alt=""\/><\/li>').fadeIn(200);
		});
		return false;
	});

// Jcarousel
	jQuery('#mycarousel').jcarousel({auto:2,wrap:'last'});

//contacto 
	$('#send').click(function(){
		if($('#nombre').val()=='' || $('#telefono').val()=='' || $('#email').val()==''){
			alert('Los campos con * son obligatorios.');
		}else{
			var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
			if(!filter.test($('#email').val())){
				alert('E-mail no es valido.');
				$('#email').focus();
			}else			
				$('#cform').submit();
		}
	});

});




