var container = 'body';
var size = 5;
var width = 50;
var height = 50;
css = new Object();
css.position = 'absolute';
css.width = size+'px';
css.height = size+'px';

function onSearchWidgetLoaded() {
	if($('#form1').length == 1)
		attachSearchWidget('form1');
	if($('#form2').length == 1)
		attachSearchWidget('form2');
}

$(document).ready(function() {
	// corners for IE only
	if($.browser.msie) {
		$('.mainMenu li a').each(function() {
			var width = $(this).width()+22;
			$(this).css({position: 'relative'}).prepend('<span class="ctl" style="top:5px;"></span><span class="ctr" style="top:5px;left:'+width+'px;"></span>');
		})
	}
	// breadcrumb
	$('.navBar').each(function() {
		$(this).children('span').remove();
		$(this).children('a').prepend('<span></span>');
		$(this).children('a:first').addClass('first');
		$(this).children('a:last').addClass('last').prepend('<span class="end"></span>');
	});
	// resize .contentHolder according to .sideMenu height
	if(($('.sideMenu').height()+100) > $('.contentHolder').height()) {
		$('.contentHolder').css({height: ($('.sideMenu').height()+100)+'px'});
	}
	// apply color style to the main menu
	$('.mainMenu li a:eq(1)').addClass('blue');
	$('.mainMenu li a:eq(2)').addClass('green');
	$('.mainMenu li a:eq(3)').addClass('pink');
	// turn pngs to gifs in ie6
	if($.browser.msie && $.browser.version == '6.0') {
		$('.kCarousel').find('img').each(function() {
			$(this).attr({src: $(this).attr('src').split('.')[0]+'.gif'});
		});
	}
	// kCarousel
	$('.kCarousel').each(function() {
		$(this).kCarousel({
			navContainer: '.mainHolder',
			topDistance: 250,
			itemWidth: 476,
			itemHeight: 316,
			itemScaleTo: 80,
			onLoad: function() { },
			onScroll: function() { if($('#form2').length == 1) { attachSearchWidget('form2'); } }
		});
	});
	// setTimeout(function() { rotate($('.kCarousel'), 'left'); }, 4000);

	// duplicate main menu and copy it into the footer
	$('.mainMenu').clone().appendTo('.footer').removeAttr('class').append('<li><a href="http://www.culturegrid.org.uk/about/contact/">Contact us</a></li>').find('li:not(:last)').append(' | ').find('span').remove();

	// shareThis module
	$('.footer').prepend('<span class="st_sharethis" displayText="ShareThis" style="float:left;margin-top:10px;margin-right:10px;"></span>');
	stLight.options({publisher:'64077dc9-578f-4af5-84b0-3669327d287d'});
});

