// onerror=handleErr
var txt=""

function handleErr(msg,url,l)
{
    txt="JAVASCRIPT ERROR.\n\n"
    txt+="Error: " + msg + "\n"
    txt+="URL: " + url + "\n"
    txt+="Line: " + l + "\n"
    txt+="Please refer this to the administrator.\n\n"
    txt+="Click OK to continue.\n\n"
    alert(txt)
    return true
}

function checkAll(theElement) {
    var theForm = theElement.form, z = 0;
        for(z=0; z<theForm.length; z++){
            if(theForm[z].type == 'checkbox'){
                theForm[z].checked = true;
            }
        }
    document.forms['searchForm'].submit();
}

function uncheckAll(theElement) {
    var theForm = theElement.form, z = 0;
        for(z=0; z<theForm.length; z++){
            if(theForm[z].type == 'checkbox'){
                theForm[z].checked = false;
            }
        }
    document.forms['searchForm'].submit();
}


function sortItByName() {
    var sort;
    sort = document.getElementById("nameSort").value;
    
    if (sort == "false")
      document.getElementById("nameSort").value = "true";
    else
      document.getElementById("nameSort").value = "false";
      
    doRedirect(1);
}


function searchCriteria(onoff, indice) {
    box = document.getElementById("boxricerca");
    
    if (onoff == 0){
        document.getElementById("searchCriteria").value = "false";
        box.style.visibility = "hidden";
        box.style.display = "none";
    }
    else{
        document.getElementById("searchCriteria").value = "true";
        box.style.visibility = "visible";
        box.style.display = "block";
    }
}

function sortItByDate() {
    var sort;
    sort = document.getElementById("dateSort").value;
    
    if (sort == "false")
      document.getElementById("dateSort").value = "true";
    else
      document.getElementById("dateSort").value = "false";
      
    doRedirect(1);
}

function downloadSubmit(i){
    var browser = navigator.appName;
    var formName = "downloadDocumentForm_"+i;
    // var b_version=navigator.appVersion
    // var version=parseFloat(b_version)
    // alert(formName);
    if (browser == 'Netscape'){
        document.forms[formName].submit();
    }
    else{
        document.getElementById(formName).submit();
    }
}
  
function doRedirect(indice) {
    var browser = navigator.appName;

    if (browser == 'Netscape'){
        document.getElementById("pageNum").value = indice;
        document.getElementById("pagingForm").submit();
    }
    else{
        document.getElementById("pageNum").value = indice;
        document.getElementById("pagingForm").submit();
    }
}

function show(id) {
    if (document.getElementById) {
        document.getElementById(id).style.display="block";
    }
    else if (document.all) {
        document.all[id].style.display="block";
    }
    else if (document.layers) {
        document.layers[id].display="block";
    } 
} 

function hide(id) {
	if (document.getElementById) {
       	document.getElementById(id).style.display="none";
	}

	else if (document.all) {
       	document.all[id].style.display="none";
	}

	else if (document.layers) {
       	document.layers[id].display="none";
	} 
}

function expandSELECT(sel) {
	var browsername= navigator.appName;

	if (browsername.indexOf("Microsoft")!=-1) {
		sel.style.width = '320px';
	}
}


function contractSELECT(sel) {
	var browsername= navigator.appName;

	if (browsername.indexOf("Microsoft")!=-1) {
		sel.style.width = '156px';
	}
}