// JavaScript Document
$(document).ready(function(){
	if($("#menu")) {
		$("#main div").each(
			function(){
				wordcount=0;
				$(this).find("a").each(
					function(){
						if($(this).text().length > wordcount){
							wordcount = $(this).text().length;
						}
					});
				if (wordcount*5.6 > 100) $(this).width(wordcount*6);
				else $(this).width(110);
			});
		
		var widths = new Array(49,74,72,83,90,111,84,86,111,61);
		count = 0;
		
		$("#menu div").each(
			function(){
				if($(this).find("img:first").width() != null) {
					//alert($(this).find("img:first").width());
					//$(this).width($(this).find("img:first").width() + 6);
					$(this).width(widths[count]);
					count++;
				}
			});
		
		$("#main div").hide();
		
		$("#sub li").hover(function(){$(this).fadeOut(100);$(this).fadeIn(400);});
		
		$("#main img").hover(function(){$(this).attr({src:$(this).attr("src").replace(/.gif/,"_b.gif")});},function(){$(this).attr({src:$(this).attr("src").replace(/_b.gif/,".gif")});});
		$("#main1 img").hover(function(){$(this).attr({src:$(this).attr("src").replace(/.gif/,"_b.gif")});},function(){$(this).attr({src:$(this).attr("src").replace(/_b.gif/,".gif")});});
																																									
		var config = {    
			 sensitivity: 1, // number = sensitivity threshold (must be 1 or higher)    
			 interval: 100, // number = milliseconds for onMouseOver polling interval    
			 over: function(){$(this).find("#sub").slideDown(200);}, // function = onMouseOver callback (REQUIRED)    
			 timeout: 400, // number = milliseconds delay before onMouseOut    
			 out: function(){$(this).find("#sub").slideUp(100);} // function = onMouseOut callback (REQUIRED)    
		};
		
		$("#menu div").hoverIntent(config);
		
		$("#sub ul li").click(function() { window.location=$(this).find("a").attr("href"); });
		
	}
});