//Gestores de Internet para Municipios


//** FUNCIÓN PARA IMPRIMIR EL DIV MAINAREA **// 

function imprSelec(nombre)
{
  var ficha = document.getElementById('mainarea');
  var ventimp = window.open(' ', 'popimpr');
  ventimp.document.write( ficha.innerHTML );
  ventimp.document.close();
  ventimp.print( );
  ventimp.close();
}


//** FUNCIÓN PARA CAMBIAR EL TAMAÑO DEL TEXTO **//

function zoomText(Accion,Elemento){
//inicializaciones
obj=document.getElementById(Elemento);
if (obj.style.fontSize==""){
obj.style.fontSize="100%";
}
actual=parseInt(obj.style.fontSize); //valor actual del tamaño del texto
incremento=10;// el valor del incremento o decremento en el tamaño

//accion sobre el texto
if(Accion=="reestablecer"){
obj.style.fontSize="100%"
}
if(Accion=="aumentar"){
valor=actual+incremento;
obj.style.fontSize=valor+"%"
}
if(Accion=="disminuir"){
valor=actual-incremento;
obj.style.fontSize=valor+"%"
}
}


//** FUNCIÓN PARA DESHABILITAR EL BOTON DERECHO DEL RATÓN **//

var sMsgIdiom="";
function rightIdima(psIdiom){
sMsgIdiom = psIdiom;
}
function right(e){
 			if (navigator.appName == 'Netscape' &&
				 (e.which == 3 || e.which == 2))
    			return false;
  			else if (navigator.appName == 'Microsoft Internet Explorer' &&
   			 (event.button == 2 || event.button == 3)){
					alert(sMsgIdiom);
					return false;
				}
				return true;
			}
			document.onmousedown=right;

			if (document.layers) window.captureEvents(Event.MOUSEDOWN);
			window.onmousedown=right;


//** FUNCIÓN PARA EL CONTROL DE LAS FECHAS EN LAS PÁGINAS QUE CONTIENEN CALENDARIO **/

function CtrFecha(cFecha)
	{
    var sw, cDia, cMes, cAnyo;
    sw = false;

    if(cFecha != "")
		{
		  var iPos = 0;

			for (iCont = 0; iCont < cFecha.length; iCont++)
			{
			  if(isFinite(cFecha.substr(iCont,1)) == false)
				{
				  if(iPos == 0)
					{
					  cDia = cFecha.substring(iPos, iCont);
					}
					else
					{
					  cMes = cFecha.substring(iPos, iCont);
					}

					iPos = iCont;
			  }
			}

			if(cDia != null && cMes != null && cMes.length > 1)
			{
			  cAnyo = cFecha.substring(iPos,iCont);
				cAnyo = cAnyo.substring(1,cAnyo.length);
				cMes = cMes.substring(1,cMes.length);

				if(isFinite(cDia) == true && isFinite(cMes) == true
				 && isFinite(cAnyo) == true && cAnyo != '' && cMes < 13)
				{
				  if(cDia.length == 1)
					  cDia = "0" + cDia;

					if(cMes.length == 1)
					  cMes = "0" + cMes;

					if(cAnyo.length == 2)
					  cAnyo = "20" + cAnyo;

					if(cAnyo < 2300 && cAnyo > 1800)
					  sw = cDia + "/" + cMes + "/" + cAnyo;
				}
			}
		}

		return sw;
  }


//** FUNCIÓN QUE ELIMINA LOS ESPACIOS EN BLANCO **//

function trim(inputString) {
	   // Removes leading and trailing spaces from the passed string. Also removes
	   // consecutive spaces and replaces it with one space. If something besides
	   // a string is passed in (null, custom object, etc.) then return the input.
	   if (typeof inputString != "string") { return inputString; }
		   var retValue = inputString;
		   var ch = retValue.substring(0, 1);
		   while (ch == " ") { // Check for spaces at the beginning of the string
	      retValue = retValue.substring(1, retValue.length);
    	  ch = retValue.substring(0, 1);
	   }
	   ch = retValue.substring(retValue.length-1, retValue.length);
	   while (ch == " ") { // Check for spaces at the end of the string
    	  retValue = retValue.substring(0, retValue.length-1);
	      ch = retValue.substring(retValue.length-1, retValue.length);
	   }
	   while (retValue.indexOf("  ") != -1) { // Note that there are two spaces in the string - look for multiple spaces within the string
	      retValue = retValue.substring(0, retValue.indexOf("  ")) + retValue.substring(retValue.indexOf("  ")+1, retValue.length); // Again, there are two spaces in each of the strings
	   }

	   while (retValue.indexOf(" ") != -1) { // Note that there is one spaces in the string - look for multiple spaces within the string
	      retValue = retValue.substring(0, retValue.indexOf(" "))
		   + retValue.substring(retValue.indexOf(" ") + 1, retValue.length); // Again, there are two spaces in each of the strings
	   }

	   return retValue; // Return the trimmed string back to the user
	} // Ends the "trim" function


//** FUNCIÓN QUE ABRE UNA VENTANA EMERGENTE **//

function nueva_ventana(url, ancho, alto, barra, name) {
	izquierda = (screen.width) ? (screen.width-ancho)/2 : 100
	arriba = (screen.height) ? (screen.height-alto)/2 : 100
	opciones = 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=' + barra + ',resizable=0,width=' + ancho + ',height=' + alto + ',left=' + izquierda + ',top=' + arriba + ''
	window.open(url, name, opciones)
}

function setActiveStyleSheet(title) {

    window.showModalDialog("procesando3A.jsp?modal=true&estilo=" + title, "tripleamodal",
          "dialogHeight:150px;dialogWidth:450px;center:Yes; help:No;resizable:No;status:No;scroll:No");

}





//** FUNCIÓN QUE SALUDA AL USUARIO DE LA OFICINA AL CONECTARSE **//

function saludar(buenosd,buenast,buenasn){
var fecha = new Date();
var hora, cad="";
var minuto = fecha.getMinutes()
var segundo = fecha.getSeconds()
if (hora < 10) {hora = "0" + hora}
if (minuto < 10) {minuto = "0" + minuto}
if (segundo < 10) {segundo = "0" + segundo}
with (fecha){
hora = getHours();
//cad += hora + ":" + minuto + ":" + segundo;
}
if (hora < 12)
     cad = buenosd + ", "+ cad;
else if (hora < 20)
     cad = buenast + ", "+ cad;
else
     cad = buenasn + ", "+ cad;

return cad
}


