
function PalabraY()
{
	document.formX.palabra.value=document.formX.palabra.value + ' & ';
	document.formX.palabra.focus();
	//document.formX.palabra.selectionStart=10;
	/*var selLength = txtarea.textLength;
	var selStart = txtarea.selectionStart;
	var selEnd = txtarea.selectionEnd;
	alert(selLength);*/
}
function PalabraFrase()
{
	document.formX.palabra.value='"' + document.formX.palabra.value + '"';
	document.formX.palabra.focus();
	//document.formX.palabra.selectionStart=10;
	/*var selLength = txtarea.textLength;
	var selStart = txtarea.selectionStart;
	var selEnd = txtarea.selectionEnd;
	alert(selLength);*/
}

function PalabraFrase2(valor)
{
	if (document.formX.palabra.value) {
		if (valor) {
			document.formX.palabra.value='"' + document.formX.palabra.value + '"';
			document.formX.palabra.focus();
		} else {
			document.formX.palabra.value=replaceAll( document.formX.palabra.value, "\"", "" )
		}
	}
}


function replaceAll( str, from, to ) {
    var idx = str.indexOf( from );


    while ( idx > -1 ) {
        str = str.replace( from, to ); 
        idx = str.indexOf( from );
    }

    return str;
}



function ShowVoces(tipo,palabra,campo)
{
	//openwin("pop_voces.php?tipo="+tipo+"&palabra="+palabra.value+"&idcampo="+campo.value,700,500,1);
	openwin("pop_voces.php?tipo="+tipo+"&palabra="+palabra.value,700,500,1);
}

function ImprimoVarios()
{
	strtemp="";
	for (i=0;i<Page_size ; i++ )
	{
		if (document.getElementById('idarticulo'+i))
		{
			pValue=document.getElementById('idarticulo'+i);
			if (pValue.checked)
			{
				if (strtemp !="") strtemp+=",";
				strtemp+=pValue.value;
			}
		}
	}
	url="articulos.php?print=1&values="+strtemp;
	w=700;
	h=500;
	if (strtemp!="")
	{
	scrwidth=screen.width;scrheight=screen.height;
	leftmargin = (scrwidth - w)/2;topmargin = (scrheight - h)/2;
	props = "left=" + leftmargin + ",";props = props + "top=" + topmargin + ",";props = props + "width=" + w+ ",";props = props + "height=" + h+ ",";
	var windowprops= "left=" + leftmargin +",top=" + topmargin +",width="+w+",height="+h+",resizable=1,location=no,fullscreen=0,menubar=yes,scrollbars=1";
	popup=window.open(url,'pop',windowprops);
	popup.focus();
	}
	//document.location="index.php?ididioma=<?echo $ididioma;?>&idbusqueda=<?echo $idbusqueda_tmp;?>&Page=<?echo $Page;?>&posicion="+posicion_ant+"&values="+strtemp;
}



function ShowFavorito(idarticulo,palabra,posicion,exacta)
{
	pBox=document.getElementById("contenido");
	pBox2=document.getElementById("box_principal");
	if (pBox.style.display!="block")
	{
		pBox.style.display="block";
		pBox2.style.display="none";
	} 


	document.getElementById('articulo_'+posicion_ant).className='menuSec2';
	document.getElementById('articulo_'+posicion).className='seleccionado';
	if (document.getElementById('contenido'))
	{
		contenido.location='articulos.php?favorito=1&idarticulo='+idarticulo+'&palabra='+palabra+'&exacta='+exacta;
	}
	posicion_ant=posicion;
}

function ShowContenido(idpais,ididioma,tipo)
{
	if (tipo!=5 && tipo!=6)
	{
		pBox=document.getElementById("contenido");
		pBox2=document.getElementById("box_principal");
		if (pBox.style.display!="block")
		{
			pBox.style.display="block";
			pBox2.style.display="none";
		} 
	}
	//if (posicion_ant2) document.getElementById('menu_'+posicion_ant2).className='menuSec2';
	//document.getElementById('menu_'+tipo).className='seleccionado_menu';

	if (tipo!=5 && tipo!=6)
	{
		if (document.getElementById('contenido'))
		{
			contenido.location='about:blank';
			contenido.location='contenidos.php?idpais='+idpais+'&ididioma='+ididioma+'&tipo='+tipo;
		}
	}
	posicion_ant2=tipo;
}

function ShowArticulo(idarticulo,palabra,posicion,exacta,opcion)
{

	document.getElementById('articulo_'+opcion+'_'+posicion_ant).className='menuSec2';
	document.getElementById('articulo_'+opcion+'_'+posicion).className='seleccionado';
	if (document.getElementById('contenido'))
	{
		contenido.location='articulos.php?idarticulo='+idarticulo+'&palabra='+palabra+'&exacta='+exacta;
	}
	posicion_ant=posicion;
}

function validateIngreso() { 
	if (document.formLogin.usuario.value=="")
	{
		alert("Debe ingresar el nombre de usuario para continuar");
		document.formLogin.usuario.focus();
		return;
	}
	if (document.formLogin.password.value=="")
	{
		alert("Debe ingresar su contraseņa para continuar");
		document.formLogin.password.focus();
		return;
	}
	document.formLogin.submit();
} 
p_posant='';
p_posant2='';
idestado=0;

function showdetail(pos,nombre)
{
	//document.getElementById('d_'+nombre+'_'+pos).style.left=document.body.scrollLeft+event.clientX-event.offsetX-3-191;
	//document.getElementById('d_'+nombre+'_'+pos).style.top=document.body.scrollTop+event.clientY-event.offsetY+18-144;
	document.getElementById('d_'+nombre+'_'+pos).style.left=document.body.scrollLeft+event.clientX-event.offsetX-3;
	document.getElementById('d_'+nombre+'_'+pos).style.top=document.body.scrollTop+event.clientY-event.offsetY+28;
	document.getElementById('d_'+nombre+'_'+pos).width=250;
	document.getElementById('d_'+nombre+'_'+pos).height=80;
	if (p_posant2!=pos)
	{
		document.getElementById('d_'+nombre+'_'+pos).style.display="block";
	}
	else
	{
		if (document.getElementById('d_'+nombre+'_'+pos).style.display!="block")
		{
			document.getElementById('d_'+nombre+'_'+pos).style.display="block";
		}
		else
		{
			document.getElementById('d_'+nombre+'_'+pos).style.display="none";
		}
	}
	p_posant2=pos;
}
var selectedCountyArray = new Array();


	function setEmisores(myState,Campo)
	{
		if (Campo.indexOf(",") > -1)
		{
			var Valores=Campo.split(",");
			var part_num=0;
			while (part_num < Valores.length)
			 {
			  //alert(Valores[part_num]);
			  CambioComboTipo(myState,Valores[part_num]);
			  part_num+=1;
			  }
		}
		else
		{
			countyField=document.getElementById('idsubemisor');
			countyField.length=0;
			var count = 0;
			countyField.length++;
			countyField.options[0].value="";
			countyField.options[0].text="-- Todos --";
			countyField.selectedIndex=0;
			CambioComboTipo(myState,Campo);
		}


	}//end function


	function setTipos(myState,Campo)
	{
		if (Campo.indexOf(",") > -1)
		{
			var Valores=Campo.split(",");
			var part_num=0;
			while (part_num < Valores.length)
			 {
			  //alert(Valores[part_num]);
			  CambioComboTipo(myState,Valores[part_num]);
			  part_num+=1;
			  }
		}
		else
		{
			countyField=document.getElementById('idsubtipo');
			countyField.length=0;
			var count = 0;
			countyField.length++;
			countyField.options[0].value="";
			countyField.options[0].text="-- Todos --";
			countyField.selectedIndex=0;
			CambioComboTipo(myState,Campo);
		}


	}//end function

	function CambioComboTipo(myState,Campo)
	{
			var countyField = document.getElementById(Campo);
			countyField.length = 0;
			
			if (myState.selectedIndex == -1) 
			{//no state chosen
				countyField.length = 1;
				countyField.options[0].value="";
				countyField.options[0].text="Seleccionar un item...";
			}
			else
			{
				//get the associated county array
				document.getElementById(Campo).length=0;
				var count = 0;
				countyField.length++;
				countyField.options[0].value="";
				countyField.options[0].text="-- Todos --";
				countyField.selectedIndex=0;
				if(window["state"+Campo+"_Desc_Array" + myState.options[myState.selectedIndex].value]!= undefined)
				{
					var myStateArray = eval("state"+Campo+"_Desc_Array" + myState.options[myState.selectedIndex].value);
					var myStateArray2 = eval("state"+Campo+"_Valores_Array" + myState.options[myState.selectedIndex].value);
					//make the selectedcounty array a string for easier searching
					var selectedCounties = selectedCountyArray.toString();
					
					count++;
					for (var i=0; i<myStateArray.length; i++)
					{
						if (selectedCounties.indexOf(myState.options[myState.selectedIndex].value + "->" + myStateArray[i]) == -1)
						{//not selected, so display it
							countyField.length++;
							countyField[count].value = myStateArray2[i];
							countyField[count].text = myStateArray[i];
							count++;
						}
					}
					if (count==2) 
					{
						countyField.selectedIndex=1;
					}
				}

			}
		}
