rexp_s=new RegExp('(.*/game/).*session=([0-9A-z]*)');
rexp_a=new RegExp('(\\d+):(\\d+):(\\d+)');
var czesci;
function ustaw() {
	tr = document.getElementsByTagName('TR');
	if (tr.length)
		for (i=0; i<tr.length; i++) {
		  td = tr[i].getElementsByTagName('TD');
			if (td.length && (adres = rexp_a.exec(td[0].firstChild.nodeValue))) {
				el=document.createElement('A');
  			el.setAttribute('href','javascript:mapa('+adres[1]+','+adres[2]+')');
  			el.appendChild(document.createTextNode('M '));						
				new_td = tr[i].appendChild(document.createElement('TD'));
				new_td.appendChild(el);
				if (td[4].firstChild) {
					if( td[4].firstChild.firstChild ) {
						el=document.createElement('A');
						el.setAttribute(
							'href','javascript:sondy('+adres[1]+','+adres[2]+','+adres[3]+')');
						el.appendChild(document.createTextNode(' S '));
						new_td.appendChild(el);						
						el=document.createElement('A');
		  			el.setAttribute('href',"javascript:gracz('"+td[4].firstChild.firstChild.nodeValue+"')");
						el.appendChild(document.createTextNode(' G'));						
					}
					new_td.appendChild(el);
				}
			}
		}
}
function pobierz() {
  numer=parent.frames['nrsesji'].document.getElementById('sesja').value;
	czesci=rexp_s.exec(numer);
}
function mapa(gal,ukl) {
	pobierz();
  okno=window.open(czesci[1]+'index.php?page=galaxy&session='+czesci[2]+'&p1='+gal+'&p2='+ukl);
}
function sondy(gal,ukl,pla) {
	pobierz();
	okno=window.open('');
//  	okno.document.write('<frameset><frame src="'+czesci[1]+'index.php?page=flotten&session='+czesci[2]+'&fstate=3&type=Spionage&gesver2=1&ladekap2=5&s=10&ft1='+gal+'&ft2='+ukl+'&ft3='+pla+'">');
  	okno.document.write('<frameset><frame name="main"></frameset>');
		rndval = new Date().getTime(); 
	okno.frames['main'].document.write('<html><body><form action="'+czesci[1]+'index.php?ajax=1&page=flottenversand&session='+czesci[2]+'" method="post"><input type="hidden" name="session" value="'+czesci[2]+'" /><input type="hidden" name="order" value="6" /><input type="hidden" name="galaxy" value="'+gal+'" /><input type="hidden" name="system" value="'+ukl+'" /><input type="hidden" name="planet" value="'+pla+'" /><input type="hidden" name="planettype" value="1" /><input type="hidden" name="shipcount" value="6" /><input type="hidden" name="speed" value="10" /><input type="hidden" name="reply" value="short" /><input type="hidden" name="rndval" value="'+rndval+'" /></form></body></html>');
	okno.frames['main'].document.forms[0].submit();	
}

ajax.setVar("session", "d9cc3026ff32");
      ajax.setVar("order", order);
      ajax.setVar("galaxy", galaxy);
      ajax.setVar("system", system);
      ajax.setVar("planet", planet);
      ajax.setVar("planettype", planettype);
      ajax.setVar("shipcount", shipcount);
      ajax.setVar("speed", 10);
      ajax.setVar("reply", "short");


function gracz(nazwa) {
	pobierz();
	okno=window.open('');
	okno.document.write('<frameset><frame name="main"></frameset>');
  	okno.frames['main'].document.write('<html><body><form id="searchform" action="'+czesci[1]+'index.php?page=suche&session='+czesci[2]+'" method="post"><input type="hidden" name="type" value="playername" /><input type="hidden" name="searchtext" value="'+nazwa+'" /></form></body></html>');
	okno.frames['main'].document.forms[0].submit();
}