﻿
function isValidEmailAddress(emailAddress) {  
	var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);  
	return pattern.test(emailAddress);  
} 

$(document).ready(function() {

	// contact form 
	$("#sendMail").click(function() {
	
		var errorMessages = "false";
	
		var thisSender = $('#sender').val();
		if (thisSender == "") {
			$("#errorName").removeClass("noShow");				
			errorMessages = "true";
			} 
		
		var thisEmail = $('#email').val();
		if (thisEmail == "") {
			$("#errorEmail").removeClass("noShow");	
			errorMessages = "true";			
			}
		else {
			if (!isValidEmailAddress(thisEmail)) {
				$("#errorEmail").removeClass("noShow");	
				errorMessages = "true";			
			}
		}		

		if (errorMessages == "true") {
			 return false;
			}
	
		else {
			var thisPhone = $('#phone').val();
			var thisComments = $('#comments').val();
			var dataString = 'sender=' + thisSender + '&email=' + thisEmail + '&phone=' + thisPhone + '&comments=' + thisComments;
			
		    //alert (dataString);
		    //return false;
		    
			$.ajax({
			    type: "POST",
			    url: "sendmail.php",
			    data: dataString,
			    success: function() {
					$("#thankyou").removeClass('noShow');	
			    },
			    error: function() {
					$("#mailerror").removeClass('noShow');				    
			    }
			  });
	
		}		
	
	});	

 $("#navigation a").click(function () { 
      var divID = "#" + $(this).attr("title");
      $('#navigation a').removeClass("current");
      $(this).addClass("current");
      $(".section").hide();
	  $(divID).slideDown("slow");
      return true;
    });

 $("h1#logo").click(function () {
      var divID = "#" + $(this).attr("title");
      $("#navigation a").removeClass("current");
      $("#navHome").addClass("current");
      $(".section").hide();
	  $(divID).slideDown("slow");
      return true;
    });

 $("div.scrollable").scrollable({
   size: 1,
   clickable: false });	  
	
	$(".imgSelector li:first").addClass('active');

	$(".imgSelector li").click(function(){
	    //Set Variables
	    var youTubeURL = $(this).find('a').attr("title"); //Get You Tube video URL
	
	    if ($(this).is(".active")) {  //If the list item is active/selected, then...
	        return false; // Don't click through - Prevents repetitive animations on active/selected list-item
	    } else { //If not active then...
            $("#videoFrame").attr({ src: youTubeURL }); //Switch the main image (URL + alt tag)
	    }

	    //Show active list-item
	    $(".imgSelector li").removeClass('active'); //Remove class of 'active' on all list-items
	    $(this).addClass('active');  //Add class of 'active' on the selected list
	    return false; 
	
	}) .hover(function(){ //Hover effects on list-item 
	    $(this).addClass('hover'); //Add class "hover" on hover 
	    }, function() {
	    $(this).removeClass('hover'); //Remove class "hover" on hover out
	});

 $(".closeGallery").click(function () {
	$("#galleryCorporate").hide();
	$("#galleryEntertainment").hide();
	$("#galleryEvents").hide();	
    $("#gallerySelect").slideDown("slow");	
 });	

 $("#showCorporate").click(function () {
	$("#gallerySelect").hide();
	$("#galleryEntertainment").hide();
	$("#galleryEvents").hide();	
    $("#galleryCorporate").slideDown("slow");	
 });	
    
 $("#showEntertainment").click(function () {
	$("#gallerySelect").hide();
	$("#galleryEvents").hide();	
    $("#galleryCorporate").hide();
	$("#galleryEntertainment").slideDown("slow");	
 });	

 $("#showEvents").click(function () {
	$("#gallerySelect").hide();
    $("#galleryCorporate").hide();
	$("#galleryEntertainment").hide();
	$("#galleryEvents").slideDown("slow");	
 });	

$('#mask').click(function() {
	$("#showBox").hide("slow");
	$(this).hide("slow");
});

$('.scrollable .items img').click(function() {
	var filename = $(this).attr("title");
	var fullname = " #414141 url(" + filename + ") no-repeat center center";
	$('#showBox').css("background", fullname);
	var winH = $(window).height();
	var winW = $(window).width();
	$('#showBox').css('top',  winH/2-$('#showBox').height()/2);
	$('#showBox').css('left', winW/2-$('#showBox').width()/2);
	$('#showBox').fadeIn(1000);

});    

$('.closeBox').click(function() {
	$("#showBox").hide("slow");
}); 


}); 

