// JavaScript Document
//Agregar a favoritos
	function agregar(){
		if ((navigator.appName=="Microsoft Internet Explorer") && (parseInt(navigator.appVersion)>=4)) {
			var url="http://www.cens.com.co/"; 
			var titulo="::: CENS S.A. E.S.P. :::";
			window.external.AddFavorite(url,titulo);
		}
		else { 
			if(navigator.appName == "Netscape") 
				alert("Presione Crtl+D para agregar este sitio a sus Favoritos."); 
		}
	}
//Establecer como pagina de inicio diferente a Explorer
	function ini() {
		var browsName = navigator.appName;
		if (browsName == "Microsoft Internet Explorer") {
			alert ("Gracias por seleccionarnos como su página de inicio en su navegador.");
		} else
		if (browsName == "Netscape") {
			alert ("\nPara poner www.cens.com.co como su página de inicio desde Mozilla Firefox:\n\n- Abra el menú Herramientas (Tools), submenu Opciones (Options).\n- Seleccione la pestaña General (General).\n- En Página de Inicio (Home Page) haga clic en el botón Usar Página Actual (Use Current Page).\n- Una vez hecho esto, pulse OK.\n\nGracias por dejarnos ser su página de inicio en su navegador.");
		} else
			alert ("\nPara poner www.cens.com.co como su página de inicio:\n\n- Consulta las instrucciones de su navegador\n\nGracias por dejarnos ser su página de inicio en su navegador.");
	}

//Funcion para tarifas.asp
	function GoMeans() {
		ocultartodas();
		valor = document.all("lstMeans").value;
		document.all('v' + valor).style.display = "" 
	}
	
	function ocultartodas() {
		for (i=1;i<=28;i++) {
			document.all("v" + i).style.display = "none";
		}
	}

//Popup
	function MM_openBrWindow(theURL,winName,features) { //v2.0
		window.open(theURL,winName,features);
	}
//Muestra las preguntas frecuentes
	function change(obj)
	{
	//alert("change");
	obj = obj.replace(" ","");
		if(document.all(obj).style.display == 'none')
		{
			document.all(obj).style.display = 'block';
			document.all(obj).focus;
		}
		else
		{
			document.all(obj).style.display = 'none';
			document.all(obj).focus;
		}
	}
	
//Busqueda en Google	
	function searchbygoogle(text)
	{
		/*this.method = "Get";
		this.action="http://www.google.com.co/custom?hl=es&q="+text ;
		this.target="_blank";q=tanuzi&sitesearch=www.industriastanuzi.com&hl=es*/
		window.open("http://www.google.com.co/custom?hl=en&domains=http%3A%2F%2Fwww.cens.com.co&sa=Search&sitesearch=www.cens.com.co&lr=lang_es&cof=L%3Ahttp%3A%2F%2Fwww.cens.com.co%2Fimages%2Flog_admin.png%3BAWFID%3Ab092bd86f7b55508%3B&q="+text,"","");
	}

//Busqueda de Personas del directorio.
	function DoSearch(n) {
		if (n==0) {
			document.all("SearchType").value = 0;
			document.all("RequestMode").value = "Show";
			document.all("btnSubmit").click();
		}
		else {		//Search
			if (document.all("txtSearchString").value=="") {
				if (document.all("optSearchDepartment").checked==true) {
					alert("Escriba el nombre de la dependencia que desea buscar");
				}
				else {
					alert("Escriba el nombre del funcionario que desea buscar");
				}
				document.all("txtSearchString").focus();
			}
			else {
				if (document.all("optSearchDepartment").checked==true) {
					document.all("SearchType").value = 1;	//Serach department
				}
				else {
					document.all("SearchType").value = 2;	//Search employee
				}
				document.all("RequestMode").value = "Search";
				document.all("btnSubmit").click();
			}
		}
	}
	
//FUNCIONES DE GRANDES CLIENTES
	function DoClick1() {
		var sFeatures = "height:400px; width:505px;";
		var f = document.form1, i;
		var valor = "";
		for(i=0;i<document.form1.rdTypeConsume.length;i++)
			if(document.form1.rdTypeConsume[i].checked) {
				valor = document.form1.rdTypeConsume[i].value;
			}
		valor_1 = "";
		for(i=0;i<document.form1.rdShowType.length;i++)
			if(document.form1.rdShowType[i].checked) {
				valor_1 = document.form1.rdShowType[i].value;
			}
		var sPage = "gcshowconsume.asp?ConsumeDate=" + document.all("lstMonthsConsume").value + "&bill=" + document.all("bill").value + "&gc=" + document.all("gcEnterprise").value + "&Consume=" + valor + "&type=" + valor_1;
		if (valor == 3)
		{
			sPage = "factura.asp?ConsumeDate=" + document.all("lstMonthsConsume").value + "&bill=" + document.all("bill").value;
		}
		window.open(sPage);
	}

	function DoClick2() {
		valor_1 = "";
		var valor = "";
		for(i=0;i<document.form1.rdTypeTariff.length;i++)
			if(document.form1.rdTypeTariff[i].checked) {
				valor = document.form1.rdTypeTariff[i].value;
			}
		for(i=0;i<document.form1.rdShowType.length;i++)
			if(document.form1.rdShowType[i].checked) {
				valor_1 = document.form1.rdShowType[i].value;
			}
		if (valor == 0)
		{
			//alert("Para esta opción solo se muestra la tabla");
			sPage  = "ReguladavsNoRegulada.asp?ConsumeDate=" + document.all("lstMonthsTariff").value + "&bill=" + document.all("bill").value + "&gc=" + document.all("gcEnterprise").value;
		}
		if (valor == 2)
		{
		var sPage = "gcshowtarifa.asp?fecha=" + document.all("lstMonthsTariff").value + "&bill=" + document.all("bill").value + "&tipo=" + document.all("componente").value + "&type=" + valor_1 + "&gc=" + document.all("gcEnterprise").value;
		}
		if (valor == 1)
		{
		var sPage = "gcshowliquidacionac.asp?fecha=" + document.all("lstMonthsTariff").value + "&bill=" + document.all("bill").value + "&tipo=" + document.all("componente").value + "&type=" + valor_1 + "&gc=" + document.all("gcEnterprise").value;
		}
		if (valor == 3)
		{
		var sPage = "gcshowliquidacionre.asp?fecha=" + document.all("lstMonthsTariff").value + "&bill=" + document.all("bill").value + "&tipo=" + document.all("componente").value + "&type=" + valor_1 + "&gc=" + document.all("gcEnterprise").value;
		}
		if (valor == 4)
		{
			sPage = "factura1.asp?ConsumeDate=" + document.all("lstMonthsTariff").value + "&bill=" + document.all("bill").value;
		}
		window.open(sPage);
	}
	
	
	
	
	function IrA(strObj){
	if(strObj=="") 
	alert("Debe Seleccionar un tipo de cuenta");
	else {
	var obj = eval("(" +strObj+ ")");
 	var wnd = window.open(obj.url,'Bancos',obj.opt);
	wnd.focus();}
	return false;
	}
	
	
	function getCheckedValue(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}

// set the radio button with the given value as being checked
// do nothing if there are no radio buttons
// if the given value does not exist, all the radio buttons
// are reset to unchecked
function setCheckedValue(radioObj, newValue) {
	if(!radioObj)
		return;
	var radioLength = radioObj.length;
	if(radioLength == undefined) {
		radioObj.checked = (radioObj.value == newValue.toString());
		return;
	}
	for(var i = 0; i < radioLength; i++) {
		radioObj[i].checked = false;
		if(radioObj[i].value == newValue.toString()) {
			radioObj[i].checked = true;
		}
	}
}

function DoVerify() {
	if (document.all("txtAccount").value=="") {
		alert("No escribió ningún número de usuario.")
		document.all('txtAccount').focus();
	}
	else {
		if (IsNumeric(document.all("txtAccount").value)==false) {
			alert("Por favor, escriba solo números.");
			document.all('txtAccount').value = "";
			document.all('txtAccount').focus();
		}
		else {
			var url = 'http://www.cens.com.co/factura3/factura.asp?usuario=' + document.all("txtAccount").value;
			window.open(url, '', 'width=800,height=600,scrollbars=yes');
		}
	}
}

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;
   
   }