var onResults=false;

function createRequestObject() {
    var ro;
    var browser = navigator.appName;
    if(browser == "Microsoft Internet Explorer"){
        ro = new ActiveXObject("Microsoft.XMLHTTP");
    }else{
        ro = new XMLHttpRequest();
    }
    return ro;
}
var http = createRequestObject();
function sndReq(action) {
    http.open('get', action);
    http.onreadystatechange = handleResponse;
    http.send(null);
}
function handleResponse() {
    if(http.readyState == 4){
		document.getElementById('searchResultsDiv').innerHTML = http.responseText;
    }
}

function search_out() {
	this.onResults=false;
}

function search_in() {
	this.onResults=true;
}

function qclick() {
	var val=document.getElementById('q').value;
	if (val=="Cerca") {
		document.getElementById('q').value="";
	}
}

function rclose() {
	var search_results=document.getElementById('searchResultsDiv');
	search_results.innerHTML='';
	search_results.style.display="none";
}

function qOut() {
	var val=document.getElementById('q').value;
	if (val=="") {
		document.getElementById('q').value="Cerca";
	}
	if (this.onResults==false) {
/*		var search_results=document.getElementById('search_results');
		search_results.innerHTML='';*/
	}
}

function searchResultRowOver (div) {
	div.style.backgroundColor="#f1f1f1";
}

function searchResultRowOut (div) {
	div.style.backgroundColor="#ffffff";
}

function prendiUrlHash(){
	
}

function doSearch(url) {
	
	var val=document.getElementById('q').value;
	var rightcap_img = document.getElementById("rightcap_img");
	if (val.length < 3) {
		rclose();
		return false;
	}
		
	if (val && val!="Cerca") {
		
		$.get('../f_and_func/ricerca_ajax_hash.php?q=' + document.getElementById('q').value,
		function(data){
			sndReq(data);
		});
		var search_results=document.getElementById('searchResultsDiv');
		search_results.style.display="block";
		return false;
	} else {
		//document.getElementById('q').value='Cerca';
		rightcap_img.src="../library/searchbox/searchbox_rightcap.gif";
	}
}
function openWindow(url) {
  window.open(url,'popupWindow','resizable=no,scrollbars=yes,toolbar=no,status=no,height=650,width=720');
}
function hideSearch(){
	document.getElementById('searchResultsDiv').display = "hidden";
}

function expandOrClose(arrow_id, list_num, list_name)  {
	/*
	var a = document.getElementById(arrow_id);
	if(a.name=='d') { 
		a.src='../library/searchbox/arrowRight.gif';
		a.name='r';
		hideSearchTypes(list_num,list_name);
	}
	else {
		a.src='../library/searchbox/arrowDown.gif';
		a.name='d';
		showSearchTypes(list_num,list_name);
	}
	return false;
	*/
}
function hideSearchTypes (i,j) { 
	/*
	var theDiv = document.getElementById(j).getElementsByTagName('li');
	for(var d = 1; d < theDiv.length; d++) {
		var theID = 'res-'+i+'-'+d;
		Effect.DropOut(theID);
	}
	*/
	
	
}	
function showSearchTypes (i,j) { 
	/*
	var theDiv = document.getElementById(j).getElementsByTagName('li');
	for(var d = 1; d < theDiv.length; d++) {
		var theID = 'res-'+i+'-'+d;
		
		Effect.Appear(theID);
	}
	*/
}
