var ic_custom = {};

ic_custom = function ()
{
	var pub = {};
	var self = {};
	var chartColors = ['#263849','#FF9900','#555','#777','#999','#bbb','#ccc','#eee'];

	pub.init = function ()
	{		
		$('#search').find ('input').live ('click' , function () { $(this).val ('') });
		$("form.form select, form.form input:checkbox, form.form input:radio, form.form input:file").uniform();
				
		$('*[rel=datatable]').dataTable ();
		
		$("*[rel=tooltip]").tipsy ({ gravity: 's' });
		$("*[rel=facebox]").facebox ();
		
		$('table.stats').each(function() 
		{		
			var chartType = '';
			
			if ( $(this).attr('title') ) 
			{ 
				chartType = $(this).attr('title'); 				
			}
			else 
			{ 
				chartType = 'area'; 
			}
			
			var chart_width = $(this).parents ('.portlet').width () * .85;
					
			$(this).hide ().visualize({		
				type: chartType,	// 'bar', 'area', 'pie', 'line'
				width: chart_width,
				height: '240px',
				colors: chartColors
			});				
		});
	}
	
	return pub;
	
}();


(function($){
	$.fn.accordion = function(options) {
	
		var defaults = 
		{

		};
	
		var options = $.extend(defaults, options);
	
		return this.each( function() 
		{		
			var $container = $(this);
			var $triggers = $container.find ('.accordion_panel');
			var $panels = $container.find ('.accordion_content');
			
			
			$panels.hide ();			
			$triggers.eq (0).addClass ('active').next ().show ();			
			
			// Set min-height to prevent content from jumping as much
			$container.css ('min-height' , $container.height ()  + 10 + 'px');
			
			$triggers.live ('click' , function () 
			{
				if ( $(this).next ().is (':hidden') )
				{
					$triggers.removeClass ('active').next ().slideUp ();
					$(this).toggleClass ('active').next ().slideDown ();
				}					
				return false;
			});
		});		
	};

})(jQuery);


(function($){
	$.fn.tabs = function(options) {
	
		var defaults = 
		{
			
		};
	
		var options = $.extend(defaults, options);
	
		return this.each( function() {
	   		
			var $tabContainer = $(this);
			var $tabLi = $tabContainer.find ('.tabs li');
			var $tabContent = $tabContainer.find ('.tab_content');
			
			$tabContent.hide ();
			$tabLi.eq (0).addClass ('active').show ();
			$tabContent.eq (0).show ();
					
			$tabLi.live ('click' , function () 
			{
				var activeTab = $(this).find ('a').attr ('href');
				
				$tabLi.removeClass("active");
				$(this).addClass("active");
				$tabContent.hide ();
				
				$tabContainer.find (activeTab).fadeIn ('slow');
				return false;
			});	
			
		});		
	};

})(jQuery);


/* Screenshots */

	$(document).ready(function(){ 
		$('.boxgrid.captionfull').hover(function(){ //On hover...
			$(".cover", this).fadeOut("fast");
		}, 
		function() { //On hover out...
			$(".cover", this).fadeIn("fast");
		});

});

loadFun = function() {

		$('#slider').cycle({ 
		    fx:      'fade', 
		    speed:    5000,
		    autostop: 1,
		    autostopCount: 13, 
		    timeout:  5000 
		});
		$('#slider2').cycle({ 
		    fx:      'fade',
		    speed:    5000, 
		    autostop: 1,
		    autostopCount: 13, 
		    timeout:  5000 
		});
		
	
		$("#table-a tr:odd").addClass("alt");


	$(".iframepci").fancybox({
			maxWidth	: 620,
			maxHeight	: 620,
			fitToView	: false,
			width		: '100%',
			height		: '100%',
			autoSize	: false,
			closeClick	: false,
			openEffect	: 'none',
			closeEffect	: 'none'
		});
		
		$(".boxgrid a").fancybox();
		$('.thumb a').fancybox();
		$('.thumb1 a').fancybox();		

		//Set default open/close settings for accordion
		$('.accordion_container').accordion ();
		$('.tab_container').tabs ();

};

$(loadFun);


