jQuery(document).ready(function(){
	jQuery(".slider img").css("display", "none");	
//--------------------------------------------------------------------------------------------
//Page scroll functions
//-------------------------------------------------------------------------------------------- 
	$('a[href*=#]').click(function() {
		 if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
 		&& location.hostname == this.hostname) {
   var $target = $(this.hash);
   $target = $target.length && $target
   || $('[name=' + this.hash.slice(1) +']');
   if ($target.length) {
  	var targetOffset = $target.offset().top;
  	$('html,body')
  	.animate({scrollTop: targetOffset}, 800);
    return false;
   }
 }
  });
//--------------------------------------------------------------------------------------------
//Portfolio hover functions
//-------------------------------------------------------------------------------------------- 
	$("#portfolio li.thumb").hover(function() {
		$(this).find('.moreinfo').stop()
		.animate({
			opacity: '0.95'
		}, 400);
	} , function() {
		$(this).find('.moreinfo').stop()
		.animate({	
			opacity: '0'
		}, 400);
	});
//--------------------------------------------------------------------------------------------
//Input Labels and Validation
//-------------------------------------------------------------------------------------------- 
	$("label.infield").inFieldLabels();
	$("form").validate({
		rules: {
			name: "required",
			email: {
				required: true,
				email: true
			},
			message: "required"
		},
		messages: {
			name: "Por favor, ingrese su nombre",
			email: {
				email: "Por favor, ingrese un email v&aacute;lido",
				required: "Por favor, ingrese su email"
			},
			message: "Por favor, ingrese un mensaje"
		}
	});	
	
	// Google Maps
	$("#map").gMap({ 
		controls: false,
		markers: [{ 
			latitude: -34.761169,
			longitude: -58.397505
		}],
	zoom: 12 
	});

//--------------------------------------------------------------------------------------------
//Contact Form
//-------------------------------------------------------------------------------------------- 
	$("#contact-form").submit(function(){
		var str = $(this).serialize();
		$.ajax({
		   type: "POST",
		   url: "send.php",
		   data: str,
		   success: function(msg){
				$("#formstatus").ajaxComplete(function(event, request, settings){
					if(msg == 'OK'){ // Message Sent? Show the 'Thank You' message and hide the form
						$("#contact-form").slideUp("fast");
						result = '<div class="formstatusok">Se ha enviado su mensaje. &iexcl;Muchas gracias!</div>';
					}
					else{
						result = msg;
					}
					$(this).html(result);
				});
			}
		 });
		return false;
	});

			
}); //end doc rdy

jQuery(window).load(function() {
//--------------------------------------------------------------------------------------------
//Fancybox functions
//-------------------------------------------------------------------------------------------- 
$("a.zoom").fancybox({
		'transitionIn'	:	'fade',
		'transitionOut'	:	'fade',
		'speedIn'		:	200, 
		'speedOut'		:	200, 
		'overlayColor' : '#000',
		'overlayOpacity' : '0.8',
		'padding' : '0'
	});
//--------------------------------------------------------------------------------------------
//Nivo slider functions
//-------------------------------------------------------------------------------------------- 
	jQuery(".slider img").fadeIn("slow");
	jQuery('.slider').nivoSlider({
		effect:'fade', //sliceDown, sliceDownLeft, sliceUp, sliceUpLeft, sliceUpDown, sliceUpDownLeft, fold, fade, random
		slices:5, //how many slices
		animSpeed:500, //Set transition speed
		pauseTime:5000, //Set pause inbetween slides
		startSlide:0, //Set starting Slide (0 index)
		directionNav:true, //Next & Prev - DO NOT CHANGE
		directionNavHide:false, //Only show on hover - DO NOT CHANGE
		controlNav:true, //1,2,3... - DO NOT CHANGE
		controlNavThumbs:false, //Use thumbnails for Control Nav - DO NOT CHANGE
		controlNavThumbsSearch: '.jpg', // DO NOT CHANGE
		controlNavThumbsReplace: '_thumb.jpg', // DO NOT CHANGE
		keyboardNav:true, //Use left & right arrows - DO NOT CHANGE
		pauseOnHover:true, //Stop animation while hovering
		manualAdvance:false, //Force manual transitions
		captionOpacity:0, // default 0.8
		beforeChange: function(){},
		afterChange: function(){},
		slideshowEnd: function(){} //Triggers after all slides have been shown
	});
});
