
function verFecha(){
	dayName = new Array ("Domingo","Lunes","Martes","Miércoles","Jueves","Viernes","Sábado")
	monName = new Array ("Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre")

	now = new Date
	document.write(dayName[now.getDay()] + " " + now.getDate() + " de " + monName[now.getMonth()] + " de " + now.getYear())
}


function MM_displayStatusMsg(msgStr)  { //v3.0
	status=msgStr; document.MM_returnValue = true;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_preloadImages() { //v3.0
 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
   var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
   if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}


var ccentralArray =  new Array("('Seleccione Servicio','',true,true)",
"('Iglesias(Cuerpos y Avanzadas)')",
"('Guarderías y Jardines')",
"('Hogares de Ancianos')",
"('Hospederías')",
"('Casas de Tránsito y Residenciales')",
"('Centros Comunitarios')",
"('Hogares de Menores')",
"('Colegios y Escuelas')",
"('Oficina de Bienestar Social')");

var ccentralArray2 =  new Array("'z'",
"'ccIglesias'",
"'ccGuarderias'",
"'ccAncianos'",
"'ccHospederias'",
"'ccResidenciales'",
"'ccComunitarios'",
"'ccMenores'",
"'ccColegios'",
"'ccBienestar'");

var norteArray =  new Array("('Seleccione Servicio','',true,true)",
"('Iglesias(Cuerpos y Avanzadas)')",
"('Hospederías')",
"('Centros Comunitarios')",
"('Hogares de Menores')",
"('Colegios y Escuelas')");

var norteArray2 =  new Array("'z'",
"'cnIglesias'",
"'cnHospederias'",
"'cnComunitarios'",
"'cnMenores'",
"'cnColegios'");

var surArray =  new Array("('Seleccione Servicio','',true,true)",
"('Iglesias(Cuerpos y Avanzadas)')",
"('Guarderías y Jardines')",
"('Centros para la 3a Edad')",
"('Casas de Tránsito y Residenciales')",
"('Centros Comunitarios')",
"('Hogares de Menores')",
"('Colegios y Escuelas')",
"('Comedores Abiertos')");

var surArray2 =  new Array("'z'",
"'csIglesias'",
"'csGuarderias'",
"'csCentros'",
"'csResidenciales'",
"'csComunitarios'",
"'csMenores'",
"'csColegios'",
"'csComedores'");

var ecuadorArray =  new Array("('Seleccione Servicio','',true,true)",
"('Iglesias(Cuerpos y Avanzadas)')",
"('Guarderías y Jardines')",
"('Centros Comunitarios')",
"('Colegios y Escuelas')",
"('Taller de Costura')",
"('Centros de Salud')");

var ecuadorArray2 =  new Array("'z'",
"'ecIglesias'",
"'ecGuarderias'",
"'ecComunitarios'",
"'ecColegios'",
"'ecTaller'",
"'ecSalud'");

var peruArray =  new Array("('Seleccione Servicio','',true,true)",
"('Iglesias(Cuerpos y Avanzadas)')",
"('Hospederías')",
"('Casas de Tránsito y Residenciales')",
"('Centros Abiertos')",
"('Colegios y Escuelas')",
"('Comedores de Emergencia')",
"('Centros de Salud')");

var peruArray2 =  new Array("'z'",
"'peIglesias'",
"'peHospederias'",
"'peTransito'",
"'peCentros'",
"'peColegios'",
"'peComedores'",
"'peSalud'");

var bcentralArray =  new Array("('Seleccione Servicio','',true,true)",
"('Iglesias(Cuerpos y Avanzadas)')",
"('Guarderías y Jardines')",
"('Centros Comunitarios')",
"('Hogares de Menores')",
"('Casas de Tránsito y Residenciales')",
"('Colegios y Escuelas')",
"('Centros de Salud')",
"('Otros')");

var bcentralArray2 =  new Array("'z'",
"'bcIglesias'",
"'bcGuarderias'",
"'bcComunitarios'",
"'bcMenores'",
"'bcTransito'",
"'bcColegios'",
"'bcSalud'",
"'bcOtros'");

var altiplanoArray =  new Array("('Seleccione Servicio','',true,true)",
"('Iglesias(Cuerpos y Avanzadas)')",
"('Centros Abiertos')",
"('Centros Comunitarios')",
"('Colegios y Escuelas')",
"('Hogares de Menores')",
"('Casas de Tránsito y Residenciales')",
"('Otros')");

var altiplanoArray2 =  new Array("'z'",
"'baIglesias'",
"'baCentros'",
"'baComunitarios'",
"'baColegios'",
"'baMenores'",
"'baTransito'",
"'baOtros'");

function populateCountry(inForm,selected) {
	var selectedArray = eval(selected + "Array");
	var selectedArray2 = eval(selected + "Array2");
	while (selectedArray.length < inForm.country.options.length) {
		inForm.country.options[(inForm.country.options.length - 1)] = null;
	}
	for (var i=0; i < selectedArray.length; i++) {
		eval("inForm.country.options[i]=" + "new Option" + selectedArray[i]);
		eval("inForm.country.options[i].value=" + selectedArray2[i]);
	}
	if (inForm.region.options[0].value == '') {
		inForm.region.options[0]= null;
		if ( navigator.appName == 'Netscape') {
			if (parseInt(navigator.appVersion) < 4) {
				window.history.go(0);
			}
			else {
				if (navigator.platform == 'Win32' || navigator.platform == 'Win16') {
					window.history.go(0);
				}
			}
		}
	}
}

////// esconde DIVs
function sh(_d)
{
  var _x = document.getElementById(_d);
  _x.style.visibility=_x.style.visibility=="hidden"?"visible":"hidden";
  _x.style.overflow=_x.style.overflow=="hidden"?"visible":"hidden";
}


var _antiguo="";
function sh2(_d,_text,_inform)
{
	if (_d!='z'){
		if (_antiguo==""){
		  _antiguo=document.getElementById(_d);
		} else {
		  _antiguo.style.visibility="hidden";
		  _antiguo.style.overflow="hidden";
		  _antiguo=document.getElementById(_d);
		}
		var _y = document.getElementById(_d);
		if (_text==_inform.country.options[0].text){
			  _y.style.visibility="hidden";
			  _y.style.overflow="hidden";
		}
		else {
			  _y.style.visibility="visible";
			  _y.style.overflow="visible";
		}
	}
}





////// para ordenar tablas
function setDataType(cValue)
  {
	// THIS FUNCTION CONVERTS DATES AND NUMBERS FOR PROPER ARRAY
	// SORTING WHEN IN THE SORT FUNCTION
	var isDate = new Date(cValue);
	if (isDate == "NaN")
	  {
		if (isNaN(cValue))
		  {
			// THE VALUE IS A STRING, MAKE ALL CHARACTERS IN
			// STRING UPPER CASE TO ASSURE PROPER A-Z SORT
			cValue = cValue.toUpperCase();
			return cValue;
		  }
		else
		  {
			// VALUE IS A NUMBER, TO PREVENT STRING SORTING OF A NUMBER
			// ADD AN ADDITIONAL DIGIT THAT IS THE + TO THE LENGTH OF
			// THE NUMBER WHEN IT IS A STRING
			var myNum;
			myNum = String.fromCharCode(48 + cValue.length) + cValue;
			return myNum;
		  }
		}
  else
	  {
		// VALUE TO SORT IS A DATE, REMOVE ALL OF THE PUNCTUATION AND
		// AND RETURN THE STRING NUMBER
		//BUG - STRING AND NOT NUMERICAL SORT .....
		// ( 1 - 10 - 11 - 2 - 3 - 4 - 41 - 5  etc.)
		var myDate = new String();
		myDate = isDate.getFullYear() + " " ;
		myDate = myDate + isDate.getMonth() + " ";
		myDate = myDate + isDate.getDate(); + " ";
		myDate = myDate + isDate.getHours(); + " ";
		myDate = myDate + isDate.getMinutes(); + " ";
		myDate = myDate + isDate.getSeconds();
		//myDate = String.fromCharCode(48 + myDate.length) + myDate;
		return myDate ;
	  }
  }
function sortTable(col, tableToSort)
  {
	var iCurCell = col + tableToSort.cols;
	var totalRows = tableToSort.rows.length;
	var bSort = 0;
	var colArray = new Array();
	var oldIndex = new Array();
	var indexArray = new Array();
	var bArray = new Array();
	var newRow;
	var newCell;
	var i;
	var c;
	var j;
	// ** POPULATE THE ARRAY colArray WITH CONTENTS OF THE COLUMN SELECTED
	for (i=1; i < tableToSort.rows.length; i++)
	  {
		colArray[i - 1] = setDataType(tableToSort.cells(iCurCell).innerText);
		iCurCell = iCurCell + tableToSort.cols;
	  }
	// ** COPY ARRAY FOR COMPARISON AFTER SORT
	for (i=0; i < colArray.length; i++)
	  {
		bArray[i] = colArray[i];
	  }
	// ** SORT THE COLUMN ITEMS
	//alert ( colArray );
	colArray.sort();
	//alert ( colArray );
	for (i=0; i < colArray.length; i++)
	  { // LOOP THROUGH THE NEW SORTED ARRAY
		indexArray[i] = (i+1);
		for(j=0; j < bArray.length; j++)
		  { // LOOP THROUGH THE OLD ARRAY
			if (colArray[i] == bArray[j])
			  {  // WHEN THE ITEM IN THE OLD AND NEW MATCH, PLACE THE
				// CURRENT ROW NUMBER IN THE PROPER POSITION IN THE
				// NEW ORDER ARRAY SO ROWS CAN BE MOVED ....
				// MAKE SURE CURRENT ROW NUMBER IS NOT ALREADY IN THE
				// NEW ORDER ARRAY
				for (c=0; c<i; c++)
				  {
					if ( oldIndex[c] == (j+1) )
					{
					  bSort = 1;
					}
					  }
					  if (bSort == 0)
						{
						  oldIndex[i] = (j+1);
						}
						  bSort = 0;
						}
		  }
	}
  // ** SORTING COMPLETE, ADD NEW ROWS TO BASE OF TABLE ....
  for (i=0; i<oldIndex.length; i++)
	{
	  newRow = tableToSort.insertRow();
	  for (c=0; c<tableToSort.cols; c++)
		{
		  newCell = newRow.insertCell();
		  newCell.innerHTML = tableToSort.rows(oldIndex[i]).cells(c).innerHTML;
		}
	  }
  //MOVE NEW ROWS TO TOP OF TABLE ....
  for (i=1; i<totalRows; i++)
	{
	  tableToSort.moveRow((tableToSort.rows.length -1),1);
	}
  //DELETE THE OLD ROWS FROM THE BOTTOM OF THE TABLE ....
  for (i=1; i<totalRows; i++)
	{
	  tableToSort.deleteRow();
	}
  }


function filter(tabla){
	var x;
	x=2;
	while (x<=tabla.rows.length){
		if (tabla.cells((tabla.cols*x)-1).innerText=='SAME'){
			tabla.deleteRow(x-1);
		} else {
			x++;
		}
	}
}

