/* function Menus() {
	
	this.innerWidth = undefined;
	this.Submenu = undefined;
	this.Margin = 24;
	
	this.Init = function Init() {
		$('#menu_topo li:has(.submenus)').each(function() {
			Submenu = $(this).children('.submenus');
			innerWidth = Submenu.innerWidth()+15;
			TotalWidth = 0;
			$(Submenu).children('a,.has_sub').each(function() {
				TotalWidth = TotalWidth + $(this).innerWidth();
			});
			innerWidth = TotalWidth;
			if(innerWidth != undefined) {
				Submenu.css({width:innerWidth+'px',left:'auto'});
				if((myMenu.Margin + innerWidth) > 864) {
					Submenu.css({marginLeft:'-'+((myMenu.Margin + innerWidth)-840)+'px'});
				}				
				myMenu.Margin = myMenu.Margin + $(this).innerWidth();
			}
		}).bind('mouseover',function() {
			$(this).children('a').addClass('hover');
			$(this).children('.submenus').css({visibility:'visible',display:'block'});
		}).bind('mouseout',function() {
			$(this).children('a').removeClass('hover');
			$(this).children('.submenus').css({visibility:'hidden',display:'none'})
		});
		
		$('.has_sub').bind('mouseover',function() { $(this).addClass('hover'); }).bind('mouseout',function() { $(this).removeClass('hover'); });
	}
}

var myMenu = new Menus();
myMenu.Init();
*/
function isset(VarName) {
	type = undefined;
	try {
		eval('type = typeof('+VarName+')');
		if(type == 'undefined') {
			return false;
		}
		else {
			return true;
		}
	}
	catch(e) {
		return 'false1';
	}
}
function Debug(Var) {
	if(isset('window.console')) {
		//window.console.debug(Var);
		return true;
	}
	return false;
}

function Menus() {
	
	this.innerWidth = undefined;
	this.Submenu = undefined;
	this.Margin = 24;
	
	this.Init = function Init() {
		$('#menu_topo li').each(function() {
			
			innerWidth = undefined;
			
			Submenu = $(this).children('.submenus');
			
			if(Submenu != undefined) {
				innerWidth = Submenu.innerWidth()+15;
				
				TotalWidth = 0;
				TotalWidth = $(Submenu).children('a:eq(0)').innerWidth();
				TotalWidth = TotalWidth == undefined ? $(Submenu).children('.has_sub:eq(0)').innerWidth() : TotalWidth;
				
				
				$(Submenu).children('a,.has_sub').each(function() {
					//TotalWidth = TotalWidth + $(this).innerWidth();
					if($(this).attr('class') == 'has_sub') {
						$(this).children('a').css({backgroundImage:'url('+BaseURL+'/imagens/bg/setasub.gif)',backgroundPosition:'right center',backgroundRepeat:'no-repeat'})
					}
					TotalWidth = $(this).innerWidth() > TotalWidth ? $(this).innerWidth() : TotalWidth;
				});
				innerWidth = TotalWidth;
			}
			
			
			
			if(innerWidth != undefined) {
				Sub2 = $(Submenu).find('.sub2');
				SubWidth = 0;
				Sub2.children('a').each(function() {
					SubWidth = $(this).innerWidth() > SubWidth ? $(this).innerWidth() : SubWidth;
				});
				
				Sub2.css({ width:SubWidth+'px' });
				
				pWidth = $(Submenu).parents('li').innerWidth();
				innerWidth = innerWidth < pWidth ? pWidth : innerWidth;

				Submenu.css({width:innerWidth+'px',left:'auto'});
				
				
				
				if((myMenu.Margin + innerWidth) > 864) {
					
					wSub2 = Sub2.innerWidth();
					if(wSub2 != undefined) {
						$(Submenu).find('.sub2').css({marginLeft:'auto',marginLeft:'-'+(wSub2)+'px'});
					}
					Submenu.css({marginLeft:'-'+((myMenu.Margin + innerWidth)-841)+'px'});
				}
				else {
					wSub2 = Sub2.innerWidth();
					Sub2.css({marginLeft:(innerWidth)+'px'});
					
					if((myMenu.Margin + innerWidth) + innerWidth > 864) {
						wSub2 = Sub2.innerWidth();
						if(wSub2 != undefined) {
							Sub2.css({marginLeft:'auto',marginLeft:'-'+(wSub2)+'px'});
						}
					}
				}
				
			}
			myMenu.Margin = myMenu.Margin + $(this).innerWidth();
		}).bind('mouseover',function() {
			$(this).children('a').addClass('hover');
			$(this).children('.submenus').css({visibility:'visible',display:'block'});
		}).bind('mouseout',function() {
			$(this).children('a').removeClass('hover');
			$(this).children('.submenus').css({visibility:'hidden',display:'none'})
		});
		
		$('.has_sub').bind('mouseover',function() { $(this).addClass('hover'); }).bind('mouseout',function() { $(this).removeClass('hover'); });
	}
}

//var myMenu = new Menus();
//myMenu.Init();
