////////// NAVIGATION //////////

jQuery(function( $ ){
	$('.main_nav a').click(function(){
		$.scrollTo( this.hash, 2000);
		return false;
	});
});

////////// TABS //////////

$(document).ready(function() {
	$('.tabs > ul').tabs();
});

////////// FOTO //////////

jQuery(document).ready(function() {
	jQuery('.foto_gallery').media_gallery({thumbnail_element: 'img', target_container: '#foto_gallery_display'});
});

////////// VIDEO //////////

jQuery(document).ready(function() {
	jQuery('.video_gallery').media_gallery({thumbnail_element: 'img', target_container: '#video_gallery_display'});
});

////////// CONTACT //////////

$(function() {
  $('.error').hide();

  $(".button").click(function() {
		// validate and process form
		// first hide any error messages
    $('.error').hide();
		
	  var name = $("input#name").val();
		if (name == "") {
      $("label#name_error").show();
      $("input#name").focus();
      return false;
    }
		var email = $("input#email").val();
		if (email == "") {
      $("label#email_error").show();
      $("input#email").focus();
      return false;
    }
		var phone = $("input#phone").val();
		if (phone == "") {
      $("label#phone_error").show();
      $("input#phone").focus();
      return false;
    }
		var themessage = document.getElementById('themessage').value;
		if (themessage == "") {
      $("label#themessage_error").show();
      $("textarea#themessage").focus();
      return false;
    }
		
		var dataString = 'name='+ name + '&email=' + email + '&phone=' + phone + '&themessage=' + themessage;
		//alert (dataString);return false;
		
		$.ajax({
      type: "POST",
      url: "bin/process.php",
      data: dataString,
      success: function() {
        $('#contact_form').html("<div id='message'></div>");
        $('#message').html("<p>Mesajul a fost trimis!</p>")
        .hide()
        .fadeIn(1500, function() {
          $('#message').append("<img id='checkmark' src='images/check.png' />");
        });
      }
     });
    return false;
	});
});