// JavaScript Document
$(document).ready(function(){
	
	$('#header .dv2 label').hover(
		function(){$(this).css('color','#000');},
		function(){$(this).css('color','#00aeef');}
	);

	$("#header .signin").toggle(
		function(){$(this).blur();$(this).css("border-right","1px solid #bababa");$("#header .r .dv3").css("display","block");},
		function(){$(this).blur();$(this).css("border-right","1px solid #ebeced");$("#header .r .dv3").css("display","none");}
	);
	
	$("#menu img").hover(
		function(){
			$(this).attr("src",$(this).attr("src").replace(".jpg","_on.jpg"));
			$("#header").css("background-color","#afb1b4");
			$("#wrap").css("background","url(/images/mainbg.jpg) #fff top left repeat-y");
			$("#bird").attr("src",$("#bird").attr("src").replace(".jpg","_on.jpg"));
		},
		function(){
			$(this).attr("src",$(this).attr("src").replace("_on.jpg",".jpg"));
			$("#header").css("background-color","#fff");
			$("#wrap").css("background","none");
			$("#bird").attr("src",$("#bird").attr("src").replace("_on.jpg",".jpg"));
		}
	);
	
	$("#leftnav a.toplevel").click(function(){
		$(this).next("ul").toggle(500);
		$("#leftnav a.toplevel").not($(this)).next("ul:visible").hide(500);
		$(this).toggleClass("active");
		$(this).siblings("a").removeClass("active");
	});
	
	
	$('#btn_search').click(function(){
		if($.trim($('#SearchKeyword').val())!='SEARCH')
		window.location.href='/search.asp?Mode=Text&Search='+$('#SearchKeyword').val();
	});
	
	$('#SearchKeyword').keydown(function(event){
		if(event.keyCode == 13)
		window.location.href='/search.asp?Mode=Text&Search='+$('#SearchKeyword').val();
	});


	$("#tinyalt img").click(function(){
		$("#tinyalt img").removeClass("on");
		$(this).addClass("on");

		var simg=$(this).attr('src').replace('tiny_','');
		$("#medimgdv").prepend('<a class="zoomimg" href="'+simg+'" style=""display:none;""><img src="'+simg+'" width="350" /></a>');
		
		var fheight = $("#medimgdv img").eq(1).height();
		var lheight = $("#medimgdv img").eq(0).height();
		if(fheight >= lheight)
		{$("#medimgdv").height(fheight);}
		else
		{$("#medimgdv").height(lheight);}
		
		$("#medimgdv a").css({"position":"absolute","top":"0","left":"0"});
		
		$("#medimgdv a").eq(1).fadeOut(1500);
		$("#medimgdv a:first").fadeIn(1500);
		
		if($("#medimgdv a").length == 3)
		{$("#medimgdv a").eq(2).remove();}
		
		$("#medimgdv a").eq(0).jqzoom({
			zoomWidth: 346,
			zoomHeight: 468,
			xOffset: 7,
			yOffset: 0,
			lens: true,
			title: false
		});
	});

	if($("#medimgdv a").length > 0)
	{
		$("#medimgdv a").jqzoom({
			zoomWidth: 346,
			zoomHeight: 468,
			xOffset: 7,
			yOffset: 0,
			lens: true,
			title: false
		});		
	}
	
	if($(".homeslides div").length > 0)
	{
		$('.homeslides').cycle({timeout:       10000,pager: '#slidetext'});
	}
	
	if($('#sbox1').height()>$('#sbox2').height())
		{$('#sbox2').height($('#sbox1').height());}
	else
		{$('#sbox1').height($('#sbox2').height());}
	
});