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('#topNav LI DIV').hide();

	
	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();
	});

	// CAPTURE AJAX BUTTONS
	jQuery('.buttonMainDoorway').click(function () {
		revealDialog('mainDoorway');
		return false;
	});
	jQuery('.buttonContact').click(function () {
		revealDialog('contact');
		return false;
	});
		jQuery('.buttonSignup').click(function () {
		revealDialog('subscribe');
		return false;
	});
	jQuery('.buttonPrivacy').click(function () {
		revealDialog('privacy');
		return false;
	});
	jQuery('.buttonLiveActs').click(function () {
		revealDialog('LiveActs');
		return false;
	});


	// NAV DESCRIPTION
	jQuery("#topNav LI").hover(function() {
		jQuery(this).css({'background':'#444'});
		jQuery(this).find('DIV').show();
	}, function() {
		jQuery(this).css({'background':'none','color':'#FC0'}); 
		jQuery(this).find('DIV').hide();
	});
	
	// NAV DESCRIPTION DIV
	jQuery("#topNav LI DIV A").hover(function() {							  
		jQuery(this).css({'background':'#5e5e5e'});
		jQuery(this).find('DIV').show();
	}, function() {
		jQuery(this).css({'background':'none','border-left':'1px solid #555','color':'#FC0'}); 
		jQuery(this).find('DIV').hide();
	});
	
});


// 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'){
			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();
						}
				});
			}
		});
		var v = jQuery('#formSubscribe').validate({
			submitHandler: function(form){
				jQuery(form).ajaxSubmit({
					target: "#ajax",
					success: function() { 
						//jQuery('#dialog').animate({borderWidth:'10px', width:'740px', height:'430px'},400);
						jQuery('#dialog').toggle();
						}  
				});
			}
		});
		var v = jQuery('#formRemove').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('#revealerItemsBoxClose').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':'0px'},200);
			return false;
	});
}





















