$(document).ready(function(){

var selectedEffect = 'blind';
var options = {};


flag = 0;
flagEnd = 0;

$("#order").click(function() {
		$("#popupCont").show(1000);
		return;
		});
$("#close").click(function() {
		$("#popupCont").hide(1000);
		});

$("#viewResults").click(function() {
		$("#voteResCont").show(1000);
		});
$("#closeRes").click(function() {
		$("#voteResCont").hide(1000);
		});

function disableAll(){
	var newElem = document.createElement('div');
	newElem.id = 'zagl';
	var insBefore = document.getElementById('cont');
	
	insBefore.parentNode.insertBefore(newElem, insBefore);
}

function enableAll(){
	var delElem = document.getElementById('zagl');
	delElem.parentNode.removeChild(delElem);
}

function resetAnimation(){
$(".plText").hide(500);
$("#textInn_1").hide(0); $("#textInn_2").hide(0); $("#textInn_3").hide(0); $("#textInn_4").hide(0); $("#textInn_5").hide(0);

$("#pic_1").animate({left: -84, top: 119}, 0);
$("#pic_2").animate({left: 214, top: -30}, 0);
$("#pic_3").animate({left: 585, top: -12}, 0);
$("#pic_4").animate({left: -138, top: -29}, 0);
$("#pic_5").animate({left: -114, top: 117}, 0);

$("#pl_1").animate({width: 150}, 500);
$("#pl_2").animate({height: 150}, 500);
$("#pl_3").animate({height: 150}, 500);
$("#pl_4").animate({width: 150}, 500);
$("#pl_5").animate({height: 150}, 500);

} 
		
$("#plText_1").click(function() {
if(flag == 1) resetAnimation();
flag = 1;
disableAll();
				$("#plBot_1").animate({left: 150,top:300}, 1000);
				$("#pl_6").animate({left: 0, top: 300}, 1000);
				$("#plText_6").animate({left: 0, top: 300}, 1000);
		//выдвигаем наверх нужные блоки
		$("#pl_1").css("z-index", "7"); 	$("#plText_1").css("z-index", "7"); 	$("#pic_1").css("z-index", "8");
		/*картинка переехала*/ $("#pic_2").hide(1000); $("#pic_3").hide(1000); $("#pic_4").hide(1000); $("#pic_5").hide(1000, function()
			{
			//остальные картинки исчезли
			$("#pic_1").show(500); $("#pic_1").animate({left: -84, top: 119}, 500, function()
				{
				//плашки подтянулись
				$("#pl_1").animate({left: 0, top: 0}, 1000);
				$("#plText_1").animate({left: 0, top: 0}, 1000);
				$("#pl_2").animate({left: 300, top: 150}, 1000);
				$("#plText_2").animate({left: 300, top: 150}, 1000);
				$("#pl_3").animate({left: 600, top: 150}, 1000);
				$("#plText_3").animate({left: 600, top: 150}, 1000);
				$("#pl_4").animate({left: 150, top: 150}, 1000);
				$("#plText_4").animate({left: 150, top: 150}, 1000);
				$("#pl_5").animate({left: 450, top: 150}, 1000);
				$("#plText_5").animate({left: 450, top: 150}, 1000, function()
					{
					/*появилась плашка под текст*/ $("#text_1").show(1000, function()
						{
						/*появился текст*/ $("#textInn_1").show(selectedEffect,options,1000);
						/*появилась стрелка у выделенного пункта*/ $("#pl_1").animate({width: 170}, 1000);
						/*заказать переехало вверх*/ $("#order").animate({top: 32}, 1000, function(){enableAll();});
						}
);});});});
		});

$("#plText_2").click(function() {
if(flag == 1) resetAnimation();
flag = 1;
disableAll();
				$("#plBot_1").animate({left: 150,top:300}, 1000);
				$("#pl_6").animate({left: 0, top: 300}, 1000);
				$("#plText_6").animate({left: 0, top: 300}, 1000);
		//выдвигаем наверх нужные блоки
		$("#pl_2").css("z-index", "7"); 	$("#plText_2").css("z-index", "7"); 	$("#pic_2").css("z-index", "8");
		/*картинка переехала*/ $("#pic_1").hide(1000); $("#pic_3").hide(1000); $("#pic_4").hide(1000); $("#pic_5").hide(1000, function()
			{
			//остальные картинки исчезли
			$("#pic_2").show(500); $("#pic_2").animate({left: 214, top: -30}, 500, function()
				{
				//плашки подтянулись
				$("#pl_1").animate({left: 0, top: 0}, 1000);
				$("#plText_1").animate({left: 0, top: 0}, 1000);
				$("#pl_2").animate({left: 150, top: 0}, 1000);
				$("#plText_2").animate({left: 150, top: 0}, 1000);
				$("#pl_3").animate({left: 600, top: 0}, 1000);
				$("#plText_3").animate({left: 600, top: 0}, 1000);
				$("#pl_5").animate({left: 450, top: 0}, 1000);
				$("#plText_5").animate({left: 450, top: 0}, 1000);
				$("#pl_4").animate({left: 0, top: 150}, 1000);
				$("#plText_4").animate({left: 0, top: 150}, 1000, function()
					{
					$("#text_2").animate({left: 150, top: 150});
					/*появилась плашка под текст*/ $("#text_2").show(1000, function()
						{
						/*появился текст*/ $("#textInn_2").show(selectedEffect,options,1000);
						/*появилась стрелка у выделенного пункта*/ $("#pl_2").animate({height: 176}, 1000);
						/*заказать переехало*/ $("#order").animate({top: 178}, 1000, function(){enableAll();});
						}
);});});});
		});

$("#plText_3").click(function() {
if(flag == 1) resetAnimation();
flag = 1;
disableAll();
				$("#plBot_1").animate({left: 0,top:300}, 1000);
				$("#pl_6").animate({left: 0, top: 150}, 1000);
				$("#plText_6").animate({left: 0, top: 150}, 1000);
		//выдвигаем наверх нужные блоки
		$("#pl_3").css("z-index", "7"); 	$("#plText_3").css("z-index", "7"); 	$("#pic_3").css("z-index", "8");
		/*картинка переехала*/ $("#pic_1").hide(1000); $("#pic_2").hide(1000); $("#pic_4").hide(1000); $("#pic_5").hide(1000, function()
			{
			//остальные картинки исчезли
			$("#pic_3").show(500); $("#pic_3").animate({left: 585, top: -12}, 0, function()
				{
				//плашки подтянулись
				$("#pl_1").animate({left: 0, top: 0}, 1000);
				$("#plText_1").animate({left: 0, top: 0}, 1000);
				$("#pl_2").animate({left: 300, top: 0}, 1000);
				$("#plText_2").animate({left: 300, top: 0}, 1000);
				$("#pl_3").animate({left: 600, top: 0}, 1000);
				$("#plText_3").animate({left: 600, top: 0}, 1000);
				$("#pl_5").animate({left: 450, top: 0}, 1000);
				$("#plText_5").animate({left: 450, top: 0}, 1000);
				$("#pl_4").animate({left: 150, top: 0}, 1000);
				$("#plText_4").animate({left: 150, top: 0}, 1000, function()
					{
					$("#text_3").animate({left: 150, top: 150});
					/*появилась плашка под текст*/ $("#text_3").show(1000, function()
						{
						/*появился текст*/ $("#textInn_3").show(selectedEffect,options,1000);
						/*появилась стрелка у выделенного пункта*/ $("#pl_3").animate({height: 175}, 1000);
						/*заказать переехало*/ $("#order").animate({top: 178}, 1000, function(){enableAll();});
						}
);});});});
		});

$("#plText_4").click(function() {
if(flag == 1) resetAnimation();
flag = 1;
disableAll();
				$("#plBot_1").animate({left: 150,top:300}, 1000);
				$("#pl_6").animate({left: 0, top: 300}, 1000);
				$("#plText_6").animate({left: 0, top: 300}, 1000);
		//выдвигаем наверх нужные блоки
		$("#pl_4").css("z-index", "7"); 	$("#plText_4").css("z-index", "7"); 	$("#pic_4").css("z-index", "8");
		/*картинка переехала*/ $("#pic_1").hide(1000); $("#pic_2").hide(1000); $("#pic_3").hide(1000); $("#pic_5").hide(1000, function()
			{
			//остальные картинки исчезли
			$("#pic_4").show(500); $("#pic_4").animate({left: -138, top: -29}, 500, function()
				{
				//плашки подтянулись
				$("#pl_1").animate({left: 150, top: 0}, 1000);
				$("#plText_1").animate({left: 150, top: 0}, 1000);
				$("#pl_2").animate({left: 300, top: 0}, 1000);
				$("#plText_2").animate({left: 300, top: 0}, 1000);
				$("#pl_3").animate({left: 600, top: 0}, 1000);
				$("#plText_3").animate({left: 600, top: 0}, 1000);
				$("#pl_5").animate({left: 450, top: 0}, 1000);
				$("#plText_5").animate({left: 450, top: 0}, 1000);
				$("#pl_4").animate({left: 0, top: 150}, 1000);
				$("#plText_4").animate({left: 0, top: 150}, 1000, function()
					{
					$("#text_4").animate({left: 150, top: 150});
					/*появилась плашка под текст*/ $("#text_4").show(1000, function()
						{
						/*появился текст*/ $("#textInn_4").show(selectedEffect,options,1000);
						/*появилась стрелка у выделенного пункта*/ $("#pl_4").animate({width: 170}, 1000);
						/*заказать переехало*/ $("#order").animate({top: 178}, 1000, function(){enableAll();});
						}
);});});});
		});

$("#plText_5").click(function() {
if(flag == 1) resetAnimation();
flag = 1;
disableAll();
				$("#plBot_1").animate({left: 150,top:300}, 1000);
				$("#pl_6").animate({left: 0, top: 300}, 1000);
				$("#plText_6").animate({left: 0, top: 300}, 1000);
		//выдвигаем наверх нужные блоки
		$("#pl_5").css("z-index", "7"); 	$("#plText_5").css("z-index", "7"); 	$("#pic_5").css("z-index", "8");
		/*картинка переехала*/ $("#pic_1").hide(1000); $("#pic_2").hide(1000); $("#pic_3").hide(1000); $("#pic_4").hide(1000, function()
			{
			//остальные картинки исчезли
			$("#pic_5").show(500); $("#pic_5").animate({left: -114, top: 117}, 500, function()
				{
				//плашки подтянулись
				$("#pl_1").animate({left: 0, top: 0}, 1000);
				$("#plText_1").animate({left: 0, top: 0}, 1000);
				$("#pl_2").animate({left: 300, top: 0}, 1000);
				$("#plText_2").animate({left: 300, top: 0}, 1000);
				$("#pl_3").animate({left: 600, top: 0}, 1000);
				$("#plText_3").animate({left: 600, top: 0}, 1000);
				$("#pl_5").animate({left: 450, top: 0}, 1000);
				$("#plText_5").animate({left: 450, top: 0}, 1000);
				$("#pl_4").animate({left: 150, top: 0}, 1000);
				$("#plText_4").animate({left: 150, top: 0}, 1000, function()
					{
					$("#text_5").animate({left: 150, top: 150});
					/*появилась плашка под текст*/ $("#text_5").show(1000, function()
						{
						/*появился текст*/ $("#textInn_5").show(selectedEffect,options,1000);
						/*появилась стрелка у выделенного пункта*/ $("#pl_5").animate({height: 175}, 1000);
						/*заказать переехало*/ $("#order").animate({top: 178}, 1000, function(){enableAll();});
						}
);});});});
		});
});

