var modalPopup = {
	open: function(d) {
		var self = this;
		self.container = d.container[0];
		d.overlay.fadeIn('slow', function () {
			$("#inline-popup", self.container).show();
			var title = $("#inline-popup-title", self.container);
			title.show();
			d.container.slideDown('slow');
		})
	},
	close: function (d) {
		var self = this;
		d.container.slideUp('fast', function() {
			self.close();
		});
	}
}

$(function() {
	$(".dataTable tr:even").addClass("even");
	$(".dataTable tr:odd").addClass("odd");

	if ($('a.lightbox').length > 0) {
		 $('a.lightbox').fancybox({
			'overlayOpacity' : 0.7,
			'overlayColor' : '#000',
			'transitionIn' : 'none',
			'transitionOut' : 'none',
			'titlePosition' : 'over',
			'titleFormat' : function(title, currentArray, currentIndex, currentOpts) {
				return '<span id="fancybox-title-over">Image ' + (currentIndex + 1) + ' / ' + currentArray.length + '<br />' + title +'</span>';
			}
		}); 
	}
	$(".opaque").animate({opacity: .5}, 250);
	$(".opaque").hover(function() {
		$(this).addClass("active").stop(true, true).animate({opacity: 1}, 250);
		}, function(){
		$(this).animate({opacity: .5}, 250).removeClass("active");
	});


	$('.contact-us').click(function() {
		$.get(base_url + 'contact.php', function(data){
			// create a modal dialog with the data
			$(data).modal({
				containerId: '#inline-popup',
				minHeight:80,
				opacity:45,
				escClose: false,
				closeClass : 'modalCloseImg',
				onOpen:modalPopup.open,
				onClose: modalPopup.close,
				onShow: function (d) {
					var options = { 
						url: base_url + "contact.php",
						success: function(responseText) { 
							if (responseText == 1) {
								$.modal.close();
							}
						} 
					}; 

					$("#contactForm").validate({
						submitHandler: function(form) {
							$(form).ajaxSubmit(options);
						}
					});
				}
			});
		});
		return false;
	});


});
