

Cufon.replace('.slogan', { fontFamily : 'Century Old Style Std' });

Cufon.replace('.slider p', { fontFamily : 'Century Old Style Std', textShadow: '2px 2px #333333' });




var index = 0;
var round = 0;
	
var zindex = { '#i1,#i2,#i3,#i4' : 3, '#i5,#i6,#i7,#i8' : 2, '#i9,#i10,#i11,#i12' : 1 };

var index2 = 0;
var round2 = 0;
var count2 = 0;
	
var zindex2 = {};


$(function () {
	$("#navigation ul li").hover(function() {
		$(this).find('.dd a').css('width', $(this).find('a').width());
		
		$(this).css({ 'z-index' : 100 });
		$(this).find(".dd").show();
		$(this).find("a:eq(0)").addClass('hover');
	}, function() {
		$(this).css({ 'z-index' : 1 });
		$(this).find(".dd").hide();
		$(this).find("a:eq(0)").removeClass('hover');
	});
	
	$("#navigation > ul > li:last").addClass('last');

	if ($('#main > .slider').length != 0) {
		StartSlider();
	}
	
	if ($('#sidebar .slider').length != 0) {
		// inner fader
		count2 = $('#sidebar .slider .image1 img').length;
		$('#sidebar .slider .image1 img').each(function (index) {
			$(this).css({ 'z-index' : count2 - index });
		});
		$('#sidebar .slider .image2 img').each(function (index) {
			$(this).css({ 'z-index' : count2 - index });
		});
		var img = 0;
		for (var i=0; i < count2; i++) {
			zindex2['#i'+ ++img +',#i'+ ++img] = count2 - i;
		}
		
		StartSlider2();
	}
});

function StartSlider2 () {
	var interval2 = setInterval(function(){
		
	window.clearInterval(interval2);
	
	$('#i' + ++index2).fadeOut(1000, function () {
		$('#i' + ++index2).fadeOut(1000, function () {
			
			var selector = CreateSelector2();
			
			ChangeZindex2(selector);
			
			round2++;
			if (round2 == count2) {
				index2 = 0;
				round2 = 0;
			}
			
			StartSlider2();
		});
	});
	}, 5000);
}

function CreateSelector2 () {
	
	var selector = '';
	for (var i = (round2 * 2) + 1; i <= (round2 * 2) + 2; i++) {
		selector += '#i' + i + ',';
	}
	
	return selector.substr(0, selector.length - 1);
}

function ChangeZindex2 (selector) {
	
	for (selec2 in zindex2) {
		zindex2[selec2]++;
	}
	zindex2[selector] = 1;
	
	ApplyZindex2(selector);
}

function ApplyZindex2 (selector) {
	
	for (selec2 in zindex2) {
		$(selec2).css('z-index', zindex2[selec2]);
	}
	
	$(selector).show();
}

function StartSlider () {
	var interval = setInterval(function(){
		
	window.clearInterval(interval);
	
	$('#i' + ++index).fadeOut(1000, function () {
		$('#i' + ++index).fadeOut(1000, function () {
			$('#i' + ++index).fadeOut(1000, function () {
				ChangeText(); // for Remanufactured
				$('#i' + ++index).fadeOut(1000, function () {
					
					var selector = CreateSelector();
					
					ChangeZindex(selector);
					
					round++;
					if (round == 3) {
						index = 0;
						round = 0;
					}
					
					StartSlider();
				});
			});
		});
	});
	}, 5000);
}

function CreateSelector () {
	
	var selector = '';
	for (var i = (round * 4) + 1; i <= (round * 4) + 4; i++) {
		selector += '#i' + i + ',';
	}
	
	return selector.substr(0, selector.length - 1);
}

function ChangeZindex (selector) {
	
	for (selec in zindex) {
		zindex[selec]++;
	}
	zindex[selector] = 1;
	
	ApplyZindex(selector);
}

function ApplyZindex (selector) {
	
	for (selec in zindex) {
		$(selec).css('z-index', zindex[selec]);
	}
	
	$(selector).show();
}

function ChangeText () { // for Remanufactured
	
	if (round == 0) {
		$('.image4 p').html('Remanufactured<br />Workstations');
	} else {
		$('.image4 p').html('Workstations');
	}
	Cufon.replace('.slider p', { fontFamily : 'Century Old Style Std', textShadow: '2px 2px #333333' });
}





