
var active_fade_img = 0;

/*$(document).ready(function() {
    $(window).load(function() {
    	$('#PresentationThumbImage0').fadeTo("fast", 1);
    });
});*/

function changeMedia(selected_product_id) {
	$('.PresentationThumbImage').fadeTo("fast", 0.4);
	$('#PresentationThumbImage' + selected_product_id).fadeTo("fast", 1);
	active_fade_img = selected_product_id;

	if ($("#PresentationBigImage").length > 0) {
		$("#mini-screens").hide();
		$("#PresentationBigImage").fadeOut(250, function() {
			$("#DemonstrationProduct").html(products[selected_product_id].media);
		});
	} else {
		$("#DemonstrationProduct").fadeOut(250, function() {
			$("#DemonstrationProduct").html(products[selected_product_id].media);
		});
	}

	$('#DemonstrationProduct').fadeIn(700);
	$('#Description').html(products[selected_product_id].description);
}

function changeImage(selected_product_id) {
	$('.PresentationThumbImage').fadeTo("fast", 0.4);
	$('#PresentationThumbImage' + selected_product_id).fadeTo("fast", 1);
	active_fade_img = selected_product_id;
	
	if ($("#PresentationBigImage").length > 0) {
		$("#PresentationBigImage").fadeOut(250, function() {
			$('#PresentationBigImage').attr('src', products[selected_product_id].images[0].main);
		});
	} else {
		$("#DemonstrationProduct").fadeOut(250, function() {
			$("#DemonstrationProduct").html('<img alt=\"\" id=\"PresentationBigImage\" src=\"' + products[selected_product_id].images[0].main + '\" style=\"display: inline;\">');
			$("#DemonstrationProduct").show();
		});
	}
	$("#PresentationBigImage").fadeIn(700);
	
	var html = "<ul>";
	html = html + '<li><a class="selected" href="" onclick="changeBigImage(this, ' + selected_product_id + ', 0); return false;"><img src="/images/clients/' + selected_product_id + '_0.jpg" height="84" width="84" alt="" ></a></li>';
	for (var i = 1; i < products[selected_product_id].images.length; i++) {
		html = html + '<li><a href="" onclick="changeBigImage(this, ' + selected_product_id + ', ' + i + '); return false;"><img src="/images/clients/' + selected_product_id + '_' + i + '.jpg" height="84" width="84" alt="" ></a></li>';
	}
	$("#mini-screens").html(html + "</ul>");
	$("#mini-screens").show();
	
	$('#Description').html(products[selected_product_id].description);
}

function changeBigImage(thumb, selected_product_id, i) {
	$("#mini-screens .selected").removeClass("selected");
	$(thumb).addClass("selected");

	$('#PresentationBigImage').fadeOut(250, function() {
		$("#PresentationBigImage").attr("src", "/images/clients/main_" + selected_product_id + "_" + i + ".jpg");
	});
	$('#PresentationBigImage').fadeIn(700);
}

function hoverFadeOut(id) {
	if (!speed) {
		var speed = "fast";
	}
	if (id != active_fade_img) { 
		$('#PresentationThumbImage' + id).fadeTo(speed, 1);
	}
}

function hoverFadeIn(id, speed) {
	if (!speed) {
		var speed = 700;
	}
	if (id != active_fade_img) { 
		$('#PresentationThumbImage' + id).fadeTo(speed, 0.4);
	}
}
