jQuery.ajaxSetup ({  
	cache: false  
});
var ajax_load = '<img src="images/loading.gif" alt="Loading..." />';  
var loadUrl = '/ajax.asp';  

jQuery(document).ready(function() {
	jQuery('H1').hide();
	// 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();
	});
	jQuery('UL.zebra LI:even').addClass('even');

	// CAPTURE AJAX BUTTONS
	jQuery('.buttonMainDoorway').click(function () {
		revealDialog('mainDoorway');
		return false;
	});
	jQuery('.buttonPostpartum').click(function () {
		revealDialog('postpartum');
		return false;
	});
	jQuery('.buttonYouth').click(function () {
		revealDialog('mainYouth');
		return false;
	});
	jQuery('.buttonContact').click(function () {
		revealDialog('contact');
		return false;
	});
	jQuery('.buttonPrivacy').click(function () {
		revealDialog('privacy');
		return false;
	});
	// NAV DESCRIPTION
	jQuery('#topNav LI DIV.links').hide();
	jQuery('#topNav LI').hover(function() {
		jQuery(this).find('.links').show();
	}, function() {
		jQuery(this).find('.links').hide();
	});
	jQuery('.abbreviated > P').append('&nbsp; <a class="more" href="#">&raquo; MORE</a>');
	jQuery('.abbreviated P A').click(function(){jQuery(this).parent().parent().find('.hide').slideToggle();return false});
	jQuery('.abbreviated').find('.hide').hide();
	jQuery('.paddedBorder').corner();
	jQuery('.intro').corner('20px');
	//jQuery('.newsItems LI').corner();
	//jQuery('.eventItems LI').corner();
	jQuery('#pastNews LI').corner();
	jQuery('.corner').corner();
	jQuery('.links LI').corner();
	jQuery('.styledList LI').corner();
	jQuery('.styledList2 LI:odd').css({'background-image':'none'});
});

// DIALOG BOX WITH AJAX
function revealDialog(element){
	jQuery('BODY').css('overflow','hidden');
	jQuery('#ajax').load(loadUrl + ' #' + element, null, function(){
		// VALIDATE FORM THEN AJAX SUBMIT
		if ((element == 'mainDoorway')||(element == 'mainYouth')){
			revealer();
		}
		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('#dialog').toggle();
						}  
				});
			}
		});
	});
	jQuery('#close').click(function () {
		jQuery('BODY').css('overflow','auto');
		jQuery('#dim').hide();
		jQuery('#dialog').css({'border':'0px solid #fff', 'width':'800px', 'height':'450px'});
		jQuery('#dialog').hide();

	});
	jQuery('#dialog').css('top', (jQuery(window).scrollTop() + 50) + 'px');
	jQuery('#dim').toggle();
	jQuery('#dialog').toggle();
}

// RESIZE DIM ON WINDOW CHANGE
jQuery(window).bind('resize', function(){
	jQuery('#dim').css('height', jQuery(window).height());
});

function revealer() {
	//jQuery('#revealerItemsBox').hide();
	jQuery('#revealerItemsAll').hide();
	jQuery('#revealerItemsBox').click(function() {
			jQuery('#revealerItemsBox').animate({'left':'1000px'},200);
	});
	jQuery('#revealerItemsList LI').hover(function() {
			jQuery(this).addClass('hover');
		}, function() {
			jQuery(this).removeClass('hover');
		})
		.click(function() {
			var tempIndex = $('#revealerItemsList LI').index(this);
			var tempLI = $('#revealerItemsAll LI:eq('+tempIndex+')');
			jQuery('#revealerItemsBox DIV').html(tempLI.html());
			jQuery('#revealerItemsBox').animate({'left':'20px'},200);
			return false;
	});
}

