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:ajax_sendForm() ======*/
/*=======================================*/
function ajax_sendForm(fileName,formName,contentLayer,method,progressMessage)
{
	var urlArgs = "";
	var pMsg = "<TABLE align='center' border='0' width='100%' cellpadding:'0'><TR><TD align='center' style=\"color:#555555; font-size:11px; font-family:'Trebuchet MS', Verdana, Arial, sans-serif;\"><IMG align='center' src='"+arguments[4]+"'><BR>cargando</TD></TR></TABLE>";
	if(arguments[1] && arguments[1] != 'noForm')
   {
	   	formName = arguments[1];
			for(i = 0; i < eval("this.document."+formName+".elements.length"); i++)
			{
				//alert(eval("this.document."+formName+".elements["+i+"].type"));
				if((eval("this.document."+formName+".elements["+i+"].type") == "checkbox" ||
				   eval("this.document."+formName+".elements["+i+"].type") == "radio"))
				{
							//alert(eval("this.document."+formName+".elements["+i+"].checked"));
					   	if(eval("this.document."+formName+".elements["+i+"].checked"))
					   	{
					   		//alert(eval("this.document."+formName+".elements["+i+"].checked"));
					   		argName = eval("this.document."+formName+".elements["+i+"].name");
								argValue = eval("this.document."+formName+".elements["+i+"].value");
					   	}
					   	else { continue; }
				}
				else
				{
					argName = eval("this.document."+formName+".elements["+i+"].name");
					argValue = eval("this.document."+formName+".elements["+i+"].value");
				}
				urlArgs = (urlArgs.length == 0) ? urlArgs+argName+"="+argValue : urlArgs+"&"+argName+"="+argValue;
				//alert(urlArgs);
			}
   }
   if(method.toUpperCase() == 'POST')
   {
   		ajax_submitForm (fileName,contentLayer,urlArgs,method,pMsg);
   }
}
/* === Function: ajax_submitForm() ======*/
/*=======================================*/
function ajax_submitForm (url,capa,valores,metodo,progressMessage)
{

          var ajax= getHTTPObject();
          var capaContenedora = document.getElementById(capa);


				/*Creamos y ejecutamos la instancia si el metodo elegido es POST*/
				if(metodo.toUpperCase()=='POST')
				{
		         	ajax.open ('POST', url, true);
		         	ajax.onreadystatechange = function()
		         	{
		         		if (ajax.readyState==1)
		         		{
		            	 capaContenedora.innerHTML=""+progressMessage;
		       		 	}
         				else if (ajax.readyState==4)
         				{
                   if(ajax.status==200)
                   {
                        document.getElementById(capa).innerHTML=ajax.responseText;
                   }
                   else if(ajax.status==404)
                   {
                      capaContenedora.innerHTML = "La direccion no existe";
                   }
                   else
                   {
                      capaContenedora.innerHTML = "Error: ".ajax.status;
                   }
                }
              }
         ajax.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
         ajax.send(valores);
         return;
				}
				/*Creamos y ejecutamos la instancia si el metodo elegido es GET*/
				if (metodo.toUpperCase()=='GET')
				{
        		ajax.open ('GET', url, true);
         		ajax.onreadystatechange = function()
         		{
         				if (ajax.readyState==1)
         				{
                    capaContenedora.innerHTML=""+progressMessage;
         				}
         				else if (ajax.readyState==4)
         				{
                   if(ajax.status==200)
                   {
                       document.getElementById(capa).innerHTML=ajax.responseText;
                   }
                   else if(ajax.status==404)
                   {
                       capaContenedora.innerHTML = "La direccion no existe";
                   }
                   else
                   {
                      capaContenedora.innerHTML = "Error: ".ajax.status;
                  	}
             	}
            }
        		ajax.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
         		ajax.send(null);
         		return;
				}
} /*= END ajax_submitForm (url,capa,valores,metodo) */

/* =======================================*/
var http = getHTTPObject();
var container = "";
var frameLevel = "";
function handleHttpResponse()
{
  //if the process is completed, decide to do with the returned data
   if (http.readyState == 4)
   {
	   sResults = http.responseText;
	   ///alert(sResults);
	   if(frameLevel == "parent") { parent.document.getElementById(container).innerHTML = sResults; }
	   else {document.getElementById(container).innerHTML = sResults; }

    }
}

function handleScript()
{
	//if (http.readyState == 4)
}

function sendHttpRequest()
{
   var urlFile = "";
   var urlArgs = "";
   var formName = "";

   if(arguments.length == 0) { return; }
   urlFile = arguments[0];

   if(arguments[1] && arguments[1] != 'noForm')
   {
			   	formName = arguments[1];
			   	//form = document.getElementById(formName);
					for(i = 0; i < eval("this.document."+formName+".elements.length"); i++)
					{
						if((eval("this.document."+formName+".elements["+i+"].type") == "checkbox" ||
						   eval("this.document."+formName+".elements["+i+"].type") == "radio"))
						{
									//alert(eval("this.document."+formName+".elements["+i+"].checked"));
							   	if(eval("this.document."+formName+".elements["+i+"].checked"))
							   	{
							   		//alert(eval("this.document."+formName+".elements["+i+"].checked"));
							   		argName = eval("this.document."+formName+".elements["+i+"].name");
										argValue = eval("this.document."+formName+".elements["+i+"].value");
							   	}
						}
						else
						{
							argName = eval("this.document."+formName+".elements["+i+"].name");
							argValue = escape(eval("this.document."+formName+".elements["+i+"].value"));
							///alert(argValue);
						}
						urlArgs = (urlArgs.length == 0) ? urlArgs+argName+"="+argValue : urlArgs+"&"+argName+"="+argValue;
						//alert(urlArgs);
					}
   }
   //:... PRINT PROGRESS VAR IF third argument is SETTED ...://
   if(arguments[2] && arguments[2].indexOf('image') != -1)
   {
     if(frameLevel == "parent")
     {parent.document.getElementById(container).innerHTML = "<BR><TABLE align='center' border='0' width='100%' cellpadding:'0'><TR><TD align='center' style=\"color:#555555; font-size:11px; font-family:'Trebuchet MS'\"><IMG align='center' src='"+arguments[2]+"'><BR>cargando</TD></TR></TABLE>";}
		  else
      {
      	//document.getElementById(container).innerHTML = "<BR><TABLE align='center' border='0' width='100%' cellpadding:'0'><TR><TD align='center' style=\"color:#555555; font-size:11px; font-family:'Trebuchet MS'\"><IMG align='center' src='"+arguments[2]+"'><BR>cargando</TD></TR></TABLE>";
      }
   }
   else
   {
          if(frameLevel == "parent")
	         {parent.document.getElementById(container).innerHTML = "&nbsp;";}
          else
            {
            	//document.getElementById(container).innerHTML = "&nbsp;";
            }
   }
   //:.........................................................://

    urlComplete = (urlFile.indexOf('.php?') == -1)? urlFile+"?"+urlArgs : urlFile+"&"+urlArgs;

    http.open("GET", urlComplete, true);
    http.onreadystatechange = handleHttpResponse   // handle what to do with the
    http.send(null);
}

function executeServerScript(scriptUrl)
{
			///alert(scriptUrl);
    http.open("GET", scriptUrl, true);
    //http.onreadystatechange = handleHttpResponse   // handle what to do with the
    http.send(null);
}