// JavaScript Document

/* index */
$(function(){
	$(".searchBox input:text").hover(function(){
			if($(this).val() == "ËÑË÷"){
				$(this).val("");
			}
			$(this).select();
			$(this).addClass("foc");
		},
		function(){
			if($(this).val() == ""){
				$(this).val("ËÑË÷");
			}
			$(this).blur();
			$(this).removeClass("foc");
		}
	)
})

/* cityLabel */
$(function(){
	$("#cityLayout").focus(function(){
		$(".cityLabel").fadeIn("fast");						
	})
	$(".cityLabel .close").click(function(){
		$(".cityLabel").fadeOut("fast");
		return false;
	})
})
/*sideNav*/
$(function(){
	$("#subnav > li").each(function(){
		$(this).find("a").click(function(){
			$("#subnav > li > a").removeClass("hover");$(this).addClass("hover");
			$("#subnav > li > ul").hide();$(this).parent("li").find("ul").show();
		})
		if($(this).find("li").size() !== 0 )
		{
			$(this).find("a").addClass("sub");
			$("#subnav > li > .sub").click(function(){return false;})
		}
	})
})

/* tabs */
$(document).ready(function(){	
	$(".tab_menu").each(function(i){		
		$(this).find("li").each(function(j){		
				$(this).click(function(e){				
				$(".tab_content:eq("+i.toString()+") .con").css("display","none");
				$(".tab_content:eq("+i.toString()+") .con:eq("+j.toString()+")").fadeIn(0);
				$(this).parent().find("li").removeClass("hover");
				$(this).addClass("hover");	
				if (e&&e.preventDefault ){
					e.preventDefault();
				}else{
					window.event.returnValue = false;
				}
				return false;
			});		
		});		
	});
	$(".tab_menu_inner").each(function(i){		
		$(this).find("li").each(function(j){		
				$(this).click(function(e){				
				$(".tab_content_inner:eq("+i.toString()+") .con_inner").css("display","none");
				$(".tab_content_inner:eq("+i.toString()+") .con_inner:eq("+j.toString()+")").fadeIn(0);
				$(this).parent().find("li").removeClass("on");
				$(this).addClass("on");	
				if (e&&e.preventDefault ){
					e.preventDefault();
				}else{
					window.event.returnValue = false;
				}
				return false;
			});		
		});		
	});
});
/* rooling */
var playing = true;
var playIndex = 0;
$(function(){
	var cont = $(".box1 .imgBox img").length-1;
	for( var i=1;i<=cont+1;i++)
	{
		if(i==1)
			{
			$("#rollingBox ul.num").html($("#rollingBox ul.num").html()+"<li class='active'><a href=#>"+i.toString()+"</a></li>");
			$("#rollingBox .box1 .imgBox a img:eq(0)").fadeIn("slow");
			}
		else
			{
			$("#rollingBox ul.num").html($("#rollingBox ul.num").html()+"<li><a href=#>"+i.toString()+"</a></li>");
			}
	}
	$("#rollingBox .num li").each(function(j){
		$(this).hover(function(){
				$("#rollingBox .box1 .imgBox a img").css("display","none");
				$("#rollingBox .box1 .imgBox a img:eq("+j+")").fadeIn("slow");	
				$("#rollingBox ul.num li").removeClass("active");
				$(this).addClass("active");
				playing = false;
				return false;
			},
			function(){
				playIndex = j ;
				playing = true;
				return false;
			}
		)							   
	})	
	$("#rollingBox .box1 .imgBox img").mouseover(function(){
		playing = false;
		clearTimeout("play()")
	})
	$("#rollingBox .box1 .imgBox img").each(function(k){	
		$(this).mouseout(function(){
			playIndex = k ;
			playing = true;
		});
	});
})
setTimeout("play()",5000);	
function play()
{
	var cont = $(".box1 .imgBox img").length;
	if(playing == true){
		playIndex++;
		if(playIndex>=cont) 
		{
			playIndex=0;
			$("#rollingBox .box1 .imgBox a img").css("display","none");
			$("#rollingBox .box1 .imgBox a img:eq("+playIndex+")").fadeIn("slow");	
		}
		else
		{
			$("#rollingBox .box1 .imgBox a img").css("display","none");
			$("#rollingBox .box1 .imgBox a img:eq("+playIndex+")").fadeIn("slow");	
		}
		$("#rollingBox ul.num li").removeClass("active");
		$("#rollingBox ul.num li:eq("+playIndex.toString()+")").addClass("active");
		
	}		
	setTimeout("play()",5000);	
}


