//var desplegarTodos = true;


function nuevaVentana (sPath, sTitulo, sPropiedades){
	window.open(sPath, sTitulo, sPropiedades);
}

function MM_openBrWindow(theURL,winName,features) {
  window.open(theURL,winName,features);
}

function crearRowsArray (oTabla){
  var rows = new Array();
  var r = 0;
  var r1;
  
  for (r1 = 0; r1 < oTabla.rows.length; r1++, r++)
  	rows[r] = oTabla.rows[r1];
  	
  return rows;
}


function mostrarTodos(sIdTabla, oTD){
	var oTabla = document.getElementById(sIdTabla);
	var aRows = crearRowsArray(oTabla);
	
	var blnOperacion = (oTD.firstChild.data == "Desplegar todos");
	
	for (i = 0; i < aRows.length; i++){
		str = aRows[i].id.toString();
		size = str.length - 1;
		if (str != "" && str.substr(size,1) == 1){
			str = str.substr(0, size);
			mostrarYOcultar(str, blnOperacion);
		}
	}

	if (blnOperacion)
		oTD.firstChild.data = "Ocultar todos";
	else
		oTD.firstChild.data = "Desplegar todos";
}

function mostrarYOcultar(sIdSeccion, blnModo){
	if (sIdSeccion.substr(0,4) == "secc")
		blnSeccionPpal = false;
	else
		blnSeccionPpal = true;

	if (blnModo){
		hideItem(sIdSeccion + "1");
		showItem(sIdSeccion + "2");
		if (!blnSeccionPpal)
			showItem(sIdSeccion + "3");
	} else {
		hideItem(sIdSeccion + "2");
		if (!blnSeccionPpal)
			hideItem(sIdSeccion + "3");	
		showItem(sIdSeccion + "1");
	}	
}

function show (oItem) {
	oItem.style.visibility ='visible';
	oItem.style.display = ''; // Es lo mismo que decirle style.display = 'block'
}

function showItem (sIdItem) {
	oItem = document.getElementById(sIdItem);
	show(oItem);
}

function showIfRadioSelected () {
	// Esta funcion es para el listado de estadisticas, que segun
	// que radio button este seleccionado al cargar la pagina tengo
	// que mostrar o no el bloque del filtro

	for(var i = 0;i < 4;i++){
		oItem = document.frmEstadisticas.tipoAccion[i];

		if(oItem.checked == true){
			if(oItem.value == 2 || oItem.value == 3 || oItem.value == 4){
				if(oItem.value == 2){
					show(document.getElementById('td_filtro_rubro_region'));	
				}
				if(oItem.value == 3){
					show(document.getElementById('td_filtro'));						
				}
				if(oItem.value == 4){
					show(document.getElementById('td_filtro'));						
				}

			} else {
				hide(document.getElementById('td_filtro'));	
				hide(document.getElementById('td_filtro_rubro_region'));
			}
		}
	}
}

function hide (oItem) {
	oItem.style.visibility ='hidden';
	oItem.style.display = 'none';
}

function hideItem (sIdItem) {
	oItem = document.getElementById(sIdItem);
	hide(oItem);
}

function obtenerMes(iMes){
	var sMes = "";
	switch(iMes){
		case 1: 
			sMes = "Enero"; 
			break;
		case 2:
			sMes = "Febrero"; 
			break;
		case 3:
			sMes = "Marzo"; 
			break;
		case 4:
			sMes = "Abril"; 
			break;
		case 5:
			sMes = "Mayo"; 
			break;
		case 6:
			sMes = "Junio"; 
			break;
		case 7:
			sMes = "Julio"; 
			break;
		case 8:
			sMes = "Agosto"; 
			break;
		case 9:
			sMes = "Septiembre"; 
			break;
		case 10:
			sMes = "Octubre"; 
			break;
		case 11:
			sMes = "Noviembre"; 
			break;
		case 12:
			sMes = "Diciembre"; 
			break;
	}
	return sMes;
}

function obtenerDia(iDia){
	var sDia = "";
	switch(iDia){
		case 0: 
			sDia = "Domingo";
			break;
		case 1: 
			sDia = "Lunes";
			break;
		case 2: 
			sDia = "Martes";
			break;
		case 3: 
			sDia = "Mi&eacute;rcoles";
			break;
		case 4: 
			sDia = "Jueves";
			break;
		case 5: 
			sDia = "Viernes";
			break;
		case 6: 
			sDia = "S&aacute;bado";
			break;
	}
	return sDia;
		
}

function imprimirFecha(){
	var mydate = new Date();
	var year = mydate.getYear();
	if (year < 1000)
		year+=1900;
	var day = mydate.getDay();
	var month = mydate.getMonth()+1;
	var daym = mydate.getDate();
	var sMes = obtenerMes(month);
	var sDia = obtenerDia(day);
	document.write(daym + "/" + month + "/" + year + "&nbsp;&nbsp;");
}
/************ captura de datos bancos ************/

function change_check(id){
	if(document.getElementById(id).checked)
		document.getElementById(id).value='s';
	else	
		document.getElementById(id).value='n';
}
function addOption(selectbox,text,value )
{
var optn = document.createElement("OPTION");
optn.text = text;
optn.value = value;
selectbox.options.add(optn);
}

function changeTipoDoc(sexo)
{
	arrTipoDoc = document.formContactenos.strTipoDocumento;
	
	if(sexo.value == "Masculino"){
		for(i=0;i < arrTipoDoc.length;i++){
			if(arrTipoDoc.options[i].value == "Lib. Cívica")
			   arrTipoDoc.remove(i);
		}
	}
	else
	{
		var encontre=false;
		for(i=0;i < arrTipoDoc.length;i++)
		{
			if(arrTipoDoc.options[i].value == "Lib. Cívica")
				encontre=true;
		}
				
		if(encontre==false)
			addOption(arrTipoDoc,'Lib. Cívica',"Lib. Cívica");	
	
	}

}

function changeSexo(tipoDoc){
	arrSexo = document.formContactenos.strSexo;
	if(tipoDoc.value == 'Lib. Cívica'){
		for(i=0;i < arrSexo.length;i++)
			if(arrSexo.options[i].value == 'Masculino')
			   arrSexo.remove(i);  
	}
	else{
	var encontre=false;
	for(i=0;i < arrSexo.length;i++)
			if(arrSexo.options[i].value == 'Masculino')
				encontre=true;
	if(encontre==false)
		addOption(arrSexo,'Masculino','Masculino');			
		
	}
	 /*if((arrSexo.selectedIndex == 0) && (arrSexo.length == 2))
				addOption(arrSexo,'Masculino',1);*/
	
}



