
$.fn.skGet = function(get, dimension, callback) {
	if(!this.length){
		return this;
	}
	
	var result;
	var m = Math[get];
	this.each(function(index) {
		var newResult = $(this)[dimension]();
		result = index ? m(result, newResult) : newResult;
	});
	
	if(typeof callback == 'function'){
		callback.call(this, result);
		return this;
	}
	
	return result;
};

$(document).ready(function(){
		
	var thickbox = new sk.widgets.Thickbox();
    thickbox.control($('.thickbox'));
    thickbox.autoWidth = true;
	
	// Carusel
	$('.news-box .box').cycle({
		timeout: 0,
		next: $('.next'),
		prev: $('.prev'),
		pause: true,
		speed: 500,
		fx: 'scrollHorz'
	});
	
	// Carusel
	$('#motive').cycle({
		timeout: 4000,
		activePagerClass: 'active',
		pager: $('#motive-paging'),
		pause: true,
		speed: 1000,
		fx: 'fade'
	});
	
	// Equal Heights
	function eq($element, item, count){
		$element.each(function(){
			var $items = $(this).find(item),
				end = $items.length;
				
			for (var i=0; i < end; i=i+count) {
				$items.slice(i, i+count).skGet('max', 'height', function(val){
					this.height(val);
		    		
		    	});
			};
		});	
	};
	eq($('.homepage #main .row'), '.box', 3);
	
	//if ( $.browser.msie && $.browser.version < 9 ){
		$('.mainmenu > li:nth-child(3n-1)').addClass('nth-child-2');
		$('.mainmenu > li:nth-child(3n)').addClass('nth-child-3');
	//}
	
});
