﻿$(document).ready(function() {
	$("#ico UL LI").mouseover(function() {
		$("#"+this.id+" A IMG").css("margin-top", "-34px")
	});
	$("#ico UL LI").mouseout(function() {
		$("#"+this.id+" A IMG").css("margin-top", "0")
	});
	
	$(".deep MAP").mouseover(function() {
		activ_id = click_id = '';
		display_project(this.id);
	});
	$(".deep MAP").mouseout(function() {
		display_project(this.id);
	});
	$(".deep MAP").click(function() {
		click_project(this.id);
	});


	/*
	$(".read_more").click(function() {
		id = $(this).parents().attr("id");
		$("#"+id+" .read_more").hide();
		$("#"+id+" .read_no").show();
		$("#"+id+" .replay").slideDown("slow");
	});
	
	$(".read_no").click(function() {
		id = $(this).parents(".list_quest").attr("id");
		$("#"+id+" .replay").slideUp("slow");
		$("#"+id+" .read_more").show();
		$("#"+id+" .read_no").hide();
	});
	*/
	
	position_popup();
});

$(window).resize(function() {
	position_popup();
});

function position_popup() {
	$(".pop_window").css("left", (document.body.clientWidth/2)-($(".pop_window").width()/2));
	$(".pop_window").css("top", (document.body.clientHeight/2)-($(".pop_window").height()/2));
}

function change_text(id, text) {
	if ($("#"+id).val() == text) {
		$("#"+id).attr("value", "");
	} else if ($("#"+id).val() == ''){
		$("#"+id).attr("value", text);
	}
}

function close_project(id) {
	$("#div_project").animate({opacity: 0},200);
	setTimeout('$("#div_project").html($("#right_top_text").html())', 200);
	$("#div_project").animate({opacity:1},400);
//	deep = $("DIV", ".deep");
//	for (i=0; i<deep.length; i++) {
//		src = $("."+$(deep[i]).attr("class")+" MAP").attr("lang");
//		$("."+$(deep[i]).attr("class")+" IMG").attr("src", "/images/"+src+".png");
//		
//	}
	deep = $('.deep > div');
	deep.each(function(index) {
		src = $(this).find('map').attr("lang");
		$(this).find('img').attr("src", "/images/"+src+".png");
	});
	$(".deep P").hide();
	activ_id = click_id = '';
}

j = 0;
activ_id = click_id = '';
function display_project(id) {
	src = $("#"+id).attr("lang");
	name = $("#"+id).attr("name");
	if (activ_id=='') {
		$("."+name+" IMG").attr("src", "/images/"+src+"_activ.png");
		activ_id = id;
		click_project(id);
	} else {
		if (click_id!=id) {
			$("."+$("#"+activ_id).attr("name")+" IMG").attr("src", "/images/"+src+".png");
		}
		activ_id = '';
	}
	//$("#div_project").stop();
}

function click_project(id) {
//	deep = $("DIV", ".deep");
//	for (i=0; i<deep.length; i++) {
//		src = $("."+$(deep[i]).attr("class")+" MAP").attr("lang");
//		id !=$(deep[i]).attr("class") ? $("."+$(deep[i]).attr("class")+" IMG").attr("src", "/images/"+src+".png") : '';
//		$("."+$(deep[i]).attr("class")+" P").hide();
//	}
	deep = $('.deep > div');
	deep.each(function(index) {
		src = $(this).find('map').attr("lang");
		if (id != $(this).find('map').attr('id')) {
			$(this).find('img').attr("src", "/images/"+src+".png");
		}
		$(this).find('p').hide();
	});
	if (id != click_id) {
		click_id = id;
		$("."+id+" P").show();
		if (j == 0) {
			j = 1;
			$("#div_project").animate({opacity: 0},200);
			setTimeout('$("#div_project").html($("#div_'+id+'").html())', 200);
			$("#div_project").animate({opacity:1},400);
			setTimeout('j = 0', 500);
		}
	} else {}
}

function other_project(id) {
	k = 0;
	new_project = id;
	all_divs = $(".right_project", ".right_top");
	divs = new Array();
	for (i=0;i<all_divs.length;i++) {
		divs[divs.length] = $(all_divs[i]).attr("id");
		if (k == 1) {
			new_project = $(all_divs[i]).attr("id");
			k = 0;
		}
		$(all_divs[i]).attr("id") == id ? k = 1 : '';
	}
	id == new_project ? new_project = divs[0] : '';
	new_project = new_project.split("_");
	activ_id = '';
	display_project(""+new_project[1]+"_"+new_project[2]+"");
	
}
