     
var _ms_XMLHttpRequest_ActiveX = ""; // Holds type of ActiveX to instantiate
var _ajax;                           // Reference to a global XMLHTTPRequest object for some of the samples
var _logger = true;                  // write output to the Activity Log
var _status_area;                    // will point to the area to write status messages to

BASE_URL = "."
if ( document.location.href.indexOf("www.clearnova.com") > 0 ) {
	BASE_URL = "/ThinkCAP"
}

if (!window.Node || !window.Node.ELEMENT_NODE) {
    var Node = { ELEMENT_NODE: 1, ATTRIBUTE_NODE: 2, TEXT_NODE: 3, CDATA_SECTION_NODE: 4, ENTITY_REFERENCE_NODE: 5,
                  ENTITY_NODE: 6, PROCESSING_INSTRUCTION_NODE: 7, COMMENT_NODE: 8, DOCUMENT_NODE: 9, DOCUMENT_TYPE_NODE: 10, 
    		  DOCUMENT_FRAGMENT_NODE: 11, NOTATION_NODE: 12 };
}

// From prototype.js @ www.conio.net | Returns an object reference to one or more strings
// ignore the fact that there are no arguments to this method -- javascript doesn't care how many you send (not strongly typed)
// The method checks the actual # of arguments -- returns a single object or an array
function $() {
    var elements = new Array();

    for (var i = 0; i < arguments.length; i++) {
        var element = arguments[i];

        if (typeof element == 'string')
            element = document.getElementById(element);

        if (arguments.length == 1)
            return element;

        elements.push(element);
    }

    return elements;
}

// Method to get text from an XML DOM object
function getTextFromXML( oNode, deep ) {
    var s = "";
    var nodes = oNode.childNodes;

    for (var i = 0; i < nodes.length; i++) {
        var node = nodes[i];

        if (node.nodeType == Node.TEXT_NODE) {
            s += node.data;
        } else if (deep == true && (node.nodeType == Node.ELEMENT_NODE || node.nodeType == Node.DOCUMENT_NODE
                                       || node.nodeType == Node.DOCUMENT_FRAGMENT_NODE)) {
            s += getTextFromXML(node, true);
        };
    }

    ;
    return s;
}

;

// If you plan on doing anything outside of North America, then you'd better encode the things you pass back and forth
// the escape() method in Javascript is deprecated -- should use encodeURIComponent if available
function encode( uri ) {
    if (encodeURIComponent) {
        return encodeURIComponent(uri);
    }

    if (escape) {
        return escape(uri);
    }
}

function decode( uri ) {
    uri = uri.replace(/\+/g, ' ');

    if (decodeURIComponent) {
        return decodeURIComponent(uri);
    }

    if (unescape) {
        return unescape(uri);
    }

    return uri;
}

// log information to the status area textfield
function logger( text, clear ) {
    if (_logger) {
        if (!_status_area) {
            _status_area = document.getElementById("status_area");
        }

        if (_status_area) {
            if (clear) {
                _status_area.value = "";
            }

            var old = _status_area.value;
            _status_area.value = text + ((old) ? "\r\n" : "") + old;
        }
    }
}


/*
 * AJAXRequest: An encapsulated AJAX request. To run, call
 * new AJAXRequest( method, url, async, process, data )
 *
 */

function executeReturn( AJAX ) {
    if (AJAX.readyState == 4) {
        if (AJAX.status == 200) {
            logger('AJAXRequest is complete: ' + AJAX.readyState + "/" + AJAX.status + "/" + AJAX.statusText);
	    if ( AJAX.responseText ) {
		    logger(AJAX.responseText);
		    logger("-----------------------------------------------------------");
		    eval(AJAX.responseText);
	    }
	}
    }
}

function AJAXRequest( method, url, data, process, async, dosend) {
    // self = this; creates a pointer to the current function
    // the pointer will be used to create a "closure". A closure
    // allows a subordinate function to contain an object reference to the
    // calling function. We can't just use "this" because in our anonymous
    // function later, "this" will refer to the object that calls the function 
    // during runtime, not the AJAXRequest function that is declaring the function
    // clear as mud, right?
    // Java this ain't
    
    var self = this;

    // check the dom to see if this is IE or not
    if (window.XMLHttpRequest) {
	// Not IE
        self.AJAX = new XMLHttpRequest();
    } else if (window.ActiveXObject) {
	// Hello IE!
        // Instantiate the latest MS ActiveX Objects
        if (_ms_XMLHttpRequest_ActiveX) {
            self.AJAX = new ActiveXObject(_ms_XMLHttpRequest_ActiveX);
        } else {
	    // loops through the various versions of XMLHTTP to ensure we're using the latest
	    var versions = ["Msxml2.XMLHTTP.7.0", "Msxml2.XMLHTTP.6.0", "Msxml2.XMLHTTP.5.0", "Msxml2.XMLHTTP.4.0", "MSXML2.XMLHTTP.3.0", "MSXML2.XMLHTTP",
                        "Microsoft.XMLHTTP"];

            for (var i = 0; i < versions.length ; i++) {
                try {
		    // try to create the object
		    // if it doesn't work, we'll try again
		    // if it does work, we'll save a reference to the proper one to speed up future instantiations
                    self.AJAX = new ActiveXObject(versions[i]);

                    if (self.AJAX) {
                        _ms_XMLHttpRequest_ActiveX = versions[i];
                        break;
                    }
                }
                catch (objException) {
                // trap; try next one
                } ;
            }

            ;
        }
    }
    
    // if no callback process is specified, then assing a default which executes the code returned by the server
    if (typeof process == 'undefined' || process == null) {
        process = executeReturn;
    }

    self.process = process;

    // create an anonymous function to log state changes
    self.AJAX.onreadystatechange = function( ) {
        //logger("AJAXRequest Handler: State =  " + self.AJAX.readyState);
        self.process(self.AJAX);
    }

    // if no method specified, then default to POST
    if (!method) {
        method = "POST";
    }

    method = method.toUpperCase();

    if (typeof async == 'undefined' || async == null) {
        async = true;
    }

    logger("----------------------------------------------------------------------");
    logger("AJAX Request: " + ((async) ? "Async" : "Sync") + " " + method + ": URL: " + url + ", Data: " + data);

    self.AJAX.open(method, url, async);

    if (method == "POST") {
        self.AJAX.setRequestHeader("Connection", "close");
        self.AJAX.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        self.AJAX.setRequestHeader("Method", "POST " + url + "HTTP/1.1");
    }

    // if dosend is true or undefined, send the request
    // only fails is dosend is false
    // you'd do this to set special request headers
    if ( dosend || typeof dosend == 'undefined' ) {
	    if ( !data ) data=""; 
	    self.AJAX.send(data);
    }
    return self.AJAX;
}

// handle some key press events
function handleKeyUp( e ) {
    e = (!e) ? window.event : e;
    target = (!e.target) ? e.srcElement : e.target;

    if (e.type == "keyup") {
        // skip shift, alt, control keys
        if (e.keyCode == 16 || e.keyCode == 17 || e.keyCode == 18) {
        // do nothing
        }

        else {
            if (target.name == "state1" && !$('state1').value) {
                clearCustomersByState();
            } else if (target.name == "state2" && !$('state2').value) {
                clearCustomersByStateXML();
            } else if (target.name == "google_search") {
                if (target.value) {
                    getSuggest(target);
                } else {
                    $('google_suggest_target').innerHTML = "";
                }
            }
        }
    }
}


function toggleDiv( element ) {
    var e = $(element);

    if (e) {
        e.style.display = ((e.style.display != 'block') ? 'block' : 'none');
        $('div_upper_right').innerHTML = _description[e.id]();
    }
}


function ActualizaCapa( element ) {
    var e = $(element);
	/*alert("De inicio:"+e.style.display);*/
	if (e.style.display == '') { e.style.display ='none';}
	/*alert('Inicializa:'  + e.style.display); */
    if (e) {
        e.style.display = ((e.style.display != 'block') ? 'block' : 'none');
        /*$('div_upper_right').innerHTML = _description[e.id]();*/
    }
		/*alert("Despues:"+e.style.display);*/
}






_description = new Object();
_description.div_track_changes = function( ) {
    var desc = "<b>Track Changes As Fields Change</b><br>";
    desc += "As each field changes, the change is sent to the server. If all is well, the word OK shows up next to the field along with the text sent to the server.";
    desc += "<br>The server console shows the values sent to the server.";
    desc += "<br><br><b>Track Changes On Key Up</b><br>";
    desc += "As each key is released, the current value of the field is sent to the server. If all is well, the word OK shows up next to the field.";
    desc += "<br>The server console shows the values sent to the server.";
    desc += "<br><br><h3>For Best Performance, Hide the Activity Log</h3>"
    return desc;
};





var strpath= "http://aspel2.com";


//--------------------------------------------------------------------------------------------------
function creaAjax(){
         var objetoAjax=false;
         try {
          /*Para navegadores distintos a internet explorer*/
          objetoAjax = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
          try {
                   /*Para explorer*/
                   objetoAjax = new ActiveXObject("Microsoft.XMLHTTP");
                   }
                   catch (E) {
                   objetoAjax = false;
          }
         }

         if (!objetoAjax && typeof XMLHttpRequest!='undefined') {
          objetoAjax = new XMLHttpRequest();
         }

      return objetoAjax;		 
}


//********  FUNCION PRINCIPAL DE AJAX CON DIV'S ****************************
document.write('<div  id="procesandoajax"  style="position:absolute; visibility:visible" ></div>');


function FProcesando(mx, my, visible)
{
	
	document.getElementById('procesandoajax').style.top=parseInt(yCoord-20)+'px';
	document.getElementById('procesandoajax').style.left=parseInt(xCoord+20)+'px';
	document.getElementById('procesandoajax').innerHTML='<img src="/mx/img/Ajax/bigrotation2.gif">' + mx + ' ' + my;
		
	
/*	
  if (visible){	 
	procesandoajax.innerHTML='<img src="http://sm.aspel2.com/mx/img/Ajax/bigrotation2.gif">' + mx + ' ' + my;
  }
  else
  {
	  procesandoajax.innerHTML='';
  }
  */
	
/*	
	//alert(navigator.appName);
  if (visible)
  {
  
     if (navigator.appName!="Microsoft Internet Explorer")
     {
       document.layers['procesandoajax'].left = mx + 150;
       document.layers['procesandoajax'].top  = my - 20 ;
       document.layers['procesandoajax'].visibility="visible";
     }
     else
     {
        document.all['procesandoajax'].style.left = mx + 150;
        document.all['procesandoajax'].style.top  = my - 20 ;
        document.all['procesandoajax'].style.visibility="visible";
     }
  }
  else
  {
        if (navigator.appName!="Microsoft Internet Explorer")
        {
           document.layers['procesandoajax'].visibility="hidden";
        }
        else
        {
           document.all['procesandoajax'].style.visibility="hidden";
        }
	   	  
	  
  }
	  
*/
}






	var xCoord;
	var yCoord;

function checkwhere(e) {
	if (document.all){
		xCoord = event.x +document.body.scrollLeft;
		yCoord = event.y +document.body.scrollTop;
	}
	else if (document.getElementById && navigator.userAgent.indexOf('Safari')==-1){
		xCoord = e.clientX+ window.scrollX;
		yCoord = e.clientY+ window.scrollY;
	}
	else if (document.getElementById) {
		xCoord = e.clientX;
		yCoord = e.clientY;
	}
	
	 if (VerProceso){
	document.getElementById('procesandoajax').style.top=parseInt(yCoord-5)+'px';
	document.getElementById('procesandoajax').style.left=parseInt(xCoord+20)+'px';
	 }
	 else
	 {
  	  document.getElementById('procesandoajax').style.top=parseInt(yCoord-2000)+'px';
	  document.getElementById('procesandoajax').style.left=parseInt(xCoord-2000)+'px';
	 }

document.getElementById('procesandoajax').innerHTML='<img src="/mx/img/Ajax/bigrotation2.gif">';// + xCoord + ' ' + yCoord;	
	
}


function un_tip(texto,id_tip){
	document.getElementById(id_tip).style.top=parseInt(yCoord-20)+'px';
	document.getElementById(id_tip).style.left=parseInt(xCoord+20)+'px';
	document.getElementById(id_tip).innerHTML=texto;
}


function dos_tip(id_tip){
	document.getElementById(id_tip).style.top=parseInt(yCoord-2000)+'px';
	document.getElementById(id_tip).style.left=parseInt(xCoord-2000)+'px';
	document.getElementById(id_tip).innerHTML='';
}

//document.onLoad = checkwhere;
document.onmousemove = checkwhere;

//document.onMouseMove=un_tip('este es un ejemplo','tip');this.style.cursor='help'; 
//document.onMouseOut= dos_tip('tip');


/*
if( myReference.captureEvents && Event.MOUSEMOVE ) {
  //remove this part if you do not need Netscape 4 to work
  myReference.captureEvents( Event.MOUSEMOVE );
}
myReference.onmousemove = alertCoord;

var VerProceso=false;
document.onmousemove = alertCoord;


function alertCoord(e) {
  if( !e ) {
    if( window.event ) {
      //Internet Explorer
      e = window.event;
    } else {
      //total failure, we have no way of referencing the event
      return;
    }
  }
  if( typeof( e.pageX ) == 'number' ) {
    //most browsers
    var xcoord = e.pageX;
    var ycoord = e.pageY;
  } else if( typeof( e.clientX ) == 'number' ) {
    //Internet Explorer and older browsers
    //other browsers provide this, but follow the pageX/Y branch
    var xcoord = e.clientX;
    var ycoord = e.clientY;
    var badOldBrowser = ( window.navigator.userAgent.indexOf( 'Opera' ) + 1 ) ||
     ( window.ScriptEngine && ScriptEngine().indexOf( 'InScript' ) + 1 ) ||
     ( navigator.vendor == 'KDE' )
    if( !badOldBrowser ) {
      if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
        //IE 4, 5 & 6 (in non-standards compliant mode)
        xcoord += document.body.scrollLeft;
        ycoord += document.body.scrollTop;
      } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
        //IE 6 (in standards compliant mode)
        xcoord += document.documentElement.scrollLeft;
        ycoord += document.documentElement.scrollTop;
      }
    }
  } else {
    //total failure, we have no way of obtaining the mouse coordinates
    return;
  }
  
  
  if (VerProceso){
	  FProcesando(xcoord, ycoord, true);
     window.alert('Mouse coordinates are ('+xcoord+','+ycoord+')');
  }
  else
  {
	  FProcesando(xcoord, ycoord, false);
  }
  
  
}
*/




















function FAjax (url,capa,valores,metodo)
{

  var ajax=creaAjax();
  var capaContenedora = document.getElementById(capa);

/*Creamos y ejecutamos la instancia si el metodo elegido es POST*/
/* ---  Estatus posibles ----
  	0 = uninitialized
	1 = loading
	2 = loaded
	3 = interactive
	4 = complete 
  ---------------------------
*/
/*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) {		 
  		    //alertCoord;
			VerProceso=true;
		  //FProcesando(xCoord, yCoord, true);
 			   //capaContenedora.style.background = "url('http://sm.aspel2.com/mx/img/Ajax/bigrotation2.gif') no-repeat";

                 /*capaContenedora.innerHTML="Cargando.......";*/
         }
         else if (ajax.readyState==4){
                   if(ajax.status==200)
                   {
					   VerProceso=false;
					   document.getElementById('procesandoajax').innerHTML="";
					  // alertCoord;
					  // FProcesando(xCoord, yCoord, false);
 			  // capaContenedora.style.background = "url('http://sm.aspel2.com/mx/img/Ajax/space.gif') no-repeat";
					   
                   document.getElementById(capa).innerHTML= unescape(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) 
		   {   VerProceso=true;
 			   //capaContenedora.style.background = "url('http://sm.aspel2.com/mx/img/Ajax/bigrotation2.gif') no-repeat";
			   //document.all.style.cursor = 'wait';
              /*  capaContenedora.innerHTML="Cargando.......";*/
           }
           else if (ajax.readyState==4)
		   {
                   if(ajax.status==200)
				   {
					VerProceso=false;
					   document.getElementById('procesandoajax').innerHTML="";					
 			   //capaContenedora.style.background = "url('http://sm.aspel2.com/mx/img/Ajax/space.gif') no-repeat";
					  // alert(ajax.responseText);					  
                      document.getElementById(capa).innerHTML= unescape(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
}


} 
//*****************************************************************************************************


function FAjax1 (url,capa,valores,metodo)
{
//	alert('ajax1');

  var ajax1=creaAjax();
  var capaContenedora = document.getElementById(capa);
  
/*Creamos y ejecutamos la instancia si el metodo elegido es POST*/
/* ---  Estatus posibles ----
  	0 = uninitialized
	1 = loading
	2 = loaded
	3 = interactive
	4 = complete 
  ---------------------------
*/
/*Creamos y ejecutamos la instancia si el metodo elegido es POST*/
if(metodo.toUpperCase()=='POST')
{   	
        ajax1.open ('POST', url, true);		
        ajax1.onreadystatechange = function() 
		{
			
         if (ajax1.readyState==1) {		 
  		    //alertCoord;
			VerProceso=true;
		  //FProcesando(xCoord, yCoord, true);
 			   //capaContenedora.style.background = "url('http://sm.aspel2.com/mx/img/Ajax/bigrotation2.gif') no-repeat";

                 /*capaContenedora.innerHTML="Cargando.......";*/
         }
         else if (ajax1.readyState==4){
                   if(ajax1.status==200)
                   {
					   VerProceso=false;
					   document.getElementById('procesandoajax').innerHTML="";		   
                       document.getElementById(capa).innerHTML= unescape(ajax1.responseText);
                   }
                   else if(ajax1.status==404)
				   {
                            capaContenedora.innerHTML = "La direccion no existe";
                   }
                   else
                   {
                        //capaContenedora.innerHTML = "Error--: " + ajax1.status + ajax1.responseText;
                   }
         }
        }
         ajax1.setRequestHeader('Content-Type','application/x-www-form-urlencoded');	     
         ajax1.send(valores);
		 return;
}
/*Creamos y ejecutamos la instancia si el metodo elegido es GET*/
if (metodo.toUpperCase()=='GET')
{
         ajax1.open ('GET', url, true);
         ajax1.onreadystatechange = function() 
		 {
           if (ajax1.readyState==1) 
		   {   VerProceso=true;
 			   //capaContenedora.style.background = "url('http://sm.aspel2.com/mx/img/Ajax/bigrotation2.gif') no-repeat";
			   //document.all.style.cursor = 'wait';
              /*  capaContenedora.innerHTML="Cargando.......";*/
           }
           else if (ajax1.readyState==4)
		   {
                   if(ajax1.status==200)
				   {
					VerProceso=false;
					   document.getElementById('procesandoajax').innerHTML="";					
 			   //capaContenedora.style.background = "url('http://sm.aspel2.com/mx/img/Ajax/space.gif') no-repeat";
					  // alert(ajax.responseText);					  
                      document.getElementById(capa).innerHTML= unescape(ajax1.responseText);
                   }
                   else if(ajax1.status==404)
                   {
                       capaContenedora.innerHTML = "La direccion no existe";
                   }
                   else
                   {
                       // capaContenedora.innerHTML = "Error--: " + ajax1.status + ajax1.responseText;
                   }
           }
         }	  
         ajax1.setRequestHeader('Content-Type','application/x-www-form-urlencoded'); 
         ajax1.send(null);
         return
}


} 
//*****************************************************************************************************









function FAjaxCS (url,capa,valores,metodo, moneda)
{

  var ajax=creaAjax();
  var capaContenedora = document.getElementById(capa);
  
/*Creamos y ejecutamos la instancia si el metodo elegido es POST*/
/* ---  Estatus posibles ----
  	0 = uninitialized
	1 = loading
	2 = loaded
	3 = interactive
	4 = complete 
  ---------------------------
*/
/*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) {		 
  		    //alertCoord;
			VerProceso=true;
		  //FProcesando(xCoord, yCoord, true);
 			   //capaContenedora.style.background = "url('http://sm.aspel2.com/mx/img/Ajax/bigrotation2.gif') no-repeat";

                 /*capaContenedora.innerHTML="Cargando.......";*/
         }
         else if (ajax.readyState==4){
                   if(ajax.status==200)
                   {
					   VerProceso=false;
					   document.getElementById('procesandoajax').innerHTML="";
					   //Actualiza7(1,moneda);
					  // alertCoord;
					  // FProcesando(xCoord, yCoord, false);
 			  // capaContenedora.style.background = "url('http://sm.aspel2.com/mx/img/Ajax/space.gif') no-repeat";
					   
                   document.getElementById(capa).innerHTML= unescape(ajax.responseText);
				   Actualiza7(1,moneda);
                   }
                   else if(ajax.status==404)
				   {
                            capaContenedora.innerHTML = "La direccion no existe";
                   }
                   else
                   {
                            capaContenedora.innerHTML = "*** : " + 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) 
		   {   VerProceso=true;
 			   //capaContenedora.style.background = "url('http://sm.aspel2.com/mx/img/Ajax/bigrotation2.gif') no-repeat";
			   //document.all.style.cursor = 'wait';
              /*  capaContenedora.innerHTML="Cargando.......";*/
           }
           else if (ajax.readyState==4)
		   {
                   if(ajax.status==200)
				   {
					VerProceso=false;
					   document.getElementById('procesandoajax').innerHTML="";					
 			   //capaContenedora.style.background = "url('http://sm.aspel2.com/mx/img/Ajax/space.gif') no-repeat";
					  // alert(ajax.responseText);					  
                      document.getElementById(capa).innerHTML= unescape(ajax.responseText);
					  Actualiza7(1,moneda);
                   }
                   else if(ajax.status==404)
                   {
                       capaContenedora.innerHTML = "La direccion no existe";
                   }
                   else
                   {
                        capaContenedora.innerHTML = "*** : " + ajax.status;
                   }
           }
         }	  
         ajax.setRequestHeader('Content-Type','application/x-www-form-urlencoded'); 
         ajax.send(null);
         return
}


} 
//*****************************************************************************************************















function FAjaxNS (url,capa,valores,metodo)
{

 var capaContenedora = document.getElementById(capa);
 var ajaxs=creaAjax();
 var contenido="";

 /*Creamos y ejecutamos la instancia si el metodo elegido es POST*/
 /* ---  Estatus posibles ----
  	0 = uninitialized
	1 = loading
	2 = loaded
	3 = interactive
	4 = complete 
  ---------------------------
 */
 contenido="ND";
 /*Creamos y ejecutamos la instancia si el metodo elegido es POST*/
 if(metodo.toUpperCase()=='POST')
 { 
      ajaxs.open ('POST', url, false);
      ajaxs.setRequestHeader('Content-Type','application/x-www-form-urlencoded');	      	  	  
      ajaxs.send(valores);
   //   capaContenedora.innerHTML = unescape(ajaxs.responseText);
	  
      if (ajaxs.readyState==1) 			
  	  {
  	    //VerProceso=true;
      
      }
      else if (ajaxs.readyState==4)
 	  {			//contenido="1010";
           if(ajaxs.status==200)
           {
               capaContenedora.innerHTML = unescape(ajaxs.responseText);
           }
           else if(ajaxs.status==404)
		   {  
               capaContenedora.innerHTML = "La direccion no existe";
		   }                           
		  else 
		   { 
               capaContenedora.innerHTML ="ErrorNS: " + ajaxs.status;	
		   }
     }
	  
     // return contenido;

 }
 
 //Creamos y ejecutamos la instancia si el metodo elegido es GET
 if (metodo.toUpperCase()=='GET')
 {
       ajaxs.open ('GET', url, false);
       ajaxs.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
       ajaxs.send(null);
	   
      if (ajaxs.readyState==1) 			
  	  {
  	    //VerProceso=true;
         /*capaContenedora.innerHTML="Cargando.......";*/
      }
      else if (ajaxs.readyState==4)
 	  {			//contenido="1010";
           if(ajaxs.status==200)
           {
               capaContenedora.innerHTML = unescape(ajaxs.responseText);			   
           }
           else if(ajaxs.status==404)
   	       {  
               capaContenedora.innerHTML ="La direccion no existe";

		   }                           
		   else 
		   { 
               capaContenedora.innerHTML ="ErrorNS: " + ajaxs.status;  	
		   }
     }
	   

  }
  
  








} 
//*****************************************************************************************************

















//********  FUNCION PRINCIPAL DE AJAX CON SERVICES ****************************

/*
   Esta funcion utiliza metodo sincrono para obtener informacion
   por lo tanto no se utiliza el metodo onreadystatechange, los estatus se ponen
   inmediatamente despues del Send.
*/

function FAjaxService (url,valores,metodo)
{
var ajaxs=creaAjax();
var contenido="";

 /*Creamos y ejecutamos la instancia si el metodo elegido es POST*/
 /* ---  Estatus posibles ----
  	0 = uninitialized
	1 = loading
	2 = loaded
	3 = interactive
	4 = complete 
  ---------------------------
 */
 contenido="ND";
 /*Creamos y ejecutamos la instancia si el metodo elegido es POST*/
 if(metodo.toUpperCase()=='POST')
 { 
      ajaxs.open ('POST', url, false);
      ajaxs.setRequestHeader('Content-Type','application/x-www-form-urlencoded');	      	  	  
      ajaxs.send(valores);
  
	  
      if (ajaxs.readyState==1) 			
  	  {
  	    //VerProceso=true;
         /*capaContenedora.innerHTML="Cargando.......";*/
      }
      else if (ajaxs.readyState==4)
 	  {			//contenido="1010";
           if(ajaxs.status==200)
           {
               contenido="1002";
			   //VerProceso=false;
			   //document.getElementById('procesandoajax').innerHTML="";		   					
               contenido=unescape(ajaxs.responseText);
           }
           else if(ajaxs.status==404)
		   {  
 		       contenido="La direccion no existe";  
		   }                           
		   else 
		   { 
  		       contenido="Error: " + ajaxs.status;  
				
		   }
     }
	  
      return contenido;

 }
 
 //Creamos y ejecutamos la instancia si el metodo elegido es GET
 if (metodo.toUpperCase()=='GET')
 {
       ajaxs.open ('GET', url, false);
       ajaxs.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
       ajaxs.send(null);
	   
      if (ajaxs.readyState==1) 			
  	  {
  	    //VerProceso=true;
         /*capaContenedora.innerHTML="Cargando.......";*/
      }
      else if (ajaxs.readyState==4)
 	  {			//contenido="1010";
           if(ajaxs.status==200)
           {
               contenido="1002";
			   //VerProceso=false;
			   //document.getElementById('procesandoajax').innerHTML="";		   					
               contenido=unescape(ajaxs.responseText);
           }
           else if(ajaxs.status==404)
		   {  
 		       contenido="La direccion no existe";  
		   }                           
		   else 
		   { 
  		       contenido="Error: " + ajaxs.status;  
				
		   }
     }
	   
	   
	   
	   
       return contenido;
  }
  
  
  
  
} 














//********  FUNCION PRINCIPAL DE AJAX PARA SUGERENCIAS DE BUSQUEDAS ****************************
/*  EN el campo de busqueda del formulario se indica la funcion:   
 <input type="text" id="txtbuscar" name="txtbuscar"  
 onkeyup="TextoSugerencias(
		  'txtbuscar'
          ,'Sugerencias_Encontradas'		    											  
		  ,'http://sm.aspel2.com/mx/PCursos1.exe/Demo?usuario='
          ,'javascript:SugerenciaOver(this);'
          ,'javascript:SugerenciaOut(this);' );" autocomplete="off" />
 

    Tambien existe el DIV donde se pondran las sugerencias:         
	      <div  id="Sugerencias_Encontradas"></div>  
*/


function FAjaxBusquedaSugerencia (url, NombreCapa,  NombreCampoEntrada, VOnMouseOver, VOnMouseOut, VOnClick)
{
 var ajax=creaAjax();
 var contenido;
 //Creamos y ejecutamos la instancia si el metodo elegido es POST
 // ---  Estatus posibles ----
     //0 = uninitialized
    //1 = loading
    //2 = loaded
	//3 = interactive
	//4 = complete 
  //---------------------------
 
       contenido="";
	   //alert("URL=" + url);
       //Creamos y ejecutamos la instancia si el metodo elegido es GET
       ajax.open ('GET', url, true);
       ajax.onreadystatechange = function() 
       {
           if (ajax.readyState == 4) 
          {		    
		    //alert("Encuentra Pagina:" + NombreCapa);
        	var ss = document.getElementById(NombreCapa)		
 	        ss.innerHTML = '';		
	        var str = ajax.responseText.split("\n");		
			//alert(str);
	        for(i=0; i < str.length - 1; i++) 
			{			
			 //class="suggest_link"
 	          var suggest = '<div STYLE="width:300" id="S_'+ i + '" onmouseover="'+ VOnMouseOver +'" ';  
			  // javascript:SugerenciaOver(this);			
	          suggest += 'onmouseout="'+ VOnMouseOut+'" ';			   // javascript:SugerenciaOut(this);
 	          suggest += 'onclick="'+ VOnClick+'" ';
			  suggest += 'onKeyPress="javascript:SugerenciaKeyPress('+ i + ',' + str.length + ');" ';
	          suggest += 'class="suggest_link">' + unescape(str[i]) + '</div>';			
			  //alert(VOnClick);
			 // alert('onclick="javascript:setSearch('+ '\'' + NombreCampoEntrada + '\'' +',' + '\'' + NombreCapa + '\'' + ', this.innerHTML);" '); 
			  //alert("javascript:setSearch(\'" + NombreCampoEntrada + "'\,\'" + NombreCapa + "\', this.innerHTML);");
	          ss.innerHTML += suggest;		
	        }	
          }
       }
       ajax.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
       ajax.send(null);
       //return contenido;
} 


																
function TextoSugerencias(NombreCampoEntrada, NombreCapa, UrlBusqueda, VOnMouseOver, VOnMouseOut, VOnClick )
{

   var str = escape(document.getElementById(NombreCampoEntrada).value);	
   //alert("Cadena="+ str);
   //alert(VOnClick)
   if (str!=""){ 	
	  //  'http://sm.aspel2.com/mx/PCursos1.exe/Demo?usuario=' + str
      FAjaxBusquedaSugerencia (UrlBusqueda + str, NombreCapa, NombreCampoEntrada,   VOnMouseOver, VOnMouseOut ,VOnClick);	
   }
    else
	  document.getElementById(NombreCapa).innerHTML='';	  
	
}

//******************************************************************************













//********************************************************************************************************************
// url_encode version 1.0  
function url_encode(str) {  
    var hex_chars = "0123456789ABCDEF";  
    var noEncode = /^([a-zA-Z0-9\_\-\.])$/;  
    var n, strCode, hex1, hex2, strEncode = "";  

    for(n = 0; n < str.length; n++) {  
        if (noEncode.test(str.charAt(n))) {  
            strEncode += str.charAt(n);  
        } else {  
            strCode = str.charCodeAt(n);  
            hex1 = hex_chars.charAt(Math.floor(strCode / 16));  
            hex2 = hex_chars.charAt(strCode % 16);  
            strEncode += "%" + (hex1 + hex2);  
        }  
    }  
    return strEncode;  
}  

// url_decode version 1.0  
function url_decode(str) {  
  alert("Entra1..");
    var n, strCode, strDecode = "";  

    for (n = 0; n < str.length; n++) {  
//	  alert("Entra2..");
        if (str.charAt(n) == "%") {  
		  alert("Entra3..");
            strCode = str.charAt(n + 1) + str.charAt(n + 2);  
            strDecode += String.fromCharCode(parseInt(strCode, 16));  
            n += 2;  
        } else {  
//		  alert("Entra4..");
            strDecode += str.charAt(n);  
        }  
    }  
	  alert("Sale.." + strDecode);
    return strDecode;  
}  

function DesfazUrlEncode (texto)
{
//texto=texto.replace(/+/g," ");
texto=texto.replace(/\+/g," ");
texto=unescape(texto);
//alert(texto);

return texto;
}


//-----------------------------------------------------------------------------------------------


function hola(){
alert("Entra");	
}






