//*****************************************************//
//* FILENAME: 		util.js
//* DATE: 		2009-06-27 17:15:00
//* GENERATOR:		Hand mode
//* REVIEWED BY:	Jorge J. Sanchez Primera. 
//*****************************************************//

function serverRequest(){
 /*    var xmlhttp=false;

        try{
           xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch(e){
                try{
                        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
                }
                catch(E) { 
		    xmlhttp = false;
		}
        }

        if (!xmlhttp && typeof XMLHttpRequest!='undefined') { 
	    xmlhttp=new XMLHttpRequest(); 
	}

    return xmlhttp;*/

var xmlHttp;
  try { 
      xmlHttp = new XMLHttpRequest();
    return xmlHttp; 
  }
  catch(e){
      try{ 
	  xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
	return xmlHttp;
      }
      catch(e){
	  try{
	      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
	    return xmlHttp;
	  }
	  catch(e){
	      alert("Your browser does not support AJAX!");
	    return false; 
	  }
      }
  }

}


function ajaxRequest(){

  store = new serverRequest();  
  store.open("post","imagesRotator/rotator.php", true);

    store.onreadystatechange=function(){
    
    var content = document.getElementById("banner_change_content");

	if(store.readyState < 4){

	  if(content){
	      content.innerHTML='<br><br><center><img id="preload" src="imagesRotator/preload.gif"></center>';
	  }
	}

	if (store.readyState==4){

	  if(content){
	      content.innerHTML='<center>'+store.responseText+'</center>';
	  }

	  store.onreadystatechange = null;

	}
    }
    store.send(null);
}


function loadBanner(rtime){
  document.write("<div id=\"banner_change_content\">")
  document.write("</div>")

    reloadBanner(rtime);

}

function reloadBanner(rtime){
  ajaxRequest(); 
   window.setTimeout("reloadBannerAgain("+rtime+")",rtime*1000)
}

//Para compatibilidad con IE

function reloadBannerAgain(rtime){
    reloadBanner(rtime);
}





