function getNextSibling(startBrother){
  	endBrother=startBrother.nextSibling;
  	if(endBrother == null) return null;
	try {
		while (endBrother.nodeType != 1) {
			endBrother = endBrother.nextSibling;
		}
		return endBrother;
	} catch(e) {}
} 

var hsf_timer='';
var secLevOpen='';
var scelta_accesa = 'post';	

function showSearchFilters() {
	stopHideSearchFilters(); // annulla la chiusura del men� se gi� aperto
	document.getElementById('search-options-button').className = 'bottone-opzioni opon';		
	document.getElementById('search-options-top').style.display = 'block';
	document.getElementById('searchFilters').style.display = 'block';
}

function showSearchFilters2liv(a) {
	stopHideSearchFilters(); // annulla la chiusura del men� se gi� aperto
	if (secLevOpen != '') { // se un sottomen� � gi� aperto lo chiude
		secLevOpen.className = 'search-options-subcat';
	}
	var tendina = getNextSibling(a);
	if(tendina != null) {
		tendina.className = 'search-options-subcat subcaton';
		secLevOpen = tendina;
	}
}	

function hideSearchFilters() {
	document.getElementById('search-options-button').className = 'bottone-opzioni';				
	document.getElementById('search-options-top').style.display = 'none';
	document.getElementById('searchFilters').style.display = 'none';
	if (secLevOpen != '') {
		secLevOpen.className = 'search-options-subcat';
		secLevOpen = '';
	}
}	

// lascia uno zik di tempo per non far chiudere il men�
// mentre l'utente naviga da un link all'altro
function startHideSearchFilters() { 
	hsf_timer = setTimeout('hideSearchFilters()', 100);
}

function stopHideSearchFilters() {	
	if(hsf_timer != '') clearTimeout(hsf_timer);	
}
	
function setSearchFilter(nuovo_filtro, url) {
	document.getElementById('spark').innerHTML = nuovo_filtro;
	// per far adattare le dimensioni del bottone devo cambiare 
	// anche la scritta invisibile all'interno di <strong id="size">
	document.getElementById('size').innerHTML = nuovo_filtro;
	document.getElementById('search_cat').value = url;
}

function setSearchWhat(container) {
	var what=container.id;
	if (what == 'blog' || what=='bottom-blog') {
		document.getElementById('search_what').value = 'blog';
		document.getElementById('blog').className = 'scelta pad accesa';
		document.getElementById('bottom-blog').className = 'scelta pad accesa';			
		document.getElementById('post').className = 'scelta';
		document.getElementById('bottom-post').className = 'scelta';			
		document.getElementById('search-options-button').style.display='none';
	} else {
		document.getElementById('search_what').value = 'post';
		document.getElementById('post').className = 'scelta accesa';
		document.getElementById('bottom-post').className = 'scelta accesa';			
		document.getElementById('blog').className = 'scelta pad';
		document.getElementById('bottom-blog').className = 'scelta pad';			
		document.getElementById('search-options-button').style.display='block';		
	}
}
