/* toglie eventuali spazi bianchi all'inizio e alla fine di una stringa */
function trimString( daString ) {
	var temp;
	if ( daString.length > 0 ) {
		if ( daString.charAt( 0 ) == ' ' )
			daString = daString.substring( 1, daString.length );
		if ( daString.charAt( daString.length - 1 ) == ' ' )
			return trimString( daString.substring( 0, daString.length - 1 ) );
		return daString;
	}
	return "";
}

function checkEmailContact() {
	var valori = new Array( "", "", "", "" );
	var campi = new Array( "Nome", "Cognome", "Email", "Commenti" );
	for ( var i = 0; i < campi.length; i++ ) 
		valori[ i ] = trimString( document.FormName[ campi[ i ] ].value );
	
	var ok = true;
	var str = "I seguenti campi obbligatori risultano mancanti: \n";
	for ( var i = 0; i < valori.length; i++ ) {
		if ( valori[ i ] == "" ) {
			ok = false;
			str += campi[ i ] + "\n";
			document.FormName[ campi[ i ] ].style.background = "#E0F7FF";
		}
		else
			document.FormName[ campi[ i ] ].style.background = "white";
	}
	if ( !ok ) 
		alert( str );
	
	return ok;
}

function apriRecensione( imgPath ) {
	window.open( imgPath );
}

function apri(page,titolo,idRicetta,w,h,isRecipe)
{
	if (isRecipe)
		window.open(page+"?idRicetta="+idRicetta,"_blank","height=700,width=500,status=yes,toolbar=no,menubar=no,location=no",false);
	else if ( idRicetta != null )
		window.open(page+"&idRicetta="+idRicetta+"&titolo="+titolo,"_blank","height=700,width=500,status=yes,toolbar=no,menubar=no,location=no",false);
	else
		window.open(page,"_blank","height=700,width=500,status=yes,toolbar=no,menubar=no,location=no",false);		
}

function mostraRicetta(titolo)
{
	window.status = titolo;
	return true;
}

function mostraPerCategoria()
{
		var oTipi = document.getElementById( "tipi" );
		var idTipo = parseInt( new String( oTipi.options[ oTipi.selectedIndex ].value ) );

		if ( idTipo > 0 )
			window.document.location.href = "ricette.asp?idTipo="+String(idTipo)+"#altre";

}

function check()
{
	if (commenti.Autore.value=="" || commenti.Commento.value=="") {
		window.alert("Errore nella compilazione del commento");
		return false;
	}
	return true;
}

function redirect(url)
{
		//window.close();
		window.open(url);
}

var currentEmbed = null;
var timer;

function popup(){
		window.open("accessiEmusica.asp","_blank","height=300,width=300,status=yes,toolbar=no,menubar=no,location=no",false);
}




