function setLang(language) {
    var url = window.location.href.split("?",1);
    window.location.href=url+'?action=setlang&lang='+language;
    return true;
}

function trim(stringToTrim) {
    if (stringToTrim!=null && stringToTrim!="undefined")
	return stringToTrim.replace(/^\s+|\s+$/g,"");
    else
        return '';
}
function ltrim(stringToTrim) {
	return stringToTrim.replace(/^\s+/,"");
}
function rtrim(stringToTrim) {
	return stringToTrim.replace(/\s+$/,"");
}

/*
//-- SLIDE DXHEADER --
//variable that will increment through the images
var image1_dxheader=new Image();
image1_dxheader.src="images/aziende_bxp6.jpg";
var image2_dxheader=new Image();
image2_dxheader.src="images/aziende_bxp7.jpg";

var step_dxheader=1;
function slide_dxheader(){
//if browser does not support the image object, exit.
if (!document.images) {
    return 0;
}


document.images.slide_dxheader.src=eval("image"+step_dxheader+"_dxheader.src");
//alert (document.images.slide_dxheader.src);

if (step_dxheader<2)
    step_dxheader++;
else
    step_dxheader=1;
//call function "slide()" every 2 seconds
setTimeout("slide_dxheader()",2000);
return 0;
}
*/

function hideDiv(id)
{
        if (document.getElementById) { // DOM3 = IE5, NS6
                document.getElementById(id).style.display = 'none';
        }
        else {
                if (document.layers) { // Netscape 4
                        document.id.display = 'none';
                }
                else { // IE 4
                        document.all.id.style.display = 'none';
                }
        }
}
function displayDiv(id)
{
        if (document.getElementById) { // DOM3 = IE5, NS6
                document.getElementById(id).style.display = 'block';
        }
        else {
                if (document.layers) { // Netscape 4
                        document.id.display = 'block';
                }
                else { // IE 4
                        document.all.id.style.display = 'block';
                }
        }
}
function toggleDiv(id)
{
    var onoff='';
        if (document.getElementById) { // DOM3 = IE5, NS6
            if (document.getElementById(id).style.display == 'block') {
                document.getElementById(id).style.display = 'none';
                onoff='off';
            }
            else {
                document.getElementById(id).style.display = 'block';
                onoff='on';
            }
        }
        else {
                if (document.layers) { // Netscape 4
                    if (document.id.display == 'block'){
                        document.id.display = 'none';
                        onoff='off';
                    }
                    else {
                        document.id.display = 'block';
                        onoff='on';
                    }
                }
                else { // IE 4
                    if (document.all.id.style.display == 'block') {
                        document.all.id.style.display = 'none';
                        onoff='off';
                    }
                    else {
                        document.all.id.style.display = 'block';
                        onoff='on';
                    }
                }
        }
    return onoff;
}

function changeLabelValue(id,text)
{
if (document.getElementById)  // DOM3 = IE5, NS6
 document.getElementById(id).innerHTML = text;
else
 document.all(id).innerHTML =text;
}

function changeLabelBackColor(id,color)
{
if (document.getElementById)  // DOM3 = IE5, NS6
 document.getElementById(id).style.backgroundColor  = color;
else
 document.all(id).innerHTML.style.backgroundColor  = color;
}

function toggleLabelValue(id,text1,text2)
{
if (document.getElementById) { // DOM3 = IE5, NS6
    if (document.getElementById(id).innerHTML == text2)
        document.getElementById(id).innerHTML = text1;
    else
        document.getElementById(id).innerHTML = text2;
}
else {
    if (document.all(id).innerHTML.innerHTML == text2)
        document.all(id).innerHTML.innerHTML = text1;
    else
        document.all(id).innerHTML.innerHTML = text2;
}
}


function imposeMaxLength(Event, Object, MaxLen)
{
        return (Object.value.length <= MaxLen)||(Event.keyCode == 8 ||Event.keyCode==46||(Event.keyCode>=35&&Event.keyCode<=40))
}

function roundNumber(rnum, rlength) { // Arguments: number to round, number of decimal places
  var newnumber = Math.round(rnum*Math.pow(10,rlength))/Math.pow(10,rlength);
  return newnumber; // Output the result 
}

function ToggleRow(id)
{
    var tr;
    if (document.getElementById)
        tr = document.getElementById(id);
    else
        tr = document.all(id);
    if (tr==null) { return; }
    var bExpand = tr.style.display == '';
    tr.style.display = (bExpand ? 'none' : '');
}

function displayRow(id){
    var tr;
    if (document.getElementById)
        tr = document.getElementById(id);
    else
        tr = document.all(id);
    if (tr==null) { return; }
    tr.style.display = '';
}

function hideRow(id){
    var tr;
    if (document.getElementById)
        tr = document.getElementById(id);
    else
        tr = document.all(id);
    if (tr==null) { return; }
    tr.style.display = 'none';
}

