
Number.prototype.toRad=function(){return this*Math.PI/180;}
function object(o){function F(){}
F.prototype=o;return new F();}
LAUNCHDM={};LAUNCHDM.maps=function(){};LAUNCHDM.maps.image_path_base='Portals/0/Location_Images/';LAUNCHDM.maps.json_path='data_json_all.ashx';LAUNCHDM.maps.json_details_path='data_json_individual.ashx';LAUNCHDM.maps.locator_max_distance=2000;LAUNCHDM.maps.locator_max_number=6;LAUNCHDM.maps.onDomReady=function(){this.in_page_map={};this.in_page_map.you_are_here_icon_image="<img src='/portals/_default/skins/vffoskin/images_map/you_are_here.png' alt='You Are Here' />";this.in_page_map.icon_image="<img src='/portals/_default/skins/vffoskin/images_map/marker.gif' height='11' width='11' alt='X' />"
this.in_page_map.createMap=function(div,zoomLevel,lat,lng,map_options_obj){zoomLevel=(zoomLevel==null?4:zoomLevel);lat=(lat==null?38:lat);lng=(lng==null?-96.6:lng);var map=new VEMap(div);var options=new VEMapOptions();options.EnableBirdseye=false;map.LoadMap(new VELatLong(lat,lng),zoomLevel,VEMapStyle.Road,null,null,null,null,options);return map;};this.in_page_map.overlaySourceSpec=function(options){var zindex=(options.zindex==null?3:options.zindex);var bounds=[new VELatLongRectangle(new VELatLong(49,-123),new VELatLong(47,-121))];var tileSourceSpec=new VETileSourceSpecification("andyMap","/portals/_default/skins/vffoskin/images_map/overlay/%4.jpg");tileSourceSpec.NumServers=1;tileSourceSpec.Bounds=bounds;tileSourceSpec.MinZoomLevel=4;tileSourceSpec.MaxZoomLevel=4;tileSourceSpec.Opacity=1;tileSourceSpec.ZIndex=zindex;return(tileSourceSpec);};this.in_page_map.createLocationLayer=function(locations_list){var location_layer=new VEShapeLayer();var i
for(i=0;i<locations_list.length;i+=1){location_layer.AddShape(locations_list[i].shape(this.icon_image));}
return location_layer;}
this.in_page_map.handleClick=function(e){if(e.elementID!=null){var shape=LAUNCHDM.maps.in_page_map.map.GetShapeByID(e.elementID);LAUNCHDM.maps.in_page_map.map.HideInfoBox();if(shape.loc_list_position!=null){LAUNCHDM.maps.more_info(shape.loc_list_position);}}
return true;};this.in_page_map.handleEventBySurpressing=function(){return true;};this.in_page_map.attachEvents=function(){var that=this;this.map.AttachEvent("onclick",that.handleClick);this.map.AttachEvent("onmousewheel",that.handleEventBySurpressing);this.map.AttachEvent("ondoubleclick",that.handleEventBySurpressing);this.map.AttachEvent("onmousedown",that.handleEventBySurpressing);};this.in_page_map.map=this.in_page_map.createMap('map_canvas_in_page',4,null,null,null);this.in_page_map.map.AddTileLayer(this.in_page_map.overlaySourceSpec({'zindex':3}),true);this.in_page_map.map.HideDashboard();this.in_page_map.attachEvents();$('#storelocator').keypress(function(e){if(e.keyCode===13){LAUNCHDM.maps.storeLocator();}});var that=LAUNCHDM.maps.in_page_map;$(window).unload(function(){that.map.Dispose();});var callback=function(json_obj,statusMsg){var i;var locations_raw_list=json_obj.locations;LAUNCHDM.maps.locations_list=[];var location_proto=LAUNCHDM.maps.createLocationProto();for(i=0;i<locations_raw_list.length;i+=1){LAUNCHDM.maps.locations_list.push($.extend(object(location_proto),locations_raw_list[i],{'loc_list_position':i}));}
location_layer=that.createLocationLayer(LAUNCHDM.maps.locations_list);that.map.AddShapeLayer(location_layer);LAUNCHDM.maps.more_info.visible_flag=false;LAUNCHDM.maps.directions.visible_flag=false;var location_text=$(document).getUrlParam("location");if(location_text!=null){LAUNCHDM.maps.storeLocator(location_text);}};$.ajax({type:"GET",url:LAUNCHDM.maps.json_path,dataType:"json",success:callback,beforeSend:function(json_obj,msg){LAUNCHDM.maps.loading_message.show("Loading Map");},error:function(XMLHttpRequest,textStatus,errorThrown){LAUNCHDM.maps.loading_message.hide();alert("An error occurred when loading the locations."+
textStatus+", "+errorThrown);},complete:function(XMLHttpRequest,textStatus){setTimeout(function(){$('#map_image_empty').css('z-index',-1);LAUNCHDM.maps.loading_message.hide();var specific_store=$(document).getUrlParam("id");if(specific_store!=null){var i=0;var foundflag=false;while((i<LAUNCHDM.maps.locations_list.length)&&(!foundflag)){if(LAUNCHDM.maps.locations_list[i].id==specific_store){foundflag=true;LAUNCHDM.maps.more_info(i);}
i+=1;}}},2000);}});};LAUNCHDM.maps.createLocationProto=function(){var location_proto={};location_proto.shape=function(icon_image){var shape=new VEShape(VEShapeType.Pushpin,new VELatLong(this.lat,this.lng));shape.loc_list_position=this.loc_list_position;if(icon_image!=null){shape.SetCustomIcon(icon_image);}
shape.SetDescription(this.infoboxDiv());return(shape);}
location_proto.infoboxDiv=function(){var infobox="<div class='infobox_body'>";infobox+=this.thumbnail();infobox+="<div class='infobox_body_inner'>";infobox+="<h1>"+LAUNCHDM.maps.text2html(this.name)+"</h1>"
infobox+="<div class='address'>";infobox+=LAUNCHDM.maps.text2html(this.address_text());infobox+="</div><div class='phone'>"+LAUNCHDM.maps.text2html(this.phone)+"</div></div>";infobox+="<div class='infobox_links'>"+
this.store_info_link('MORE INFO','first')+" "+
this.directions_link('DIRECTIONS','second')+"</div>";infobox+="</div>";return infobox;};location_proto.address_text=function(){return this.address+"<br />";};location_proto.store_hours_table=function(){return this.hours;};location_proto.store_info_link=function(text,class_name){text=(text==null?'Store Information':text);var link="<a href='#' class='"+class_name+"' onclick=\"LAUNCHDM.maps.more_info("+
this.loc_list_position+");return false;\">"+text+"</a>";return link;};location_proto.directions_link=function(text,class_name){text=(text==null?'Directions':text);var link="<a href='#' class='"+class_name+"' onclick=\"LAUNCHDM.maps.directions("+
this.loc_list_position+");return false;\">"+text+"</a>";return link;};location_proto.thumbnail=function(){return"<img alt='"+this.city+"' width='237' height='152' src='"+LAUNCHDM.maps.image_path_base+"thumb_"+this.image+"' />";};location_proto.more_info_image=function(){return"<img alt='"+this.city+"' width='481' src='"+LAUNCHDM.maps.image_path_base+this.image+"' />";};location_proto.distance=function(latlng){var dlat=(latlng.Latitude-this.lat).toRad();var dlon=(latlng.Longitude-this.lng).toRad();var a=Math.sin(dlat/2)*Math.sin(dlat/2)+
Math.cos(this.lat.toRad())*Math.cos(latlng.Latitude.toRad())*Math.sin(dlon/2)*Math.sin(dlon/2);var c=2*Math.atan2(Math.sqrt(a),Math.sqrt(1-a));var d=3957*c;return Math.round(d*10)/10;}
return(location_proto);};LAUNCHDM.maps.loading_message=function(text){$('#loading_message').html(text);};LAUNCHDM.maps.loading_message.show=function(text){$('#loading_message').html(text);$('#loading_message_outer').fadeIn('slow');};LAUNCHDM.maps.loading_message.hide=function(){$('#loading_message_outer').fadeOut('slow');};LAUNCHDM.maps.more_info=function(location_number){this.in_page_map.map.HideInfoBox();LAUNCHDM.maps.more_info.show();var that=LAUNCHDM.maps;var callback=function(json_details,statusMsg){var msg='';msg+="<img alt='"+
LAUNCHDM.maps.text2html(that.locations_list[location_number].city)+"' width='481' height='295' src='"+
LAUNCHDM.maps.image_path_base+that.locations_list[location_number].image+"' />";msg+="<div id='info'>"
msg+="<div id='close'>"+"<img onclick='LAUNCHDM.maps.directions("+location_number+")' src='/portals/_default/skins/vffoskin/images_map/directions.gif' border='0'>"+"<img onclick='LAUNCHDM.maps.more_info.hide()' src='/portals/_default/skins/vffoskin/images_map/close.gif' border='0'>"+"</div><!-- end close --><span class='moreheader'>"+
LAUNCHDM.maps.text2html(that.locations_list[location_number].state.toUpperCase())+"</span><br><br>";msg+=LAUNCHDM.maps.text2html(json_details.hours);msg+="<span class='moresub'>"+
LAUNCHDM.maps.text2html(that.locations_list[location_number].city.toUpperCase())+"</span><br />";msg+=LAUNCHDM.maps.text2html(that.locations_list[location_number].address_text())+
LAUNCHDM.maps.text2html(that.locations_list[location_number].phone)+'<br />';msg+='<span class="dots"><img src="/portals/_default/skins/vffoskin/images/blank.gif" width="460" height="1"/></span><br />';msg+="<div id='specials'><span class='sub'>Additional information for this VF Outlet location</span><br />";msg+=LAUNCHDM.maps.text2html(json_details.info);if(json_details.carveout==undefined||json_details.carveout===''){}else{msg+="<br /><br />"+LAUNCHDM.maps.text2html(json_details.carveout);}
msg+="</div><!--specials--></div><!-- end info -->";$('#more_info_box').html(msg);};$.ajax({type:"GET",url:"data_json_individual.ashx?id="+that.locations_list[location_number].id,dataType:"json",success:callback,beforeSend:function(json_obj,msg){LAUNCHDM.maps.loading_message.show("Loading Details");},error:function(XMLHttpRequest,textStatus,errorThrown){alert("An error occurred when loading the details."+
textStatus+", "+errorThrown);},complete:function(XMLHttpRequest,textStatus){LAUNCHDM.maps.loading_message.hide();$('#scrollarea').jScrollPane({scrollbarWidth:18,dragMaxHeight:32});}});};LAUNCHDM.maps.more_info.show=function(){var timedelay;if(!LAUNCHDM.maps.more_info.visible_flag){LAUNCHDM.maps.in_page_map.map.HideInfoBox();if(LAUNCHDM.maps.directions.visible_flag){timedelay=1000;}else{timedelay=0;}
LAUNCHDM.maps.directions.hide();setTimeout(function(){$("#mask").css("z-index",31);$("#moreinfobox").animate({left:"161px"},1000);$('#scrollarea').jScrollPane({scrollbarWidth:18,dragMaxHeight:32});},timedelay);LAUNCHDM.maps.more_info.visible_flag=true;}}
LAUNCHDM.maps.more_info.hide=function(){if(LAUNCHDM.maps.more_info.visible_flag){$("#moreinfobox").animate({left:"681px"},1000,function(){$("#mask").css("z-index",-1);});LAUNCHDM.maps.more_info.visible_flag=false;}}
LAUNCHDM.maps.directions=function(location_number,user_address){this.directions.show();var loc_lat_lng=new VELatLong(this.locations_list[location_number].lat,this.locations_list[location_number].lng);this.in_page_map.map.PanToLatLong(loc_lat_lng);this.in_page_map.map.SetZoomLevel(8);this.in_page_map.map.PanToLatLong(loc_lat_lng);this.user_address=user_address||LAUNCHDM.maps.user_address;var msg='';var style_values='';msg+="<div id='close'><img onclick='LAUNCHDM.maps.directions.hide()'"+"src='/portals/_default/skins/vffoskin/images_map/close.gif' border='0'>"+"</div><!-- end close -->";msg+='<h1>Directions</h1>';msg+="<span class='store'>"+
this.locations_list[location_number].city+', '+this.locations_list[location_number].state+'</span>&nbsp;&nbsp;';msg+=this.locations_list[location_number].store_info_link('STORE INFO','go')+'<br />';msg+='<input id="location_number" name="location_number" type="hidden" value="'+location_number+'" />';msg+="<span class='filler_words'>from</span><br />";msg+="<div class='your_address'><h2>Your Address</h2>";if(this.user_address!=null){style_values='display: none;';msg+="<span class='filler_words'>"+this.user_address.Name+"</span>";msg+="  <a href='#' class='go' onclick=\"$('#enter_user_address').toggle('slow');return false;\"><br />Change Address</a><br /><br />";var options=new VERouteOptions;options.RouteCallback=function(route){LAUNCHDM.maps.loading_message.hide();if(route==null){alert("We could not calculate your route either starting or ending point could not be found.");}else{var turns='<img style="border-width:0px; cursor:pointer;" alt="Print" src="/images/action_print.gif" title="Print"/ onclick="LAUNCHDM.maps.directions.print();"><br />';turns+='<b>Trip Duration</b><br />'+route.Distance.toFixed(1)+' miles, '+
(route.Time/60).toFixed(0)+' minutes';var legs=route.RouteLegs;var turnNum=0;legs[0].Itinerary
var i,j,stripe;stripe=false;turns+='<table><tr><th>Details</th><th>Dist.</th></tr>';for(i=0;i<legs.length;i+=1){var step_list=legs[i].Itinerary.Items;for(j=0;j<step_list.length;j+=1){turns+='<tr class="'+(stripe?'stripe1':'stripe2')+'"><td>'+turnNum+': '+step_list[j].Text;turns+='</td><td>'+step_list[j].Distance.toFixed(1)+' mi</td></tr>'
turnNum+=1;stripe=(stripe?false:true);}}
turns+='</table>';$('#map_text_popup').append(turns);setTimeout("$('#map_text_popup_scrollarea').jScrollPane({scrollbarWidth: 18, dragMaxHeight: 32})",100);}};LAUNCHDM.maps.loading_message.show('Loading Directions');this.in_page_map.map.GetDirections([this.user_address.LatLong,loc_lat_lng],options);}
msg+=LAUNCHDM.maps.directions.text_box(style_values);msg+="</div>";$('#map_text_popup').html(msg);$('#user_address').keypress(function(e){if(e.keyCode===13){LAUNCHDM.maps.directions.need_user_address();}});};LAUNCHDM.maps.directions.show=function(){var timedelay;$('#map_image_empty').css('z-index',2);$('#map_text_popup_scrollarea').jScrollPane({scrollbarWidth:18,dragMaxHeight:32});if(!LAUNCHDM.maps.directions.visible_flag){LAUNCHDM.maps.in_page_map.map.HideInfoBox();if(LAUNCHDM.maps.more_info.visible_flag){timedelay=1000;}else{timedelay=0;}
LAUNCHDM.maps.more_info.hide();var map_popup_div=$('#map_popup');$('#map_canvas_popup').append($('#map_canvas_in_page'));setTimeout(function(){map_popup_div.fadeIn('slow');},timedelay);LAUNCHDM.maps.in_page_map.map.HideTileLayer('andyMap');LAUNCHDM.maps.in_page_map.map.DetachEvent('onmousewheel',LAUNCHDM.maps.in_page_map.handleEventBySurpressing);LAUNCHDM.maps.in_page_map.map.DetachEvent('ondoubleclick',LAUNCHDM.maps.in_page_map.handleEventBySurpressing);LAUNCHDM.maps.in_page_map.map.DetachEvent('onmousedown',LAUNCHDM.maps.in_page_map.handleEventBySurpressing);LAUNCHDM.maps.in_page_map.map.ShowDashboard();$('#map_popup :text').unbind('keypress');LAUNCHDM.maps.in_page_map.map.Resize(496,250);LAUNCHDM.maps.directions.visible_flag=true;}}
LAUNCHDM.maps.directions.hide=function(){if(LAUNCHDM.maps.directions.visible_flag){$('#map_image_empty').css('z-index',2);var map_popup_div=$('#map_popup');$('#map_canvas_container').append($('#map_canvas_in_page'));$('#map_canvas_in_page').height(400);$('#map_canvas_in_page').width(665);var that=LAUNCHDM.maps.in_page_map;that.map.Dispose();that.map=that.createMap('map_canvas_in_page',4,null,null,null);that.map.AddTileLayer(that.overlaySourceSpec({'zindex':3}),true);that.map.HideDashboard();var location_layer=that.createLocationLayer(LAUNCHDM.maps.locations_list);that.map.AddShapeLayer(location_layer);that.attachEvents();map_popup_div.fadeOut('slow');LAUNCHDM.maps.directions.visible_flag=false;setTimeout(function(){$('#map_image_empty').css('z-index',-1);},500);}}
LAUNCHDM.maps.directions.text_box=function(style_values){var tb="<div id='enter_user_address' style=\""+style_values+"\"><input id='user_address' name='user_address' type='text' "+"class='locatorbox' value='' size='30' maxlength='80' /> "+"<a href='###' class='go' "+'onclick="LAUNCHDM.maps.directions.need_user_address();return false;">GO</a>'+'</div>';return tb;}
LAUNCHDM.maps.directions.print=function(){myWindow=window.open('','mywindow','resizable=yes,scrollbars=yes,toolbars=no,top=10,left=10');var dir_content=$('#map_text_popup').html();dir_content=dir_content.replace(/^.*LAUNCHDM.maps.directions.print\(\);\"\>/,"");myWindow.document.write(dir_content);myWindow.document.close();}
LAUNCHDM.maps.directions.need_user_address=function(where,location_number){var where=where||$('#user_address').get(0).value;var location_number=(location_number!=null?location_number:$('#location_number').get(0).value);var callback_function=function(a,b,addri,d,e){var i;if(addri!=null){if(addri[0].MatchConfidence===0||addri.length===1){LAUNCHDM.maps.directions(location_number,addri[0]);}else{msg="<span class='leading_message'>More than one location was returned.<br />"+"Please select the location you were looking for:</span><br />";for(i=0;i<addri.length;i+=1){msg+="<a href='#' class='go' onclick=\"LAUNCHDM.maps.directions.need_user_address('";msg+=addri[i].Name+"',"+location_number+");return false;\">";msg+=addri[i].Name;msg+="</a><br />";}
msg+='Enter a new address: <br />';msg+='<input id="location_number" name="location_number" type="hidden" value="'+location_number+'" />';msg+=LAUNCHDM.maps.directions.text_box();$('#map_text_popup').html(msg);}}};LAUNCHDM.maps.FindAddriList(where,callback_function);};LAUNCHDM.maps.storeLocator=function(location_strng){var where=location_strng||$('#storelocator').get(0).value;if(where!=null&&where!=''){var msg="<div id='close'><img onclick='LAUNCHDM.maps.directions.hide()'"+"src='/portals/_default/skins/vffoskin/images_map/close.gif' border='0'>"+"</div><!-- end close -->";msg+="<h1>Store Locator Results</h1>";$('#map_text_popup').html(msg);var call_backfunction=function(a,b,addri,d,e){var max_distance=LAUNCHDM.maps.locator_max_distance;var i,j;var msg='';var style_options;if(addri!=null){if(addri[0].MatchConfidence===0||addri.length===1){LAUNCHDM.maps.in_page_map.map.SetCenterAndZoom(addri[0].LatLong,6);LAUNCHDM.maps.user_address=addri[0];var loc_dist_list=[];style_options='display: none;';msg="<span class='user_where'>"+addri[0].Name+"</span> <a href='#' class='go' onclick =\""+"$('#enter_user_address_store_locator').toggle('slow');return false;\">"+"<br />Change Address</a><br />";msg+="<div id='enter_user_address_store_locator' "+"style='"+style_options+"'>Enter a new location<br />";msg+="<input id='update_locatorbox' name='update_locatorbox' type='text' "+"class='locatorbox' value='' size='30' maxlength='80' /> "+"<a href='###' class='go' "+"onclick=\"LAUNCHDM.maps.storeLocator($('#update_locatorbox').get(0).value);return false;\">GO</a></div>";$('#map_text_popup').append(msg);msg='';for(i=0;i<LAUNCHDM.maps.locations_list.length;i+=1){var loc_dist={};loc_dist.loc_num=i;loc_dist.distance=LAUNCHDM.maps.locations_list[i].distance(addri[0].LatLong);if(loc_dist.distance<max_distance){loc_dist_list.push(loc_dist);}}
LAUNCHDM.maps.sortPositionDistance(loc_dist_list);var stripe=false;if(loc_dist_list.length>0){msg+="<table>";var max=LAUNCHDM.maps.locator_max_number;var len=(loc_dist_list.length<max?loc_dist_list.length:max);for(j=0;j<len;j+=1){i=loc_dist_list[j].loc_num;msg+='<tr class="'+(stripe?'stripe1':'stripe2')+'"><td>';stripe=(stripe?false:true);msg+=LAUNCHDM.maps.locations_list[i].distance(addri[0].LatLong)+' miles ';msg+="</td><td>";msg+="<a href='#' class='go' onmouseover=\"LAUNCHDM.maps.in_page_map.map.SetCenter("+"new VELatLong(LAUNCHDM.maps.locations_list["+i+"].lat, "+"LAUNCHDM.maps.locations_list["+i+"].lng));return false;\""+"onclick=\"LAUNCHDM.maps.more_info("+i+");return false;\""+">";msg+=LAUNCHDM.maps.locations_list[i].city+' '+LAUNCHDM.maps.locations_list[i].state+'</a> ';msg+="</td><td>";msg+="(<a href='#' class='go' "+"onmouseover=\"LAUNCHDM.maps.in_page_map.map.SetCenter("+"new VELatLong(LAUNCHDM.maps.locations_list["+i+"].lat, "+"LAUNCHDM.maps.locations_list["+i+"].lng));return false;\""+"onclick=\"LAUNCHDM.maps.directions("+i+");return false;\""+">directions</a>)";msg+="</td></tr>";}
msg+="</table>";}else{msg+="No stores are located within "+max_distance+" miles of your location."
msg+="<br />Please change your address.";$('#enter_user_address_store_locator').show();}}else{msg="More than one location was returned. "+"Please select the location you were looking for:<br />";for(i=0;i<addri.length;i+=1){msg+="<a href='#' class='go'"+"onclick=\"LAUNCHDM.maps.storeLocator('"+addri[i].Name+"');"+"return false;\">"+addri[i].Name+"</a><br />";}
msg+="or";msg+="<div id='enter_user_address_store_locator' "+"style='"+style_options+"'>Enter a new location: ";msg+="<input id='update_locatorbox' name='update_locatorbox' type='text' "+"class='locatorbox' value='' size='30' maxlength='80' /> "+"<a href='###' class='go' "+"onclick=\"LAUNCHDM.maps.storeLocator($('#update_locatorbox').get(0).value);return false;\">GO</a></div>";}
$('#map_text_popup').append(msg);$('#update_locatorbox').keypress(function(e){if(e.keyCode===13){LAUNCHDM.maps.storeLocator($('#update_locatorbox').get(0).value);}});setTimeout("$('#map_text_popup_scrollarea').jScrollPane({scrollbarWidth: 18, dragMaxHeight: 32})",100);}else{$('#map_text_popup').append("You location does not compute");}};LAUNCHDM.maps.directions.show();LAUNCHDM.maps.FindAddriList(where,call_backfunction);}else{alert("Please enter location information (Zip Code or City State or Full Address)");}};LAUNCHDM.maps.FindAddriList=function(where,callback_function){var what=null;var start_index=null;var numberOfResults=null;var showResult=null;var createResult=null;var disambiguation=false;var bestMapView=false;try{this.in_page_map.map.Find(what,where,null,null,start_index,numberOfResults,showResult,createResult,disambiguation,bestMapView,callback_function);}catch(e){alert('FindAddriList Error: '+e.message);}};LAUNCHDM.maps.sortPositionDistance=function(loc_dist_list){var i,temp;var still_working_flag=true;while(still_working_flag){still_working_flag=false;for(i=1;i<loc_dist_list.length;i+=1){if(loc_dist_list[i].distance<loc_dist_list[i-1].distance){temp=loc_dist_list[i];loc_dist_list[i]=loc_dist_list[i-1];loc_dist_list[i-1]=temp;still_working_flag=true;}}}}
LAUNCHDM.maps.text2html=function(text){return text.replace(/&lt;/g,"<").replace(/&gt;/g,'>').replace(/&amp;/g,"&").replace(/&quot;/g,'"').replace(/&apos;/g,"'");};