// nivo slider options
$(window).load(function() {
    $('#slider').nivoSlider();
});
	
// function to validate email		
function validateEmail(email) { 
    var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
    return re.test(email);
} 
// ajax submit contact form	
$(function() {
  $('.errormess').hide();
  $("#submit_btn").click(function() {
    $('.errormess').hide();
	$('.contact_loading').html('<img src="templates/default/assets/images/loading.gif" align="absmiddle">');	
	var name = $("input#name").val();
	if (name == "") {
       $('.contact_loading').hide();	
	   $("div#name_error").show();
       return false;
    }
	var email = $("input#email").val();
	if (email == "") {
       $('.contact_loading').hide();	
	   $("div#email_error").show();
       return false;
    }
	if (!validateEmail(email)) {
       $('.contact_loading').hide();	
	   $("div#email_error").show();
       return false;
    }	
	var title = $("input#title").val();
	if (title == "") {
       $('.contact_loading').hide();	
	   $("div#title_error").show();
       return false;
    }
	var message = $("textarea#message").val();
	if (message == "") {
       $('.contact_loading').hide();	
	   $("div#message_error").show();
       return false;
    }
	
	var dataString = 'title='+ title + '&message=' + message + '&name='+ name +'&email='+ email;

	$.ajax({
      type: "POST",
      url: 'include/ajax.php?method=contact',
      data: dataString,
	  dataType: "html",
      success: function(data) {
	  if (data == 1) {
			$('.contact_loading').hide();	
			$('div#success_send').show();
			document.getElementById("pmcontactform").reset();
		} else {
			$('div#error_message').show();
		}
      }
     });
    return false;
	});
});
// superbox options
$(function(){
			$.superbox.settings = {
				closeTxt: "Close",
				loadTxt: "Loading...",
				nextTxt: "Next",
				prevTxt: "Previous"
			};
			$.superbox();
		});