(function($){$.fn.selectChain=function(options){var defaults={key:"id",value:"label",preselect:":first"};var settings=$.extend({},defaults,options);if(!(settings.target instanceof $))settings.target=$(settings.target);var preselect_string=settings.preselect;if(typeof(settings.preselect)!="undefined"&&settings.preselect!=''&&settings.preselect!=':first'){preselect_string='[value='+settings.preselect+']';}
return this.each(function(){var $$=$(this);$$.change(function(){var data=null;if(typeof settings.data=='string'){data=settings.data+'&'+this.name+'='+$$.val();}else if(typeof settings.data=='object'){data=settings.data;data[this.name]=$$.val();}
settings.target.empty();$.ajax({url:settings.url,data:data,type:(settings.type||'get'),dataType:'json',success:function(j){var options=[],i=0,o=null;for(i=0;i<j.length;i++){o=document.createElement("OPTION");o.value=typeof j[i]=='object'?j[i][settings.key]:j[i];o.text=typeof j[i]=='object'?j[i][settings.value]:j[i];settings.target.get(0).options[i]=o;}
setTimeout(function(){if(settings.target.find(preselect_string).length==0){preselect_string=':first';}
settings.target
.find(preselect_string)
.attr('selected','selected')
.parent('select')
.trigger('change');},0);},error:function(xhr,desc,er){alert("An internal error occured. Please try again in a few seconds.");}});});});};})(jQuery);

$(document).ready(function(){var continent=$('#maps-continent');var map=$('#maps-map');var month=$('#maps-month');continent.selectChain({target:map,url:'/wind-cgi/qa-maps.pl',data:{mode:'windstat'}});map.change(function(){if(map.val()!=""){location.href="/windstats/windstatistic_map_"+map.val()+".htm";}});month.change(function(){if(month.val()!=""){location.href="/windstats/windstatistic_map_"+month.val()+".htm";}});continent.trigger('change');})

