jQuery.ajaxSetup ({  
	cache: false  
});
var ajax_load = '<img src="/images/loading.gif" alt="Loading..." />';  
var loadUrl = '/ajax.asp';  

jQuery(document).ready(function() {
// SETUP DIALOG DIVS
	jQuery('#dialog').hide();
	jQuery('#dim').hide();
	jQuery('#dim').css('height', jQuery(document).height());
	jQuery('#dim').click(function() {
		jQuery('BODY').css('overflow','auto');
		jQuery('#dim').toggle();
		jQuery('#dialog').hide();
	});

// CLEAR LAST LI BORDER
	jQuery('.lined LI:last-child').css('border','none');

// CAPTURE AJAX BUTTONS - in your code use the format <a href="/ajax/page-name">
	jQuery('a[href*="ajax"]').click(function () {
		var temp = jQuery(this).attr('href');
		temp = temp.split('/');
		var page = temp.pop();
		revealDialog(page);
		return false;
	});
	jQuery('.buttonContact').click(function () {
		revealDialog('contact');
		return false;
	});
	jQuery('.buttonPrivacy').click(function () {
		revealDialog('privacy');
		return false;
	});

});

// DIALOG BOX WITH AJAX
function revealDialog(element){
	jQuery('BODY').css('overflow','hidden');
	jQuery('#ajax').load(loadUrl + ' #' + element, null, function(){
		jQuery('.zebra TR:even').addClass('zebraEven');
		// VALIDATE FORM THEN AJAX SUBMIT
		var t = jQuery('#formWithCaptcha').captcha();
		var v = jQuery('#formContact').validate({
			submitHandler: function(form){
				jQuery(form).ajaxSubmit({
					target: "#ajax",
					success: function() { 
						//jQuery('#dialog').animate({borderWidth:'10px', width:'740px', height:'430px'},400);
						jQuery('#dialogWrapper').toggle();
						}  
				});
			}
		});
	});
	jQuery('#close').click(function () {
		jQuery('BODY').css('overflow','auto');
		jQuery('#dim').hide();
		jQuery('#dialog').css({'border':'0px solid #fff', 'width':'760px', 'height':'450px'});
		jQuery('#dialog').hide();

	});
	jQuery('#dialog').css('top', (jQuery(window).scrollTop() + 50) + 'px');
	var tempHeight = jQuery(window).height();
	jQuery('#dialog').css('height', tempHeight-100 + 'px');
	jQuery('#dim').toggle();
	jQuery('#dialog').toggle();
}

// RESIZE DIM ON WINDOW CHANGE
jQuery(window).bind('resize', function(){
   jQuery('#dim').css('height', jQuery(window).height());
});

