// for remotely hosted pools

function menuLoad (sgame,origin) {
 var mlink,ml,mt,gcls,glink,mgl="";
 menulinks=""; gmnu=""; var oplink='';
 
 var mgms=(menuc != null && menuc != "") ? menuc.split(":"): '';
 for(var g=0; g<mgms.length; g++) {
 	var mg=mgms[g].split("-"); var mgame=mg[0]; var mitems=mg[1]; gcls=(mgame == sgame)?"class=sel":"";
  gmnu+='<div '+gcls+'><a href="javascript:menuLoad(\''+mgame+'\',\'gm\');" style="outline:none;">'+mgame+'</a></div>';
  if (mgame != sgame) {continue;} 
  if (mgame == sgame) {game=sgame;} 
  
 	document.body.className=sgame+"bg"; 
 	document.getElementById('Menu').className=sgame; 
 	document.getElementById('Header').className=sgame+"hd";	 
 	var mis=mitems.split(","); 
 	for(var i=0; i<mis.length; i++) {var mi=mis[i].split("="); var ml=mi[0]; var mt=mi[1];
 	 if (mi.length > 0) {
 	 	menulinks+='<div id=Mlink class=mlink><a href="javascript:act(\''+lstr+'ac='+ml+'&game='+sgame+'\',\'Output\');">'+mt+'</a></div><div id=Msep></div>';
   } 
  }
 }
 menu='<div id=Msep></div>';
 menu+='<div id=Mlink class=mlink> <a href="javascript:act(\''+lstr+'game='+sgame+'&ac=home\',\'Output\');">HOME</a></div><div id=Msep></div>';
 if (logresult != "Y") {menu+='<div id=Mlink class=mlink> <a href="javascript:act(\''+lstr+'ac=join\',\'Output\');">JOIN</a></div><div id=Msep></div>';}
 if (logresult == "Y") {menu+=menulinks;}
 menu+='<div id=Mlink class=mlink> <a href="javascript:act(\''+lstr+'game='+sgame+'&ac=rules\',\'Output\');">RULES</a></div><div id=Msep></div>';
 menu+='<div id=Mlink class=mlink style="outline:none;"> <a href="javascript:act(\''+lstr+'game='+sgame+'&ac=contact\',\'Output\');">CONTACT</a></div><div id=Msep></div>';
 menu+='<div id=Mlink class=mlink> <a href="javascript:act(\''+lstr+'game='+sgame+'&ac=help\',\'Output\');">HELP</a></div><div id=Msep></div>';
 if (logresult != "Y") {menu+='<div id=Mlink class=mlink> <a href="javascript:act(\''+lstr+'game='+sgame+'&ac=help\',\'Output\');">PLEASE LOGIN</a></div><div id=Msep></div>';}
   
 if (marquee != "" && document.getElementById("Marquee")) {document.getElementById("Marquee").innerHTML=marquee; document.getElementById("MarqueeS").innerHTML=marquee;}
 if (origin == "lp") { 	// setup custom images if present
 	if (cstyle.substr(0,1) != "x") {
 	 var pStyle=document.styleSheets[0]; var pcss = (pStyle.cssRules) ? pStyle.cssRules : pStyle.rules;
	 var imgarr=cstyle.split(":::"); 	
 	 for(var i=0; i<imgarr.length; i++) {
    var cimg=imgarr[i].split("+");
    var celem=cimg[0]; var cval=cimg[1];
    for(c=0; c < pcss.length; c++){ if(pcss[c].selectorText == celem) {pcss[c].style.cssText = cval;} }
   }
 	} 
 	document.getElementById("Output").innerHTML=news; // insert news from initial load
  if (document.getElementById("Widget")) {document.getElementById("Widget").innerHTML=widgets;}
 }
 else {
 	if (wp == '') { // if pool is not set
 	 menu='<div id=Msep></div>';
 	 menu+='<div id=Mlink class=mlink title="POOL FIND: Enter one of the following\r&#10102; 8 digit pool number\r&#10103; Portion of pool name\r&#10104; Part of managers name\rThen click on FIND YOUR POOL"><form id="find" name="find" style="float:left;" onsubmit="return noenter();">';
 	  menu+='<input type=text name="wp" id="wp" style="width:60px; position:relative; top:-3px; margin-right:3px;" onKeyPress="return noenter(event)"></form>';
 	  menu+='<span style=""><a href="javascript:setPool(\'xx\');">FIND YOUR POOL</a></span></div><div id=Msep></div>';
 	 menu+='<div id=Mlink class=mlink> <a href="javascript:act(\'ac=nowp&sa=admin\',\'Output\');">ADMIN</a></div><div id=Msep></div>';
 	 menu+='<div id=Mlink class=mlink> <a href="javascript:act(\'ac=nowp&sa=contact\',\'Output\');">CONTACT</a></div><div id=Msep></div>';
 	 menu+='<div id=Mlink class=mlink> <a href="javascript:act(\'ac=nowp&sa=help\',\'Output\');">HELP</a></div><div id=Msep></div>';
 	 menu+='<div id=Mlink class=mlink> <a href="javascript:act(\'ac=nowp&sa=help\',\'Output\');">PLEASE LOGIN</a></div><div id=Msep></div>';
 	 
 	 
 	 var ln="ac=nowp&game="+game; act(ln,'Output');
 	}
 	else {
 	 var ln="&ac=home&loadR=Y&game="+game; 
 	 var limg='<img src="http://www.superbrawl.com/images/shim.gif" onload="javascript:act(\''+ln+'\',\'Output\');">';
 	 document.getElementById("Output").innerHTML=limg;
 	}
 }
 // get extra menu links from page
 var xmlinx=document.getElementById("xe_menu").innerHTML; xmlinx=xmlinx.replace(/\n/g,""); xmlinx=xmlinx.replace(/\t/g,"");
 if (xmlinx != "") {
 	var xmis=xmlinx.split("|");
 	for(var i=0; i<xmis.length; i++) {menu+='<div id=Mlink class=mlink>'+xmis[i]+'</div><div id=Msep></div>';}
 }
 document.getElementById("Menu").innerHTML=menu;
 if (mgms.length > 1) {document.getElementById("Gmnu").innerHTML='<div class=lt title="pd:'+pdom+'"></div>'+gmnu+'<div class=rt></div>';}
 
 if (xid != "") {var xac='ac=xcon&xid='+xid; act(xac,'xcon');}
 
 // if (pdom != '' && window.location.host != pdom && phost !='www.superbrawl.com') {var actions="ac=misc&sa=ua&ph="+phost+"&wp="+wp+"&pd="+pdom; act(actions,"Output");}
}

function chgWidget (wv) {
 if (typeof(wv) === 'undefined') {
 	var wv=document.getElementById("swidget").value;
 }
 document.getElementById(wv).style.display="block";
 var wl=document.getElementById("wlist").value;
 var hides=wl.split(":"); 
 for(var i=0; i<hides.length; i++) {
 	var hd=hides[i]; 
 	if (hd == wv) {continue;}
 	
 	document.getElementById(hd).style.display="none";
 }
}
