function moverz(d){
	ajax('localizacion-ajax.php','GET','d='+d+'',function (oXML) { document.getElementById('ajimagen').innerHTML=(oXML.responseText); });
	window.frames['iotrosheroes'].location.reload();
	ajax('localizacion-ajax2.php','GET','',function (oXML) { document.getElementById('edifszona').innerHTML=(oXML.responseText); });
}
function volverz(){
	ajax('localizacion-ajax.php','GET','d=0',function (oXML) { document.getElementById('ajimagen').innerHTML=(oXML.responseText); });
	window.frames['iotrosheroes'].location.reload();
	ajax('localizacion-ajax2.php','GET','',function (oXML) { document.getElementById('edifszona').innerHTML=(oXML.responseText); });
}
function movered(d){
	ajax('localizacion-ajax3.php','GET','d='+d+'',function (oXML) { document.getElementById('edifszona').innerHTML=(oXML.responseText); });
	window.frames['iotrosheroes'].location.reload();
	//ajax('localizacion-ajax2.php','GET','',function (oXML) { document.getElementById('edifszona').innerHTML=(oXML.responseText); });
}

function leeAJAXc1(jh){
var ruleta1 = 0;
if (document.casino1.ruleta[0].checked){
    ruleta1 = 0;
}
if (document.casino1.ruleta[1].checked){
    ruleta1 = 1;
}
if (document.casino1.ruleta[2].checked){
    ruleta1 = 2;
}
if (document.casino1.ruleta[3].checked){
    ruleta1 = 3;
}
if (document.casino1.ruleta[4].checked){
    ruleta1 = 4;
}
if (document.casino1.ruleta[5].checked){
    ruleta1 = 5;
}
if (document.casino1.ruleta[6].checked){
    ruleta1 = 6;
}
	ajax('includes/edificios/casino1-ajax.php','GET','ruleta='+ruleta1+'&apuesta1='+document.casino1.apuesta1.value+'&numsolo='+document.casino1.numsolo.value+'',function (oXML) { document.getElementById('dcasino1').innerHTML=(oXML.responseText); });
}

function leeAJAXc2(jh){
	ajax('includes/edificios/casino2-ajax.php','GET','jugarh=1',function (oXML) { document.getElementById('dcasino2').innerHTML=(oXML.responseText); });
}


function XHConn() {
  var xmlhttp, bComplete = false;
  try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); }
  catch (e) { try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); }
  catch (e) { try { xmlhttp = new XMLHttpRequest(); }
  catch (e) { xmlhttp = false; }}}
  if (!xmlhttp) return null;
  this.connect = function(sURL, sMethod, sVars, fnDone) {
    if (!xmlhttp) return false;
    bComplete = false;
    sMethod = sMethod.toUpperCase();

    try {
      if (sMethod == "GET")
      {
        xmlhttp.open(sMethod, sURL+"?"+sVars, true);
        sVars = "";
      }
      else
      {
        xmlhttp.open(sMethod, sURL, true);
        xmlhttp.setRequestHeader("Method", "POST "+sURL+" HTTP/1.1");
        xmlhttp.setRequestHeader("Content-Type",
          "application/x-www-form-urlencoded");
      }
      xmlhttp.onreadystatechange = function(){
        if (xmlhttp.readyState == 4 && !bComplete)
        {
          bComplete = true;
          fnDone(xmlhttp);

        }};
      xmlhttp.send(sVars);
    }
    catch(z) { return false; }
    return true;
  };
  return this;
}

function ajax(archivo, metodo, variables, funcion) {
	var myConn = new XHConn();
	if (!myConn) alert("XMLHTTP not available. Try a newer/better browser.");
	myConn.connect(archivo, metodo, variables + '&Now=' + Date(), funcion);
}

function $(id) { return document.getElementById(id); }



//cerrar avisos
function cerraraviso(ida){
	document.getElementById(ida).style.position='absolute';
	document.getElementById(ida).style.visibility='hidden';
	AJAXcerraraviso(ida);
}

function cerrarta(){
	document.getElementById('ta').style.position='absolute';
	document.getElementById('ta').style.visibility='hidden';
	AJAXcerraraviso('ta');
}


function AJAXcerraraviso(ida){
	oXML = AJAXCrearObjeto2();
	oXML.open('GET', 'ajax/cerraraviso.php?ida='+ida);
	oXML.send('');
}

function AJAXCrearObjeto2(){
  var obj;
  if(window.XMLHttpRequest) { // no es IE
    obj = new XMLHttpRequest();
  } else { // Es IE o no tiene el objeto
     try {
       obj = new ActiveXObject("Microsoft.XMLHTTP");
    }  catch (e) {
      alert('El navegador utilizado no está soportado');
    }
  }
  return obj;
}


var num = 0;
//recoger recursos
function recoge(edif,rec){
		document.getElementById('bct').style.visibility='hidden';
	num = rec;
	recursos(num,1);

	oXML = AJAXCrearObjeto2();
	oXML.open('GET', 'ajax/recoger-recursos.php?ide='+edif);
	oXML.onreadystatechange = recursos1;
	oXML.send('');

}
function recursos1(){
 if (oXML.readyState  == 4) {
        document.getElementById('recrec').innerHTML = oXML.responseText;
  } 
}
function recursos(nump,pri){
	if (pri==1)
	{
		num = nump;
	}
	if(num >= 0){
		if(num<10){
			num = "0" + num
		}
		document.getElementById('recrec').innerHTML= '<b>'+num+'</b> ';
		num--
		setTimeout('recursos(0,0)',10)
	}else{
		setTimeout('sinrecursos1()',100);
		setTimeout('sinrecursos2()',500);
		setTimeout('sinrecursos1()',1000);
		setTimeout('sinrecursos2()',1500);
		setTimeout('sinrecursos1()',2000);
	}
}
function sinrecursos1(){
		document.getElementById('recrec').innerHTML= '<b>0</b>';
		document.getElementById('bct').style.visibility='visible';
		document.getElementById('bct').innerHTML = '<font color=\"red\" style=\"background-color:#FFCC99;padding:3px;border:2px solid blue;font-size:20px;\">sin recursos</font>';
}
function sinrecursos2(){
		document.getElementById('bct').innerHTML = '<font color=\"red\" style=\"background-color:#FFCC99;padding:3px;border:2px solid blue;font-size:20px;color:#FFCC88;\">sin recursos</font>';
}


//menu flotante
function setVariables() {
if (navigator.appName == "Netscape") {
v=".top=";
dS="document.";
sD="";
y="window.pageYOffset";
}
else {
v=".pixelTop=";
dS="";
sD=".style";
y="document.body.scrollTop";
   }
}
function checkLocation() {
object="object1";
yy=eval(y);
eval(dS+object+sD+v+yy);
setTimeout("checkLocation()",10);
}


//desabilitar boton derecho
var message="Botón derecho deshabilitado.\n";            
 
function clickIE() {if (document.all) {(message);return false;}}
function clickNS(e) {if 
(document.layers||(document.getElementById&&!document.all)) {
if (e.which==2||e.which==3) {(message);return false;}}}
if (document.layers) 
{document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}

document.oncontextmenu=new Function("return false")



/*
var url = "";
url = window.top.location.toString();
if (url.indexOf("galaxy.php")<0 ){
    window.location='error1.php';
}*/

	  function cierra(e)
	  {
	    c=(document.getElementById(e).style.display == 'none') ? 'block' : 'none';
	    document.getElementById(e).style.display = c;
	  }

      var ns4 = (document.layers)? true:false
      var ie4 = (document.all)? true:false
      var ns6 = (document.getElementById && !document.all) ? true: false;
      var coorX, coorY;

      if (ns6) document.addEventListener("mousemove", mouseMove, true)
      if (ns4) {document.captureEvents(Event.MOUSEMOVE); document.mousemove = mouseMove;}

      function mouseMove(e)    {
                if (ns4||ns6)    {
                    coorX = e.pageX;
                    coorY = e.pageY -15;
					//coorY -= document.body.scrollTop;
                }
                if (ie4)    {
                    coorX = event.x;
                    coorY = event.y - 15;
					coorY += document.body.scrollTop;
                }
                coorX += document.body.scrollLeft;
               
                return true;
      }

      function ini()    {
                if (ie4)    document.body.onmousemove = mouseMove;				
      }

      function mostrar(dato)    {
                with(document.getElementById("ayuda"))    {
                    style.top = coorY;
                    style.left = coorX + 10;
                    style.visibility = "visible";
                    innerHTML = dato;
                }
      }

      function ocultar()    {
                document.getElementById("ayuda").style.visibility = "hidden";
      }

      function mover()    {
                with(document.getElementById("ayuda"))    {
                    style.top = coorY;
                    style.left = coorX + 10;
                }
      }	
      
     
      



	  //inicio imagen de sustitucion
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

	  //fin imagen de sustitucion

 
 function desactivar(url){
   
        for(a=0;a<document.links.length;a++){
                //document.links[a].href="#";  
                document.links[a].style.visibility='hidden';    
        }  
     window.location = url;    
}
