jQuery(document).ready(function() {
	
	$(this).defaultBehaviour();	

});

// -- default behaviour

(function($) {
	$.fn.defaultBehaviour = function(options){
		var $this = $(this);
		
		$this.find('input.has-hint,textarea.has-hint').hint();		

		$this.find(".product-trigger").fancybox({
			titleShow: false,
			width: 780,
			height: 600,
			autoScale: false,
			autoDimensions: false,
			transitionIn: 'none',
			transitionOut: 'none',
			type: 'iframe',
			padding: 0,
			showCloseButton: false
		});
		
		$this.find('#close').click(function() {
			parent.$.fancybox.close();
			return false;
		});
		
		// -- request form --
	
		$this.find("form#request-form").submit(function() {
			
			if (!$('#request-name').val() || !$('#request-email').val() || !$('#request-phone').val()) {
				$("#request-error").show();
				$(this).find('input.has-hint,textarea.has-hint').hint();				
				return false;
			}
			
			$.post(this.action, $(this).serialize());
			$(this).hide();
			$('#request-sent').show();
			
			return false;
		});
	}
})(jQuery);
