var current_resort=-1;var symbols="";var CROSSHAIR_GAP=5;var default_map_width=603;var default_map_height=410;var PLACES_X=2;var PLACES_Y=3;var icons_dir="/pa/fcmaps/images/";function imgLoadError(a){alert("For some reason, image "+this.src+" could not be loaded. This might be a temporary\n connection problem - try clicking Refresh button. If this message reoccurs, please contact us.")}function scriptLoadError(a){alert("For some reason, script "+this.src+" could not be loaded. This might be a temporary\n connection problem - try clicking Refresh button. If this message reoccurs, please contact us.")}var ScriptLoader={loaded:0,scripts:[],add:function(a){this.scripts[this.scripts.length]=a},load:function(){var a;var c=document.getElementsByTagName("head")[0];for(var b=0;b<this.scripts.length;b++){a=document.createElement("script");if(a.attachEvent){a.attachEvent("onreadystatechange",ScriptLoader.onScriptLoaded)}else{if(a.addEventListener){a.addEventListener("load",ScriptLoader.onScriptLoaded,false)}else{return false}}a.type="text/javascript";a.src=this.scripts[b];a.defer=false;c.appendChild(a)}},onScriptLoaded:function(b){b=b||window.event;var a=b.target||b.srcElement;var c=true;if(typeof a.readyState!="undefined"){c=(a.readyState=="complete"||a.readyState=="loaded")}if(c){ScriptLoader.loaded++;if(ScriptLoader.loaded==ScriptLoader.scripts.length){ScriptLoader.onLoadComplete()}}},onLoadComplete:function(){}};var ImageLoader={loaded:0,images:[],image_objects:new Object(),add:function(a){this.images[this.images.length]=a},load:function(){var b;for(var a=0;a<this.images.length;a++){b=document.createElement("img");b.onload=ImageLoader.onImageLoaded;b.onerror=ImageLoader.onImageLoaded;b.onabort=ImageLoader.onImageLoaded;this.image_objects[this.images[a]]=b;this.image_objects[this.images[a]].src=this.images[a]}},onImageLoaded:function(a){ImageLoader.loaded++;if(ImageLoader.loaded==ImageLoader.images.length){ImageLoader.onLoadComplete()}},onLoadComplete:function(){}};function setMouseOver(b){if(symbols=="livecams"){var c=places_multi[b.id][1]+'<br/><img class="maptipimg" src="http://img.snow-forecast.com/webcams/t_'+places_multi[b.id][0]+'.jpg" />';var a="img-map-tip"}else{if(symbols=="mountain"){var c=places_multi[b.id][1]+" ("+places_multi[b.id][5]+")";var a="map-tip"}else{var c=places_multi[b.id][1];var a="map-tip"}}$(b).wTooltip({content:c,className:a,style:false})}function mouseClick(){if(symbols=="livecams"){top.location="http://www.snow-forecast.com/resorts/"+places_multi[this.id][0]+"/webcams/latest"}else{if(symbols=="liveswell"){top.location="http://www.surf-forecast.com/buoys/"+places_multi[this.id][0]+"/by_filename"}else{if((symbols!="liveweather")&&(symbols!="livewind")&&(symbols!="livetemp")){switch(places_multi[this.id][4]){case 1:top.location="http://www.snow-forecast.com/resorts/"+places_multi[this.id][0];break;case 2:top.location="http://www.surf-forecast.com/breaks/"+places_multi[this.id][0];break;case 3:top.location="http://www.weather-forecast.com/locations/"+places_multi[this.id][0];break;case 4:top.location="http://www.tide-forecast.com/locations/"+places_multi[this.id][0]+"/tides/latest";break;case 5:top.location="http://www.mountain-forecast.com/peaks/"+places_multi[this.id][0];break}}}}}function getSymbolOffset(){if(symbols=="liveweather"){return 14}else{if(symbols=="liveswell"){return 13}else{if(symbols=="livewind"){return 18}else{if(symbols=="livetemp"){return 18}else{if(symbols=="livecams"){return 10}else{return 3}}}}}}function getSymbolSize(){if(symbols=="liveweather"){return 28}else{if(symbols=="liveswell"){return 27}else{if(symbols=="livewind"){return 36}else{if(symbols=="livetemp"){return 36}else{if(symbols=="livecams"){return 20}else{return 7}}}}}}function highlightResort(d){var b=getSymbolOffset();var h=document.getElementById("mapimg");var g=h.width?parseInt(h.width):default_map_width;var k=h.height?parseInt(h.height):default_map_height;var i=document.getElementById("crossL");var a=Math.round(places_multi[d][PLACES_X])-b-CROSSHAIR_GAP;if(a>0){i.style.width=a+"px";i.style.top=(Math.round(places_multi[d][PLACES_Y]))+"px";i.style.display="block"}else{i.style.display="none"}var e=document.getElementById("crossR");a=g-Math.round(places_multi[d][PLACES_X])-b-CROSSHAIR_GAP;if(a>0){e.style.width=a+"px";e.style.top=(Math.round(places_multi[d][PLACES_Y]))+"px";e.style.display="block"}else{setTimeout("highlightResort("+d+")",250);e.style.display="none"}var f=document.getElementById("crossU");var j=Math.round(places_multi[d][PLACES_Y])-b-CROSSHAIR_GAP;if(j>0){f.style.height=j+"px";f.style.left=(Math.round(places_multi[d][PLACES_X]))+"px";f.style.display="block"}else{f.style.display="none"}var c=document.getElementById("crossD");var j=k-Math.round(places_multi[d][PLACES_Y])-b-CROSSHAIR_GAP;if(j>0){c.style.height=j+"px";c.style.left=(Math.round(places_multi[d][PLACES_X]))+"px";c.style.display="block"}else{c.style.display="none"}current_resort=d}function cleanResortsSelect(d){var a=document.getElementById("filtered_resorts");for(var c=a.options.length-1;c>=0;c--){a.options[c]=null}if(d){var b=new Option("------------",c);a.options[0]=b}}function findActiveResort(){for(var a=0;a<places_multi.length;a++){place_arr=places_multi[a];if(params.highlight==place_arr[0]){return a}}return -1}function setResortSelect(c){var b=document.getElementById("filtered_resorts");for(var a=0;a<b.options.length;a++){if(b.options[a].value==c){b.options[a].selected=true;break}}}function showPlaces(a){symbols=a;if(a=="none"){cleanResortsSelect(true);return}else{ScriptLoader.loaded=0;ScriptLoader.scripts=[];ScriptLoader.add(getSymbolsFileName(a));ScriptLoader.onLoadComplete=function(){checkShowPlaces(false)};ScriptLoader.load()}}function checkShowPlaces(o){var q;var g=document.getElementById("mapcontainer");var h=document.createElement("div");var l;var d=document.getElementById("filtered_resorts");if(typeof places_multi!="undefined"){if(params.highlight){var n=findActiveResort();if((n==-1)&&(params.x)){if((symbols=="liveweather")||(symbols=="livetemp")||(symbols=="livewind")){places_multi[places_multi.length]=new Array(params.highlight,params.name,params.x,params.y)}else{places_multi[places_multi.length]=new Array(params.highlight,params.name,params.x,params.y,1)}n=places_multi.length-1}}if((n==-1)||(typeof n=="undefined")){n=0}if(places_multi.length){cleanResortsSelect(false)}else{cleanResortsSelect(true)}var c=getSymbolOffset();var m=c;var j=getSymbolSize();var p=j;if(!o){var k=new Object();var a;ImageLoader.loaded=0;ImageLoader.images=[];ImageLoader.image_objects=new Object();ImageLoader.onLoadComplete=function(){checkShowPlaces(true)};var f=0;for(var e=0;e<places_multi.length;e++){q=places_multi[e];if(symbols=="liveweather"){if(q[4]){a=icons_dir+"smallweathericons/"+q[4]}else{a=icons_dir+"smallweathericons/daynoweather.gif"}}else{if(symbols=="liveswell"){a="/smallswellicons/small"+convert_swell_icon(q[4],units)}else{if(symbols=="livewind"){if(q[5]){a=icons_dir+"smallwindicons/"+convert_wind_icon(q[5],units)}else{a=icons_dir+"smallweathericons/daynoweather.gif"}}else{if(symbols=="livetemp"){if(q[14]){a=icons_dir+"smalltempicons/"+units+"."+Math.round(parseFloat(q[14]))+".gif"}else{a=icons_dir+"smallweathericons/daynoweather.gif"}}else{if(symbols=="livecams"){a="/pa/fcmaps/images/Camera.gif"}else{switch(q[4]){case 1:a="/pa/fcmaps/images/red.gif";break;case 2:a="/pa/fcmaps/images/blue.gif";break;case 3:a="/pa/fcmaps/images/city.gif";break;case 4:a="/pa/fcmaps/images/darkblue.gif";break;case 5:a="/pa/fcmaps/images/mountain.gif";break}}}}}}if(!k[a]){k[a]=true;ImageLoader.add(a);f++}}ImageLoader.load()}else{for(var e=0;e<places_multi.length;e++){q=places_multi[e];var b=new Option(q[1],e);d.options[e]=b;if(symbols=="liveweather"){if(q[4]){a=icons_dir+"smallweathericons/"+q[4]}else{a=icons_dir+"smallweathericons/daynoweather.gif"}}else{if(symbols=="liveswell"){a="/smallswellicons/small"+convert_swell_icon(q[4],units)}else{if(symbols=="livewind"){if(q[5]){a=icons_dir+"smallwindicons/"+convert_wind_icon(q[5],units)}else{a=icons_dir+"smallweathericons/daynoweather.gif"}}else{if(symbols=="livetemp"){if(q[14]){a=icons_dir+"smalltempicons/"+units+"."+Math.round(parseFloat(q[14]))+".gif"}else{a=icons_dir+"smallweathericons/daynoweather.gif"}}else{if(symbols=="livecams"){a="/pa/fcmaps/images/Camera.gif"}else{switch(q[4]){case 1:a="/pa/fcmaps/images/red.gif";break;case 2:a="/pa/fcmaps/images/blue.gif";break;case 3:a="/pa/fcmaps/images/city.gif";break;case 4:a="/pa/fcmaps/images/darkblue.gif";break;case 5:a="/pa/fcmaps/images/mountain.gif";break}}}}}}l=ImageLoader.image_objects[a].cloneNode(false);l.width=j;l.height=p;l.id=e;setMouseOver(l);if(!noClick){l.onclick=mouseClick;l.style.cursor="pointer"}l.style.position="absolute";l.style.left=q[2]-c+"px";l.style.top=q[3]-m+"px";l.style.zIndex=2;g.appendChild(l)}if(places_multi.length){highlightResort(n)}if(params.highlight){setResortSelect(n)}}}return}function switchSymbols(a){var c=document.getElementById("mapcontainer");var b=0;while(img_obj=document.getElementById(b++)){c.removeChild(img_obj)}showPlaces(a)}function convert_wind_icon(b,a){if(a=="metric"){return b}else{var c=/(wind[A-Z]+)(\d+)metric\.gif/;result=c.exec(b);if(result!=null){val=parseFloat(result[2]);tmp=Math.round(val*0.6214/5)*5;return result[1]+tmp+"imperial.gif"}else{return b}}}function convert_swell_icon(b,a){if(a=="metric"){return b}else{var c=/(swell\.[A-Z-]+)\.(\d+)\.metric\.([\d-]+)\.gif/;result=c.exec(b);if(result!=null){val=parseFloat(result[2]);tmp=Math.round(val*3.281/5)*5;return result[1]+"."+tmp+".imperial."+result[3]+".gif"}else{return b}}};