function loadSelectWithJsonObject(selId, res){
	infoObj = eval('('+res+')');
	var selectElem = getElement(selId);
	  for (x33 = selectElem.length; x33 >= 0; x33--) {
		  selectElem[x33] = null;
	  }
	if (infoObj.length > 0){
		for(r=0; r<infoObj.length; r++){
			selectElem.options[r] = new Option(infoObj[r][1],infoObj[r][0]);
		}
	}
}

function padDigitsNumbers0_9(n){
	if (n>=0 && n<10){
		n = n.toString();
		n = '0'+n;
	}
	return n;
}

function openClose(tag){
	var elemTag = getElement(tag);
	var newStyle;
	if (elemTag.style.display==''){
		newStyle = 'none';
	}
	else{
		newStyle = '';
	}
	setDisplay(tag, newStyle);
}

function getElement(tag){
	return document.getElementById(tag);
}

function setDisplay(tag, newDisplay){
	var elemDisplay = getElement(tag);
	if (elemDisplay != null){
		elemDisplay.style.display = newDisplay;
	}
}

function popUp(URL,SCROLL,ANCHO,ALTO) {
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=" +SCROLL+ ",location=0,statusbar=0,menubar=0,resizable=0,width=" +ANCHO+",height="+ALTO+"');");
}

function loadImage(){
	var imElem = getElement('sessionImage');
	imElem.src = 'session_image.php';
}

function setClass(tag, nClass){
 	getElement(tag).className = nClass;
}

function setInnerHtml(tag, text){
 	getElement(tag).innerHTML = text;
}

function MM_goToURL() {
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

function replaceStr(string,text,by) {
	var strLength = string.length, txtLength = text.length;
	if ((strLength == 0) || (txtLength == 0)) return string;

	var i = string.indexOf(text);
	if ((!i) && (text != string.substring(0,txtLength))) return string;
	if (i == -1) return string;

	var newstr = string.substring(0,i) + by;

	if (i+txtLength < strLength)
	newstr += replaceStr(string.substring(i+txtLength,strLength),text,by);

	return newstr;
}

function URLDecode (encodedString) {
  var output = encodedString;
  var binVal, thisString;
  var myregexp = /(%[^%]{2})/;
  while ((match = myregexp.exec(output)) != null
             && match.length > 1
             && match[1] != '') {
    binVal = parseInt(match[1].substr(1),16);
    thisString = String.fromCharCode(binVal);
    output = output.replace(match[1], thisString);
  }
  output = replaceStr(output, '+', ' ');
  return output;
}


