function getIndices(selector){var myArray=new Array()
var i;for(i=0;i<$(selector).length;i=i+1){var j;var numSelected;for(j=0,numSelected=0;j<$(selector)[i].length;j=j+1){if($(selector)[i][j].selected){numSelected=numSelected+1;if(numSelected===8){alert("A maximum of 7 options may be chosen at once, only the first 7 options will be displayed.");break;}
myArray.push($(selector)[i][j].text);}}}
return myArray;}
function registerSelectHandlers(){$("select").click(function(e){$("select").not($(this)).attr("disabled",1);});}
function registerButtonHandlers(){$("#buttonClear").click(function(e){$("select").attr("selectedIndex",-1).attr("disabled",0);$("#content").html($(document).data("defaultContent").html());e.preventDefault();});$("#buttonSubmit").click(function(e){var companies=getIndices("#companiesSelect");var provinces=getIndices("#provincesSelect");var regions=getIndices("#regionsSelect");var strikes=getIndices("#strikesSelect");$.ajax({type:"post",url:"../../cgi-bin/xiApp_CgiAreaSearch.py",data:{"companies":companies,"provinces":provinces,"regions":regions,"strikes":strikes},cache:false,global:false,beforeSend:function(){$("#contentLoading").show("fast");},success:function(html){$("#content").html(html);},complete:function(){$("#contentLoading").fadeOut("fast");}});e.preventDefault();});}
function registerEventHandlers(){registerSelectHandlers();registerButtonHandlers();}
function populateSelects(){$.ajax({type:"get",url:"../../cgi-bin/xiApp_CgiAreaSearch.py?selectors=true",cache:false,global:false,beforeSend:function(){$("#contentLoading").show("fast");},success:function(html){$("#selectors").append(html);},complete:function(){registerEventHandlers();$("#contentLoading").fadeOut("fast");}});}
$(function(){populateSelects();$(document).data("defaultContent",$("#content").clone())});


