$(document).ready(function(){

	$(".thumbnails div").css("opacity","1.0"); // OPACITY OF BUTTON SET TO 50%
	
	$(".thumbnails div").hover(function () { // ON MOUSE OVER
		$(this).stop().animate({ opacity: 0.5 }, "slow"); // SET OPACITY TO 100%
	},
		
	function () { // ON MOUSE OUT
		$(this).stop().animate({ opacity: 1.0 }, "slow"); // SET OPACITY BACK TO 50%
	});
	
	// initialize scrollable
	$(".scrollable").scrollable({ 
		'disabledClass'	:	'disabled',
		'easing'				:	'swing',
		'speed'				:	700
	}).navigator();
	
	// fancybox image zoom
	$(".thumblink").fancybox({
		'overlayColor'		:  '#000000',
		'overlayOpacity'	:  0.7,
		'imageScale'		:	true,
		'zoomSpeedIn'		:	600,
		'zoomSpeedOut'		:	500,
		'showCloseButton'	:	true
	});
	
	$(".thumblink-video").fancybox({
		'overlayColor'		:  '#000000',
		'overlayOpacity'	:  0.7,
		'imageScale'		:	true,
		'frameWidth'		:	657,
		'frameHeight'		:	377,
		'padding'			:	0,
		'zoomSpeedIn'		:	600,
		'zoomSpeedOut'		:	500,
		'showCloseButton'	:	true
	});
	
	// slide out enquiry form
	$("a.contact").toggle( 
			function () { 
				$("#contactArea").animate({height: "210px"}, {queue:false, duration: 800}) 
         }, 
         function () { 
				$("#contactArea").animate({height: "0px"}, {queue:false, duration: 800})  
			} 
		);
		
	$('#subject').dropkick();
});

function popUp(URL) {
	day = new Date();
   id = day.getTime();
   eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=1,menubar=0,resizable=1,width=600,height=750,left = 590,top = 150');");
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

//JQuery form validation

$.validator.setDefaults({
	//submitHandler: function() { alert("submitted!"); },
	highlight: function(input) {
		/*$(input).addClass("ui-state-highlight");*/
		$(input).css('border', '2px solid yellow');
	},
	unhighlight: function(input) {
		$(input).removeClass("ui-state-highlight");
		$(input).css('border', '1px solid #999');
	}
});

$(document).ready(function(){	
	// validate signup form on keyup and submit
	$("#enquiry-form").validate({
		rules: {
			name: {required: true, minlength: 3},
			email: {required: true, email: true},
			enquiry: {required: true, minlength: 3},
			verify: {required: true,minlength: 5},
			/*
			topic: { required: "#newsletter:checked", minlength: 2 },
			agree: "required"
			*/
		},
		messages: {
			name: { required: "Please enter your name", minlength: "Your name must be at least 3 characters" },
			email: "Please enter a valid email address",
			enquiry: { required: "Please enter your enquiry", minlength: "Please use at least 3 characters" },
			verify: { required: "Please enter the text you see in the image", minlength: "The verify box must contain 5 characters" },
		}
	});
});

