
// Creates the contact box for sending a message to the agents.
function contactBox(p) {
    var B='contactbox';
    var R='result-'+p;
    while($(B)){Element.remove($(B));}
    new Insertion.Bottom(R,'<div id=\"'+B+'\" style=\"display:none\"></div><br clear=\"left\" />');
    new Ajax.Updater(B, '/browse/contact_agent/'+p,{onComplete:function(){new Effect.SlideDown(B);}});
}

function selectall() {
    $$('input.cbx').collect(function(x){return x.id.substr(4,20)}).each(function(i){cbx_select(i);});
}
function cbx_toggle(id) {if($('li'+id).hasClassName('selected')){cbx_deselect(id);} else {multiselect(id);}}

function cbx_select(id) {
    $('li'+id).addClassName('selected');
    $('li'+id).removeClassName('notsel');
    $('area'+id).value=id;
}

function cbx_deselect(id) {
    $('li'+id).addClassName('notsel');
    $('li'+id).removeClassName('selected');
    $('area'+id).value='';
}

function cbx_prep() {
    alert($$('area[]').each(function(f){return f.value}))
}

function doform() {
    a=$$('input.cbx').collect(function(x){if(x.value!=''){return x.value}}).compact();
    if(a==0) {
        $('flash').update('<p><strong>You have not chosen any areas to search.</strong></p>');
        return false;
    } else {return true;}
}

var G=[];
// Central SW
G[0]=[28,53,58];
G[1]=[12,50,11];
G[2]=[56,46,67];
G[3]=[15,29,25];
G[4]=[71,14,49];
G[5]=[30,26];
G[6]=[43,17,16,75];
G[7]=[27,55,65];
G[8]=[57];
// Northwest
G[9]=[42,59,35,32];
G[10]=[64,31,44,40,4];
G[11]=[33,8,41];
G[12]=[5,9,66,10];
G[13]=[74,6,34,7];
// SoR
G[14]=[22,63,21];
G[15]=[18,20,19,37];
G[16]=[38,24,39];
G[17]=[61,69,70];
G[18]=[72,68,62];


function multiselect(id) {
        var w = G.find(function(list){return list.include(id)});
        if(w) w.each(function(a){cbx_select(a)});
}