function subir(o) {
	if(o.selectedIndex > 0) {
		text = o.options[o.selectedIndex].text;
		value = o.options[o.selectedIndex].value;
		o.options[o.selectedIndex].text = o.options[o.selectedIndex-1].text;
		o.options[o.selectedIndex].value = o.options[o.selectedIndex-1].value;
		o.options[o.selectedIndex-1].text = text;
		o.options[o.selectedIndex-1].value = value; 
		o.selectedIndex--;											
	}									
}
function bajar(o) {
	if((o.selectedIndex != -1) && (o.selectedIndex < o.options.length-1)) {
		text = o.options[o.selectedIndex].text;
		value = o.options[o.selectedIndex].value;
		o.options[o.selectedIndex].text = o.options[o.selectedIndex+1].text;
		o.options[o.selectedIndex].value = o.options[o.selectedIndex+1].value;
		o.options[o.selectedIndex+1].text = text;
		o.options[o.selectedIndex+1].value = value; 
		o.selectedIndex++;											
	}																		
}

function vacia_lista(elem){
  var total=elem.length;
  for(var i=0;i<=total;i++){
	elem.options[0] = null;
  };
}

function SelectAllList(CONTROL){
	for(var i = 0;i < CONTROL.length;i++){
		CONTROL.options[i].selected = true;
	}
}

function ordenar_alfabeticamente(o) {
	var actual = new Array();
	var nuevo = new Array();
	var total=o.length;
	for(var i=0;i<total;i++){
		actual[o.options[i].text] = temp = new Array(o.options[i].text,o.options[i].value);
		nuevo[i] = o.options[i].text;
	};
	nuevo.sort();
	vacia_lista(o);
	for (x in nuevo){
		o.options[o.length] = new Option(actual[nuevo[x]][0],actual[nuevo[x]][1]);
	};
}
var oldwidget;
function showText(elem) {
	document.getElementById(elem.name+'_manual_container').style.display='';
	document.getElementById(elem.name+'_manual').disabled=false;	
}
function disableShowText(elem) {
	document.getElementById(elem.name+'_manual_container').style.display='none';
	document.getElementById(elem.name+'_manual').disabled=true;	
}

function showText2(elem) {
	document.getElementById(elem.name+'_manual_container').style.display='';
	document.getElementById(elem.name+'_manual').disabled=false;	
}
function disableShowText2(elem) {
	document.getElementById(elem.name+'_manual_container').style.display='none';
	document.getElementById(elem.name+'_manual').disabled=true;	
}

function selectwidget(name) {
	
	this.name = name;
	this.jsdata = new Array();
	
	this.setDataToField = function(id,field,destination) {
		var value;
		for(var i=0;i<this.jsdata.length;i++) {
			if(this.jsdata[i][0] == parseInt(id)) {
				destination = FCKeditorAPI.GetInstance(destination);
				destination.SetHTML(Base64.decode(jsObjects['plantilla'].jsdata[i][field]));
			}
		}
	}
	
}
