// Eurostile for post headers
Cufon.replace('h2', {
	textShadow: '1px 1px 0px #f1eee0'
});

// Eurostile for other stuff
Cufon.replace('#mainMenu li a, .widget_links ul li a, .widget_mylinkorder ul li a, #footer', {
	hover: true
});

$(document).ready(function(){

	// -- ie7 z-index fix
	// this is such a fucking hack but it works
	// re-index all divs on the page, then make sure ul#mainMenu is still on top due to a strange quirk
	$(function() {
		var zIndexNumber = 1000;
		$('div').not("#colorbox").each(function() {
			$(this).css('zIndex', zIndexNumber);
			zIndexNumber -= 10;
		});
	});
	$("#mainMenu").css('zIndex', 1001);
	// -- end ie7 z-index fix
	
	// fade effect on main menu hovers
	$("#mainMenu > li").hoverIntent(function() {
		$(this).children("ul")
			.fadeIn(150).css({ zIndex: "1000" });
	}, function() {
		$(this).children("ul")
			.fadeOut(125).css({ zIndex: "0" });
	});
	
	// setup header images crossfading
	$('#crossfade').crossSlide({
		sleep: 8,
		fade: 2
	}, [
		{ src: '/wordpress/wp-content/themes/kse/style/images/header-photo-0.jpg' },
		{ src: '/wordpress/wp-content/themes/kse/style/images/header-photo-6.jpg' },
		{ src: '/wordpress/wp-content/themes/kse/style/images/header-photo-2.jpg' },
		{ src: '/wordpress/wp-content/themes/kse/style/images/header-photo-3.jpg' },
		{ src: '/wordpress/wp-content/themes/kse/style/images/header-photo-5.jpg' }
	]);
	
	// set up default text for search forms
	$(".sForm").example('Search');
	
	// limit the number of photos in the footer to a max of 3
	var maxPhotos = 3;
	var numPhotos = $("#footerPhotoContainer .footerPhoto").size();
	if(numPhotos > maxPhotos) {
		var counter = 0;
		$("#footerPhotoContainer .footerPhoto").each(function() {
			counter++;
			if (counter > 3) {
				$(this).remove();
			}
		});
	}
	if(numPhotos == 2) {
		$("#footerPhotoContainer .footerPhoto:first-child").clone().appendTo("#footerPhotoContainer");
	}
	if(numPhotos == 1) {
		$("#footerPhotoContainer .footerPhoto:first-child").clone().appendTo("#footerPhotoContainer")
		$("#footerPhotoContainer .footerPhoto:first-child").clone().appendTo("#footerPhotoContainer");
	}
});
