var xmlHttp;
var xmlHttp1;
var xmlHttp2;
var xmlHttp3;
var xmlHttp4;
var xmlHttp5;
var dependingField;
var dependingField1;
var dependingField2;
var dependingField3;
var dependingField4;
var dependingField5;
var filter;
var temas;
var strIdDiv;
var strIdScrollCall = '';
var intInstancia = 0;

function GetXmlHttpObject() 
{
	var xmlHttp;
	var xml = new Array();
	xml[0] = "MSXML2.XMLHTTP";
	xml[1] = "MSXML2.XMLHTTP.5.0";
	xml[2] = "MSXML2.XMLHTTP.4.0";
	xml[3] = "MSXML2.XMLHTTP.3.0";
	xml[4] = "Microsoft.XMLHTTP";
	xml[5] = "WinHttp.WinHttpRequest.5";
	xml[6] = "WinHttp.WinHttpRequest.5.1";
	if (window.ActiveXObject) {
		for (var i=0; i<xml.length; i++) {
		try {
			xmlHttp = new ActiveXObject(xml[i]);
			break;
		} catch(e) {
			xmlHttp = null;
		}
	}
	}else if(window.XMLHttpRequest) {
		try {
			xmlHttp = new XMLHttpRequest();
		} catch(e) {
			xmlHttp = null;
		}
	}
	return xmlHttp;
}

function GetXmlHttpObject1() 
{
	var xmlHttp1;
	var xml = new Array();
	xml[0] = "MSXML2.XMLHTTP";
	xml[1] = "MSXML2.XMLHTTP.5.0";
	xml[2] = "MSXML2.XMLHTTP.4.0";
	xml[3] = "MSXML2.XMLHTTP.3.0";
	xml[4] = "Microsoft.XMLHTTP";
	xml[5] = "WinHttp.WinHttpRequest.5";
	xml[6] = "WinHttp.WinHttpRequest.5.1";
	if (window.ActiveXObject) {
		for (var i=0; i<xml.length; i++) {
		try {
			xmlHttp1 = new ActiveXObject(xml[i]);
			break;
		} catch(e) {
			xmlHttp1 = null;
		}
	}
	}else if(window.XMLHttpRequest) {
		try {
			xmlHttp1 = new XMLHttpRequest();
		} catch(e) {
			xmlHttp1 = null;
		}
	}
	return xmlHttp1;
}

function GetXmlHttpObject2() 
{
	var xmlHttp2;
	var xml = new Array();
	xml[0] = "MSXML2.XMLHTTP";
	xml[1] = "MSXML2.XMLHTTP.5.0";
	xml[2] = "MSXML2.XMLHTTP.4.0";
	xml[3] = "MSXML2.XMLHTTP.3.0";
	xml[4] = "Microsoft.XMLHTTP";
	xml[5] = "WinHttp.WinHttpRequest.5";
	xml[6] = "WinHttp.WinHttpRequest.5.1";
	if (window.ActiveXObject) {
		for (var i=0; i<xml.length; i++) {
			try {
				xmlHttp2 = new ActiveXObject(xml[i]);
				break;
			} catch(e) {
				xmlHttp2 = null;
			}
	}
	}else if(window.XMLHttpRequest) {
		try {
			xmlHttp2 = new XMLHttpRequest();
		} catch(e) {
			xmlHttp2 = null;
		}
	}
	return xmlHttp2;
}

function GetXmlHttpObject3()
{
	var xmlHttp3;
	var xml = new Array();
	xml[0] = "MSXML2.XMLHTTP";
	xml[1] = "MSXML2.XMLHTTP.5.0";
	xml[2] = "MSXML2.XMLHTTP.4.0";
	xml[3] = "MSXML2.XMLHTTP.3.0";
	xml[4] = "Microsoft.XMLHTTP";
	xml[5] = "WinHttp.WinHttpRequest.5";
	xml[6] = "WinHttp.WinHttpRequest.5.1";
	if (window.ActiveXObject) {
		for (var i=0; i<xml.length; i++) {
		try {
			xmlHttp3 = new ActiveXObject(xml[i]);
			break;
		} catch(e) {
			xmlHttp3 = null;
		}
	}
	}else if(window.XMLHttpRequest) {
		try {
			xmlHttp3 = new XMLHttpRequest();
		} catch(e) {
			xmlHttp3 = null;
		}
	}
	return xmlHttp3;
}

function GetXmlHttpObject4() 
{
	var xmlHttp4;
	var xml = new Array();
	xml[0] = "MSXML2.XMLHTTP";
	xml[1] = "MSXML2.XMLHTTP.5.0";
	xml[2] = "MSXML2.XMLHTTP.4.0";
	xml[3] = "MSXML2.XMLHTTP.3.0";
	xml[4] = "Microsoft.XMLHTTP";
	xml[5] = "WinHttp.WinHttpRequest.5";
	xml[6] = "WinHttp.WinHttpRequest.5.1";
	if (window.ActiveXObject) {
		for (var i=0; i<xml.length; i++) {
		try {
			xmlHttp4 = new ActiveXObject(xml[i]);
			break;
		} catch(e) {
			xmlHttp4 = null;
		}
	}
	}else if(window.XMLHttpRequest) {
		try {
			xmlHttp4 = new XMLHttpRequest();
		} catch(e) {
			xmlHttp4 = null;
		}
	}
	return xmlHttp4;
}


function stateDepends1() 
{	
	if (xmlHttp1.readyState==4)
	{
		document.getElementById('Comparar').innerHTML = "";
		document.getElementById(dependingField1).innerHTML = xmlHttp1.responseText;
		window.location.href = '#topofPage';
	}
}
function stateDepends2() 
{	
	if (xmlHttp2.readyState==4)
	{
		document.getElementById('Comparar').innerHTML = "";
		document.getElementById(dependingField2).innerHTML = xmlHttp2.responseText;
		window.location.href = '#topofPage';
	}
}

function stateDepends3(){
	if (xmlHttp3.readyState==4)
	{
		document.getElementById('Comparar').innerHTML = "";
		document.getElementById(dependingField3).innerHTML = xmlHttp3.responseText;
		window.location.href = '#topofPage';
	}
}

function stateDepends4(){
	if (xmlHttp4.readyState==4)
	{
		Image1= new Image(26,20)
		Image1.src = "../images/voto_3.gif"
		Image2 = new Image(21,20)
		Image2.src = "../images/voto_1.gif"
		Image3 = new Image(21,20)
		Image3.src = "../images/voto_2.gif"
		document.getElementById(dependingField3).innerHTML = "";
		document.getElementById(dependingField4).innerHTML = xmlHttp4.responseText;
		window.location.href = '#topofMenu';
		setTimeout('ReajustarContenedor()',500);
		setInterval("ReajustarContenedor()",5000);
	}
}

function etapaA(){
	var url         = "";
	dependingField1 = "Etapa_n";
	xmlHttp1        = GetXmlHttpObject1();
	var url         = "../asp/Paso1.asp";
	var strParam    = "fFiltros="+document.form.fFiltros.value+"&fIdLeyes="+document.form.fIdLeyes.value+"&fxCat="+document.form.fxCat.value+"&fDesde="+document.form.fDesde.value+"&fHasta="+document.form.fHasta.value+"&fPeriodoDesde="+document.form.fPeriodoDesde.value+"&fPeriodoHasta="+document.form.fPeriodoHasta.value;
	variableSesion	= 'strIdSesion='+document.form.hddIdSession.value;
	
	strParam = strParam + '&' + variableSesion;
	
	if (document.form.paso1.value == 1)
		if (document.form.paso2.value == 1)
			if (document.form.paso3.value == 1)
				if (document.form.paso4.value == 1)
					PLMenu(4);
				else
					PLMenu(3);
			else
				PLMenu(2);
		else
			PLMenu(1);
	else
		PLMenu(0);
		
	//prompt('',url);
	document.getElementById(dependingField1).innerHTML = "";
	xmlHttp1.open("POST", url, true);
	xmlHttp1.onreadystatechange = stateDepends1;
	xmlHttp1.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	xmlHttp1.send(strParam);
}

function etapaB(){
	var url         = "";
	dependingField2 = 'Etapa_n';
	xmlHttp2        = GetXmlHttpObject2();
	
	var variables	= "";
	var url			= '../asp/quevoto.asp';
	variables		= 'fFiltros='+ document.form.fFiltros.value+'&fIdLeyes='+document.form.fIdLeyes.value + '&fMiVoto2=' + document.form.mivoto2.value + '&fMiVoto=' + document.form.mivoto.value + '&fPeriodoDesde=' + document.form.fPeriodoDesde.value+'&fPeriodoHasta='+document.form.fPeriodoHasta.value+'&fxCat='+document.form.fxCat.value;
	variableSesion	= 'strIdSesion='+document.form.hddIdSession.value;
	mivoto = "";
	
	variables = variables + '&' + variableSesion;
	
	document.getElementById(dependingField2).innerHTML = "";
	
	if (document.form.paso2.value == 1)
		if (document.form.paso3.value == 1)
			if (document.form.paso4.value == 1)
				PLMenu(4);
			else
				PLMenu(3);
		else
			PLMenu(2);
	else
		PLMenu(1);
	
	xmlHttp2.open("POST", url, true);
	xmlHttp2.onreadystatechange = stateDepends2;
	xmlHttp2.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	xmlHttp2.send(variables);
}

function etapaC(){
	var url         = "";
	dependingField3 = 'Etapa_n';
	xmlHttp3        = GetXmlHttpObject3();
	var variables   = "";
	
	var url			= '../asp/Paso3.asp';
	variables		= 'fDetalle='+ document.form.fDetalle.value+'&fEleccion='+document.form.fEleccion.value + '&fCargo=' + document.form.fCargo.value + '&fDistrito=' + document.form.fDistrito.value + '&fHasta='+document.form.fHasta.value+'&fLista='+document.form.fLista.value;
	variableSesion	= 'strIdSesion='+document.form.hddIdSession.value;
	
	variables = variables + '&' + variableSesion;
	
	if (document.form.paso3.value == 1)
		if (document.form.paso4.value == 1)
			PLMenu(4);
		else
			PLMenu(3);	
		
	//prompt('',url);
	document.getElementById(dependingField3).innerHTML = "";
	xmlHttp3.open("POST", url, true);
	xmlHttp3.onreadystatechange = stateDepends3;
	xmlHttp3.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	xmlHttp3.send(variables);
	PLMenu(3);
}	

function etapaD(){
	var url         = "";
	dependingField4 = 'Etapa_n';
	xmlHttp4        = GetXmlHttpObject4();
	var variables	= "";
	var url			= '../asp/Paso4.asp?id='+new Date().getTime();
	variablesPaso2	= 'fFiltros=' + document.form.fFiltros.value+'&fIdLeyes='+document.form.fIdLeyes.value + '&fMiVoto_MisVostos=' + document.form.mivoto2.value + '&fMiVoto_LeyesVotadas=' + document.form.mivoto.value + '&fPeriodoDesde=' + document.form.fPeriodoDesde.value+'&fPeriodoHasta='+document.form.fPeriodoHasta.value+'&fxCat='+document.form.fxCat.value;
	variablesPaso3	= 'fDetalle='+ document.form.fDetalle.value+'&intIdEleccion='+document.form.fEleccion.value + '&intIdCargo=' + document.form.fCargo.value + '&intIdDistrito=' + document.form.fDistrito.value + '&intIdLista=' + document.form.fLista.value;
	variableSesion	= 'strIdSesion='+document.form.hddIdSession.value;
	
	variables = variablesPaso2 + '&' + variablesPaso3 + '&' + variableSesion;
	
	if (document.form.paso3.value == 1)
		if (document.form.paso4.value == 1)
			PLMenu(4);
		else
			PLMenu(3);
	
	xmlHttp4.open("POST", url, true);
	xmlHttp4.onreadystatechange = stateDepends4;
	xmlHttp4.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	document.getElementById(dependingField3).innerHTML = "";
	document.getElementById(dependingField4).innerHTML = "";	
	document.getElementById(dependingField4).innerHTML = "<table border='0' cellspacing='0' cellpadding='0' align='center'><tr><td align='center'><img src='../images/ajax-loader.gif' style='height:30px;width:30px;' /></td></tr><tr><td style='padding:5px;' align='center'><B>Procesando...</B><BR><BR>Esperá un instante, esto puede tardar varios segundos</td></tr></table>";
	PLMenu(4);
	xmlHttp4.send(variables);
}

function IrPaso2(){
	var strCategorias	= "";
	var strPeriodos		= ""
	var conec    		= "";
	var seguir   		= "false";
	isChecked    		= "false";	
	var fFiltros 		= 4;
	var strDesde		= "";
	var strHasta		= "";
	var dtmDesde		= "";
	var dtmHasta		= "";
	
	//====== GUARDO LAS CATEGORIAS SELECCIONADAS ======
	for (i = 0;i < document.form.xCat.length;i++){
		if (document.form.xCat[i].checked == true){
			strCategorias = strCategorias + conec + document.form.xCat[i].value;
			conec = ",";
		}
	}
	document.form.fxCat.value = strCategorias;
	conec = "";
	
	//====== GUARDO LOS PERIODOS LEGISLATIVOS SELECCIONADOS ======
	for (i = 0;i < document.form.Hasta.length;i++){
		if (document.form.Hasta[i].checked == true){
			strPeriodos = strPeriodos + conec + document.form.Hasta[i].value;
			conec = ",";
		}
	}
	document.form.fHasta.value = strPeriodos;
	conec = "";
	
	//====== GUARDO LOS PERIODOS LEGISLATIVOS SELECCIONADOS (YA ARMADOS CON FECHAS) ======
	for (i = 0;i < document.form.Hasta.length;i++){
		if (document.form.Hasta[i].checked == true){
			dtmDesde = '10/12/' + document.form.Hasta[i].value;
			dtmHasta = '09/12/' + (parseInt("2")+parseInt(document.form.Hasta[i].value));
			strDesde = strDesde + conec + dtmDesde;
			strHasta = strHasta + conec + dtmHasta;
			conec = ",";
		}
	}
	document.form.fPeriodoDesde.value = strDesde;
	document.form.fPeriodoHasta.value = strHasta;
	
	if (EligeLeyes() == false){
		return false;
	}
	
	if (document.form.fIdLeyes.value != ""){
		document.form.fFiltros.value = fFiltros;
		seguir = "true";
	}
	
	if (seguir == "true"){
		document.form.mivoto2.value	= '';
		document.form.mivoto.value	= '';
		PLMenu(1);
		etapaB();
	}else if (seguir == "false") {
		alert("Seleccioná algún filtro para poder continuar");
	}else{
		return false;
	}
}

function IrPaso3(cant)
{
	var aux = new Array();
	var aux3 = 0;
	
	if (document.form.mivoto.value != ''){
		aux = document.form.mivoto.value.split(",");
		aux3 = parseInt(aux.length);
	}
	if (aux3 == 0){
		alert('Votá las leyes seleccionadas para poder continuar');
	}else{
		PLMenu(3);
		etapaC();
	}
}

function IrPaso4()
{
	var fDetalle = 0;
	
	for (i = 0;i < document.form.Detalle.length;i++){
		if (document.form.Detalle[i].checked == true){
				fDetalle = document.form.Detalle[i].value;
		}
	}
	document.form.fDetalle.value = fDetalle;
	
	if (fDetalle == 0){
		alert("Seleccioná una forma de visualizar antes de continuar.");
	}
	else{
		if (document.getElementById('chkIncCandidatos').checked == true){
			document.form.slcEleccion.value = document.getElementById('chkIncCandidatos').value;
		}else{
			if(document.form.slcEleccion.value == document.getElementById('chkIncCandidatos').value){
				document.form.slcEleccion.value = '';
			}
		}
		for (i = 0;i < document.form.slcCargo.length;i++){
			if (document.form.slcCargo[i].selected == true){
				document.form.fCargo.value = document.form.slcCargo[i].value;
			}
		}
		for (i = 0;i < document.form.slcDistrito.length;i++){
			if (document.form.slcDistrito[i].selected == true){
				document.form.fDistrito.value = document.form.slcDistrito[i].value;
			}
		}
		for (i = 0;i < document.form.slcEleccion.length;i++){
			if (document.form.slcEleccion[i].selected == true){
				document.form.fEleccion.value = document.form.slcEleccion[i].value;
			}
		}
		for (i = 0;i < document.form.slcLista.length;i++){
			if (document.form.slcLista[i].selected == true){
				document.form.fLista.value = document.form.slcLista[i].value;
			}
		}
		PLMenu(4);
		etapaD();	
	}
}

function FinPaso4()
{
	document.form.paso4.value = 1;
}

function ASeleccionManual()
{	
	wohin  = '/QEV/asp/SeleccionManual.asp?fIdLeyes='+document.form.fIdLeyes.value;
	remote = window.open(wohin, 'Finder','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=700,height=500')
	if (navigator.appVersion.indexOf("(X11") != -1) window.open(wohin,'Finder')
}

function ATildar(idcheckbox)
{	
	if(document.getElementById(idcheckbox).checked == true)
	{
		document.getElementById('temacheckbox').value = parseInt(document.getElementById('temacheckbox').value) + 1;
		document.form.fTema.checked = true;
	}
	else if(document.getElementById(idcheckbox).checked == false)
	{
		document.getElementById('temacheckbox').value = parseInt(document.getElementById('temacheckbox').value) - 1;
		if (document.getElementById('temacheckbox').value == 0)
			document.form.fTema.checked = false;	
	}
}

function ADestildar(idcheckbox)
{
	document.getElementById('fTema').checked = false;
	document.getElementById('fOpuestas').checked = false;
	document.getElementById('fPeriodo').checked = false;
}
function show_hide(idx)
{
	var element;
	
	element = document.getElementById(idx).style;
	if (element.display == "none")
	{
		element.display = "";		
	}
	else if (element.display == "")
	{
		element.display = "none";
	}
	document.form.fFiltros[0].checked = true;
}

function show_hide2()
{
	document.form.fFiltros[0].checked = true;
}

function Votar()
{	
	wohin = '../asp/QueVoto.asp?fFiltros=' + document.form.fFiltros.value + '&fIdLeyes=' + document.form.fIdLeyes.value + '&fDesde=' + document.form.fDesde.value + '&fHasta='+ document.form.fHasta.value;
	remote = window.open(wohin, 'Finder','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=700,height=500')
	if (navigator.appVersion.indexOf("(X11") != -1) window.open(wohin,'Finder')
}

function Tildar()
{
	if (document.form.fEleccion.value!='')
	{
		document.form.fPeriodoElectoral.checked = true;
	}
	if (document.form.fDistrito.value!='')
	{
		document.form.fPorDistrito.checked = true;
	}
}

function TildarCargo(idcheckbox)
{	
	if(document.getElementById(idcheckbox).checked == true)
	{
		document.getElementById('cargocheck').value = parseInt(document.getElementById('cargocheck').value) + 1;
		document.form.fCargo.checked = true;
	}
	else if(document.getElementById(idcheckbox).checked == false)
	{
		document.getElementById('cargocheck').value = parseInt(document.getElementById('cargocheck').value) - 1;
		if (document.getElementById('cargocheck').value == 0)
			document.form.fCargo.checked = false;		
	}
}

function VerResultado()
{
	isChecked = false;
	for(r=0;r<=2;r++)
	{ if(document.form.fDetalle[r].checked)
		isChecked = true;
	}
	if (!isChecked)
	{	alert("Seleccioná detalle");
		return false;
	}
	document.form.action='../asp/Comparar.asp'
	document.form.submit();
	//etapaD();
}

function VerResultado()
{	
	document.form.senal.value=1;
	document.form.submit();
}

function PLMenu(xId)
{
	var url         = "";
	dependingField5 = "PLMenu";
	xmlHttp5        = GetXmlHttpObject5();
	var url         = "../asp/PrincipalesLeyes_menu.asp";
	var strParam    = "fmenuState="+xId;
	
	//prompt('',url);
	document.getElementById(dependingField5).innerHTML = "";
	xmlHttp5.open("POST", url, true);
	xmlHttp5.onreadystatechange = stateDepends5;
	xmlHttp5.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	xmlHttp5.send(strParam);
}

function GetXmlHttpObject5()
{
	var xmlHttp5;
	var xml = new Array();
	xml[0] = "MSXML2.XMLHTTP";
	xml[1] = "MSXML2.XMLHTTP.5.0";
	xml[2] = "MSXML2.XMLHTTP.4.0";
	xml[3] = "MSXML2.XMLHTTP.3.0";
	xml[4] = "Microsoft.XMLHTTP";
	xml[5] = "WinHttp.WinHttpRequest.5";
	xml[6] = "WinHttp.WinHttpRequest.5.1";
	if (window.ActiveXObject) {
		for (var i=0; i<xml.length; i++) {
		try {
			xmlHttp5 = new ActiveXObject(xml[i]);
			break;
		} catch(e) {
			xmlHttp5 = null;
		}
	}
	}else if(window.XMLHttpRequest) {
		try {
			xmlHttp5 = new XMLHttpRequest();
		} catch(e) {
			xmlHttp5 = null;
		}
	}
	return xmlHttp5;
}

function stateDepends5()
{
	if (xmlHttp5.readyState==4)
	{
		document.getElementById(dependingField5).innerHTML = "";
		document.getElementById(dependingField5).innerHTML = xmlHttp5.responseText;
	}
}

function scrollSecciones(IdDiv){
	strIdDiv = IdDiv
	if (strIdScrollCall!=''){
		clearTimeout(strIdScrollCall)
	}
	//strIdScrollCall = setTimeout(EjecutarScrollSecciones,25);
}	

function verTemas(xId)
{
	if (document.getElementById(xId).checked == true)
		SelectToCheck('fTema_Categorias','');
	else
		selectO(0);
}
var mivoto = "";

function YaVote()
{
	var fAFavor     = 0;
	var fEnContra   = 0;
	var fIndistinta = 0;
	var check       = 0;
	var votos       = "";
	var conector    = "";
	var totalvotos = parseInt(document.form.voto.length);
	
	for(i=0;i<totalvotos;i++)
	{
		if (document.form.voto[i].checked)
		{
			votos = document.form.voto[i].value;
			check += 1;
			if (document.form.voto[i].value == 1)
				fAFavor += 1;
			else if (document.form.voto[i].value == 2)
				fEnContra += 1;
			else if (document.form.voto[i].value == 3)
				fIndistinta += 1;
		}
	}
	/*alert("total de leyes:"+(totalvotos/3));
	alert("A Favor: "+fAFavor+" En Contra: "+fEnContra+" Abstenciones: "+fIndistinta);*/
	
	if (check == (totalvotos/3))
	{
		self.opener.document.form.fAFavor.value     = fAFavor;
		self.opener.document.form.fEnContra.value   = fEnContra;
		self.opener.document.form.fIndistinta.value = fIndistinta;
		self.opener.document.form.mivoto.value      = mivoto;
		window.close();
	}
	else
	{
		alert('<%=LabelTXT("Tenes que votar todas las leyes seleccionadas")%>.');
	}
}

function verPeriodo()
{
	document.getElementById('Periodo').style.display = '';	
}

function miVoto(IdLey,Voto)
{
	var aux  = new Array();
	var cant = 0;
		
	aux = document.form.mivoto.value.split(",");
	aux2 = document.form.mivoto2.value.split(',');
	
	for (i = 0;i < aux.length;i++){
		if (aux[i] == IdLey){
			aux2[i] = Voto;
			cant = 1;
		}
	}
	if (cant != 1){
		if (document.form.mivoto.value == ''){
			document.form.mivoto.value = document.form.mivoto.value + IdLey;
			document.form.mivoto2.value = document.form.mivoto2.value + Voto;
		}
		else{
			document.form.mivoto.value = document.form.mivoto.value + "," + IdLey;
			document.form.mivoto2.value = document.form.mivoto2.value + "," + Voto;
		}
	}else{
		var cx = "";
		document.form.mivoto.value = "";
		document.form.mivoto2.value = "";
		for(i=0;i<aux.length;i++){
			document.form.mivoto.value = document.form.mivoto.value + cx + aux[i];
			document.form.mivoto2.value = document.form.mivoto2.value + cx + aux2[i];
			cx = ",";
		}
	}
	document.getElementById('Ley_'+IdLey).value = Voto;
}

function DeseleccionarRadio()
{	
	for (i = 0;i < document.form.Filtros.length;i++)
	{
		if (document.form.Filtros[i].checked == true)
		{
			if (i == 0)
				document.getElementById('cat').style.display = 'none';
			document.form.Filtros[i].checked = false;
		}
	}	
}

function verCategorias()
{
	document.getElementById('cat').style.display = '';
}

function ViewDetail(Politico)
{
	wohin = '../asp/DetalleLegislador.asp?IdPolitico='+Politico;
	remote = window.open(wohin, 'Finder','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=800,height=550')
	if (navigator.appVersion.indexOf("(X11") != -1) window.open(wohin,'Finder')
}

function ViewDetailPartido(IdPartido)
{
	wohin = '../asp/DetallePartido.asp?IdPartido='+IdPartido;
	remote = window.open(wohin, 'Finder','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=700,height=550')
	if (navigator.appVersion.indexOf("(X11") != -1) window.open(wohin,'Finder')
}

function DetalleLey(Ley)
{
	wohin = '../asp/DetalleLey.asp?IdLey='+Ley;
	remote = window.open(wohin, 'Finder1','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=620,height=375')
	if (navigator.appVersion.indexOf("(X11") != -1) window.open(wohin,'Finder')
}

function verSeleccionManual()
{
	document.getElementById('SeleccionManual').style.display = '';
}

function EligeLeyes()
{
	var fIdLeyes, conector, fIdLeyes ;
	fIdLeyes = "";
	conector ="";
	select=document.getElementsByName("select");
	
	for (i=0;i<document.form.cant.value;i++)
	{
		if(select[i].checked){
			fIdLeyes=fIdLeyes+conector+select[i].value;
			conector = ",";
		}
	}
	if (fIdLeyes==''){alert("No seleccionaste ninguna ley, seleccioná alguna para poder continuar");return false;}
	document.form.fIdLeyes.value = fIdLeyes;
	//self.opener.document.form.senal.value = '1';	
	//window.close();
}

function ocultarDivP1(IdFiltro)
{
	if (IdFiltro == 1){
		document.getElementById('Periodo').style.display         = 'none';
		document.getElementById('SeleccionManual').style.display = 'none';
	}else if (IdFiltro == 2){
		document.getElementById('cat').style.display             = 'none';
		document.getElementById('Periodo').style.display         = 'none';
		document.getElementById('SeleccionManual').style.display = 'none';
	}else if (IdFiltro == 3){
		document.getElementById('cat').style.display             = 'none';
		document.getElementById('Periodo').style.display         = 'none';
		document.getElementById('SeleccionManual').style.display = 'none';
	}else if (IdFiltro == 4){
		document.getElementById('Periodo').style.display = 'none';
		document.getElementById('cat').style.display     = 'none';
	}else if (IdFiltro == 5){
		document.getElementById('cat').style.display             = 'none';
		document.getElementById('SeleccionManual').style.display = 'none';
	}
}

function getListas(IdEleccion,idDistrito){
	var url         = "";
	dependingField	= "divSlcLista";
	xmlHttp			= GetXmlHttpObject();
	var url         = "../asp/getPrincipalesLeyes.asp?id="+new Date().getTime();
	var strParam    = "Campo=Lista&Valor="+idDistrito+"&IdEleccion="+IdEleccion;
	
	//prompt('',url);
	xmlHttp.open("POST", url, true);
	xmlHttp.onreadystatechange = stateDependsListas;
	xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	xmlHttp.send(strParam);
}

function getDistrito(idEleccion){
	var url         = "";
	dependingField	= "divSlcDistrito";
	xmlHttp			= GetXmlHttpObject();
	var url         = "../asp/getPrincipalesLeyes.asp?id="+new Date().getTime();
	var strParam    = "Campo=Distrito&Valor="+idEleccion;
	
	//prompt('',url);
	xmlHttp.open("POST", url, true);
	xmlHttp.onreadystatechange = stateDepends;
	xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	xmlHttp.send(strParam);
}

function getCargo(IdEleccion,idDistrito){
	var url         = "";
	dependingField	= "divSlcCargo";
	xmlHttp			= GetXmlHttpObject();
	var url         = "../asp/getPrincipalesLeyes.asp?id="+new Date().getTime();
	var strParam    = "Campo=Cargo&Valor="+idDistrito+"&IdEleccion="+IdEleccion;
	
	//prompt('',url);
	xmlHttp.open("POST", url, true);
	xmlHttp.onreadystatechange = stateDependsCargo;
	xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	xmlHttp.send(strParam);
}

function stateDepends(){
	if (xmlHttp.readyState==4){
		document.getElementById(dependingField).innerHTML = xmlHttp.responseText;
	}
}

function stateDependsCargo(){
	if (xmlHttp.readyState==4){
		document.getElementById(dependingField).innerHTML = xmlHttp.responseText;
	}
}

function stateDependsListas(){
	if (xmlHttp.readyState==4){
		document.getElementById(dependingField).innerHTML = xmlHttp.responseText;
		getCargo(document.form.slcEleccion.value,document.form.slcDistrito.value);
	}
}

function MostrarAyuda(){
	if (document.getElementById('DivAyuda').style.display == 'none'){
		document.getElementById('DivAyuda').style.display = '';
	}else{
		document.getElementById('DivAyuda').style.display = 'none';
	}
}

function AchicarContenedor(){
	if (parseInt(document.getElementById('DivScrollable').style.height) > 100){
		document.getElementById('DivScrollable').style.height = parseInt(document.getElementById('DivScrollable').style.height) - 100;
	}
}

function AgrandarContenedor(){
	document.getElementById('DivScrollable').style.height = parseInt(document.getElementById('DivScrollable').style.height) + 100;
}

function ReajustarContenedor(){
	if (document.getElementById('DivScrollable')){
		if (intInstancia == 0){
			document.getElementById('DivScrollable').style.height = parseInt(document.getElementById('DivScrollable').style.height) + 1;
			intInstancia = 1;
		}else{
			document.getElementById('DivScrollable').style.height = parseInt(document.getElementById('DivScrollable').style.height) - 1;
			intInstancia = 0;
		}
	}
}

function ajustarDivComparacion(){
	if (document.getElementById('DivScrollable')){
		AgrandarContenedor();
		AchicarContenedor();
	}
}

function selaccionarTodasLeyesIndistintas(){
	
	document.getElementById('mivoto').value = document.getElementById('LeyesPaso2').value;
	document.getElementById('mivoto2').value = document.getElementById('VotosPaso2').value;
}

function mostrarFiltrosCondidatos(){
	if (document.getElementById('DivFiltrosCondidatos').style.display == 'none'){
		document.getElementById('DivFiltrosCondidatos').style.display = '';
	}else{
		document.getElementById('DivFiltrosCondidatos').style.display = 'none';
	}
}

function selectTilde(IdEleccion){
	if (document.getElementById('chkIncCandidatos').value == IdEleccion){
		document.getElementById('chkIncCandidatos').checked = true;
	}else{
		document.getElementById('chkIncCandidatos').checked = false;
	}
}

function ActualizarLista(){
	var url         	= "";
	var strCategorias	= "&Categorias=";
	var strDesde		= "&Desde=";
	var strHasta		= "&Hasta=";
	var strConector		= "";
	var dtmHasta		= "";
	var dtmDesde		= "";
	dependingField		= "SeleccionManual";
	xmlHttp				= GetXmlHttpObject();
	var url         	= "../asp/getPrincipalesLeyes.asp?id="+new Date().getTime();
	var strParam    	= "Campo=ListaLeyes";
	
	for (i = 0;i < document.form.xCat.length;i++){
		if (document.form.xCat[i].checked == true){
			strCategorias = strCategorias + strConector + document.form.xCat[i].value;
			strConector = ",";
		}
	}
	strConector = "";
	
	for (i = 0;i < document.form.Hasta.length;i++){
		if (document.form.Hasta[i].checked == true){
			dtmDesde = '10/12/' + document.form.Hasta[i].value;
			dtmHasta = '09/12/' + (parseInt("2")+parseInt(document.form.Hasta[i].value));
			strDesde = strDesde + strConector + dtmDesde;
			strHasta = strHasta + strConector + dtmHasta;
			strConector = ",";
		}
	}
	
	strParam = strParam + strCategorias + strDesde + strHasta;
	
	//prompt('',url);
	xmlHttp.open("POST", url, true);
	xmlHttp.onreadystatechange = stateDepends;
	xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	xmlHttp.send(strParam);
}

function SelectAllChecks(id){
	selectAll		= document.getElementById(id).checked;
	checkboxes	= document.getElementsByName("select");
	
	if (selectAll){
		for (i=0;i<checkboxes.length;i++){
			checkboxes[i].checked = true;
		}
	}else{
		for (i=0;i<checkboxes.length;i++){
			checkboxes[i].checked = false;
		}
	}
}