/*----------------------------------------
DEMA Javascript
Author: Marcus Ellis
Last Updated: June 17, 2011
(c) 2011 Affiniscape, Inc.
All Rights Reserved. This JavaScript file must not be reproduced without the express written permission of Affiniscape, Inc.
For questions regarding licensing or setup please contact Affiniscape, projects @ affiniscape dot com
----------------------------------------*/

var j = jQuery.noConflict();
j(document).ready(function($){
	
	// Mktg Banner
	$('#banner ul').incMarketingBanner({
		showBtns: false,
		showPager: false
	});
	
	// Left Nav Accordion
	$('#leftnavcell > ul > li').each(function(){
		$(this).wrapInner('<span></span>');
		$('ul',this).appendTo($(this));
	});
	$('#leftnavcell > ul > li > span').click(function(e){
		$(this).parent().toggleClass('open');
		$(this).next('ul').slideToggle();
		e.preventDefault();
	});
	var curr = window.location.href;
	$('#leftnavcell ul ul a').each(function(){
		var href = $(this).attr("href");
		if (href && curr == this) {
			$(this).parent('li').addClass('current').parent('ul').show().parent('li').addClass('open');
		}
	});
	
	// Search
	$('#structuraltable').after('<div id="search-widget"></div>');
	$('#search-widget').incSearchWidget({
		formAction: 'http://www.dema.org/searchsite.cfm',
		showLabel: false,
		buttonImage: '/associations/1017/imgs/btn-search.png',
		hoverImage: '/associations/1017/imgs/btn-search-hover.png'
	});
	
	// Translate
	$('#structuraltable').after('<div id="translate-widget"></div>');
	$('#translate-widget').incTranslationWidget();
	$('#navtop1item_1').hover(function(){ 
		$('#translate-links').show();
	},function(){ 
		$('#translate-links').hide();
	});

	// Footer
	$('body').addMegaFooter({
		columns: 12
	});
	$('#assnfooter .container_12')
		.after('<div id="coral-left" class="coral"></div>')
		.after('<div id="coral-right" class="coral"></div>');

	// Clickable Logo
    $('body').addClickableLogo({
        name: 'Diving Equipment &amp; Marketing Association',
        url: 'http://www.dema.org'
    });
    
    // Depth Gauge
	$('#structuraltable').after('<div id="depth-gauge"><span id="depth-top"></span><span id="depth-arrow"></span></div>');
	var h = $(document).height() - 100;
	$('#depth-gauge').height(h);
	var steps = Math.ceil(h / 100);
	for (i=0; i<steps; i++) {
		var top = i * 100;
		var d = i + 2;
		$('#depth-gauge').append('<span class="depth" style="top:'+ top +'px">'+ d +'0ft</span>');
	}
	/*$(window).scroll(function(event){
		$('#depth-gauge').mousemove();
	});*/
	$(document).mousemove(function(event){
		var top = event.pageY - 100;
		if (top < -50) { top = -50 }
		$('#depth-arrow').stop().animate({
			top: top
		},100);
	});

	// Parallax
	$('#structuraltable')
		.after('<div id="fish1" class="parallax"></div>')
		.after('<div id="fish2" class="parallax"></div>')
		.after('<div id="diver" class="parallax"></div>')
		.after('<div id="stingray" class="parallax"></div>');
	$('#fish1').scrollingParallax({
		staticSpeed: 0.6,
		staticScrollLimit: false
	});
	$('#fish2').scrollingParallax({
		staticSpeed: 0.8,
		staticScrollLimit: false
	});
	$('#diver').scrollingParallax({
		staticSpeed: 2,
		staticScrollLimit: false
	});
	$('#stingray').scrollingParallax({
		staticSpeed: 0.5,
		staticScrollLimit: false
	});

});

