// JavaScript Document

$(document).ready(init);

function init()
{
	if ($("#map").get(0)&&$("#hint").get(0)) map();
	if ($("#gallery").get(0)) gallery();
	dropdownMenu();
	//form01
	var a = (document.forms[0]).getElementsByTagName("a")[0];
	$(a).click(function(){
		//alert(this.parentNode.getElementsByTagName("input")[0].value);	
		this.parentNode.submit();
						
	})
}

function map() {
	
	
	$("#map > ul > li > span").mouseover(
	function () {
					
					//$(this).css("border", "1px solid #A7263C");
					
					var x = $(this).css("left"); x = x.substring(0, x.length-2); x=x*1+5;
					var y = $(this).css("top"); y = y.substring(0, y.length-2); y=y*1+25;
					var id = this.className.substring(3, this.className.length)*1;
					
					var capt = $("#map > ul > li > ul > li").get(id*2-2).innerHTML;
					var text = $("#map > ul > li > ul > li").get(id*2-1).innerHTML;
					var position = $("#map > ul > li > ul > li").get(id*2-2).parentNode.className;
					
					if (position=='left') { x = x - 400;}
					if (position=='top') { y = y - 240; x = x - 350;}
					$("#hint").empty();
					$("#hint").html("<div><span>"+capt+"</span>"+text+"</div>");
					//alert($("#hint").html());
					$("#hint").css(
						  {
						
							left: x+"px",
							top: y+"px",
							filter: "alpha(opacity=90)"  
						  }
					);
					$("#hint").fadeIn(300);
				//	$(this).css("font-weight", "bold");
				
					
				}//func							  
	); //mouseover
	
	$("#map > ul > li > span").mouseout(
	function () {
					//$(this).css("border", "none");
					$("#hint").fadeOut(300);
					//$(this).css("font-weight", "normal");
				}//func							  
	); //mouseout
}

function gallery() {
		$("#gallery a").fancybox({
			overlayShow: true,
			overlayOpacity: 0.5,
			frameWidth: 690,
			frameHeight: 470
    });
}



	function dropdownMenu(){
		$("#nav").find("img:nth-child(odd)").each(
			function () {
					$(this).mouseover(function(){
								var arr = this.parentNode.getElementsByTagName("img");
								$(arr[1]).fadeIn(400);
								//$(arr[1]).css("display", "block");
							})
				}						
		)
		
		$("#nav").find("img:nth-child(even)").each(
			function () {
					$(this).mouseout(function(){
								$(this).fadeOut(400);
								//$(this).css("display", "none");
							})
				}						
										
		)
		
		var i=0;
		$("#nav").find("ul").each(
				function()		
					{
						var li = $(this.parentNode).find("span").get(0);
						
						var ul = this;
						i++; ul.i = i;
						li.ch = this;
						ul.over = null;
						
						
						ul.hideBox = function () {
							$(this).slideUp(200); 	
							//$(this).css("display", "none");
						} 
						ul.showBox = function () {
							$(this).slideDown(200); 
							$(this).css("display", "block");	
						} 
						
						$(li).mouseover(
								function () {
									var ul = this.ch;
									window.clearTimeout(ul.tm);
									ul.showBox();
								}
						)//mouseover
						
						$(li).mouseout(
								function () {
									var ul = this.ch;
									window['obj'+ul.i] = ul;
									ul.tm = window.setTimeout("this['obj"+ul.i+"'].hideBox()",200);
								}
						)//mouseout
						
						$(ul).mouseover(
							function () {
								window.clearTimeout(this.tm);
							}
						)//mouseover
						
						$(ul).mouseout(
								function () {
									var ul = this;
									window['obj'+ul.i] = ul;
									ul.tm = window.setTimeout("this['obj"+ul.i+"'].hideBox()",200);
								}
						)//mouseout
					}
		)//each
	}
