/**
 * Checkbox and Radio Button Replacement
 */
$(function(){
	if (typeof document.body.style.maxHeight !== "undefined")
	{
		// NOT IE6
		$('input').checkBox();
	}
});

/**
 * YouTube Videos
 * 
 * Simply use: <a href="http://www.youtube.com/v/jz2kQjFn0rY">Plastic Recycling 1 PET Video on YouTube</a>
 */
$(document).ready(function(){ 
	$('a[href^="http://www.youtube.com/v/"]').flash(
		{ width: 270, height: 165, wmode: "transparent", allowscriptaccess: "always", allowfullscreen: "true" },
		{ version: 8, expressInstall: true},
		function(htmlOptions) {
			$this = $(this);
			htmlOptions.src = $this.attr('href');
			$this.before($.fn.flash.transform(htmlOptions));
		}
	);
});

/**
 * FishEye example
 */
$(function(){
		$('.jCarousel').jCarouselLite({
			btnNext: ".next",
			btnPrev: ".prev",
			visible: 4
		});
		
		$('.jCarousel img').mouseover(function(){
			$(this).stop().animate({ 
				width: 105,
				height: 124
			}, 100 );
		}).mouseout(function(){
			$(this).stop().animate({ 
				width: 89,
				height: 102
			}, 100 );
		}).click(function(){
			$('.slide').hide();
			$('#'+$(this).attr('id')+'Content').show();
		});
		
});


/**
 *  Search Button Logic
 * 
 *  Used to determine if were searching the blog, or the site.
 */
$(function(){
	$('#searchSubmit').click(function(){
		if ($('#searchSite').attr('checked')){
			// Its a site search, leave everything as is and submit.
			return true;
		} else {
			// Its a blog search, forward to wordpress
			/*$('#cse-search-box').attr('method','post').attr('action','some_other_url.html');
			return true;*/
			window.location = "http://www.recyclemore.ie/recycling_news_blog/?s="+document.getElementById('searchInput').value;
			return false;
		}
	});
});

/**
 * Graham: Whats all this??
 */
$(function(){
    $('.contentArea140AccordianContainer .contentArea140Accordian .content').hide();
    $('.contentArea140AccordianContainer .contentArea140Accordian .content').addClass('collapsed');
    $('.contentArea140AccordianContainer #findUsOn .content').show();
    $('.contentArea140AccordianContainer #findUsOn .content').addClass('expanded');
    $('.contentArea140AccordianContainer #findUsOn .content').removeClass('collapsed');
    $('#rssAndEmail .footer').hide();
    $('.contentArea140AccordianContainer .contentArea140Accordian .header').mouseover(function() {
		if ($(this).next().is('.expanded')) {
       
		}else if($.browser.msie && $.browser.version == '6.0'){
			$('.expanded').hide()
			$('.expanded').addClass('collapsed');
			$('.expanded').removeClass('expanded');
			
			$(this).next().show();
			$(this).next().addClass('expanded');
			$(this).next().removeClass('collapsed');
			if ($(this).parent().attr('id') == 'rssAndEmail'){
				$('#rssAndEmail .footer').show();
			} else {
				$('#rssAndEmail .footer').hide();
			}
		}else{
			$('.expanded').slideUp('slow')
			$('.expanded').addClass('collapsed');
			$('.expanded').removeClass('expanded');
			
			$(this).next().slideDown('slow');
			$(this).next().addClass('expanded');
			$(this).next().removeClass('collapsed');
			if ($(this).parent().attr('id') == 'rssAndEmail'){
				$('#rssAndEmail .footer').show();
			} else {
				$('#rssAndEmail .footer').hide();
			}
		}
        
    });
    $('#header .linksContainer .links li').mouseover(function() {
    	var i = 0;	
		$('#header .linksContainer .links li.active').removeClass('active');
    	switch ($(this).attr('id')){
    		case 'why':
    			$('#why').addClass('active');
    			i = (182 * 1) + (20 * 1);
    			break;
    		case 'what':
    			$('#what').addClass('active');
    			i = (182 * 2) + (20 * 2);
    			break;
    		case 'where':
				$('#where').addClass('active');
				i = (182 * 3) + (20 * 3);
    			break;
    		case 'how':
    			$('#how').addClass('active');
    			i = (182 * 4) + (20 * 4);
    			break;
			default:
				i = 0;
				break;
    	} 
    	$("#slideContainer").stop().animate({ 
			top: '-'+i+'px'
			}, 500, 'linear'
		);
    });
});

// Config required for the AddThis widget
var addthis_config =
{
   username: "recyclemore"
}
