function hideFlash() { 
	var flash = document.getElementsByTagName('object');
	for ( i=0; i<flash.length; i++) { 
		flash[i].style.visibility = 'hidden'
	}
}

function showFlash() { 
	var flash = document.getElementsByTagName('object');
	for ( i=0; i<flash.length; i++) { 
		flash[i].style.visibility = 'visible'
	}
}

(function($) {
	$(document).ready(function() {
		// SHOW SPLASH PAGE
		var top = ( $(window).height() - $('div.splash').height() ) / 2;
		var left = ( $(window).width() - $('div.splash').width() ) / 2;
		$('div#overlay').css('height', $(document).height() + 'px');
		$('div#overlay').show();		
		$('div.splash').css('top', top + 'px');
		$('div.splash').css('left', left + 'px');
		$('div.splash').show(function() { hideFlash(); });
		
		
		// SPLASH CLOSE BUTTON ACTION
		$('a.close').click(function() {
			$('div.splash').hide();
			$('div#overlay').hide();
			showFlash();
			return false;
		});
		
		/* Show Me More */ 
		 $('a.readBtn').click(function() {
			if ( $(this).text() == 'Read More' ) { 
				$(this).parent().find('div.more').slideDown();
				$(this).html('<span>Read Less</span>');
			}
			else if ( $(this).text() == 'Read Less' ) { 
				$(this).parent().find('div.more').slideUp();
				$(this).html('<span>Read More</span>');
			}
			return false;
		});
		
		/* BEGIN NEW ADDITIONS */
		// Initialize Superfish Menu
		$('ul.sf-menu').superfish({
			pathClass: 'current',
			dropShadows: 'false'
		});
		
		$('form#searchCriteria input#emailAddress').focus(function() {
			if ( $(this).val() == 'Enter your Email Address' ) { 
				$(this).val('');
			}
		});
		
		$('form#searchCriteria input#emailAddress').blur(function() {
			if ( $(this).val() == '' ) { 
				$(this).val('Enter your Email Address');
			}
		});
		
		$('form#searchArchive input#searchKeywords').focus(function() {
			if ( $(this).val() == 'Search Archive' ) { 
				$(this).val('');
			}
		});
		
		$('form#searchArchive input#searchKeywords').blur(function() {
			if ( $(this).val() == '' ) { 
				$(this).val('Search Archive');
			}
		});
		
		$('ul#languageMenu li a').hover(function() {
			$(this).next('div').slideDown();
		});
		/* END NEW ADDITIONS */
		
		// JCarousel Initialization
		$('ul#contributorsList').jcarousel({
			vertical: true,
			scroll: 6
		});
		
		$('#library').jcarousel({
			vertical: true,
			scroll: 5
		});
		
		// FAQ Collapsible Panels JS
		$('div.collapsible h6').hover(function() {
			$(this).css('cursor','pointer');
		}, function() {
			$(this).css('cursor','default');
		});
		
		$('div.collapsible h6').click(function() {
			$(this).next().slideToggle();	
		});
		
		$('a#expandall').click(function() {
			$('div.collapsible p').slideDown();	
			$(this).hide();
			$('a#collapseall').show();
			return false;
		});
		
		$('a#collapseall').click(function() {
			$('div.collapsible p').slideUp();	
			$(this).hide();
			$('a#expandall').show();
			return false;
		});
		
		// TOOLTIP INITIALIZATION
		$('ul#contributorsList img').each(function() {
			var el = $(this);
			el.tooltip({
				tip: '#tip' + el.attr('tipid'),
				position: 'top right',
				offset: [0, -85],
				effect: 'slide',
				predelay: 500
			});	
		});	
		
		$('img#help').tooltip({
			tip: '#languageHelp',
			position: 'top left',
			offset: [0, 220],
			effect: 'slide',
			predelay: 100
		});
		
		// CONTRIBUTORS SETTINGS
		$('input#contributors').click(function() {
			if ( $(this).attr('checked') ) { 
				$('span#contributorsList').slideDown();
			}
			else if ( $(this).attr('checked') == false) { 
				$('span#contributorsList').slideUp();
				$('span#contributorsList input').removeAttr('checked');
			}
		});
		
		
		
		
		
		
		
	});
})(jQuery);
