// JavaScript Document - Funzioni utili

// Funzione che elimina gli spazi vuoti di "contorno" da una stringa
function trim(str)  {
    if (str.length > 0)  {
        var blank = str.substring(0, 1);
        while(blank == " ")  {
            str = str.substring(1, str.length);
            if (str.length > 0)  {
                blank = str.substring(0, 1);
            }
            else  {
                return str;
            }
        }
        var index = str.length - 1;
        blank = str.substring(index, str.length);
        while(blank == " ")  {
            str = str.substring(0, index);
            if (str.length > 0)  {
                index = str.length - 1;
                blank = str.substring(index, str.length);
            }
            else  {
                return str;
            }
        }
    }
    return str;
}

// Zoom delle immagini
function zoom(img, width, height)  {
	var left = (screen.width - width) / 2;
	var top = (screen.height - height) / 2;
	var settings = 'height='+height+',width='+width+',top ='+top+',left='+left+',scrollbars=0,resizable=0,titlebar=0,toolbar=0';
	window.open('popup.php?img=' + img, 'popup', settings);
}

// Zoom delle immagini
function zoom2(img, width, height)  {
	var left = (screen.width - width) / 2;
	var top = (screen.height - height) / 2;
	var settings = 'height='+height+',width='+width+',top ='+top+',left='+left+',scrollbars=0,resizable=0,titlebar=0,toolbar=0';
	window.open('popup2.php?img=' + img, 'popup', settings);
}