function xhideCurrentPopup(idElementName) {
	document.getElementById(idElementName).style.display = 'none';
	
}

function xshowCurrentPopup(idElementName) {
	document.getElementById(idElementName).style.display = 'block';
		
}

function Ucase(x)
{
	x.value=x.value.toUpperCase();
}


function getSelectedValueFromRadio(radioname)
{
var rbgroup_value;

rbgroup_value = '';

for (i=0;i < radioname.length;i++)
{
      if (radioname[i].checked)
      {
             rbgroup_value = radioname[i].value;
      }
}

return rbgroup_value;
}

function trim(stringa) {
    while (stringa.substring(0,1) == ' ')
    {
        stringa = stringa.substring(1, stringa.length);
    }
    while (stringa.substring(stringa.length-1, stringa.length) == ' ')
    {
        stringa = stringa.substring(0,stringa.length-1);
    }
    return stringa;
}

function multiselect2list(id,tutti,sep) {
    var o,ret,i;
    o = document.getElementById(id);
    if (!o || !o.options)
        return "";
    ret = "";
    if (!sep)
        sep = ',';
    for (i=0;i<o.options.length;i++) {
        if (o.options[i].selected || (tutti && tutti > 0))
            ret += o.options[i].value+sep;
    }
    return ret;
}

Array.prototype.in_array = function ( obj ) {
    var len = this.length;
    for ( var x = 0 ; x <= len ; x++ ) {
        if ( this[x] == obj ) return true;
    }
    return false;
}

String.prototype.replaceAll = function (old,nuovo) {
    var temp,dato;
    temp = '';
    dato = '';
    dato = this.substr(0);
    while (temp != dato) {
        temp = dato;
        dato = dato.replace(old,nuovo);
    }
    return dato;
}

function check_data(el) {
    var pattern = new RegExp('[0-9]{2}[-\/][0-9]{2}[-\/][0-9]{4}');
    
    var val,dd,day,month,year,source_date;

    if (typeof(el) == 'object')    
	val = el.value;
    else
	val = el;

    if (!val.match(pattern))
	return false;

    val = val.replace('/','-');
    val = val.replace('/','-');

    if (typeof(el) == 'object')    
	el.value = val;

    dd = val.split('-');
    
    day = dd[0];
    month = dd[1] - 1;
    year = dd[2];
	
    source_date = new Date(year,month,day);
    
    if (year != source_date.getFullYear() || month != source_date.getMonth() || day != source_date.getDate())
	return false;
	    
    return true;
        	       
}

