//** hiding FOUC of contact form **//

$('html').addClass('js');

// ** page tools ** //

$(document).ready(function() {
	$('ul#tools').prepend('<li class="print"><a href="#print" title="Click to print this page in text format">Print</a></li>');
	$('ul#tools li.print a').click(function() {
		window.print();
		return false;
	});
});

//** modals **//

			$(document).ready(function(){
$("a[rel='nofollow']").colorbox({width:"90%", height:"90%", iframe:true});
$("a.youtube").colorbox({width:"405", height:"340", iframe:true});
$("a.img").colorbox({transition:"elastic", slideshow:true});
				
			});
			
	//** tabs **//


    $(document).ready(function(){
    	$(".comtabs").accessibleTabs({
    	    tabhead:'h5',
    	    fx:"fadeIn"
    	});
    });

//** zebra tables **//



	
	//** scroller **//	


$(document).ready(function() {
	$("a.scroller").anchorAnimate()
});

jQuery.fn.anchorAnimate = function(settings) {

 	settings = jQuery.extend({
		speed : 1100
	}, settings);	
	
	return this.each(function(){
		var caller = this
		$(caller).click(function (event) {	
			event.preventDefault()
			var locationHref = window.location.href
			var elementClick = $(caller).attr("href")
			
			var destination = $(elementClick).offset().top;
			$("html:not(:animated),body:not(:animated)").animate({ scrollTop: destination}, settings.speed, function() {
				window.location.hash = elementClick
			});
		  	return false;
		})
	})
}

// ** sliding sidebar 2 ** //


$(document).ready(function() {	

	//Get the height of the first item
	$('#mask').css({'height':$('#panel-1').height()});	
	
	//Calculate the total width - sum of all sub-panels width
	//Width is generated according to the width of #mask * total of sub-panels
	$('#panel').width(parseInt($('#mask').width() * $('#panel div').length));
	
	//Set the sub-panel width according to the #mask width (width of #mask and sub-panel must be same)
	$('#panel div').width($('#mask').width());
	
	//Get all the links with rel as panel
	$('a[rel=panel]').click(function () {
	
		//Get the height of the sub-panel
		var panelheight = $($(this).attr('href')).height();
		
		//Set class for the selected item
		$('a[rel=panel]').removeClass('selected');
		$(this).addClass('selected');
		
		//Resize the height
		$('#mask').animate({'height':panelheight},{queue:false, duration:500});			
		
		//Scroll to the correct panel, the panel id is grabbed from the href attribute of the anchor
		$('#mask').scrollTo($(this).attr('href'), 800);		
		
		//Discard the link default behavior
		return false;
	});
	
});

/** equal height columns **/
$(document).ready(function() {
 $('.items').equalHeights(); 
	});
	
	
/** sliding home features **/

$(document).ready(function () {
  $('.infiniteCarousel').infiniteCarousel();
});


/** pagination **/

    $(document).ready(function(){
				$("#results li").quickpaginate({ perpage: 15, pager : $("#pagecounter") });
			});
			

/** table sorter **/

$(document).ready(function() {
	// call the tablesorter plugin
	$("table").tablesorter({
		// sort on the first column and third column, order desc
		sortList: [[0,1]]
	});
}); 

/** toggle **/

  $(document).ready(function(){
    $("#toggler").eede({
	speed:"slow"
	});
  });