var GetChaturl = "http://movies.filmax.com/_phpcomunes/comercio_ajax.php";
var ver_iframe;

//Inicio de las funciones AJAX

window.onload = initJavaScript;

//initiates the XMLHttpRequest object
//as found here: http://www.webpasties.com/xmlHttpRequest
function getHTTPObject() {
  var xmlhttp;
  /*@cc_on
  @if (@_jscript_version >= 5)
    try {
      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (E) {
        xmlhttp = false;
      }
    }
  @else
  xmlhttp = false;
  @end @*/
  if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
    try {
      xmlhttp = new XMLHttpRequest();
    } catch (e) {
      xmlhttp = false;
    }
  }
  return xmlhttp;
}

function initJavaScript() {
//	receiveChatText(); //initiates the first data query
}

//initiates the first data query
function receiveChatText() {
	if (httpReceiveChat.readyState == 4 || httpReceiveChat.readyState == 0) {
	  	httpReceiveChat.open("GET",GetChaturl + '?id_pelicula=' + id_pelicula + '&rand='+Math.floor(Math.random() * 1000000), true);
//	  	alert(GetChaturl + '?id_pelicula=' + id_pelicula + '&rand='+Math.floor(Math.random() * 1000000));
		httpReceiveChat.onreadystatechange = handlehHttpReceiveChat; 
	  	httpReceiveChat.send(null);
	}
}

//deals with the servers' reply to requesting new content
function handlehHttpReceiveChat() {
  if (httpReceiveChat.readyState == 4) {
    if(httpReceiveChat.responseText=='1')
    {
    	iframe = document.getElementById("win_comercio");
    	iframe.style.height='75';

    }
  }
}

// initiates the two objects for sending and receiving data
var httpReceiveChat = getHTTPObject();

//Fin de las funciones AJAX

function clava_comercio(){
  cadVariables = location.search.substring(1,location.search.length); // sin ?
  arrVariables = cadVariables.split("&");  // array de cadenas de tipo "var1=valor1"
  for (i=0; i<arrVariables.length; i++) {
	    arrVariableActual = arrVariables[i].split("=");
	    if (isNaN(parseFloat(arrVariableActual[1])))
 		 eval(arrVariableActual[0]+"='"+unescape(arrVariableActual[1])+"';");
	    else
  		  eval(arrVariableActual[0]+"="+arrVariableActual[1]+";");
 }
 id_pelicula=arrVariableActual[1];
 var logico="/_phpcomunes/";
 var archivo_comercio="comercio.php";
 var width="725";
 var height="75";
 
 document.write('<iframe name="win_comercio" id="win_comercio" src="'+logico+archivo_comercio+'?id_pelicula='+id_pelicula+'" width="'+width+'" height="0" frameborder="0" scrolling="no"></iframe>');
 
 receiveChatText();
// alert(ver_iframe);
/* while(ver_iframe==undefined)
 {
 	//do nothing
 	
 }
 */
 
//Realizamos una consulta ajax transparente para usuario. Obtenemos si hay o no comercio.
 
 if(ver_iframe==true) { //
 	}
  
}