function borra(SelectObj)
{
//	var temp = document.principal.ciudad.options.length;
	var temp = SelectObj.options.length;
	for (var x=0;x <= temp ;x++)
	{
		//document.principal.ciudad.options.remove(temp-x);
//		document.principal.ciudad.options[temp-x]=null;
		SelectObj.options[temp-x]=null;
	};
}
//************************************
function getSelected(opt)
		{
           	var selected = new Array();      

            for (var intLoop = 0; intLoop < opt.length; intLoop++)
			{
               if ((opt[intLoop].selected) ||
                   (opt[intLoop].checked))
					{
                  index = selected.length;
                  selected[index] = new Object;
                  selected[index].value = opt[intLoop].value;
                  selected[index].index = intLoop;
               	}
            }
            return selected;
         }
//***********************************
function outputSelected(opt)
			{
            var sel = getSelected(opt);
            var strSel = "";
				for (var item in sel)
					strSel += sel[item].value;
			return strSel;
         	}

//************************************
function addNew(text, value,i,j)
{
	// Add a new option.
	var el = new Option(text,value);

	if (j == 1 )
           document.principal.ciudad.options[i] = el;

}

//*************************************
function mensaje(opt1)
{
	var Lista_Nombres=new Array();
	var Lista_Codigos=new Array();
	var seleccion = outputSelected(opt1.options);

	//----------------------------------
	borra(document.principal.ciudad);
	//----------------------------------
	if (seleccion == "0"){
			Lista_Nombres = Lista_Ciudad_Nom_0;
			Lista_Codigos = Lista_Ciudad_Cod_0;
        }
	//----------------------------------
	if (seleccion == "1"){
			Lista_Nombres = Lista_Ciudad_Nom_1;
			Lista_Codigos = Lista_Ciudad_Cod_1;
        }
	//----------------------------------
	if (seleccion == "2"){
			Lista_Nombres = Lista_Ciudad_Nom_2;
			Lista_Codigos = Lista_Ciudad_Cod_2;
        }
	//----------------------------------
	if (seleccion == "3"){
			Lista_Nombres = Lista_Ciudad_Nom_3;
			Lista_Codigos = Lista_Ciudad_Cod_3;
	}
	//----------------------------------
	if (seleccion == "4"){
			Lista_Nombres = Lista_Ciudad_Nom_4;
			Lista_Codigos = Lista_Ciudad_Cod_4;
	}
	//----------------------------------
	if (seleccion == "5"){
			Lista_Nombres = Lista_Ciudad_Nom_5;
			Lista_Codigos = Lista_Ciudad_Cod_5;
	}
	//----------------------------------
	if (seleccion == "6"){
			Lista_Nombres = Lista_Ciudad_Nom_6;
			Lista_Codigos = Lista_Ciudad_Cod_6;
	}
	//----------------------------------
	if (seleccion == "7"){
			Lista_Nombres = Lista_Ciudad_Nom_7;
			Lista_Codigos = Lista_Ciudad_Cod_7;
	}
	//----------------------------------
	if (seleccion == "8"){
			Lista_Nombres = Lista_Ciudad_Nom_8;
			Lista_Codigos = Lista_Ciudad_Cod_8;
	}
	//----------------------------------
	if (seleccion == "9"){
			Lista_Nombres = Lista_Ciudad_Nom_9;
			Lista_Codigos = Lista_Ciudad_Cod_9;
	}
	//----------------------------------
	if (seleccion == "10"){
			Lista_Nombres = Lista_Ciudad_Nom_10;
			Lista_Codigos = Lista_Ciudad_Cod_10;
	}
	//----------------------------------
	if (seleccion == "11"){
			Lista_Nombres = Lista_Ciudad_Nom_11;
			Lista_Codigos = Lista_Ciudad_Cod_11;
	}
	//----------------------------------
	if (seleccion == "12"){
			Lista_Nombres = Lista_Ciudad_Nom_12;
			Lista_Codigos = Lista_Ciudad_Cod_12;
	}
	//----------------------------------
	if (seleccion == "-1"){
			Lista_Nombres = Lista_Ciudad_Nom_T;
			Lista_Codigos = Lista_Ciudad_Cod_T;
	}

	for (var x=0 ; x< Lista_Nombres.length ; x++)
			addNew(Lista_Nombres[x],Lista_Nombres[x],x,1); 

	if (seleccion == 0)	
        	document.principal.ciudad.options[0].selected = true;
	else
        	document.principal.ciudad.options[0].selected = true;

}

function outputSelected2(opt)
			{
            var sel = getSelected2(opt);
            var strSel = "";
				for (var item in sel)
					strSel += sel[item].value;
			return strSel;
         	}

function getSelected2(opt)
		{
           	var selected = new Array();      

            for (var intLoop = 0; intLoop < opt.length; intLoop++)
			{
               if ((opt[intLoop].selected) ||
                   (opt[intLoop].checked))
					{
                  index = selected.length;
                  selected[index] = new Object;
                  selected[index].value = opt[intLoop].text;
                  selected[index].index = intLoop;
               	}
            }
            return selected;
         }
function cogevalor(){
return document.form.ciudad.selectedIndex
}

function muestra(opt)
{
opt.ciudad2.value=outputSelected2(opt.ciudad.options);
opt.region2.value=outputSelected2(opt.region.options);
}