$(document).ready(function() {
	$('#contactUs').hide();
	//-------------- Set Contact Us button position
	setContactButtonPosition();
	
	//-------------- Main Menu
	ddsmoothmenu.init({
		mainmenuid		: 'mainMenu', 
		orientation		: 'h', 
		classname		: 'mainNav', 
		contentsource	: 'markup' 
	})

	//--------------- Home page showcase
	$("#showcase").scrollable({
		vertical: true,
		next: '.n',
		prev: '.p',
		speed: 1400
	}).navigator("#showcaseMenu");

	//--------------- Featured project and Latest news
	$("div.scrollableBox").scrollable({easing: 'custom', speed: 700, circular: true});

	//---------------- Hide ditto curent page number when only one page
	( !$('#content a.ditto_page').length ) ? $('span.ditto_currentpage').css('display','none') : '';
	
	
	$('#showcaseMenu li').eq(0).addClass('active');
	
	
	var containerHeight = $('#wrapper').height();
	if (containerHeight > 1000) { 
		$('#backToTop').show();
		$('#backToTop').click(function(){
			$('html, body').animate({scrollTop:0}, 'slow'); 
			return false;
		});
	}

	equalHeight($('#homeBoxes .box'));
	
	$('.client_grid_item:odd').css('margin-right','0');
	
	
});

$(window).resize(function() {
	setContactButtonPosition();
});

$(window).bind("load", function() {								
});

$.easing.custom = function (x, t, b, c, d) {
	var s = 1.70158; 
	if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
	return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
}
function equalHeight(group) {
	tallest = 0;
	group.each(function() {
		thisHeight = $(this).height();
		if(thisHeight > tallest) {
			tallest = thisHeight;
		}
	});
	group.height(tallest);
}
function setContactButtonPosition() {
	var offset = $('#wrapper').offset();
	o = offset.left + 950;
	$('#contactUs').css('left',o).show();
}
