function selectAll(theElement) {
    var theForm = theElement.form, z = 0;
    for(z=0; z<theForm.length;z++){
        if(theForm[z].type == 'checkbox' && theForm[z].name != 'selectall'){
            theForm[z].checked = theElement.checked;
        }
    }
}

function show( id , call ) {
    var theElement = document.getElementById( id );
    if ( !theElement ) return;
    
    theElement.style.display = (theElement.style.display == 'none') ? 'block' : 'none';
    call.innerHtml = 'Hide Search';
}


/*
    The following scripting is used to populate the select boxes for the company
    and location hierarchy.
*/
var ajax = new sack();
var sub;

function getLocationList(sel, dep) {
	var val = sel.options[sel.selectedIndex].value;
	sub = document.getElementById(dep);
	sub.options.length = 0;
	if(val == -1) {
		sub.disabled = true;
		sub.options[0] = new Option('','-1');
	}
	else {
		ajax.requestFile = '/getLocations.php?company=' + val;
		ajax.onCompletion = evaluate;
		ajax.runAJAX();
	}
}

function getRelatedList(sel, dep) {
	var val = sel.options[sel.selectedIndex].value;
	sub = document.getElementById(dep);
	sub.options.length = 0;
	if(val == -1) {
		sub.disabled = true;
		sub.options[0] = new Option('','-1');
	}
	else {
		ajax.requestFile = '/getRelated.php?company=' + val;
		ajax.onCompletion = evaluate;
		ajax.runAJAX();
	}
}

function setView(doc_name)
{
	var link = document.getElementById("view_document");
	link.style.display = "inline";
	link.href="/files/pm_docs/" + doc_name;
}

function evaluate() {
	eval(ajax.response);
}

/*
    END Section
*/