function trim(str)
{
   return str.replace(/^\s+|\s+$/g,"");
}
function conferma_eli(testo)
{
    if(confirm(testo))
	return true;
    else
	return false;
}
function conferma_elimina()
{
    if(confirm("Attenzione si sta per eliminare la squadra dalla lega. CONTINUARE?"))
    {
	return true;
    }
    else
    {
	return false;
    }
}

function colora_l(indice, part)
{
    document.getElementById(part+indice).style.background = "#94dbeb";
}

function scolora_l(indice, part)
{
    if(indice%2 == 0)
    {
	document.getElementById(part+indice).style.background = "#ddd";
    }
    else
    {
	document.getElementById(part+indice).style.background = "#fff";
    }
}

function in_array (needle, haystack, argStrict) 
{
    var key = '', strict = !!argStrict;
 
    if (strict) {
        for (key in haystack) {
            if (haystack[key] === needle) {
                return true;
            }
        }
    } else {
        for (key in haystack) {
            if (haystack[key] == needle) {
                return true;
            }
        }
    }
 
    return false;
}

function espandiCollassa(div, icona)
{
    var element = document.getElementById(div);
    element.style.display = (element.style.display == "none") ? "block" : "none";
    if(icona != '')
    {
	var ico = document.getElementById(icona);
	//icona.style.addclass() = (element.style.display == "none") ? "block" : "none";
    }
}

function is_mail(mail)
{
    var pattern = /^[a-zA-Z0-9._%-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
    if(pattern.test(mail) == false)
    {
	return false;
    }
    else
    {
	return true;
    }
}
