function replaceSubstring(inputString, fromString, toString) {
   var temp = "" + inputString;
   if (fromString == "") 
   {
      return inputString;
   }
   if (toString.indexOf(fromString) == -1) 
   { 
      while (temp.indexOf(fromString) != -1) 
      {
         var toTheLeft = temp.substring(0, temp.indexOf(fromString));
         var toTheRight = temp.substring(temp.indexOf(fromString)+fromString.length, temp.length);
         temp = toTheLeft + toString + toTheRight;
      }
   } else { 
      var midStrings = new Array("~", "`", "_", "^", "#");
      var midStringLen = 1;
      var midString = "";
      while (midString == "") {
         for (var i=0; i < midStrings.length; i++) 
         {
            var tempMidString = "";
            for (var j=0; j < midStringLen; j++) { tempMidString += midStrings[i]; }
            if (fromString.indexOf(tempMidString) == -1) 
            {
               midString = tempMidString;
               i = midStrings.length + 1;
            }
         }
      }
      while (temp.indexOf(fromString) != -1) 
      {
         var toTheLeft = temp.substring(0, temp.indexOf(fromString));
         var toTheRight = temp.substring(temp.indexOf(fromString)+fromString.length, temp.length);
         temp = toTheLeft + midString + toTheRight;
      }
      while (temp.indexOf(midString) != -1) 
      {
         var toTheLeft = temp.substring(0, temp.indexOf(midString));
         var toTheRight = temp.substring(temp.indexOf(midString)+midString.length, temp.length);
         temp = toTheLeft + toString + toTheRight;
      }
   }
   return temp;
}
function CambiaPag(NROPAG)
{
	NPAG = NROPAG;
	
	RecargarPagina();
}
function OrdenaPag(CAMPO,ORDENARPOR,SENTIDO)
{
	
	NPAG = 1;
	if (CAMPO == ORDENARPOR)
	{
		if (SENTIDO == 0)
		{	
			SENT = 1;
		}else{
			SENT = 0;
		}
	}else{
		ORBY = CAMPO;
		SENT = 0;
	}
	
	RecargarPagina();

}
function IsNumeric(sText)
{
   var ValidChars = "0123456789,";
   var IsNumber=true;
   var Char;
 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
      { 
      Char = sText.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber;
}


//funciones para chequear strings
function isEmpty(s)
{   return ((s == null) || (s.length == 0))
}

//caracteres de espacio blanco
var whitespace = " \t\n\r";

function isWhitespace (s)
{   var i;

    // reviso si el string esta vacio
    if (isEmpty(s)) return true;

    // revisa todo el largo del literal(string)
    // īpara ver si encuentra un caracter que no sea
    // blanco, si lo hace devuelve true

    for (i = 0; i < s.length; i++)
    {   
        // reviso el caracter
        var c = s.charAt(i);

        if (whitespace.indexOf(c) == -1) return false;
    }

    // si todos me dan blanco devuelvo true
    return true;
}
function MostrarVentana(ANCHO,ALTO,PATH,STATUS)
{
	var winmail;
	var TextLink = PATH
	
	if (typeof(STATUS) != "undefined"){STATUS="yes";}else{STATUS="no";}
	
	if (window.screen) 
	{
		var ancho = window.screen.width;
		var alto = window.screen.height;
			
		ancho = ancho - ANCHO;
		ancho = ancho /2;
			
		alto = alto - ALTO;
		alto = alto /2;
			
		var propiedades = "toolbar=no,location=no,directories=no,status="+STATUS+",menubar=no,scrollbars=yes,resizable=yes,width="+ANCHO+",height="+ALTO+",top="+alto+",left="+ancho;
		winmail = window.open(TextLink, "_blank", propiedades);
		winmail.focus();
	}
}
function MostrarImprimir(ANCHO,ALTO,PATH)
{
	var winmail;
	var TextLink = PATH
		
	if (window.screen) 
	{
		var ancho = window.screen.width;
		var alto = window.screen.height;
			
		ancho = ancho - ANCHO;
		ancho = ancho /2;
			
		alto = alto - ALTO;
		alto = alto /2;
			
		var propiedades = "toolbar=no,location=no,directories=no,status=no,menubar=yes,scrollbars=yes,resizable=yes,width="+ANCHO+",height="+ALTO+",top="+alto+",left="+ancho;
		winmail = window.open(TextLink, "_blank", propiedades);
		winmail.focus();
	}
}
function MostrarVentanaOpciones(ANCHO,ALTO,PATH,OPCION)
{
	var winmail;
	var TextLink = PATH
		
	if (window.screen) 
	{
		var ancho = window.screen.width;
		var alto = window.screen.height;
			
		ancho = ancho - ANCHO;
		ancho = ancho /2;
			
		alto = alto - ALTO;
		alto = alto /2;
			
		var propiedades = OPCION + ",width="+ANCHO+",height="+ALTO+",top="+alto+",left="+ancho;
		winmail = window.open(TextLink, "winmail", propiedades);
		winmail.focus();
	}
}
function isMail(obj){
	var ValorCampo;

	ValorCampo=obj.value;
	if(ValorCampo.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) == -1){
		return(false);
	}else{
		return(true);
	}
}
function CargarArchivo(CDOC,CUSO,EXTENDIDO,TITULO)
{
	if (typeof(EXTENDIDO) == "undefined"){EXTENDIDO = 0}
	if (typeof(TITULO) == "undefined"){TITULO = 0}
	var winmail;
	var TextLink = "/BackOffice/Uploads/Uploads_Archivos_Cliente.asp?CDOC="+CDOC+"&CUSO="+CUSO+"&EXT="+EXTENDIDO+"&TTL="+TITULO;
	
	if (window.screen) 
	{
		var ancho = window.screen.width;
		var alto = window.screen.height;
			
		ancho = ancho - 520;
		ancho = ancho /2;
			
		alto = alto - 350;
		alto = alto /2;
			
		var propiedades = "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width="+520+",height="+350+",top="+alto+",left="+ancho;
		winmail = window.open(TextLink, "Uploads", propiedades);
		winmail.focus();
	}
}
function DevuelveExtension(TEXTO)
{
	var str_tmp = TEXTO.toString();
	var largo = str_tmp.length;
	var indice = str_tmp.lastIndexOf(".");
	var ext = str_tmp.substring(indice+1,largo);
	var ext = ext.toLowerCase();
	return(ext)	
}
function MostrarVentanaBarra(ANCHO,ALTO,PATH)
{
	var winmail;
	var TextLink = PATH
		
	if (window.screen) 
	{
		var ancho = window.screen.width;
		var alto = window.screen.height;
			
		ancho = ancho - ANCHO;
		ancho = ancho /2;
			
		alto = alto - ALTO;
		alto = alto /2;
			
		var propiedades = "toolbar=no,location=no,directories=no,status=no,menubar=yes,scrollbars=yes,resizable=yes,width="+ANCHO+",height="+ALTO+",top="+alto+",left="+ancho;
		winmail = window.open(TextLink, "winmail", propiedades);
		winmail.focus();
	}
}
function AreaEdicion(LCACC,LCARE)
{
	MostrarVentana(420,200,"/BackOffice/Empresas/Ventana_Areas_General.asp?CACC="+LCACC+"&CARE="+LCARE);
}
function CargoEdicion(LCACC,LCCGO)
{
	MostrarVentana(420,200,"/BackOffice/Empresas/Ventana_Cargos_General.asp?CACC="+LCACC+"&CCGO="+LCCGO);
}
function FuenteEdicion(LCACC,LCFNT)
{
	MostrarVentana(420,300,"/BackOffice/Generales/Ventana_Fuentes_General.asp?CACC="+LCACC+"&CFNT="+LCFNT);
}
function ProfesionEdicion(LCACC,LCPRF)
{
	MostrarVentana(420,200,"/BackOffice/Contactos/Ventana_Profesiones_General.asp?CACC="+LCACC+"&CPRF="+LCPRF);
}
function ProfesionEliminar(LCACC,LCPRF,LEN1)
{
	var K = confirm(LEN1);
	if (K){window.location.href = "Eliminar_Profesiones_General.asp?CACC="+LCACC+"&CPRF="+LCPRF;}	
}
function TituloEliminar(LCACC,LCTTL,LEN1)
{
	var K = confirm(LEN1);
	if (K){window.location.href = "Eliminar_Titulos_General.asp?CACC="+LCACC+"&CTTL="+LCTTL;}	
}
function TituloContactos(LCACC,LCTTL)
{
	MostrarVentana(560,500,"/BackOffice/Contactos/Ventana_Titulos_Contactos.asp?CACC="+LCACC+"&CTTL="+LCTTL);
}
function TituloEdicion(LCACC,LCTTL)
{
	MostrarVentana(420,200,"/BackOffice/Contactos/Ventana_Titulos_General.asp?CACC="+LCACC+"&CTTL="+LCTTL);
}
function TipoObraEdicion(LCACC,LOTPO)
{
	MostrarVentana(420,200,"Tipos_General.asp?CACC="+LCACC+"&OTPO="+LOTPO);
}
function TipologiaObraEdicion(LCACC,LOTPL)
{
	MostrarVentana(420,200,"Tipologias_General.asp?CACC="+LCACC+"&OTPL="+LOTPL);
}
function IntervencionObraEdicion(LCACC,LOINT)
{
	MostrarVentana(420,200,"Intervenciones_General.asp?CACC="+LCACC+"&OINT="+LOINT);
}
function EstadoObraEdicion(LCACC,LOEST,LCANT)
{
	MostrarVentana(420,200,"Estados_General.asp?CACC="+LCACC+"&OEST="+LOEST+"&CANT="+LCANT);
}
function ContactoImprimir(LCACC,LCCON)
{
	MostrarImprimir(690,400,"/BackOffice/Contactos/Contactos_Imprimir.asp?CACC="+LCACC+"&CCON="+LCCON);
}
function ContactoEdicion(LCACC,LCCON)
{
	MostrarVentana(470,400,"/BackOffice/Contactos/Ventana_Contactos_General.asp?CACC="+LCACC+"&CCON="+LCCON);
}
function ContactosLista(CACC)
{
	location.href = "Contactos_Lista.asp?CACC="+CACC;
}
function ContactosBuscar(CACC)
{
	location.href = "Contactos_Buscar.asp?CACC="+CACC;
}
function ContactosSeleccion(LCACC,LCVAR,VENTANA,VIENEDE)
{
	if (VENTANA == 1)
	{
		MostrarVentana(720,500,"/BackOffice/Contactos/Ventana_Seleccion_Contactos.asp?CACC="+LCACC+"&CVAR="+LCVAR+"&VIENEDE="+VIENEDE);
	}else{
		location.href = "/BackOffice/Contactos/Ventana_Seleccion_Contactos.asp?CACC="+LCACC+"&CVAR="+LCVAR+"&VIENEDE="+VIENEDE;
	}
}
function ContactosSeleccionBuscar(LCACC,LCVAR,VENTANA,VIENEDE)
{
	if (VENTANA == 1)
	{
		MostrarVentana(720,500,"/BackOffice/Contactos/Ventana_Seleccion_Buscar.asp?CACC="+LCACC+"&CVAR="+LCVAR+"&VIENEDE="+VIENEDE);
	}else{
		location.href = "/BackOffice/Contactos/Ventana_Seleccion_Buscar.asp?CACC="+LCACC+"&CVAR="+LCVAR+"&VIENEDE="+VIENEDE;
	}
}
function EmpresaImprimir(LCACC,LCEMP)
{
	MostrarImprimir(690,500,"/BackOffice/Empresas/Empresas_Imprimir.asp?CACC="+LCACC+"&amp;CEMP="+LCEMP);
}
function EmpresasSeleccion(LCACC,LCVAR,VENTANA,VIENEDE)
{
	if (VENTANA == 1)
	{
		MostrarVentana(720,500,"/BackOffice/Empresas/Ventana_Seleccion_Empresas.asp?CACC="+LCACC+"&CVAR="+LCVAR+"&VIENEDE="+VIENEDE);
	}else{
		location.href = "/BackOffice/Empresas/Ventana_Seleccion_Empresas.asp?CACC="+LCACC+"&CVAR="+LCVAR+"&VIENEDE="+VIENEDE;
	}
}
function EmpresasSeleccionBuscar(LCACC,LCVAR,VENTANA,VIENEDE)
{
	if (VENTANA == 1)
	{
		MostrarVentana(720,500,"/BackOffice/Empresas/Ventana_Seleccion_Buscar.asp?CACC="+LCACC+"&CVAR="+LCVAR+"&VIENEDE="+VIENEDE);
	}else{
		location.href = "/BackOffice/Empresas/Ventana_Seleccion_Buscar.asp?CACC="+LCACC+"&CVAR="+LCVAR+"&VIENEDE="+VIENEDE;
	}
}
function EmpresaEdicion(LCACC,LCEMP)
{	
	MostrarVentana(560,500,"/BackOffice/Empresas/Ventana_Empresas_General.asp?CACC="+LCACC+"&CEMP="+LCEMP);
}
function EtapaObraEdicion(LCACC,LCETP)
{
	MostrarVentana(420,200,"Etapas_General.asp?CACC="+LCACC+"&CETP="+LCETP);
}
function ObraImprimir(LCACC,COBR)
{
	MostrarImprimir(690,500,"/BackOffice/Obras/Obras_Imprimir.asp?CACC="+LCACC+"&COBR="+COBR);
}
function DCMEstadoImprimir(LCACC)
{
	MostrarImprimir(690,400,"/BackOffice/Documentos/DCM_Imprimir.asp?CACC="+LCACC);
}
function AvisosVer(LCACC,CDOC)
{
	MostrarVentana(620,400,"Ventana_Avisos_Lista.asp?CACC="+LCACC+"&CDOC="+CDOC);
}
function ContenidoPrevio(LCCTN)
{	
	MostrarImprimir(600,500,"/BackOffice/Contenidos/Ventana_Previo.asp?CCTN="+LCCTN);
}
function ContenidoMultiple(LCCTN)
{	
	var ventanaprev = showModelessDialog("/BackOffice/Contenidos/Ventana_Multiple.asp?CCTN="+LCCTN,"","dialogWidth:600px; dialogHeight:500px" );
}
function ContenidoTexto(LCACC,LCCTN,LCOBJ,VAR)
{
	MostrarVentana(620,450,"/BackOffice/Contenidos/Ventana_Textos.asp?CACC="+LCACC+"&CCTN="+LCCTN+"&COBJ="+LCOBJ+"&VVAR="+VAR);
}
function ContenidoImagen(LCACC,LCUSO,CVAR,EXT)
{
	MostrarVentana(320,450,"/BackOffice/Contenidos/Ventana_Imagenes.asp?CACC="+LCACC+"&CUSO="+LCUSO+"&CVAR="+CVAR+"&EXT="+EXT);
}
function ContenidoLink(LCACC,LCUSO,LCOBJ,EXT)
{
	MostrarVentana(320,450,"/BackOffice/Contenidos/Ventana_Links.asp?CACC="+LCACC+"&CUSO="+LCUSO+"&COBJ="+LCOBJ+"&EXT="+EXT);
}
function EnviosPrevio(LCENV,LCMOD,PREV)
{
	MostrarImprimir(700,600,"/BackOffice/Envios/Envios_Previo.asp?CENV="+LCENV+"&CMOD="+LCMOD+"&PREV="+PREV);
}
function CategoriaDocEdicion(LCACC,LDCAT)
{
	MostrarVentana(420,200,"Ventana_Categorias_General.asp?CACC="+LCACC+"&DCAT="+LDCAT);
}
function DocumentoSubir(LCACC,LCDOC,ORIGEN,DESTINO)
{
	MostrarVentana(520,400,"/BackOffice/Documentos/Ventana_Subir_Documento.asp?CACC="+LCACC+"&CDOC="+LCDOC+"&ORIGEN="+ORIGEN+"&DESTINO="+DESTINO);
}
function ListaImprimir(LCACC,LCLIS)
{
	MostrarImprimir(690,500,"/BackOffice/Listas/Listas_Imprimir.asp?CACC="+LCACC+"&CLIS="+LCLIS);
}
function ListaContenidos(LCACC,LCLIS)
{
	MostrarVentana(660,550,"/BackOffice/Listas/Ventana_Listas_Contenidos.asp?CACC="+LCACC+"&CLIS="+LCLIS);
}
function SucursalConexion(LCACC,LCEMP,LCSUC,LCVAL)
{
	MostrarVentana(460,250,"/BackOffice/Empresas/Ventana_Empresas_Conexion.asp?CACC="+LCACC+"&CEMP="+LCEMP+"&CSUC="+LCSUC+"&CVAL="+LCVAL);
}
function SucursalEliminar(LCACC,LCSUC,TEXTO)
{
	var K = confirm(TEXTO);
	if (K){window.location.href = "/BackOffice/Empresas/Eliminar_Empresas_Sucursal.asp?CACC="+LCACC+"&CSUC="+LCSUC;}
}
function SucursalEdicion(LCACC,LCEMP,LCSUC,WIZZ)
{	
	MostrarVentana(560,550,"/BackOffice/Empresas/Ventana_Empresas_Sucursal.asp?CACC="+LCACC+"&CEMP="+LCEMP+"&CSUC="+LCSUC+"&WIZZ="+WIZZ);
}
function ArchivoImprimir(LCACC,LCDOC)
{
	MostrarImprimir(690,500,"/BackOffice/Uploads/Uploads_Imprimir.asp?CACC="+LCACC+"&CDOC="+LCDOC);
}
function ArchivoEdicion(LCACC,LCUSO,LCDOC)
{
	window.location.href = "/BackOffice/Uploads/Uploads_General.asp?CACC="+LCACC+"&CDOC="+LCDOC+"&CUSO="+LCUSO;
}
function ArchivoEliminar(LCACC,LCDOC,LEN1)
{
	var K = confirm(LEN1);
	if (K){window.location.href = "/BackOffice/Uploads/Eliminar_Uploads_General.asp?CACC="+LCACC+"&CDOC="+LCDOC;}
}
function VistasPrevio(LCACC,LCVTS,ORIENTACION)
{
	MostrarVentanaBarra(770,500,"/BackOffice/Vistas/Ventana_Vistas_Previo.asp?CACC="+LCACC+"&CVTS="+LCVTS+"&ORIENTACION="+ORIENTACION);
}
function VistasEliminar(LCACC,LCVTS,LEN1)
{
	var K = confirm(LEN1);
	if (K){window.location.href = "/BackOffice/Vistas/Eliminar_Vistas_General.asp?CACC="+LCACC+"&CVTS="+LCVTS;}
}
function VistasEdicion(LCACC,LCUSO,LCVTS)
{
	location.href = "Vistas_General.asp?CACC="+LCACC+"&CVTS="+LCVTS+"&LCUSO="+LCUSO;
}
function VistasSettings(LCACC,LCUSO)
{
	MostrarVentana(320,250,"/BackOffice/Sistema/Ventana_Settings_Vistas.asp?CACC="+LCACC+"&LCUSO="+LCUSO);
}
function EdicionesVer(LCACC,LCOBJ,LCINS)
{
	MostrarVentana(420,400,"/BackOffice/Sistema/Ventana_Ediciones.asp?CACC="+LCACC+"&COBJ="+LCOBJ+"&CINS="+LCINS);
}
function BackupEdicion(LCACC,LCBCK)
{
	location.href = "Backups_General.asp?CACC="+LCACC+"&CBCK="+LCBCK;
}
function GrupoEdicion(LCACC,LCGRP)
{
	location.href = "Grupos_Resumen.asp?CACC="+LCACC+"&CGRP="+LCGRP;
}
function GrupoNuevo(LCACC)
{
	location.href = "Grupos_General.asp?CACC="+LCACC;
}
function GrupoEliminar(LCACC,LCGRP,LEN1)
{
	var K = confirm(LEN1);
	if (K){window.location.href = "Eliminar_Grupos_General.asp?CACC="+LCACC+"&CGRP="+LCGRP;}
}
function GrupoImprimir(LCACC,LCGRP)
{
	MostrarImprimir(690,500,"/BackOffice/Grupos/Grupos_Imprimir.asp?CACC="+LCACC+"&CGRP="+LCGRP);
}
function VerContenidos(LCACC,LCUSO,CVAR,PRINT)
{
	if (PRINT == 0)
	{
		MostrarVentana(600,550,"/BackOffice/Vistas/Ventana_Vistas_Contenidos.asp?CACC="+LCACC+"&CVAR="+CVAR+"&LCUSO="+LCUSO+"&PRINT="+PRINT);
	}else{
		MostrarImprimir(600,550,"/BackOffice/Vistas/Ventana_Vistas_Contenidos.asp?CACC="+LCACC+"&CVAR="+CVAR+"&LCUSO="+LCUSO+"&PRINT="+PRINT);
	}
}
function RubroEdicion(LCACC,LCUSO,CRUB)
{
	MostrarVentana(320,250,"/BackOffice/Rubros/Ventana_Rubros_General.asp?CACC="+LCACC+"&LCUSO="+LCUSO+"&CRUB="+CRUB);
}
function SubrubroEdicion(LCACC,LCUSO,CREL)
{
	MostrarVentana(320,300,"/BackOffice/Rubros/Ventana_Subrubros_General.asp?CACC="+LCACC+"&LCUSO="+LCUSO+"&CREL="+CREL);
}
function ItemEdicion(LCACC,LCUSO,CREL)
{
	MostrarVentana(320,350,"/BackOffice/Rubros/Ventana_Items_General.asp?CACC="+LCACC+"&LCUSO="+LCUSO+"&CREL="+CREL);
}
function RubrosLista(LCACC,LCUSO)
{
	MostrarVentana(640,450,"/BackOffice/Rubros/Ventana_Rubros_Lista.asp?CACC="+LCACC+"&LCUSO="+LCUSO);
}
function InformeItemEdicion(LCACC,LCINF,LCITM)
{
	MostrarVentana(420,230,"/BackOffice/Informes/Ventana_Items_General.asp?CACC="+LCACC+"&CINF="+LCINF+"&CITM="+LCITM);
}
function NovedadesPrevio(CNVD)
{	
	MostrarImprimir(630,500,"/BackOffice/Novedades/Ventana_Previo.asp?CNVD="+CNVD);
}
function InformeItemEliminar(LCACC,LCITM,LEN1)
{
	var K = confirm(LEN1);
	if (K){window.location.href = "Eliminar_Items_General.asp?CACC="+LCACC+"&CITM="+LCITM;}
}
function EnviosContenidos(LCACC)
{
	MostrarVentana(520,500,"/BackOffice/Contenidos/Ventana_Contenidos.asp?CACC="+LCACC);
}
function CambiaColorCelda(celda)
{
	for (var i=0, j=document.all.length; i<j; i++)
	{
		var Nombre = document.all(i).id;
		if (Nombre.substring(0,8) == "CeldaRes")
		{
			if (Nombre == celda)
			{
				document.all(i).className = "CeldaResaltada";
			}else{
				document.all(i).className = "";
			}
		}
			
		
	}
	
}