/*--------------------------------------
 [01] SCROLL
 [02] FORM / VALIDATOR & SEND COMMENT

--------------------------------------*/


$(document).ready(function() {
/* [01] SCROLL
--------------------------------------*/

$('div.pane').scrollTo( 0 );
$.scrollTo( 0 );

var $paneTarget = $('#columna-izq');

$('#inicio_btn').click(function(){
	$paneTarget.stop().scrollTo( '#inicio', 1400 );
});
$('#historia_btn').click(function(){
	$paneTarget.stop().scrollTo( '#historia', 1400 );
});
$('#ubicacion_btn').click(function(){
	$paneTarget.stop().scrollTo( '#ubicacion', 1200 );
});
$('#contacto_btn').click(function(){
	$paneTarget.stop().scrollTo( '#contacto', 1200 );
});

/* [02] FORM / VALIDATOR & SEND COMMENT
--------------------------------------*/
$("#myform").validator().submit(function(e) {
	$('#res').html('');
	if (!e.isDefaultPrevented()) {
		$.ajax({
			type: "post",
			url: "send.php",
			data: $(this).serializeArray(),
			dataType: "html",
			success: function(data) {
				$('#res').html(data);
			}
		});
		e.preventDefault();
	}
	return false;
});

/* [03] CountDown
--------------------------------------*/
$('#countdown_dashboard').countDown({
  targetDate: {
	  'day': 		1,
	  'month': 	5,
	  'year': 	2011,
	  'hour': 	13,
	  'min': 		0,
	  'sec': 		0					
	  },
	  omitWeeks: true
});

/* [04] Map
--------------------------------------*/

/*-------------- FIN -----------------*/
});
function initialize() {
    var latlng = new google.maps.LatLng(-33.45128047441761,-70.628521);
    var myOptions = {
      zoom: 17,
      center: latlng,
      mapTypeId: google.maps.MapTypeId.HYBRID,
      mapTypeControlOptions: {
        style: google.maps.MapTypeControlStyle.HORIZONTAL_BAR,
        position: google.maps.ControlPosition.LEFT_BOTTOM
      },
      navigationControl: false
    };
    var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
    var markerLng = new google.maps.LatLng(-33.45128047441761,-70.629011);
    var marker = new google.maps.Marker({
      position: markerLng, 
      map: map, 
      title:"Te estamos esperando!"
    });
}


function check_mail(data){
  var patron = /^[\w-\.]+@([\w-]+\.)+[\w-]{2,4}$/;
  if(!patron.test(data.value)|| data.value == '')
    $('#error').html('Correo no válido').fadeIn('fast');
}
function no_null(data){
  if (data.value == '')
    $('#error').html('El nombre es obligatorio').fadeIn('fast');
}
function limpiar_mensajes(){  
  $('#error').fadeOut();
	$('#res').fadeOut();
}

