slides = new Array("g66", "nouz", "currr", "nx-01", "gribochek");
numOfSlides = slides.length-1;
currentPos = 0;

function changeSlide(next)
{
	$("#presentation_"+slides[currentPos]+", #text_"+slides[currentPos]).fadeOut(30, function() {
		$("#presentation_"+slides[next]+", #text_"+slides[next]).fadeIn(100);});

	currentPos = next;
}

function presentationNext()
{
	$("#link_"+slides[currentPos]).removeClass("selected");
	if (currentPos < numOfSlides) nextPos = currentPos + 1;
	else nextPos = 0;
	$("#link_"+slides[nextPos]).addClass("selected");

	changeSlide(nextPos);
}

function presentationPrev()
{
	$("#link_"+slides[currentPos]).removeClass("selected");
	if (currentPos > 0) nextPos = currentPos - 1;
	else nextPos = numOfSlides;
	$("#link_"+slides[nextPos]).addClass("selected");

	changeSlide(nextPos);
}

function presentationDirect(slideName)
{
	$("#link_"+slides[currentPos]).removeClass("selected");
	var slideNum = $.inArray(slideName, slides);
	nextPos = slideNum;
	$("#link_"+slides[nextPos]).addClass("selected");

	changeSlide(nextPos);
}

$(window).load(function() {
	$("#toTheLeft_container").hover(
		function() {
		$("#toTheLeft").css({"background-position": "0px -39px"});
		}, 
		
		function() {
		$("#toTheLeft").css({"background-position": "0px 0px"});
		}
	);

	$("#toTheRight_container").hover(function() {
		$("#toTheRight").css({"background-position": "40px -39px"});
		},
		function() {
		$("#toTheRight").css({"background-position": "40px 0px"});
		}
	);

	$("#toTheRight_container").mousedown(function() {
		presentationNext();
	});

	
	$("#toTheLeft_container").mousedown(function() {
		presentationPrev();
	});


	$("#selector a").click(function() {
		return false;
	});

	$("#selector a").mousedown(function() {
		var slideName = this.id.replace("link_", "");
		presentationDirect(slideName);
	});

	$(".colorbox").each(function () {
		picAddr = this.href;
		if (this.id != "") picAddr = this.id;
		$(this).colorbox({href: picAddr, current: "{current}/{total}", transition: "none", opacity: 0.85, preload: true, scrolling: false, maxWidth: window.innerWidth, maxHeight: window.innerHeight});
	});
	
	$(".embed").colorbox({html: '<object width="560" height="340"><param name="movie" value="http://www.youtube.com/v/hJbYJCVfI6I&hl=ru_RU&fs=1&hd=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/hJbYJCVfI6I&hl=ru_RU&fs=1&hd=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="700" height="420"></embed></object>', innerWidth:702, innerHeight:422, scrolling: false});

	// Graphics

});