//FUNCIONES GENERALES
var bloque = 0;
var existe =0;
var bloquevisible = 0;
var nombreASP= "";


		//*******************FUNCIONES PARA AJAX *************
var XMLHttpRequestObject_infoCandidato = false;

if (window.XMLHttpRequest) {
	XMLHttpRequestObject_infoCandidato = new XMLHttpRequest(); 		
}
else if (window.ActiveXObject) {
	XMLHttpRequestObject_infoCandidato = new ActiveXObject("Microsoft.XMLHTTP");		
}

function buscar(seccion){
	if(XMLHttpRequestObject_infoCandidato) {
		   var Comments = document.getElementById('search'); 
		   
		   XMLHttpRequestObject_infoCandidato.open("GET", "/libre/offlines/calculadoralegislativa_web/includes/buscar2.asp?idSeccion="+document.getElementById('publicacion').value+"&entidad="+document.getElementById('cbxEntidad').value+"&tipoCargo="+seccion); 
		 
		   XMLHttpRequestObject_infoCandidato.onreadystatechange = function(){
					if (XMLHttpRequestObject_infoCandidato.readyState == 4 && XMLHttpRequestObject_infoCandidato.status == 200) {
					   Comments.innerHTML = XMLHttpRequestObject_infoCandidato.responseText; 					    
					  	 if (document.getElementById('nombrelegis').innerHTML != "" && seccion != 4)
						 {
						 nombreASP = document.getElementById('nombrelegis').innerHTML;					
							despligainfo(nombreASP,1)
						 }						
				   }
		   }
		   XMLHttpRequestObject_infoCandidato.send(null);
	} 
}
	
function buscalegislador(seccion) {

	if (seccion ==4)
	{						 
		 nombreASP = document.getElementById('cbxEntidad').value;		
		despligainfo(nombreASP,4)
	}
	else
	{						 
	buscar(seccion);	}
}


function despligainfo(legisName,opc)
{
	var pintahtm = document.getElementById("diputados");
	var strEstado = '';
	var contenido='';
	
	if(legisName)
	{
		legisName=legisName.replace( "á", "&#225;").replace( "é", "&#233;").replace( "í", "&#237;").replace( "ó", "&#243;").replace( "ú", "&#250;").replace( "ü", "&#252;").replace( "ñ", "&#241;");
		legisname=legisName.replace( "Á", "&#193;").replace( "É", "&#201;").replace( "Í", "&#205;").replace( "Ó", "&#211;").replace( "Ú", "&#218;").replace( "Ñ", "&#209;");
	}

		
	contenido=contenido+'<table width="998" border="0" cellspacing="0" cellpadding="0" bgcolor="white" height="45">'
	contenido=contenido+'<tr>'
	contenido=contenido+'<td class="arblanco12" rowspan="2" width="20"><img src="img/pix.gif" alt="" height="1" width="20" border="0"></td>'
	contenido=contenido+'<td align="center" valign="middle" bgcolor="#ad0c0c" width="958"><font color="#cc0000"><span class="arblanco12">Desglose por diputado pendiente. Datos sujetos al Sistema de Informaci&oacute;n Legislativa (SIL)</span></font></td>'
	contenido=contenido+'<td rowspan="2" width="20"><img src="img/pix.gif" alt="" height="1" width="20" border="0"></td>'
	contenido=contenido+'</tr>'
	contenido=contenido+'<tr height="20">'
	contenido=contenido+'<td align="center" valign="middle" width="958" height="20"><img src="img/pix.gif" alt="" height="20" width="1" border="0"></td>'
	contenido=contenido+'</tr>'
	contenido=contenido+'</table>'

	
	//UNINOMINALES
	contenido=contenido+'<table width="998" border="0" cellspacing="0" cellpadding="0" bgcolor="white">'
	contenido=contenido+'<tr height="160">'
	contenido=contenido+'<td valign="top" width="499" height="160">'
	contenido=contenido+'<table width="499" border="0" cellspacing="0" cellpadding="0">'
	contenido=contenido+'<tr height="16">'
	contenido=contenido+'<td rowspan="1000" width="20" height="160"><img src="../img/pix.gif" alt="" height="1" width="20" border="0"></td>'
	contenido=contenido+'<td align="left" width="265" height="16"><span class="argris12"><b>DIPUTADOS UNINOMINALES</b></span></td>'
	contenido=contenido+'<td rowspan="1000" align="left" width="10" height="160"><img src="../img/pix.gif" alt="" height="1" width="10" border="0"></td>'
	contenido=contenido+'<td width="21" height="16"></td>'
	contenido=contenido+'<td rowspan="1000" width="10" height="160"><img src="../img/pix.gif" alt="" height="1" width="10" border="0"></td>'
	contenido=contenido+'<td align="center" width="75" height="16"><span class="argris12"><b>PARTIDO</b></span></td>'
	contenido=contenido+'<td rowspan="1000" width="10" height="160"><img src="../img/pix.gif" alt="" height="1" width="10" border="0"></td>'
	contenido=contenido+'<td align="left" width="68" height="16"><span class="argris12"><b>VOTACION</b></span></td>'
	contenido=contenido+'<td rowspan="1000" width="20" height="160"><img src="../img/pix.gif" alt="" height="1" width="20" border="0"></td>'
	contenido=contenido+'</tr>'
	
	for (intX=0;intX<arrLegis.length;intX++)
	{		
		//Estado
		if (strEstado != arrLegis[intX][3])
		{
			contenido=contenido+'<tr height="16">'
			contenido=contenido+'<td align="left" width="265" height="16"><img src="../img/pix.gif" alt="" height="16" width="1" border="0"></td>'
			contenido=contenido+'<td width="21" height="16"></td>'
			contenido=contenido+'<td align="center" width="75" height="16"></td>'
			contenido=contenido+'<td align="left" width="68" height="16"></td>'
			contenido=contenido+'</tr>'
			contenido=contenido+'<tr height="16">'
			contenido=contenido+'	<td align="left" width="265" height="16"><span class="argris11"><b>'+arrLegis[intX][3]+'</b></span></td>'
			contenido=contenido+'	<td width="21" height="16"></td>'
			contenido=contenido+'	<td align="center" width="75" height="16"></td>'
			contenido=contenido+'	<td align="left" width="68" height="16"></td>'
			contenido=contenido+'</tr>'
			strEstado = arrLegis[intX][3];
		}
		
		//Nombres
		contenido=contenido+'<tr height="16">'
		
		if (opc == 4)		
		nombreLegis= arrLegis[intX][3];
		else
		nombreLegis= arrLegis[intX][1];
		
		
		
		if (legisName == nombreLegis)		
			clase = 'arrojo11';
		else
			clase = 'argris11';
		
		if (arrLegis[intX][8] != 0)
			contenido=contenido+'	<td align="left" width="265" height="16"><span class="'+clase+'"><a href="http://www.reforma.com/libre/offlines/observatoriodegobierno_web/perfiles/'+arrLegis[intX][8]+'.htm?idcandidato='+arrLegis[intX][8]+'">'+arrLegis[intX][1]+'</a></span></td>';
		else
			contenido=contenido+'	<td align="left" width="265" height="16"><span class="'+clase+'">'+arrLegis[intX][1]+'</span></td>';
		
		if (arrLegis[intX][5] != '')
				contenido=contenido+'	<td width="21" height="16"><a href="javascript:PoPup(\'/libre/offlines/calculadoralegislativa_web/includes/intermedia.asp?mail='+arrLegis[intX][5]+'&id='+arrLegis[intX][0]+'&idLey='+arrLegis[0][7]+'\');"><img src="../img/email.gif" alt="" height="9" width="21" border="0"></a></td>'
		else
			contenido=contenido+'	<td width="21" height="16"></td>'
		contenido=contenido+'	<td align="center" width="75" height="16"><span class="'+clase+'"><b>'+arrLegis[intX][2].toUpperCase()+'</b></span></td>'
		contenido=contenido+'	<td align="left" width="68" height="16"><span class="'+clase+'">'+arrLegis[intX][6]+'</span></td>'
		contenido=contenido+'</tr>'
		
	}
	contenido=contenido+'<tr height="16">'
	contenido=contenido+'<td align="left" width="264" height="16"><img src="../img/pix.gif" alt="" height="16" width="1" border="0"></td>'
	contenido=contenido+'<td width="21" height="16"></td>'
	contenido=contenido+'<td align="center" width="75" height="16"></td>'
	contenido=contenido+'<td align="left" width="68" height="16"></td>'
	contenido=contenido+'</tr>'
	contenido=contenido+'<tr><td><span class="argris11">*ND = No Disponible</span></td></tr>'
	contenido=contenido+'	</table>'
	contenido=contenido+'</td>'
	
	//PLURINOMINALES
	contenido=contenido+'<td bgcolor="#cccccc" width="1" height="160"><font color="#cccccc"><img src="../img/pix.gif" alt="" height="1" width="1" border="0"></font></td>'
	contenido=contenido+'<td valign="top" width="498" height="160">'
	contenido=contenido+'<table width="498" border="0" cellspacing="0" cellpadding="0">'
	contenido=contenido+'<tr height="16">'
	contenido=contenido+'<td rowspan="1000" width="20" height="112"><img src="../img/pix.gif" alt="" height="1" width="20" border="0"></td>'
	contenido=contenido+'<td align="left" width="264" height="16"><span class="argris12"><b>DIPUTADOS PLURINOMINALES</b></span></td>'
	contenido=contenido+'<td rowspan="1000" align="left" width="10" height="112"><img src="../img/pix.gif" alt="" height="1" width="10" border="0"></td>'
	contenido=contenido+'<td width="21" height="16"></td>'
	contenido=contenido+'<td rowspan="1000" width="10" height="112"><img src="../img/pix.gif" alt="" height="1" width="10" border="0"></td>'
	contenido=contenido+'<td align="center" width="75" height="16"><span class="argris12"><b>PARTIDO</b></span></td>'
	contenido=contenido+'<td rowspan="1000" width="10" height="112"><img src="../img/pix.gif" alt="" height="1" width="10" border="0"></td>'
	contenido=contenido+'<td align="left" width="68" height="16"><span class="argris12"><b>VOTACION</b></span></td>'
	contenido=contenido+'<td rowspan="1000" height="112"><img src="../img/pix.gif" alt="" height="1" width="20" border="0"></td>'
	contenido=contenido+'</tr>'	
	contenido=contenido+'<tr height="16">'
	contenido=contenido+'<td align="left" width="264" height="16"><img src="../img/pix.gif" alt="" height="16" width="1" border="0"></td>'
	contenido=contenido+'<td width="21" height="16"></td>'
	contenido=contenido+'<td align="center" width="75" height="16"></td>'
	contenido=contenido+'<td align="left" width="68" height="16"></td>'
	contenido=contenido+'</tr>'
	
	for (intX=0;intX<arrLegisPluri.length;intX++)
	{
		
		contenido=contenido+'<tr height="16">'
		contenido=contenido+'<td align="left" width="264" height="16"><span class="argris11"><span class="argris11">'+arrLegisPluri[intX][1]+'</span></span></td>'
		if (arrLegisPluri[intX][5] != '')
			contenido=contenido+'<td width="21" height="16"><a href="javascript:PoPup(\'/libre/offlines/calculadoralegislativa_web/includes/intermedia.asp?mail='+arrLegisPluri[intX][5]+'&id='+arrLegisPluri[intX][0]+'&idLey='+arrLegisPluri[0][7]+'\');"><img src="../img/email.gif" alt="" height="9" width="21" border="0"></a></td>'
		else
			contenido=contenido+'<td width="21" height="16"></td>'
		contenido=contenido+'<td align="center" width="75" height="16"><span class="argris11"><b>'+arrLegisPluri[intX][2].toUpperCase()+'</b></span></td>'
		contenido=contenido+'<td align="left" width="68" height="16"><span class="argris11"><span class="argris11">'+arrLegisPluri[intX][6]+'</span></span></td>'
		contenido=contenido+'</tr>'
	}
	contenido=contenido+'<tr height="16">'
	contenido=contenido+'<td align="left" width="264" height="16"><img src="../img/pix.gif" alt="" height="16" width="1" border="0"></td>'
	contenido=contenido+'<td width="21" height="16"></td>'
	contenido=contenido+'<td align="center" width="75" height="16"></td>'
	contenido=contenido+'<td align="left" width="68" height="16"></td>'
	contenido=contenido+'</tr>'
	contenido=contenido+'<tr><td><span class="argris11">*ND = No Disponible</span></td></tr>'
	contenido=contenido+'<tr height="20">'
	contenido=contenido+'<td colspan="3" align="center" valign="top" width="998" height="20"><img src="../img/pix.gif" alt="" height="20" width="1" border="0"></td>'
	contenido=contenido+'</tr>'
	contenido=contenido+'</table>'
	contenido=contenido+'</td>'
	contenido=contenido+'</tr>'
	var pintalink = document.getElementById("paraLink");
	
	if (opc){
		pintalink.innerHTML ='<a href="#" onclick="javascript:despligainfo();"><img src="../img/btn_lista_menos.gif"  height="30" width="254" border="0"></a>';
		pintahtm.innerHTML =contenido;
		bloquevisible=1;}
	else
	{
		if (bloquevisible==0)
		{
			pintalink.innerHTML ='<a href="#" onclick="javascript:despligainfo();"><img src="../img/btn_lista_menos.gif"  height="30" width="254" border="0"></a>';
			pintahtm.innerHTML =contenido;}
		else
		{
			pintalink.innerHTML ='<a href="#" onclick="javascript:despligainfo();"><img src="../img/btn_lista.gif"  height="30" width="254" border="0"></a>';
			pintahtm.innerHTML =" ";
		}
		if (bloquevisible==0)
		{
			bloquevisible=1;
		}
		else
		{
		   bloquevisible=0;
		}
	}
}

function PoPup(direccion)
{	
    var aleatorio = "P"+Math.round(Math.random()*1000);
	LeftPosition = (screen.width) ? (screen.width-800)/2 : 0; 
	TopPosition = (screen.height) ? (screen.height-400)/2 : 0;
	window.open(direccion,aleatorio,'top=' + TopPosition + ',left=' + LeftPosition + ',width=800,height=400,directories=no,location=no,menubar=no,scrollbars=no,status=no,toolbar=no,resizable=yes');
}
function Completa(direccion)
{	
    var aleatorio = "P"+Math.round(Math.random()*1000);
	LeftPosition = (screen.width) ? (screen.width-800)/2 : 0; 
	TopPosition = (screen.height) ? (screen.height-400)/2 : 0;
	window.open(direccion,aleatorio,'top=' + TopPosition + ',left=' + LeftPosition + ',width=800,height=400,directories=yes,location=yes,menubar=yes,scrollbars=yes,status=yes,toolbar=yes,resizable=yes');
}

dominio = document.domain;
if (dominio.indexOf('elnorte')>-1)
{
	var home = 'www.elnorte.com';
	var grupoHome = 'gruporeforma.elnorte.com';
	var color = '#229ED0';
	var idplaza = 2;
	var plaza = 'elnorte';
}
else
{
	if (dominio.indexOf('mural')>-1)
	{
		var home = 'www.mural.com';
		var grupoHome = 'gruporeforma.mural.com';		
		var color = '#BF1818';
		var idplaza = 3;
		var plaza = 'mural';
	}
	else
	{
		if (dominio.indexOf('palabra')>-1)
		{
			var home = 'www.palabra.com';
			var grupoHome = 'gruporeforma.palabra.com';			
			var color = '#D9D7B9';
			var idplaza = 4;
			var plaza = 'palabra';
		}
		else
		{
			var home = 'www.reforma.com';
			var grupoHome = 'gruporeforma.reforma.com';			
			var color = '#519145';
			var idplaza = 1;
			var plaza = 'reforma';
		}
	}
}


//***********************************************************************

