function showId(id) {
     document.getElementById(id).style.display = "inline";
}

function hideId(id) {
     document.getElementById(id).style.display = "none";
}

function toggleId(id) {
     if (document.getElementById(id).style.display == "none") {
          showId(id);
     } else {
          hideId(id);
     }
}


function crearObj(tag, idname, dest, txt) {
	c = document.createElement(tag);
	c.id = idname;
	c.innerHTML = txt;
	document.getElementById(dest).appendChild(c);
}

function borrarObj(principal, borrarid) {
	document.getElementById(principal).removeChild(document.getElementById(borrarid));
}

function llenarSelect(control, min, max, defaultSelected) {
	var a = document.getElementById(control).length;
	for (i=min;i<=max;i++) {
//		if (i == defaultSelected) document.getElementById(control).options[a++] = new Option(i, i, "defaultSelected");
//		else document.getElementById(control).options[a++] = new Option(i, i);
		document.getElementById(control).options[a++] = new Option(i, i);

	}
	document.getElementById(control).value = defaultSelected;
}

function cambioPais(control) {
	document.getElementById(control).length = 0;
	document.getElementById(control).options[0] = new Option('Cargando...');
}

function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}

function removeOptionsByText(id, text) {
	selectName = document.getElementById(id);
  for (var i=selectName.options.length-1; i>=0; i--) {
    if (selectName.options[i].text == text) {
      selectName.options[i] = null;
    }
  }
}

function removeOptionsByValue(id, value) {
	selectName = document.getElementById(id);
  for (var i=selectName.options.length-1; i>=0; i--) {
    if (selectName.options[i].value == value) {
      selectName.options[i] = null;
    }
  }
}

function sortlist(id) {
	var lb = document.getElementById(id);
	arrTexts = new Array();
	
	for(i=0; i<lb.length; i++)  {
	  arrTexts[i] = lb.options[i].text;
	}
	
	arrTexts.sort();
	
	for(i=0; i<lb.length; i++)  {
	  lb.options[i].text = arrTexts[i];
	  lb.options[i].value = arrTexts[i];
	}
}
