$(function() {
	
	$('.menubg,.menubgb').each( function() {
		var mt='';
		$(this).find('.menuitem').each( function() {
			if ($(this).find('a').size()<1) mt+='<LI class=current>'; else mt+='<LI>';
			mt+=$(this).html(); mt+='</LI>';
		});
		if (mt!='') { 
			var y=mt.indexOf('<'+'!--'); var y1=0;
			// Remove comments
			while (y>=0) {
				y1=mt.indexOf('-->',y+1); mt=mt.substr(0,y)+mt.substr(y1+3);
				y=mt.indexOf('<'+'!--');
			}
			mt=mt.replace(/\<\/a\>\<\/a\>/gi,'</a>');
			mt='<UL class=usr_menu>'+mt+'</UL>'; 
			mt='<DIV class=usr_menubg width="'+$(this).width()+'">'+mt+'</DIV>'; 
			if ($(this).attr('tagname')=='TABLE') mt='<TR><TD align=center>'+mt+'</TD></TR>';
			$(this).html(mt);
			$('.usr_menubg').css('background-color',$(this).css('background-color'));

//			$(this).removeClass('menubg'); //.addClass('usr_menubg');
			$(this).css('margin',0).css('padding',0);
		}
//alert($(this).parent().attr('tagname')+' '+$(this).attr('tagname'));
//alert($(this).parent().html());
	});

	$('.usr_menu').gr8_menu({width:'auto'});
//	$('.usr_menubg').fadeTo('slow', 0.9);

//	$('.usr_menu').lavaLamp({fx: "backout", speed: 700 });

	$('.roundedmain, .rounded, .roundedlinks').corners('10px 10px');
//	$('.roundwrap').corners('5px 5px');
	$('.imgr_wrapper img').imgr({size:"0px",color:"azure",radius:"10px"});

	var d=true;
	if (runningInGr8stuff()) { if (parent.location.href.indexOf('gr8cr8_webedit')>0) d=false; }
	if (d) {
		$('.elebg').each(function() {
			$(this).css('top',$('.menubgb').parent().offset().top-$(this).height()+7);
			$(this).css('left',$('.menubgb').parent().offset().left);
		});
	}
}); 

function runningInGr8stuff() { 
//	if ( typeof(parent.inGr8stuff)=='function') { return true; } else { return false; }
//alert(parent.location.href+'\n'+location.href);
	if (location.href.indexOf('gr8cr8_')>0) return true;
	if (parent.location.href==location.href) { return false; } else { return true; } 
}

