function SelectAll (bSelect)
{
	var thisForm = self.document.prospect;
			
	for(i = 0 ; i < thisForm.elements.length ; i++)
		if(thisForm.elements[i].name == 'i')
			thisForm.elements[i].checked = bSelect;			
}
		
function VisSelect ()
{
	var i;
	var test = false;
	var str;			
	var thisForm = self.document.prospect;
				
	for(i = 0 ; i < thisForm.elements.length ; i++)	 			
		if(thisForm.elements[i].name == 'i')
			test = test || thisForm.elements[i].checked;

	if (!test)
		alert ("Almeno un testo deve essere selezionato.");
	else
		thisForm.submit();
}
			
function resetIt()
{
	document.clearSession.clearS.value = 1;
	document.clearSession.submit();
}		
		
function SubmitIt(pn)
{
	window.document.searchForm.pn.value = pn;
	window.document.searchForm.submit();
}
		
function SvuotaBiblio()
{
	window.document.flow.svuota.value = "1";
	window.document.flow.submit();
}
		
function testForm(s)
{
	var i;
	var test = false;

	for (i=0; i<s.length; i++)
	{
		if (s.substr(i, 1) != " ")
			test = true;
	}				
	return test;
}
		
function GoCatalogo()
{
	window.document.flow.submit();
}
/*		
function Bibliografia(sPath)
{
	window.document.location.href=sPath;
}
*/
function document_onkeydown(cod) {
	//alert (cod);

	if(event.keyCode == 13)
	{
		//ricerca da main
		if (cod==0)
			if (window.document.searchForm.ricerca.value != '')
				search_book();
			else
				alert ("Inserire un elemento di ricerca!");

		//ricerca da rtitolof
		else if (cod==1)
			search_book();

		//ricerca di una cittą
		else if (cod>1)
			if (txtCitta.value != '')
			{
				//provengo dalla directory asp
				if (cod==2)
					search_region('');

				//provengo dalla directory root
				else
					search_region('asp/');
			}
			else
			{
				alert ("Inserire il nome di una cittą!");
			}
	}
}

function search_region(path)
{
	if(txtCitta.value == "") {
		alert("Inserire un elemento di Ricerca");
		return;
	}
	else {			
		prm = path + "result_regioni.asp?reg=&amp;cit=" + txtCitta.value;
		window.document.location.href=prm;
	}
}

function SelezionaBiblio()
{
	var i;
	var selenco = new String("");
	var thisForm = self.document.addBib;
			
	for(i = 0 ; i < thisForm.elements.length ; i++)	 			
		if(thisForm.elements[i].name == 'i')
			if (thisForm.elements[i].checked)	 					
				if (selenco.length == 0)
					selenco = "'" + thisForm.elements[i].value + "'";	 						
				else
					selenco = selenco + ", '" + thisForm.elements[i].value + "'";


	window.document.flow.biblioteche.value = selenco;
	 		
	window.document.flow.submit();		
}	

function viewHighlightButton(imgName)
{
	document.images[imgName].src = eval("r" + imgName + ".src");
}

function viewNormalButton(imgName)
{
	document.images[imgName].src = eval("g" + imgName + ".src");
}

function SendRequestBib(email, param, c_bib)
{
	var str;
	
	if (param == 0)
	{
		str = '../asp/desiderata_request.asp?';				
	}
	else if (param == 1)
	{
		str = '../asp/enrolment_request.asp?';
	}
	
	str += 'mail_bib=' + email + '&c_bib=' + c_bib;

	wname = "SalvataggioDati";
	searchWin = window.open(str, "SalvaDati", "toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=yes, resizable=no, copyhistory=no, width=480, height=500, top=100, left=100");
	searchWin.creator = self;
}

