// JavaScript Document
function getRef(obj) {
      if(typeof obj == "string")
         obj= document.getElementById(obj);
      return obj;
}
function newWin(url,titul,w,h) {
	x=window.screen.availWidth;
	y=window.screen.availHeight;
	x=(x-w)/2;
	y=(y-h)/2;
	p=window.open(url,titul,"width="+w+",height="+h+",left="+x+",top="+y);
	p.focus();
}
function resalta(obj,clase) {
	getRef(obj).className = clase;
}
/*SIN USAR*/
function newWin2(url,titul,w,h) {
	x=window.screen.availWidth;
	y=window.screen.availHeight;
	x=(x-w)/2;
	y=(y-h)/2;
	p=window.open(url,titul,"width="+w+",height="+h+",left="+x+",top="+y+",scrollbars=yes,resizable=yes");
	p.focus();
}
function aparecer(obj){
	if(getRef(obj).className=="displayTrue")
		getRef(obj).className = "displayFalse";
	else
		getRef(obj).className = "displayTrue";
}
function limpiar(obj){
	getRef(obj).value="";
}

function randomRef(obj, str, limit){
	num=Math.floor(Math.random()*limit);
	getRef(obj).value=str+num;
}
// preload( '01.gif', '02.gif' ); 
function preload()
{ 
  var args = preload.arguments;
  document.imageArray = new Array(args.length);
  for(var i=0; i<args.length; i++)
  {
    document.imageArray[i] = new Image;
    document.imageArray[i].src = args[i];
  }
}
function show(obj) {
	getRef(obj).className = "displayTrue";
}

function hide(obj) {
	getRef(obj).className = "displayFalse";
}


/**/
function URLEncode(txt)
{
	// The Javascript escape and unescape functions do not correspond
	// with what browsers actually do...
	var SAFECHARS = "0123456789" +					// Numeric
					"ABCDEFGHIJKLMNOPQRSTUVWXYZ" +	// Alphabetic
					"abcdefghijklmnopqrstuvwxyz" +
					"-_.!~*'()";					// RFC2396 Mark characters
	var HEX = "0123456789ABCDEF";

	var plaintext = txt;//document.URLForm.F1.value;
	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

	//document.write(encoded);
	//document.URLForm.F2.value = encoded;
	return encoded;
};
