var timeout    = 0;
var closetimer = 0;
var menuItems = 0;
var sper = 5;
function menuOver(obj) {
	var img = $(obj).find('img:first');
	img.attr('src', img.attr('overImg'))
}

function menuOut(obj) {
	var img = $(obj).find('img:first');
	if (img.attr('status') != 'on') {
		img.attr('src', img.attr('orgImg'))
	}
}

function getImgPath(obj) {
	var index = obj.attr('src').lastIndexOf('/');
	return obj.attr('src').substring(0, index) + '/'
}

function menuInit()
{
	$(".cs-menu ul").css('opacity', '0.8');
	//var li = $(".menu > li:last");
	//var x = li.find("ul").width() - li.width();
	//li.find("ul").css({'left': x +"px"})
	
}

	function dropDownOver()
	{
	cancelDropDownTimer();
	dropDownOut();
	
	var pos = $(this).position();
	var x = pos.left;
	var y = pos.top;	
	menuItems = $(this).find("ul").css({'visibility':'visible', 
									   	  'top':(y+ $(this).height()-sper) + "px"
										  })
	//var maxLength = getCharMaxLength($(this).find("ul").find("a"))
    //$(this).find("ul").width(maxLength*10) 
	
	if($(".menu > li").index(this) == ($(".menu > li").size()-1))
	{
		//var x = x- ($(this).find("ul").width() - $(this).width())
	//	$(this).find("ul").css({'left': x +"px"})
	}
	
	}
	function dropDownOut()
	{
		if(menuItems)
		menuItems.css({'visibility':'hidden'})
	}
	function timer()
	{
		closetimer = window.setTimeout(dropDownOut, timeout);
	}
	function  cancelDropDownTimer(){
		if(closetimer)
		{
	  	window.clearTimeout(closetimer);
      	closetimer = null;
	    }
	}

