/*----------------------------------------
COAFP Javascript
Author: Marcus Ellis
Last Updated: October 5, 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($){
    
	// Expand collapse Right Nav content sections
	$('#rightnavcell h5').each(function(){
		$(this).nextUntil('h5, h6').wrapAll('<div class="wrap"></div>');
	}).prepend('<span></span>').hover(
		function(){
			$(this).addClass('hover');
		},
		function(){
			$(this).removeClass('hover');
		})
	.click(function(){
		$(this).children('span').toggleClass('open');
		$(this).next('.wrap').slideToggle();
	});
	$('#rightnavcell h5:first span').addClass('open');
	$('#rightnavcell h5:first + div').slideDown('slow');

	// Wrap Footer
	$('#assnfootercell, #footertablecell').wrapInner('<div id="assnfooterdiv"></div>');

	// Sliding Flyouts
	$('#navtop2list').addSlidingFlyouts();
	
	// Fix Hex Colors
	$('.module #maincontentcell').fixHexColors();

	// Horizontal Rules
	$('.ie hr').each(function(){
		$(this).after('<div class="hr"><img src="/global/imgs/trans1.gif" height="1" /></div>');
	}).remove();


 
	// HOME PAGE //
	if($('.home').length){
	
		// Login Widget
		$('#login-widget').incLoginWidget({
			buttonType: 'image',
			buttonImage: '/associations/7513/imgs/btn-login.png',
			hoverImage: '/associations/7513/imgs/btn-login-hover.png',
			callback: function(){
				$('#quick_login a.forgotpass').text('Forgot password?');
				$('#quick_login form').append('<a href="#" class="registerlink">Register Now</a>');	
			}
		});
		
		// Marketing Banner
		$('#banner ul li').each(function(){
			var slide = $(this).html();
			$(this).html('<div>' + slide + '</div>');
		});
		$('#banner ul li div').each(function(){
			$(this).before($(this).children('img'));
		});
		
		// Mktg Banner
		$('#banner ul').incMarketingBanner({
			showButtons: true
		});
		
		// Events
		$('#events-widget').inc247events({
			url: '/feeds/getEvent.cfm',
			items: 5,
			showLink: false,
			style: 'compact'
		});
		
		// Jobs
		var delay = 2500;
		function scrollJobs(d){
			var height = $('#jobs-content-inner').height();
			var pos = $('#jobs-content-inner').position();
			var dist = Math.round(height + pos.top);
			var time = Math.round(dist * 75);
			$('#jobs-content-inner').delay(d).animate({
				top: '-'+ height +'px'
			}, time, 'linear', function(){
				$(this).hide().css('top','5px').fadeIn();
				scrollJobs(delay);
			});
		}
		$('#jobs-content-inner').hover(
			function(){ $(this).stop(true);	},
			function(){ scrollJobs(0); }
		);
		scrollJobs(delay);
		
		// Feed Widget
		$('#feed-global').incFeedWidget({
			url: 'http://feeds.reuters.com/reuters/globalmarketsNews',
			items: 1,
			showDate: true,
			showTime: true,
			showDesc: true,
			dateFormat: 'full',
			callback: function(){
				$('#feed-economic').incFeedWidget({
					url: 'http://feeds.reuters.com/reuters/GCAeconomicNews',
					items: 1,
					showDate: true,
					showTime: true,
					showDesc: true,
					dateFormat: 'full'
				});			
			}
		});
		
		// Sponsors
		$('#sponsors ul').incSponsorBox();
		
		// Sidebar
		 $('#sidebar ul.links').makeacolumnlists({
			cols: 2,
			colWidth: 149,
			equalHeight: true
		}); 
	}						   
	
	// Clickable Logo
    $('body').addClickableLogo({
        name: 'Central Ohio Association of Financial Professionals',
        url: 'http://www.coafp.net'
    });

});




