// Some examples of using FireUnit
if ( typeof fireunit === "object" ) {
	// Simple true-like/false-like testing
//	fireunit.ok( true, "I'm going to pass!" );
//	fireunit.ok( false, "I'm going to fail!" );

	// Compare two strings - shows a diff of the
	// results if they're different
	fireunit.compare(
		"The lazy fox jumped over the log.",
		"The lazy brown fox jumped the log.",
		"Are these two strings the same?"
	);

	// Compare a string using a regular expression
	fireunit.reCompare(
		"The .* fox jumped the log.",
		"The lazy brown fox jumped the log.",
		"Compare a string using a RegExp."
	);

	// Display the total results
//	fireunit.testDone();
}

var UniqueID = 314; // Make each link open in a new window 
var newWinOffset = 0; // Position of first pop-up
var salir_pausa = 0; // Position of first pop-up

ajax_noticias=0;



var esperar="espera";
var espera_imagen="loading.gif";

var secs;
var timerID = null;
var timerRunning = true;
var delay = 50000;

self.status = secs;
secs = secs - 1;
timerRunning = true;
timerID = self.setTimeout("Actualizar()", delay);

var isRichText = false;
var rng;
var currentRTE;
var allRTEs = "";

var isIE;
var isGecko;
var isSafari;
var isKonqueror;

var imagesPath;
var includesPath;
var cssFile;

var language;

var DH = 0;
var an = 0;
var al = 0;
var ai = 0;
if ($) {
	ai = 1; DH = 1;
}else {
	if (document.all) {
		al = 1; DH = 1;
	}else{
		browserVersion = parseInt(navigator.appVersion);
		if ((navigator.appName.indexOf('Netscape') != -1) && (browserVersion == 4)) {
			an = 1; DH = 1;
		}
	}
} 

function clollapseText(len,campo)
{
	var p = $(campo);
	if (p) 
	{
		
		var trunc = p.innerHTML;
		if (trunc.length > len) {
		trunc = trunc.substring(0, len);
		trunc += '<a href="#" ' +
		'onclick="this.parentNode.innerHTML=' +
		'unescape(\''+escape(p.innerHTML)+'\');return false;">' +
		'...<\/a>';
		p.innerHTML = trunc;
	  }
	}
}

function espera(estado)
{
	oEspera=$(esperar);
	if(estado==0)
	{
		oEspera.update('');
	}else{
		oEspera.update('<img src="images/wait.gif" alt="">');
	}
}





//** Tab Content script-  Dynamic Drive DHTML code library (http://www.dynamicdrive.com)
//** Last updated: Nov 8th, 06

var enabletabpersistence=1 //enable tab persistence via session only cookies, so selected tab is remembered?

////NO NEED TO EDIT BELOW////////////////////////
var tabcontentIDs=new Object()

function expandcontent(linkobj){
var ulid=linkobj.parentNode.parentNode.id //id of UL element
var ullist=$(ulid).getElementsByTagName("li") //get list of LIs corresponding to the tab contents
for (var i=0; i<ullist.length; i++){
ullist[i].className=""  //deselect all tabs
if (typeof tabcontentIDs[ulid][i]!="undefined") //if tab content within this array index exists (exception: More tabs than there are tab contents)
$(tabcontentIDs[ulid][i]).style.display="none" //hide all tab contents
}
linkobj.parentNode.className="selected"  //highlight currently clicked on tab
$(linkobj.getAttribute("rel")).style.display="block" //expand corresponding tab content
saveselectedtabcontentid(ulid, linkobj.getAttribute("rel"))
}

function expandtab(tabcontentid, tabnumber){ //interface for selecting a tab (plus expand corresponding content)
var thetab=$(tabcontentid).getElementsByTagName("a")[tabnumber]
if (thetab.getAttribute("rel"))
expandcontent(thetab)
}

function savetabcontentids(ulid, relattribute){// save ids of tab content divs
if (typeof tabcontentIDs[ulid]=="undefined") //if this array doesn't exist yet
tabcontentIDs[ulid]=new Array()
tabcontentIDs[ulid][tabcontentIDs[ulid].length]=relattribute
}

function saveselectedtabcontentid(ulid, selectedtabid){ //set id of clicked on tab as selected tab id & enter into cookie
if (enabletabpersistence==1) //if persistence feature turned on
setCookie(ulid, selectedtabid)
}

function getullistlinkbyId(ulid, tabcontentid){ //returns a tab link based on the ID of the associated tab content
var ullist=$(ulid).getElementsByTagName("li")
for (var i=0; i<ullist.length; i++){
if (ullist[i].getElementsByTagName("a")[0].getAttribute("rel")==tabcontentid){
return ullist[i].getElementsByTagName("a")[0]
break
}
}
}

function initializetabcontent(){
	for (var i=0; i<arguments.length; i++)
	{ //loop through passed UL ids
		if (enabletabpersistence==0 && getCookie(arguments[i])!="") //clean up cookie if persist=off
			setCookie(arguments[i], "")
		
		var clickedontab=getCookie(arguments[i]) //retrieve ID of last clicked on tab from cookie, if any
		var ulobj=$(arguments[i])
		var ulist=ulobj.getElementsByTagName("li") //array containing the LI elements within UL
		
		for (var x=0; x<ulist.length; x++){ //loop through each LI element
			var ulistlink=ulist[x].getElementsByTagName("a")[0]
			if (ulistlink.getAttribute("rel")){
			savetabcontentids(arguments[i], ulistlink.getAttribute("rel")) //save id of each tab content as loop runs
			ulistlink.onclick=function(){
			expandcontent(this)
			return false
			}

			if (ulist[x].className=="selected" && clickedontab=="") //if a tab is set to be selected by default
			expandcontent(ulistlink) //auto load currenly selected tab content
			}
		} //end inner for loop
		if (clickedontab!=""){ //if a tab has been previously clicked on per the cookie value
		var culistlink=getullistlinkbyId(arguments[i], clickedontab)
		if (typeof culistlink!="undefined") //if match found between tabcontent id and rel attribute value
		expandcontent(culistlink) //auto load currenly selected tab content
		else //else if no match found between tabcontent id and rel attribute value (cookie mis-association)
		expandcontent(ulist[0].getElementsByTagName("a")[0]) //just auto load first tab instead
		}
	} //end outer for loop
}


function getCookie(Name){ 
var re=new RegExp(Name+"=[^;]+", "i"); //construct RE to search for target name/value pair
if (document.cookie.match(re)) //if cookie found
return document.cookie.match(re)[0].split("=")[1] //return its value
return ""
}

function setCookie(name, value){
document.cookie = name+"="+value //cookie value is domain wide (path=/)
}


///////////////////AJAX////////////////


var updateInterval = 1000; // how many miliseconds to wait to get new message
var debugMode = true;

/******Buscar Noticias******/
function buscar(aBuscar){
	tomarContenido(100,-1,-1,aBuscar,"contenido")
	return;
}

function Actualizar(){
	clearTimeout(timerID);
	try{
		var ov=$("clima").name;
		tomarAutomatico(951,0,0,0);
		timerID = self.setTimeout("Actualizar()", delay);
	}
	catch(e)
	{
		//nada
		var z=false;
	}
	
	
}
 function HTMLentities(texte) {
if (typeof texte == "undefined") { return ''};
texte = texte.replace(/"/g,'&quot;'); // 34 22
texte = texte.replace(/&/g,'&amp;'); // 38 26
texte = texte.replace(/\'/g,'&#39;'); // 39 27
texte = texte.replace(/</g,'&lt;'); // 60 3C
texte = texte.replace(/>/g,'&gt;'); // 62 3E
texte = texte.replace(/\^/g,'&circ;'); // 94 5E
texte = texte.replace(//g,'&lsquo;'); // 145 91
texte = texte.replace(//g,'&rsquo;'); // 146 92
texte = texte.replace(//g,'&quot;'); // 147 93
texte = texte.replace(//g,'&quot;'); // 148 94
texte = texte.replace(//g,'&bull;'); // 149 95
texte = texte.replace(//g,'&ndash;'); // 150 96
texte = texte.replace(//g,'&mdash;'); // 151 97
texte = texte.replace(//g,'&tilde;'); // 152 98
texte = texte.replace(//g,'&trade;'); // 153 99
texte = texte.replace(//g,'&scaron;'); // 154 9A
texte = texte.replace(//g,'&rsaquo;'); // 155 9B
texte = texte.replace(//g,'&oelig;'); // 156 9C
texte = texte.replace(//g,'&#357;'); // 157 9D
texte = texte.replace(//g,'&#382;'); // 158 9E
texte = texte.replace(//g,'&Yuml;'); // 159 9F
// texte = texte.replace(/ /g,'&nbsp;'); // 160 A0
texte = texte.replace(//g,'&iexcl;'); // 161 A1
texte = texte.replace(//g,'&cent;'); // 162 A2
texte = texte.replace(//g,'&pound;'); // 163 A3
//texte = texte.replace(/ /g,'&curren;'); // 164 A4
texte = texte.replace(//g,'&yen;'); // 165 A5
texte = texte.replace(//g,'&brvbar;'); // 166 A6
texte = texte.replace(//g,'&sect;'); // 167 A7
texte = texte.replace(//g,'&uml;'); // 168 A8
texte = texte.replace(//g,'&copy;'); // 169 A9
texte = texte.replace(//g,'&ordf;'); // 170 AA
texte = texte.replace(//g,'&laquo;'); // 171 AB
texte = texte.replace(//g,'&not;'); // 172 AC
texte = texte.replace(//g,'&shy;'); // 173 AD
texte = texte.replace(//g,'&reg;'); // 174 AE
texte = texte.replace(//g,'&macr;'); // 175 AF
texte = texte.replace(//g,'&deg;'); // 176 B0
texte = texte.replace(//g,'&plusmn;'); // 177 B1
texte = texte.replace(//g,'&sup2;'); // 178 B2
texte = texte.replace(//g,'&sup3;'); // 179 B3
texte = texte.replace(//g,'&acute;'); // 180 B4
texte = texte.replace(//g,'&micro;'); // 181 B5
texte = texte.replace(//g,'&para'); // 182 B6
texte = texte.replace(//g,'&middot;'); // 183 B7
texte = texte.replace(//g,'&cedil;'); // 184 B8
texte = texte.replace(//g,'&sup1;'); // 185 B9
texte = texte.replace(//g,'&ordm;'); // 186 BA
texte = texte.replace(//g,'&raquo;'); // 187 BB
texte = texte.replace(//g,'&frac14;'); // 188 BC
texte = texte.replace(//g,'&frac12;'); // 189 BD
texte = texte.replace(//g,'&frac34;'); // 190 BE
texte = texte.replace(//g,'&iquest;'); // 191 BF
texte = texte.replace(//g,'&Agrave;'); // 192 C0
texte = texte.replace(//g,'&Aacute;'); // 193 C1
texte = texte.replace(//g,'&Acirc;'); // 194 C2
texte = texte.replace(//g,'&Atilde;'); // 195 C3
texte = texte.replace(//g,'&Auml;'); // 196 C4
texte = texte.replace(//g,'&Aring;'); // 197 C5
texte = texte.replace(//g,'&AElig;'); // 198 C6
texte = texte.replace(//g,'&Ccedil;'); // 199 C7
texte = texte.replace(//g,'&Egrave;'); // 200 C8
texte = texte.replace(//g,'&Eacute;'); // 201 C9
texte = texte.replace(//g,'&Ecirc;'); // 202 CA
texte = texte.replace(//g,'&Euml;'); // 203 CB
texte = texte.replace(//g,'&Igrave;'); // 204 CC
texte = texte.replace(//g,'&Iacute;'); // 205 CD
texte = texte.replace(//g,'&Icirc;'); // 206 CE
texte = texte.replace(//g,'&Iuml;'); // 207 CF
texte = texte.replace(//g,'&ETH;'); // 208 D0
texte = texte.replace(//g,'&Ntilde;'); // 209 D1
texte = texte.replace(//g,'&Ograve;'); // 210 D2
texte = texte.replace(//g,'&Oacute;'); // 211 D3
texte = texte.replace(//g,'&Ocirc;'); // 212 D4
texte = texte.replace(//g,'&Otilde;'); // 213 D5
texte = texte.replace(//g,'&Ouml;'); // 214 D6
texte = texte.replace(//g,'&times;'); // 215 D7
texte = texte.replace(//g,'&Oslash;'); // 216 D8
texte = texte.replace(//g,'&Ugrave;'); // 217 D9
texte = texte.replace(//g,'&Uacute;'); // 218 DA
texte = texte.replace(//g,'&Ucirc;'); // 219 DB
texte = texte.replace(//g,'&Uuml;'); // 220 DC
texte = texte.replace(//g,'&Yacute;'); // 221 DD
texte = texte.replace(//g,'&THORN;'); // 222 DE
texte = texte.replace(//g,'&szlig;'); // 223 DF
texte = texte.replace(//g,'&aacute;'); // 224 E0
texte = texte.replace(//g,'&aacute;'); // 225 E1
texte = texte.replace(//g,'&acirc;'); // 226 E2
texte = texte.replace(//g,'&atilde;'); // 227 E3
texte = texte.replace(//g,'&auml;'); // 228 E4
texte = texte.replace(//g,'&aring;'); // 229 E5
texte = texte.replace(//g,'&aelig;'); // 230 E6
texte = texte.replace(//g,'&ccedil;'); // 231 E7
texte = texte.replace(//g,'&egrave;'); // 232 E8
texte = texte.replace(//g,'&eacute;'); // 233 E9
texte = texte.replace(//g,'&ecirc;'); // 234 EA
texte = texte.replace(//g,'&euml;'); // 235 EB
texte = texte.replace(//g,'&igrave;'); // 236 EC
texte = texte.replace(//g,'&iacute;'); // 237 ED
texte = texte.replace(//g,'&icirc;'); // 238 EE
texte = texte.replace(//g,'&iuml;'); // 239 EF
texte = texte.replace(//g,'&eth;'); // 240 F0
texte = texte.replace(//g,'&ntilde;'); // 241 F1
texte = texte.replace(//g,'&ograve;'); // 242 F2
texte = texte.replace(//g,'&oacute;'); // 243 F3
texte = texte.replace(//g,'&ocirc;'); // 244 F4
texte = texte.replace(//g,'&otilde;'); // 245 F5
texte = texte.replace(//g,'&ouml;'); // 246 F6
texte = texte.replace(//g,'&divide;'); // 247 F7
texte = texte.replace(//g,'&oslash;'); // 248 F8
texte = texte.replace(//g,'&ugrave;'); // 249 F9
texte = texte.replace(//g,'&uacute;'); // 250 FA
texte = texte.replace(//g,'&ucirc;'); // 251 FB
texte = texte.replace(//g,'&uuml;'); // 252 FC
texte = texte.replace(//g,'&yacute;'); // 253 FD
texte = texte.replace(//g,'&thorn;'); // 254 FE
texte = texte.replace(//g,'&yuml;'); // 255 FF
return texte;
}


/**
*
* Base64 encode / decode
* http://www.webtoolkit.info/
*
**/

var Base64 = {

    // private property
    _keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",

    // public method for encoding
    encode : function (input) {
        var output = "";
        var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
        var i = 0;

        input = Base64._utf8_encode(input);

        while (i < input.length) {

            chr1 = input.charCodeAt(i++);
            chr2 = input.charCodeAt(i++);
            chr3 = input.charCodeAt(i++);

            enc1 = chr1 >> 2;
            enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
            enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
            enc4 = chr3 & 63;

            if (isNaN(chr2)) {
                enc3 = enc4 = 64;
            } else if (isNaN(chr3)) {
                enc4 = 64;
            }

            output = output +
            this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) +
            this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4);

        }

        return output;
    },

    // public method for decoding
    decode : function (input) {
        var output = "";
        var chr1, chr2, chr3;
        var enc1, enc2, enc3, enc4;
        var i = 0;

        input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");

        while (i < input.length) {

            enc1 = this._keyStr.indexOf(input.charAt(i++));
            enc2 = this._keyStr.indexOf(input.charAt(i++));
            enc3 = this._keyStr.indexOf(input.charAt(i++));
            enc4 = this._keyStr.indexOf(input.charAt(i++));

            chr1 = (enc1 << 2) | (enc2 >> 4);
            chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
            chr3 = ((enc3 & 3) << 6) | enc4;

            output = output + String.fromCharCode(chr1);

            if (enc3 != 64) {
                output = output + String.fromCharCode(chr2);
            }
            if (enc4 != 64) {
                output = output + String.fromCharCode(chr3);
            }

        }

        output = Base64._utf8_decode(output);

        return output;

    },

    // private method for UTF-8 encoding
    _utf8_encode : function (string) {
        string = string.replace(/\r\n/g,"\n");
        var utftext = "";

        for (var n = 0; n < string.length; n++) {

            var c = string.charCodeAt(n);

            if (c < 128) {
                utftext += String.fromCharCode(c);
            }
            else if((c > 127) && (c < 2048)) {
                utftext += String.fromCharCode((c >> 6) | 192);
                utftext += String.fromCharCode((c & 63) | 128);
            }
            else {
                utftext += String.fromCharCode((c >> 12) | 224);
                utftext += String.fromCharCode(((c >> 6) & 63) | 128);
                utftext += String.fromCharCode((c & 63) | 128);
            }

        }

        return utftext;
    },

    // private method for UTF-8 decoding
    _utf8_decode : function (utftext) {
        var string = "";
        var i = 0;
        var c = c1 = c2 = 0;

        while ( i < utftext.length ) {

            c = utftext.charCodeAt(i);

            if (c < 128) {
                string += String.fromCharCode(c);
                i++;
            }
            else if((c > 191) && (c < 224)) {
                c2 = utftext.charCodeAt(i+1);
                string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
                i += 2;
            }
            else {
                c2 = utftext.charCodeAt(i+1);
                c3 = utftext.charCodeAt(i+2);
                string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
                i += 3;
            }

        }

        return string;
    }

}


function loginFormulario(formulario){
	
		var count = formulario.elements.length
		var datos="";
		for(i=0; i<count; i++)
		{
			inputValue = formulario.elements[i].value;
			fieldID = formulario.elements[i].id;
			inputValue = encodeURIComponent(inputValue);
			fieldID = encodeURIComponent(fieldID);
			datos+= "" + fieldID + "=" + inputValue  + "&"; //+fieldID+"_fieldID=" + fieldID+"";
		}
		datos+=""+formulario.id+"_formdID="+formulario.id;
		
   return datos;
}

function login(formulario)
{
	var cache = new Array();
	try
	{
		if(formulario=="Logout")
		{
			cache.push("logout=1");
		}else{
			cache.push(loginFormulario(formulario));
		}
	}
	
	catch(e)
	{
		alert("Error "+e.number+":"+e.message+" - Estado servidor: "+xmlHttpLogin.statusText);
	}
	
	espera(1);
	var url = this_url + loginURL;
	
	var oRespuesta = $("respuestaLogin");
	oRespuesta.update("<center><img src='images/loading.gif' alt=''><br>Espere un momento por favor...</center>");
	var oBotonesRespuesta = $("botonesLogin");
	oBotonesRespuesta.className='ocultar';
	
	var cacheEntry = cache.shift();
	
	new Ajax.Request(url, {
			method: 'post',
            parameters: cacheEntry,
			onComplete: function(transport) {
			if (200 == transport.status || 4 == transport.status )
			{
				var response = transport.responseText;
				
				if (response.indexOf("ERRNO") >= 0	|| response.indexOf("error:") >= 0	|| response.length == 0)
				throw(response.length == 0 ? "Server error." : response);
				
				responseSplit=response.split(';');
				switch(responseSplit[0]){
					case 0:
					case '0':
						var oRespuesta = $("ingresologin");
						tomarMenuPanel();
					break;
					case 4:
					case '4':
						var oRespuesta = $("ingresologin");
						tomarMenuPanel();
					break;
					default:
						var oRespuesta = $("respuestaLogin");
						tomarMenuPanel();
					break;
				}
				var oBotonesRespuesta = $("botonesLogin");
					oBotonesRespuesta.className='mostrar';
						
				oRespuesta.innerHTML=response.substring(responseSplit[0].length+1,response.length);
			}	
			espera(0);
		}
	});
	return
}



function loginPanel(formulario)
{
	
	try
	{
		if(formulario=="Logout")
		{
			cache.push("logout=1");
		}else{
			cache.push(loginFormulario(formulario));
		}
	}
	
	catch(e)
	{
		alert("Error "+e.number+":"+e.message+" - Estado servidor: "+xmlHttpLogin.statusText);
	}
	
	espera(1);
	var url = this_url + loginURL;
	
	var oRespuesta = $("respuestaLogin");
	oRespuesta.update("<center><img src='images/loading.gif' alt=''><br>Espere un momento por favor...</center>");
	var oBotonesRespuesta = $("botonesLogin");
	oBotonesRespuesta.className='ocultar';
	
	var cacheEntry = cache.shift();
	
	new Ajax.Request(url, {
			method: 'post',
            parameters: cacheEntry,
			onComplete: function(transport) {
			if (200 == transport.status || 4 == transport.status )
			{
				var response = transport.responseText;
				
				if (response.length > 0)
				{
					var myData = response.evalJSON();
					switch(myData['tipo']){
						case 0:
						case '0':
							var oRespuesta = $("egresologin");
							$("ingresologin").update('');
						break;
						case 4:
						case '4':
							var oRespuesta = $("ingresologin");
							$("egresologin").update('');
						break;
						default:
							var oRespuesta = $("respuestaLogin");
							espera(0);
						break;
					}
					
					if(oRespuesta){
						oRespuesta.update(myData['HTML'].msmDecode());
					}
					
					var oBotonesRespuesta = $("botonesLogin");
					if(oBotonesRespuesta){
						oBotonesRespuesta.className='mostrar';
					}	
					espera(1);
					tomarMenuPanel();
				}
				
			}	
			
		}
	});
	return
}

///////////////// PAGINADOR////////////////////

function tomarPaginador(id,tipo,mtipo,art,pagina,destino,como)
{
	
	if(xmlHttpContenido)
	{
		try
		{
			if (xmlHttpContenido.readyState == 4 || xmlHttpContenido.readyState == 0)
			{
				espera(1);
				if(como){
					if(como==1){}else{
							var oSampleText = $(como);
						oSampleText.innerHTML = "<table width='100%' height='100%' align='center' valign='middle'><tr><td><img src='images/loading.gif' alt='' /></td></tr></table>";
					}
				}else{
					if(destino!=""){
						var oSampleText = $(destino);
						oSampleText.innerHTML = "<table width='100%' height='100%' align='center' valign='middle'><tr><td><img src='images/loading.gif' alt='' /></td></tr></table>";
					}
				}
				params = "?id=" + id + "&tipo=" + tipo + "&mtipo=" + mtipo + "&articulo=" + art + "&cont=" + destino;
				//alert("si:"+contenidoURL+params);
				xmlHttpContenido.open("GET", contenidoURL+params, true);
				xmlHttpContenido.onreadystatechange = handleTomarContenido;
				xmlHttpContenido.send(null);
			}
		}
		catch(e)
		{
			alert("Error "+e.number+":"+e.message+" - Estado servidor: "+xmlHttpContenido.statusText);
		}
	}
}
function handleTomarPaginador()
{
	if (xmlHttpContenido.readyState == 4)
	{
		if (xmlHttpContenido.status == 200)
		{
			try
			{
				mostrarContenido();
			}
			catch(e)
			{
				alert("Error "+e.number+":"+e.message+" - Estado servidor: "+xmlHttpContenido.statusText);
		}
		}else{
			alert("Error "+e.number+":"+e.message+" - Estado servidor: "+xmlHttpContenido.statusText);
		}
	}
}
function mostrarPaginador()
{

	response=xmlHttpContenido.responseText;
	//alert(response);
	ja = response.split(";");
	//alert(ja[0]);
	var oRespuesta = $(ja[0]);
	
	
	if (response.indexOf("ERRNO") >= 0	|| response.indexOf("error:") >= 0	|| response.length == 0)
	throw(response.length == 0 ? "Error" : response);
	
	//var oContenido = $("contenido");
	//oContenido.innerHTML = response;
	
	//response=xmlHttpDatos.responseText;				
	oRespuesta.innerHTML = response.substring(ja[0].length+1,response.length);
	espera(0);
	
}



if (!String.prototype.URLEncode) {


	String.prototype.URLEncode =function ()
	{
		// The Javascript escape and unescape functions do not correspond
		// with what browsers actually do...
		plaintext=this;
		var SAFECHARS = "0123456789" +					// Numeric
						"ABCDEFGHIJKLMNOPQRSTUVWXYZ" +	// Alphabetic
						"abcdefghijklmnopqrstuvwxyz" +
						"-_.!~*'()";					// RFC2396 Mark characters
		var HEX = "0123456789ABCDEF";

		var encoded = "";
		for (var i = 0; i < plaintext.length; i++ ) {
			var ch = plaintext.charAt(i);
		    if (ch == " ") {
			    encoded += "+";				// x-www-urlencoded, rather than %20
			} else if (SAFECHARS.indexOf(ch) != -1) {
			    encoded += ch;
			} else {
			    var charCode = ch.charCodeAt(0);
				if (charCode > 255) {
				    alert( "Unicode Character '" 
	                        + ch 
	                        + "' cannot be encoded using standard URL encoding.\n" +
					          "(URL encoding only supports 8-bit characters.)\n" +
							  "A space (+) will be substituted." );
					encoded += "+";
				} else {
					encoded += "%";
					encoded += HEX.charAt((charCode >> 4) & 0xF);
					encoded += HEX.charAt(charCode & 0xF);
				}
			}
		} // for

		return encoded;
	}

}

if (!String.prototype.msmDecode) {


	String.prototype.msmDecode =function ()
	{
		var codificado=this;
		var temporal=codificado.URLDecode();
		return(temporal._utf8_decode());
	}

}

if (!String.prototype.URLDecode) {


	String.prototype.URLDecode =function ()
	{
	   // Replace + with ' '
	   // Replace %xx with equivalent character
	   // Put [ERROR] in output if %xx is invalid.
	   var encoded=this;
	   var HEXCHARS = "0123456789ABCDEFabcdef"; 
	   var plaintext = "";
	   var i = 0;
	   while (i < encoded.length) {
	       var ch = encoded.charAt(i);
		   if (ch == "+") {
		       plaintext += " ";
			   i++;
		   } else if (ch == "%") {
				if (i < (encoded.length-2) 
						&& HEXCHARS.indexOf(encoded.charAt(i+1)) != -1 
						&& HEXCHARS.indexOf(encoded.charAt(i+2)) != -1 ) {
					plaintext += unescape( encoded.substr(i,3) );
					i += 3;
				} else {
					alert( 'Bad escape combination near ...' + encoded.substr(i) );
					plaintext += "%[ERROR]";
					i++;
				}
			} else {
			   plaintext += ch;
			   i++;
			}
		} // while
	   return plaintext;
	}

}


if (!String.prototype._utf8_encode) {


	String.prototype._utf8_encode=function ()
	{
  
     // private method for UTF-8 encoding  
      
        var string = this.replace(/\r\n/g,"\n");  
        var utftext = "";  
  
        for (var n = 0; n < string.length; n++) {  
  
            var c = string.charCodeAt(n);  
  
            if (c < 128) {  
                utftext += String.fromCharCode(c);  
            }  
            else if((c > 127) && (c < 2048)) {  
                utftext += String.fromCharCode((c >> 6) | 192);  
                utftext += String.fromCharCode((c & 63) | 128);  
            }  
            else {  
                utftext += String.fromCharCode((c >> 12) | 224);  
                utftext += String.fromCharCode(((c >> 6) & 63) | 128);  
                utftext += String.fromCharCode((c & 63) | 128);  
            }  
  
        }  
  
        return utftext;  
    }
}


if (!String.prototype._utf8_decode) {


	String.prototype._utf8_decode=function ()
	{
		var utftext=this;
        var string = "";  
        var i = 0;  
        var c = c1 = c2 = 0;  
  
        while ( i < utftext.length ) {  
  
            c = utftext.charCodeAt(i);  
  
            if (c < 128) {  
                string += String.fromCharCode(c);  
                i++;  
            }  
            else if((c > 191) && (c < 224)) {  
                c2 = utftext.charCodeAt(i+1);  
                string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));  
                i += 2;  
            }  
            else {  
                c2 = utftext.charCodeAt(i+1);  
                c3 = utftext.charCodeAt(i+2);  
                string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));  
                i += 3;  
            }  
  
        }  
  
        return string;  
    }  
  
}



///////////////////////////////////
function popup(page,popupname,height,width) {
var topPosition = (screen.height - height) / 2;
var leftPosition = (screen.width - width) / 2;
var windowprops = "width=" + width + ",height=" + height + ",location=no,menubar=no,toolbar=no,scrollbars=yes,resizable=no,status=no";
newWindow = window.open(page,popupname,windowprops);
}
function popup2(page,popupname,height,width){
	var windowprops="width="+width+",height="+height+",location=no,menubar=no,toolbar=no,scrollbars=yes,resizable=yes,status=no";
	newWindow=window.open(page,popupname,windowprops);
}


function popup3(URL,width,height) {
var topPosition = (screen.height - height) / 2;
var leftPosition = (screen.width - width) / 2;
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=" + width + ",height=" + height + ",left = " + leftPosition + ",top = " + topPosition + "');");
return false;
}
function fd(oi, wS) {
	if (ai) return wS ? $(oi).style:$(oi);
	if (al) return wS ? document.all[oi].style: document.all[oi];
	if (an) return document.layers[oi];
}

function pw() {
	return window.innerWidth != null? window.innerWidth: document.body.clientWidth != null? document.body.clientWidth:null;
}

function mouseX(evt) {
	if (evt.pageX) return evt.pageX;
	else if (evt.clientX)return evt.clientX + (document.documentElement.scrollLeft ?  document.documentElement.scrollLeft : document.body.scrollLeft);
	else return null;
}

function mouseY(evt) {
	if (evt.pageY) return evt.pageY;
	else if (evt.clientY)return evt.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);
	else return null;
}

function popUpHoras(evt,oi,este) {
	//if (!DH) {
		var wp = pw();
		 ds = fd(oi,1); 
		 dm = fd(oi,0); 
		abj = fd(este,1); 
		 st = ds.visibility;
		 if (dm.offsetWidth) ew = dm.offsetWidth;
		else if (dm.clip.width) ew = dm.clip.width;
			
			var ooob=$(este);
			
			var lv=0;
			lv=docjslib_getRealLeft(ooob);
			
			var tv=0;
			tv=docjslib_getRealTop(ooob);
			
			var oboj=$(oi);
			oboj.style.left = lv+'px'; 
			oboj.style.top = (tv+21)+'px'; 
			//alert(oboj.style.top +'   '+oboj.style.left);
			if(oboj.style.visibility == "visible")
			{
				oboj.style.visibility = "hidden"
			}else{
				oboj.style.visibility = "visible";
			}
		
	//}
}



var titulopordefecto = "Foto"; //Si no se especifica un ttulo al llamar a la funcin colocar el que se especifique aqu
var ventana;
var cont=0;

function afoto(cual,titulo){
	if(cont==1){ventana.close();ventana=null}
	if(titulo==null){titulo=titulopordefecto}
	ventana=window.open('','ventana','resizable=yes,scrollbars=no')
	ventana.document.write('<html><head><title>' + titulo + '</title></head><body style="overflow:hidden" marginwidth="0" marginheight="0" topmargin="0" bottommargin="0" leftmargin="0" rightmargin="0" scroll="no" onUnload="opener.cont=0"><img src="' + cual + '" onLoad="opener.redimensionar(this.width, this.height)">');
	ventana.document.close();
	cont++;
}
function redimensionar(ancho, alto){
	ventana.resizeTo(ancho+12,alto+28);
	ventana.moveTo((screen.width-ancho)/2,(screen.height-alto)/2); //centra la ventana. Eliminar si no se quiere centrar el popup
}

function Ventana (url,ancho,alto)
{
	var Windor = window.open (url, "Windor", "width="+ancho+",height="+alto+",toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no");
}


Number.prototype.zeroFormat = function(n, f, r){
    return n = new Array((++n, f ? (f = (this + "").length) < n ? n - f : 0 : n)).join(0), r ? this + n : n + this;
}

function hora(lahora,operador,limite){
	var oHora=$(lahora);
	var hora=oHora.value;
	try{
		if(operador==1)
		{
			hora++;
		}else{
			hora--;
		
		}
		if(hora>limite-1){
		 hora=0;
		}
		if(hora<0){
		 hora=limite-1;
		}
		
		oHora.value=hora.zeroFormat(2,true);
	}
	catch(e){
		alert("Error "+e.number+":"+e.message);
		
	}
}

function modificarHora(lahora,elminuto,destino){
	var oHora=$(lahora);
	var hora=oHora.value;
	
	var oMinuto=$(elminuto);
	var minuto=oMinuto.value;
	
	var oDestino=$(destino);
	try{
		oDestino.value=''+hora+':'+minuto;
	}
	catch(e){
		alert("Error "+e.number+":"+e.message);
		
	}
}




///////////////AUMENTAR EL TAMANIO LETRA///////////////////////
function TamanioTxt(objetoId,tipo,minimo,maximo) {
  // alert(objetoId);
   var oId=$(objetoId);
	var actual=oId.style.fontSize;
	var nodefinida=0;
	if(!actual){nodefinida=1;}
	var actual=actual.split('pt');
	var actual=actual[0];
	//alert(actual);
	if(actual<minimo){actual=minimo;}
	if(actual>maximo){actual=maximo;}
	//actual++;
	
	if (tipo=='+'){
		if(nodefinida){actual++;}
		actual++;
		if(actual>maximo){actual=maximo;}
		
		
    }else{
		actual--;
		if(actual<minimo){actual=minimo;}
    }
	
	//alert(oId.childNodes.lenght);
 
	oId.style.fontSize = actual+'pt';
	return;
}

	
function str_replace(busca, repla, orig)
{
	str 	= new String(orig);

	rExp	= "/"+busca+"/g";
	rExp	= eval(rExp);
	newS	= String(repla);

	str = new String(str.replace(rExp, newS));

	return str;
}


function hint(me, status,este)  {
      //var  theObj=$('hint_');
      // theObj.onmousemove=updatePos('hint_',event);
	
     $('hint_').innerHTML=$(me).innerHTML;
	//window.onscroll=updatePos('hint_',event);
     if(status==1)
	{
	  hintUp(este,me);
	  
     }else{
	   hintDown();
     }
	   
}


function hintUp(xobj,lyr,ytop,xleft) {
	var xdx = $(lyr);
	var ddx = $('hint_');
	ddx.innerHTML=xdx.innerHTML;
	ddx.style.display = "block";
	var alto= (docjslib_getRealTop(xobj)-25);
	if(alto<0) alto=0;
	ddx.style.top =alto+ 'px';
	ddx.style.left = (docjslib_getRealLeft(xobj) +20)+ 'px';
}

function hintDown(lyr) {
	var x = $('hint_');
	x.style.display = "none";

}    

function findPos(me) {
	var obj=me;
	var curleft = curtop = 0;
			
	if (obj.offsetParent) {
		do {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
	
		} while (obj = obj.offsetParent);
	}
	return [curleft,curtop];
}

function docjslib_getRealLeft(imgElem) {
	xPos = imgElem.offsetLeft;
	tempEl = imgElem.offsetParent;
  	while (tempEl != null) {
  		xPos += tempEl.offsetLeft;
  		tempEl = tempEl.offsetParent;
  	}
	return xPos;
}

function docjslib_getRealTop(imgElem) {
	yPos = imgElem.offsetTop;
	tempEl = imgElem.offsetParent;
	while (tempEl != null) {
  		yPos += tempEl.offsetTop;
  		tempEl = tempEl.offsetParent;
  	}
	return yPos;
}


////SEGURIDAD
function chk_marcar(formulario2,posterior){
		var formulario=$('form'+formulario2);
		var count = formulario.elements.length
		var datos="";
		var posterior2='check_'+posterior;
		var oID2='';
		var otemporal='';
		//MARCAR LOS ANTERIORES
		var anteriores=posterior.split('_');
		var stringTemporal='';
		
		
		for(i=2; i<(anteriores.length); i++)
		{
			
			stringTemporal='';
			for(i2=2; i2<(i); i2++)
			{
				stringTemporal=stringTemporal+'_'+anteriores[i2];
			}
			stringTemporal='check_'+anteriores[0]+'_'+anteriores[1]+stringTemporal;
			//oID2=$(stringTemporal);
			//oID2.checked =true;
			//alert(stringTemporal);
			for(xi=0; xi<count; xi++)
			{
				inputValue = formulario.elements[xi].value;
				fieldID = formulario.elements[xi].id;
				inputValue = encodeURIComponent(inputValue);
				fieldID = encodeURIComponent(fieldID);
				
				
				if(fieldID==stringTemporal)
				{
					
					formulario.elements[xi].checked =true;
				}

				if(fieldID=='h'+stringTemporal)
				{
					
					formulario.elements[xi].value =1;
				}
				
			}	
			
		}
		
		
		for(i=0; i<count; i++)
		{
			inputValue = formulario.elements[i].value;
			fieldID = formulario.elements[i].id;
			inputValue = encodeURIComponent(inputValue);
			fieldID = encodeURIComponent(fieldID);
			
			var oLargo=posterior2.length;
			var fieldIDActual=fieldID.substr(0,oLargo);
			
			var fieldIDActual2=fieldID.substr(0,oLargo+1);
			//
			otemporal=posterior2;
			if(otemporal!=fieldID)
			{
				if(fieldIDActual==posterior2)
				{
					
					//alert(fieldIDActual+' '+posterior2+' otemporal  '+otemporal+' fieldID'+fieldID);
					oID2=$(otemporal);
					
					if(oID2.checked)
					{
						formulario.elements[i].checked =true;
					}else{
						formulario.elements[i].checked = false;	
					}
				}
				
				if(fieldIDActual2=='h'+posterior2 )
				{
					
					oID2=$(otemporal);
					
					if(oID2.checked)
					{
						formulario.elements[i].value =1;
					}else{
						formulario.elements[i].value = 0;	
					}
				}
			}
		}
 
 return;
}


function replaceAll( str, from, to ) {
    var idx = str.indexOf( from );


    while ( idx > -1 ) {
        str = str.replace( from, to ); 
        idx = str.indexOf( from );
    }

    return str;
}

function hilite(este,nombre,imagen1,imagen2)
{

        var elementos_hilite = document.getElementsByName(nombre);
        for (var i=0; i<elementos_hilite.length; i++)
        {
            elementos_hilite[i].src=imagen2;
        }
		$(este).src=imagen1;
}





function AC_FL_RunContent2(){
	if (AC_FL_RunContent == 0) {
		alert("This page requires AC_RunActiveContent.js.");
	} else {
		//alert(arguments.length);
		var loc = window.location.href;
		var pos=loc.indexOf("?videoID=");
		if (pos != -1){var videoID = loc.substring(pos + 9, loc.length);}
		var argumentos = new Array();
		for(i=0;i<arguments.length;i++)
		{
			if(arguments[i].indexOf('&videoId=')>0)
			{
				//argumentos[i]=arguments[i]+videoID;
				//alert(argumentos[i]);
				argumentos[i]=arguments[i];
			}else{
				argumentos[i]=arguments[i];
			}
		}
		var ret = 
	    AC_GetArgs
	    (  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
	     , "application/x-shockwave-flash"
	    );
		
	  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
	}
  
 }
 