function _el(id){
    return document.getElementById(id);
}

function setElVisibility(id,status) {
    _el(id).style.display = (status)?'':'none';
}
function showHide(id) {
    _el(id).style.display = (_el(id).style.display=='none')?'':'none';
    return false;
}


var oldid=0;
function showoffice(id) {
    _el('office'+oldid).style.display='none';
    _el('office'+id).style.display='';
    _el('office').selectedIndex=id;
    oldid = id;
}


function fillCompanyId() {
    var str = '';
    for(i=0;i<6;i++) {
        _el('CompanyID_'+(i+1)).value = (_el('ch3'+i).checked)?_el('ch3'+i).value:'';
    }
}

function checkSearchForm() {
    
    if (!(_el('ch30').checked || _el('ch31').checked || _el('ch32').checked || _el('ch33').checked || _el('ch34').checked || _el('ch35').checked)) {
        alert('Please select office');
        return false;
    }

    if (_el('Min').value!='' && !parseInt(_el('Min').value)) {
        alert('Price is not numeric');
        return false;
    }
    if (_el('Max').value!='' && !parseInt(_el('Max').value)) {
        alert('Price is not numeric');
        return false;
    }

    fillCompanyId()
    
    return true;
}

function checkallcompany(checked) {
    for(i=0;i<6;i++) {
        _el('ch3'+i).checked = checked;
    }
    _el('checkall').checked = checked;
}

function checksalerent() {
    if (_el('r2').checked) {
        checkallcompany(true);
        return;
    }
    if (arguments.length==1 && !arguments[0]) {
        _el('checkall').checked = arguments[0];
    }
}