$(document).ready(function() {
$(".menus_to_fix").each(function(index,item){
	var to_add_class = $(item).find(".second_li").size();

	$(item).addClass("menus"+to_add_class);
})
        // Tooltip only Text
$(".main_cat").hover(function(){
	var winW = 630, winH = 460;
	if (document.body && document.body.offsetWidth) {
	 winW = document.body.offsetWidth;
	 winH = document.body.offsetHeight;
	}
	if (document.compatMode=='CSS1Compat' &&
		document.documentElement &&
		document.documentElement.offsetWidth ) {
	 winW = document.documentElement.offsetWidth;
	 winH = document.documentElement.offsetHeight;
	}
	if (window.innerWidth && window.innerHeight) {
		 winW = window.innerWidth;
		 winH = window.innerHeight;
	}
	var offset = 0;
	if(winW>980){
		offset = 	(winW-980)/2;
	}
	var position_left = $(this).parent().position().left;
	//alert(position_left)
	var position_width = $(this).parent().find("ul.drop-down").outerWidth();
	if(offset+position_left+position_width>winW && position_left - position_width > 0){
		$(this).parent().find("ul.drop-down").removeClass("drop-down-right").addClass("drop-down-right");
	}else{
		$(this).parent().find("ul.drop-down").removeClass("drop-down-right");
	}
	
});
});
