$(document).ready(function(){

	$('#referencesSlider').jcarousel({
		vertical: false,
		scroll: 1,
		auto: 4,
		wrap: 'both'
	});
	
	var isIE6 = ($.browser.msie && $.browser.version==6);

	$('#fwNavMain>ul>li>ul>li:first-child, #fwService ul li:first-child').addClass('first');
	$('#fwService ul li:last-child').addClass('last');

	var fwNavMainDisplayFix = $('<span></span>').addClass('displayFix').html('<span><span></span></span>');
	$('#fwNavMain>ul>li.hasSub').append(fwNavMainDisplayFix);

	$('#fwNavMain>ul>li.hasSub').mouseover(function(){ $(this).addClass('hover') });
	$('#fwNavMain>ul>li.hasSub').mouseout(function(){ $(this).removeClass('hover') });

	$('#fwNavMain ul li ul li').mouseover(function(){
		$(this).addClass('hover');
	});
	$('#fwNavMain ul li ul li').mouseout(function(){
		$(this).removeClass('hover');
	});

	$('#fwNavMain ul li ul').each(function(){
		var toggler = 0;
		$('li a', this).each(function(){
			if(toggler) {
				$(this).addClass('b');
				toggler = 0;
			} else {
				$(this).addClass('a');
				toggler = 1;
			}
		});
	});

	if($('.cycle').length>0) {
		if(isIE6) {
			if($('.cycle img').length>1) {
				ie6cycleImages = new Array();
				ie6cycleCurrentImage = 0;
				ie6cycleReplacement();
			}
		} else {
			$('.cycle').cycle({
				fx: 'fade',
				cleartypeNoBg: true
			});
		}
	}

	$(document).pngFix();

});

function ie6cycleReplacement() {
	ie6cycleImages = $('.cycle img');
	ie6cycleCurrentImage = ie6cycleImages.length-1;
	$('.cycle img').pngFix();
	ie6cycleChange();
	// window.setInterval(function(){ie6cycleChange();}, 4000);
}

function ie6cycleChange() {
	ie6cycleCurrentImage++;
	if(ie6cycleCurrentImage>(ie6cycleImages.length-1)) {
		ie6cycleCurrentImage = 0;
	}
	$('.cycle img').hide();
	$('.cycle img').eq(ie6cycleCurrentImage).show();
	// document.title = ie6cycleCurrentImage;
	// $('.cycle').empty().append(ie6cycleImages[ie6cycleCurrentImage]).pngFix();
	
}
