

	var rows = new Array()
	rows[0]="row0";
	rows[1]="row1";
	rows[2]="row2";

	var searchItems= new Array;	
	
	searchItems[0]="todo";
	searchItems[1]="rubros";
	searchItems[2]="calles";
	searchItems[3]="noticias";
	searchItems[4]="servicios";

	
	//searchLabels array is localized and embedded in the page
	
	function csrch()
	{
		var fs=document.srch.q;
		fs.value=fs.value.replace(/^([ \t])+/gi,"").replace(/([ \t])+$/gi,"");
		if (fs.value.length < 3){
			alert("La expresion a buscar es muy corta");
			fs.focus();
			return false;
		}
		return true;
	}
	
	function getCurrentSearch()
	{	    
	    var item;
		for (i=0;i<searchItems.length; i++)
		{		 		    
		    item = document.getElementById(searchItems[i]);		    
		    if (item != null && item.className=="active")   
			    return i;			    			    
		}
	}
	
	function setSearchTarget(p_t)
	{
	  
		var item;
		var menuIndex;	
     		
		//turn off all selections
		for (x=0; x<searchItems.length-1; x++)
	    {		    
		    item = document.getElementById(searchItems[x]);		  		    
		    if (item != null)
			    item.className="inactive";
		} 								    
		item = document.getElementById(p_t);		
		if (item != null)
		    document.getElementById(p_t).className="active";
		
		var currSearch = getCurrentSearch();						
		if (currSearch != undefined)
		{
			document.srch.submitBtn.value=searchLabels[currSearch];
			document.srch.q.focus();
		}

		document.srch.t.value=p_t;
		return true;
	}
	
	
	function getCurrentRow()
	{
		for (i=0;i<rows.length; i++)
		{
			if (document.getElementById(rows[i]).className=="show") return i;
		}
	}
	
	function showRow(row)
	{
	    var item;
		for (i=0;i<rows.length; i++)
		{		    
		    item = document.getElementById(rows[i]);		  		    
		    if (item != null)
			    item.className="hide";
		}
		
		document.getElementById(rows[row]).className="show";		
		//turn on the first item in each row
				
		if (getCurrentRow()==0) setSearchTarget("todo");
	
	}
	
