/* ====================================================================================== */
/* jQuery document-is-ready function. Place all calls here */
jQuery(document).ready(function() {

	var ARTICLE_DELAY = 1500; // milliseconds, 1500 = 1.5s
	
// 
// specific case for the contact form (mdp 3 feb 2011)
//	
	var ARTICLE_FORM_DELAY = 0; 

	// ---------------------------------------------------------------------------------------------------
	$("a[rel^='prettyPhoto']").prettyPhoto({
		default_width:	600,
		allowresize:	false,
		animationSpeed:	'fast',
		opacity:		0.4,
		showTitle:		false,
		theme:			'light_square'
	});
	
	$("#form_status").click();
	// ---------------------------------------------------------------------------------------------------
	/*if($("#homepage_banner").length > 0) {
		// Initially hide then show the banner
		//if( ! $.browser.msie)
			//$("#homepage_banner").css("display","none").pause(ARTICLE_DELAY).fadeIn("slow",0.8)
		//else
			$("#homepage_banner").css("display","none").pause(ARTICLE_DELAY).fadeTo("slow",0.8)
	}*/
	
	// For the article box, add some show/hide controls
	if($("#article").length > 0) {
	
		// Initially hide the article
		$("#article").css("display","none");//.addClass("trans");

		// ---------------------------------------------------------------------------------------------------
		// Internet Explorer can't handle text on a transparent background. Microsoft chose to turn off 
		// Cleartext because they couldn't make it work (it looks like an Atari 800 from the mid 80's)
		// Here we detect IE and if not IE, add our nice transparency effect
		/*if( ! $.browser.msie) {
			$("#article").addClass("trans");
			$("#submenu").addClass("trans");
		} */
		
		// Show the article after a short delay
		$("#article").pause(ARTICLE_DELAY).slideDown("fast");
		
		var box_open = "<div id=\"article_show\"><img src=\"/media/template/b_open.gif\" /></div>";
		var box_close = "<div id=\"article_hide\"><img src=\"/media/template/b_close.gif\" /></div>";
		$("#showhide").prepend(box_close);

		// Toggle the article area when Open/Close is clicked
		$("#showhide").live('click',function() {
			if($("#article_hide").length > 0) {
				// Close the Article column if requested
				$("#article").slideUp("fast",function() {
					$("#article_hide").replaceWith(box_open);
				});
			} else {
				// Open the Article column if requested
				$("#article").slideDown("fast",function() {
					$("#article_show").replaceWith(box_close);
				});
			}
		});
	}
	
// 
// specific case for the contact form (mdp 3 feb 2011)
//
if($("#article_FORM").length > 0) {
	
		// Initially hide the article
		$("#article_FORM").css("display","none");//.addClass("trans");
		
		// Show the article after a short delay
		$("#article_FORM").pause(ARTICLE_FORM_DELAY).slideDown("fast");
		
		var box_open = "<div id=\"article_show\"><img src=\"/media/template/b_open.gif\" /></div>";
		var box_close = "<div id=\"article_hide\"><img src=\"/media/template/b_close.gif\" /></div>";
		$("#showhide").prepend(box_close);

		// Toggle the article area when Open/Close is clicked
		$("#showhide").live('click',function() {
			if($("#article_hide").length > 0) {
				// Close the Article column if requested
				$("#article_FORM").slideUp("fast",function() {
					$("#article_hide").replaceWith(box_open);
				});
			} else {
				// Open the Article column if requested
				$("#article_FORM").slideDown("fast",function() {
					$("#article_show").replaceWith(box_close);
				});
			}
		});
	}	
});

// Pause function
$.fn.pause = function(duration) {
	$(this).animate({ dummy: 1 }, duration);
	return this;
};
/* ====================================================================================== */
