$(document).ready(function(){
//	$('.sub_menu').hide();
	$("ul.main_menu li:first").click(function(){
		$('.sub_menu').show();
		return false;
	});
	
	$(".search input.find").focus(function(){
		$(this).css('background-image', 'none');
	});
	$(".search input.find").blur(function(){
		if($(this).val()=='')
			$(this).css('background-image', 'url(\'/images/search_bg.png\')');
	});
	try{
		$("div.text_frame:first").fadeIn('slow');
		$("div.hp_menu ul li a").mouseover(function(){
			$("div.text_frame").fadeOut('fast');
			$("div.hp_menu ul li a").css('color', '');
			$("#div_" + this.href.split('id=')[1]).fadeIn('fast');
			$("div.hp_menu").css("background-image", "url('images/" + $("#div_" + this.href.split('id=')[1]).attr('title') + "_sample_img.jpg')");
			//$(this).css('color', 'red');
			return false;
		});
	}catch(er){}
	$("ul.main_menu li.sub_menu td a").hover(function(){
		if($(this).parent("td").prev("td").attr('rel')!='selected'){
			var prevText = $(this).parent("td").prev("td").html();
			if(prevText=='|') $(this).parent("td").prev("td").html('&nbsp;');
			$(this).parent("td").prev("td").css('background-position', 'left bottom');
		}
		if($(this).parent("td").next("td").attr('rel')!='selected'){
			var nextText = $(this).parent("td").next("td").html();
			if(nextText=='|') $(this).parent("td").next("td").html('&nbsp;');
			$(this).parent("td").next("td").css('background-position', 'right bottom');
		}
	}, function(){
		if($(this).parent("td").prev("td").attr('rel')!='selected'){
			var prevText = $(this).parent("td").prev("td").html();
			if(prevText=='&nbsp;') $(this).parent("td").prev("td").html('|');
			$(this).parent("td").prev("td").css('background-position', 'center bottom');
			if(prevText=='<IMG src="images/pixel.png" width=6>' || prevText=='<img src="images/pixel.png" width="6">'){
				$(this).parent("td").prev("td").css('background-position', 'left top');
			}
		}
		if($(this).parent("td").next("td").attr('rel')!='selected'){
			var nextText = $(this).parent("td").next("td").html();
			if(nextText=='&nbsp;') $(this).parent("td").next("td").html('|');
			$(this).parent("td").next("td").css('background-position', 'center bottom');
			if(nextText=='<IMG src="images/pixel.png" width=6>' || nextText=='<img src="images/pixel.png" width="6">'){
				$(this).parent("td").next("td").css('background-position', 'right top');
			}
		}
	});
	
	$("div.main_content").css('min-height', parseInt($("body").context.documentElement.scrollHeight) + 'px')
	$("div.hp_content").css('min-height', parseInt($("body").context.documentElement.scrollHeight) + 'px')
	$("div.main_content").height($(".content_text").height())
//	PageHeight = $("div.main_content").height();
//	RightHeight = $("div.right_content").height();
//	alert(PageHeight)
//	alert(parseInt(RightHeight))
//	if (parseInt(RightHeight) > parseInt(PageHeight)){
//		$("div.main_content").height(RightHeight);
//	}else{
//		$("div.right_content").height(PageHeight);
//	}
	$("#search_form").submit(function(){
		query = $(this).serialize()
		$("#result").load('result.asp?'+query, function(){
			$(this).slideDown(0);
		})
		return false;
	});
	if($(window).width() < 1200){
		$("div.main_content").css("background-position", "1em -5px")
	}
});

function setSelectedSubMenu(obj){
	$(obj).css({'background-image': 'url(/images/sub_menu_bg.png)', 'background-position': 'right', 'color': '#ffffff'});
	var prevText = $(obj).parent("td").prev("td").html();
	var nextText = $(obj).parent("td").next("td").html();
	if(prevText=='|') $(obj).parent("td").prev("td").html('&nbsp;');
	if(nextText=='|') $(obj).parent("td").next("td").html('&nbsp;');
	$(obj).parent("td").prev("td").css('background-position', 'left bottom').attr('rel', 'selected');
	$(obj).parent("td").next("td").css('background-position', 'right bottom').attr('rel', 'selected');
}
