// JavaScript Document
/**
 * @description
 * @author DC
 * @created 2008-04-21
 */
jQuery(function(){	
	/*
	jQuery('.sharethisvideo').hover(
		function(){
			jQuery(this).addClass("sharethisvideohovered");
			//this placeholder is necessary to prevent other content flowing in to fill the gap as this becomes absolutely positioned
			jQuery(this).parent().append('<div class="sharethisvideoplaceholder"></div>');
		},
		function(){
			jQuery(this).removeClass("sharethisvideohovered");
			jQuery(this).parent().find('.sharethisvideoplaceholder').remove();
		}
	);
	*/
	
	//footer slider
	var container = jQuery('#canitberecycledscroller');
	var ul = jQuery('ul', container);
	var itemsWidth = (jQuery('#canitberecycledscroller .items li').length * 79) - container.outerWidth();
	
	jQuery('#canitberecycledscroller').css("height","152px");
	jQuery('#canitberecycledscroller .hidden').show();
	jQuery('#canitberecycledscroller .items').css("width", (jQuery('#canitberecycledscroller .items li').length * 79) + "px");
	jQuery('.slider', container).slider({
		minValue: 0,
		maxValue: itemsWidth,
		handle: '.handle',
		stop: function (event, ui) {
			ul.animate({'left' : ui.value * -1}, 500);
		},
		slide: function (event, ui) {
			ul.css('left', ui.value * -1);
		}
	});
	
	
	//quicksearch select dropdown
	jQuery('#quicksearchitem').change(function(){
		jQuery('#quicksearch').submit();
	});
	
	jQuery('#quicksearch').submit(function(){
		if(jQuery('#quicksearchitem').val().length){
			document.location.href=jQuery('#quicksearchitem').val();
			return false;
		}
	});
	
	//Share this links
	jQuery('.sharethis a').click(function(){
		window.open(jQuery(this).attr("href"),'Share this', 'toolbar=0,status=0,width=600,height=400');
		return false;
	});
	
	//OL styling in rich-text content
	jQuery('.content-descr ol').addClass('pretty-ol');
	jQuery('.content-descr ol.pretty-ol').each(applyOlBulletStyleToList);
	
	
	/*
	jQuery.sifrSettings();
	jQuery("h1:not([class*=nosifr])").sifr({path:'/javascript/jquery/sifr/fonts/', font:'futuraboldcondensed'});
	jQuery("h2:not([class*=nosifr])").sifr({path:'/javascript/jquery/sifr/fonts/', font:'futuraboldcondensed', link:'#7FBB28', hover:'#C06401'});
	jQuery(".featurelist h2:not([class*=nosifr])").sifr({path:'/javascript/jquery/sifr/fonts/', font:'futuraboldcondensed', link:'#7FBB28', hover:'#C06401'});
	jQuery("h3:not([class*=nosifr])").sifr({path:'/javascript/jquery/sifr/fonts/', font:'futuraboldcondensed', link:'#7FBB28', hover:'#C06401'});
	jQuery("#secondary_navigation .toplevel").sifr({path:'/javascript/jquery/sifr/fonts/', font:'futuraboldcondensed'});
	*/
	
	if(jQuery('#newsticker')){
		jQuery('#newsticker').cycle({
			fx: 'fade', 
			speed: 1000, 
			timeout: 5000 
		});
	}
});

//process each ol, and call function to style the li 
function applyOlBulletStyleToList(index, elem){
  jQuery(elem).children("li").each(displayOlBulletItem);
}

//process each li
function displayOlBulletItem(index, elem){
  jQuery(elem).addClass( 'number_' +  String(Number(index)+1));
}
