/*%gray_images% - переменная для вставки картинок в главный шаблон (клиенты много картинок), где сейчас сделано хардкодом. 
Из шаблона вынесена специально, так как закоментить нельзя IE видит эту переменную в коментах*/

id = setTimeout("Update();", 4000);

function Update() {
	if( $('.steep-i:last').is(':visible') ) {
		$('#steep .steep-i:last').fadeOut(800);
		$('#steep .steep-i:first').fadeIn(800);
	} else {
		$('#steep .steep-i:visible').fadeOut(800).next().fadeIn(800);
	}
	id = setTimeout("Update();", 4000);
}

var loaded = new Array();

img_logo = ['l1.jpg', 'l2.jpg', 'l3.jpg', 'l4.jpg', 'l5.jpg', 'l6.jpg', 'l7.jpg', 'l8.jpg', 'l9.jpg', 'l10.jpg', 'l11.jpg', 'l12.jpg'];
load_logo= new Array();

loaded_partners = new Array();

$(document).ready(function() {
	if (client_images) {
		for (var i = 0; i < client_images.length; i++) {
			var img = new Image();
			img.src = client_images[i];
			loaded[i] = img;
		}
	}
    
    $('#partners').find('img').each(function() {
        var src = $(this).attr('src');
        src = src.replace('grayscale', 'colored');
        var img = new Image();
        img.src = src;
        loaded_partners.push(img);
    }).end().find('a').hover(
        function() {
            var img = $(this).find('img');
            var src = img.attr('src').replace('grayscale', 'colored');
            img.attr('src', src);
        },
        function() {
            var img = $(this).find('img');
            var src = img.attr('src').replace('colored', 'grayscale');
            img.attr('src', src);
        }
    );
    
	for (var i = 0; i < img_logo.length; i++) {
		var img = new Image();
		img.src = 'img/'+img_logo[i];
		load_logo[i] = img;
	}
	
	$('#next_steep').click(function() { 
		if( $('.steep-i:last').is(':visible') ) {
			$('#steep .steep-i:last').fadeOut(800);
			$('#steep .steep-i:first').fadeIn(800);
		} else {
			$('#steep .steep-i:visible').fadeOut(800).next().fadeIn(800);
		}
	});
				
	$('#back_steep').click(function() { 
		if( $('.steep-i:first').is(':visible') ) {
			clearTimeout(id);
			$('#steep .steep-i:first').fadeOut(800);
			$('#steep .steep-i:last').fadeIn(800);
			$('#stop_steep').css({display: "none"}).next().css({display: "block"});
		} else {
			clearTimeout(id);
			$('#steep .steep-i:visible').fadeOut(800).prev().fadeIn(800);
			$('#stop_steep').css({display: "none"}).next().css({display: "block"});
		}
	});
				
	$('#stop_steep').click(function() { 
		$(this).css({display: "none"}).next().css({display: "block"});
		clearTimeout(id);
	});
				
	$('#play_steep').click(function() { 
		$(this).css({display: "none"}).prev().css({display: "block"});
		Update();
	});
	
	$('#client_img img').hover(
		function() { 
			$(this).attr("src", function() { 
				return $(this).attr('src').replace('/small_gray/', '/small/');
			});
		}, 
        function () {
            $(this).attr("src", function() { 
				return $(this).attr('src').replace('/small/', '/small_gray/');
			});
       }
	);
});
