$(document).ready(function(){$("#keywordSearch .text, #locationSearch .text, #searchAddress").toggleVal('inputFocus');$("#dataBtn").click(function(){if(!$(this).hasClass("active")){$(this).addClass("active");$("#mapBtn").removeClass("active");$("#map, #photoBox, #busBtn").hide();$("#dataView").show();$("#dataView h3.heading small").show();$("#dataView .notes h3.heading small").html('('+n_t+')');$("#dataView .photos h3.heading small").html('('+p_t+')');dv_first_open=true;$("#noteList").load("/data/notes/",{pid:this_artist},function(responseText,textStatus,request){if($("#noteList li.next").html()!="1"){$("#notePagination li.next").hide();}else{$("#notePagination li.next").show();}
$(".notes .dataBody").show();fetchFirstDataNote();});$("#photoList").load("/data/photos/",{pid:this_artist},function(responseText,textStatus,request){if($("#photoList li.next").html()!="1"){$("#photoPagination li.next").hide();}else{$("#photoPagination li.next").show();}
$(".photos .dataBody").show();});}
return false;});$("#mapBtn").click(function(){$("#dataBtn").removeClass("active");$(this).addClass("active");$("#photoBox, #dataView, #dataView h3.heading small").hide();$("#map, #busBtn").show();map.checkResize();selected_tour_date=0;note_page=0;photo_page=0;$(".dataBody, #notePagination li.next, #notePagination li.prev, #photoPagination li.next, #photoPagination li.prev").hide();if($.browser.msie&&user_markers.length>0)showSearchMarker(0);return false;});$("#busBtn").click(function(){if(tour_markers.length>0){GEvent.trigger(tour_markers[0],"click");map.setCenter(tour_markers[0].point,8);}
return false;})
$("#busBtn").mouseup(function(){$(this).removeClass('active');}).mousedown(function(){$(this).addClass('active');});$("#closeAdd").click(function(){removeMarker(marker);return false;});$("#closeSearch").click(function(){closeSearchBar();return false;});$("#addNoteButton").click(function(){if(login_required){openLightbox('userLoginBox',false);}else{if(!allow_add){toggleAddMarkerBar();note_type='note';$("#markerBox li a").addClass('buttonOpacity');}}
return false;});$("#addPhotoButton").click(function(){if(login_required){openLightbox('userLoginBox',false);}else{if(!allow_add){toggleAddMarkerBar();note_type='photo';$("#markerBox li a").addClass('buttonOpacity');}}
return false;});$("#locationSearch").submit(function(){locationSearch();$("#dataView").hide();$("#map").show();return false;});$("#keywordSearch").submit(function(){$("#dataView").hide();$("#map").show();var search_query=$("#keyword_q").val();if(search_query!=_t("Name/Keyword")&&search_query!=""){getSearchMarkers(null,search_query);}
return false;});fetchFirstDataNote();$("#notePagination li.next a").click(function(){note_page++;toggleLoader($("#notePagination"));$("#noteList").load("/data/notes/",{p:note_page,pid:this_artist,tid:selected_tour_date},function(responseText,textStatus,request){if($("#noteList li.next").html()!="1")$("#notePagination li.next").hide();toggleLoader($("#notePagination"));fetchFirstDataNote();});if(note_page>0)$("#notePagination li.prev").show();return false;});$("#notePagination li.prev a").click(function(){if(note_page>0)note_page--;toggleLoader($("#notePagination"));$("#noteList").load("/data/notes/",{p:note_page,pid:this_artist,tid:selected_tour_date},function(responseText,textStatus,request){if($("#noteList li.next").html()=="1")$("#notePagination li.next").show();fetchFirstDataNote();toggleLoader($("#notePagination"));});if(note_page==0){$("#notePagination li.prev").hide();$("#notePagination li.next").show();}
return false;});$("#photoPagination li.next a").click(function(){photo_page++;toggleLoader($("#photoPagination"));$("#photoList").load("/data/photos/",{p:photo_page,pid:this_artist,tid:selected_tour_date},function(responseText,textStatus,request){if($("#photoList li.next").html()!="1")$("#photoPagination li.next").hide();toggleLoader($("#photoPagination"));});if(photo_page>0)$("#photoPagination li.prev").show();return false;});$("#photoPagination li.prev a").click(function(){if(photo_page>0)photo_page--;toggleLoader($("#photoPagination"));$("#photoList").load("/data/photos/",{p:photo_page,pid:this_artist,tid:selected_tour_date},function(responseText,textStatus,request){if($("#photoList li.next").html()=="1")$("#photoPagination li.next").show();toggleLoader($("#photoPagination"));});if(photo_page==0){$("#photoPagination li.prev").hide();$("#photoPagination li.next").show();}
return false;});$("#searchBar li.next a").click(function(){if(search_result_count>1){search_marker++;if(search_marker==search_result_count)search_marker=0;showSearchMarker(search_marker);}
return false;});$("#searchBar li.prev a").click(function(){if(search_result_count>1){search_marker--;if(search_marker<0)search_marker=(search_result_count-1);showSearchMarker(search_marker);}
return false;});$("#addNoteButton, #addPhotoButton").tooltip({top:-40,left:-25,showURL:false,delay:100});$("img.help, p.help a, a.help").tooltip({top:-40,left:-25,showURL:false,delay:500});$("#viewMoreBtn").click(function(){user_page++;removeOverlays(user_markers);getUserMarkers(user_page);return false;});$("#legend").toggle(legendHide,legendShow);$("#accountStatus a.profile").click(function(){alert('Soon...');return false;});$(document).keydown(function(e){if(e.which==27){closeLightbox();}});$("#backdrop").click(function(){closeLightbox();return false;});$(window).resize(function(){$("#backdrop").css({height:$(window).height(),opacity:0.70});});$("#artistList").hover(function(){$("#artistListPop").show();$("#artistList p.button a").addClass('open');},function(){$("#artistListPop").hide();$("#artistList p.button a").removeClass('open');});var max_value=(tourYearRange.length-1)*12;$("#dateSlider").slider({animate:true,range:true,min:1,max:max_value,values:[tourStartRange[0],tourStartRange[1]],slide:function(event,ui){var value1=ui.values[0];var value2=ui.values[1];var value1_output=[12-((Math.ceil(value1/12)*12)-value1)-1,tourYearRange[Math.ceil(value1/12)-1]];var value2_output=[12-((Math.ceil(value2/12)*12)-value2)-1,tourYearRange[Math.ceil(value2/12)-1]];$("#dateSliderValue .date1").html(months[value1_output[0]]+' '+value1_output[1]);$("#dateSliderValue .date2").html(months[value2_output[0]]+' '+value2_output[1]);},stop:function(event,ui){if(!tourIgnoreRange){var value1=ui.values[0];var value2=ui.values[1];var value1_output=[12-((Math.ceil(value1/12)*12)-value1),tourYearRange[Math.ceil(value1/12)-1]];var value2_output=[12-((Math.ceil(value2/12)*12)-value2),tourYearRange[Math.ceil(value2/12)-1]];getTourDates([value1_output,value2_output]);}}});var value1=$("#dateSlider").slider("values",0);var value2=$("#dateSlider").slider("values",1);var value1_output=months[12-((Math.ceil(value1/12)*12)-value1)-1]+' '+tourYearRange[Math.ceil(value1/12)-1];var value2_output=months[12-((Math.ceil(value2/12)*12)-value2)-1]+' '+tourYearRange[Math.ceil(value2/12)-1];$("#dateSliderValue .date1").html(value1_output);$("#dateSliderValue .date2").html(value2_output);templates={markers:jQuery.createTemplateURL('/templates/markers_json.tpl',null,{filter_data:false}),dates:jQuery.createTemplateURL('/templates/dates_json.tpl',null,{filter_data:false})};lang={'_details':_t('Details'),'_related_link':_t('View Related Notes/Photos')};});var center;var map;var marker;var newcount=0;var allow_add=false;var geocoder=null;var note_type=null;var infowindowHTML=null;var button_css=null;var tour_markers=[];var tour_polylines=[];var user_markers=[];var current_tour_marker=null;var markers_set=false;var note_tour_lines=[];var login_required=l_r;var using_facebook=u_f;var send_fb_feed=send_twitter=false;var note_page=0;var photo_page=0;var user_page=0;var search_results=false;var search_marker=0;var search_result_count=0;var selected_date_year=null;var selected_tour_date=0;var selected_flickr_photo=null;var twuser=twpass=null;var current_marker_ref=null;var dv_first_open=true;var info_window_open=false;var set_tour_show=false;var templates=lang={};if(typeof months=='undefined')
var months=["January","February","March","April","May","June","July","August","September","October","November","December"];function load(){if(GBrowserIsCompatible()){map=new GMap2(document.getElementById("map"));map.addControl(new GLargeMapControl3D());geocoder=new GClientGeocoder();var pos=new GControlPosition(G_ANCHOR_BOTTOM_RIGHT,new GSize(384,-3));pos.apply(document.getElementById("viewMoreControl"));map.getContainer().appendChild(document.getElementById("viewMoreControl"));var pos=new GControlPosition(G_ANCHOR_BOTTOM_RIGHT,new GSize(0,40));pos.apply(document.getElementById("legend"));map.getContainer().appendChild(document.getElementById("legend"));$("#mapView").css('top',($("#map").position().top)+"px");$("#mapView").show();var tourIcon=new GIcon(G_DEFAULT_ICON,"/inc/images/map/tour-icon.png");tourIcon.shadow="";tourIcon.iconSize=new GSize(14,14);tourIcon.iconAnchor=new GPoint(7,6);tourIcon.infoWindowAnchor=new GPoint(110,-5);var blueTourIcon=new GIcon(G_DEFAULT_ICON,"/inc/images/map/marker-blue.png");blueTourIcon.shadow="";blueTourIcon.iconSize=new GSize(16,16);blueTourIcon.iconAnchor=new GPoint(8,8);blueTourIcon.infoWindowAnchor=new GPoint(110,-5);var greyTourIcon=new GIcon(G_DEFAULT_ICON,"/inc/images/map/marker-grey.png");greyTourIcon.shadow="";greyTourIcon.iconSize=new GSize(16,16);greyTourIcon.iconAnchor=new GPoint(8,8);greyTourIcon.infoWindowAnchor=new GPoint(110,-5);var tourIconUp=new GIcon(G_DEFAULT_ICON,"/inc/images/map/bus-ani.gif");tourIconUp.shadow="";tourIconUp.iconSize=new GSize(23,27);tourIconUp.iconAnchor=new GPoint(11.5,13.5);tourIconUp.infoWindowAnchor=new GPoint(110,-5);var noteIcon=new GIcon(G_DEFAULT_ICON,"/inc/images/map/note-icon.png");noteIcon.shadow="";noteIcon.iconSize=new GSize(22,29);noteIcon.iconAnchor=new GPoint(8,29);noteIcon.infoWindowAnchor=new GPoint(110,-5);var photoIcon=new GIcon(G_DEFAULT_ICON,"/inc/images/map/photo-icon.png");photoIcon.shadow="";photoIcon.iconSize=new GSize(26,25);photoIcon.iconAnchor=new GPoint(8,25);photoIcon.infoWindowAnchor=new GPoint(110,-5);var formIcon=new GIcon(G_DEFAULT_ICON);formIcon.infoWindowAnchor=new GPoint(110,-5);tourMarkerOptions={icon:tourIcon};tourBlueMarkerOptions={icon:blueTourIcon};tourGreyMarkerOptions={icon:greyTourIcon};tourUpMarkerOptions={icon:tourIconUp,zIndexProcess:function(marker,b){return 100000;}};noteMarkerOptions={icon:noteIcon};photoMarkerOptions={icon:photoIcon};formMarkerOptions={icon:formIcon,draggable:true};getUserMarkers();getTourDates();GEvent.addListener(map,"click",function(overlay,latlng){if(latlng&&allow_add){placeMarkerForm(latlng,5,null);}});GEvent.addListener(map,"extinfowindowopen",function(){if(!info_window_open){legendHide();}
info_window_open=false;});GEvent.addListener(map,"extinfowindowbeforeclose",function(){if(!info_window_open){legendShow();}});GEvent.addListener(map,"moveend",function(){refreshUserMarkers();});}}
function setMapCenter(){if(tour_markers.length>0){if(startCoords){center=new GLatLng(startCoords[0],startCoords[1]);map.setCenter(center,startCoords[2]);startCoords=false;}else{var bounds=new GLatLngBounds;for(var i=0;i<tour_markers.length;i++){bounds.extend(tour_markers[i].point);}
map.setCenter(bounds.getCenter(),map.getBoundsZoomLevel(bounds));}}else{if(this_artist==13){center=new GLatLng(53.367759,-3.383789);map.setCenter(center,5);}else{center=new GLatLng(37.4419,-97.1419);map.setCenter(center,4);}}}
function helpScreen(){openLightbox('helpscreen',false);return false;}
function legendHide(){$("#legend").animate({width:'15px'},1000);$("#legendBtn").addClass('active');}
function legendShow(){$("#legend").animate({width:'139px'},1000);$("#legendBtn").removeClass('active');}
function fetchFirstDataNote(){if($("#noteList ul li").length<=1){$("#noteList ul.listing, #dataWindow").hide();}else{$("#noteList ul.listing, #dataWindow").show();viewDataNote($("#noteList a.selected"));}}
function viewDataNote(el){var note_detail=$(el).parent().find("ul");if(!dv_first_open){$("#dataWindow .name, #dataWindow h3, #dataWindow .content, #dataWindow .sub").fadeOut("fast",function(){$("#dataWindow .name").html($(note_detail).find("li.name").html());$("#dataWindow h3").html($(note_detail).find("li.title").html());$("#dataWindow .content").html($(note_detail).find("li.content").html());$("#dataWindow .sub").html($(note_detail).find("li.date").html());$("#dataWindow .name, #dataWindow h3, #dataWindow .content, #dataWindow .sub").fadeIn("fast");});}else{$("#dataWindow .name").html($(note_detail).find("li.name").html());$("#dataWindow h3").html($(note_detail).find("li.title").html());$("#dataWindow .content").html($(note_detail).find("li.content").html());$("#dataWindow .sub").html($(note_detail).find("li.date").html());dv_first_open=false;}
$(el).parent().parent().find("li a.selected").removeClass("selected");$(el).addClass("selected");return false;}
function placeMarkerForm(latlng,zoom,pos){if(newcount>0)map.removeOverlay(marker);if(map.getZoom()<zoom){map.setZoom(zoom);pos='center';}
if(pos=='center')map.setCenter(latlng);if(using_facebook==false){$(".facebookElement").hide();}else{$(".facebookElement").show();}
if(note_type=='note'){infowindowHTML=$("#addNoteMarker").html();}else{infowindowHTML=$("#addPhotoMarker").html();}
marker=new GMarker(latlng,formMarkerOptions);GEvent.addListener(marker,'click',function(){marker.openExtInfoWindow(map,"markerWindow",infowindowHTML);});map.addOverlay(marker);setTimeout(function(){marker.openExtInfoWindow(map,"markerWindow",infowindowHTML)},10);newcount++;}
function tourDateForm(id,date,type,infowindow){if(login_required){openLightbox('userLoginBox',false);}else{assignTourDate(id,date);note_type=type;if(note_type=='note'){tourFormHTML=$("#addNoteMarker .inner").html();}else{tourFormHTML=$("#addPhotoMarker .inner").html();}
var infowindowBody=$(infowindow).parent().parent().parent();$(infowindowBody).hide();$(infowindowBody).parent().parent().find('.formBody').html(tourFormHTML).show();$(infowindowBody).parent().parent().find('.formBody .note_show').hide();map.getExtInfoWindow().resize();marker=current_marker_ref;marker.tourWindowBody=infowindowBody;}
return false;}
function createMarker(marker){if(marker.type!='date'){var template=templates.markers;}else{var template=templates.dates;}
GEvent.addListener(marker,'click',function(){if(map.getExtInfoWindow())info_window_open=true;marker.openExtInfoWindow(map,"markerWindow",jQuery.processTemplateToText(template,marker.note_data,lang));current_marker_ref=marker;});GEvent.addListener(marker,'mouseover',function(){if(marker.type=='date'){for(var i=0;i<user_markers.length;i++){if(user_markers[i]&&user_markers[i].tour_id==marker.point_id){var tourline=new GPolyline([marker.getLatLng(),user_markers[i].getLatLng()],'#000000',2,0.3);note_tour_lines.push(tourline);map.addOverlay(tourline);}}}else{if(marker.tour_id>0){for(var i=0;i<tour_markers.length;i++){if(tour_markers[i]&&tour_markers[i].point_id==marker.tour_id){marker.note_tour_line=new GPolyline([marker.getLatLng(),tour_markers[i].getLatLng()],'#000000',2,0.3);map.addOverlay(marker.note_tour_line);}}}}});GEvent.addListener(marker,'mouseout',function(){if(marker.note_tour_line){map.removeOverlay(marker.note_tour_line);}
for(var i=0;i<note_tour_lines.length;i++){map.removeOverlay(note_tour_lines[i]);}
note_tour_lines=[];});map.addOverlay(marker);}
function removeOverlays(marker_set){if(marker_set.length>0){while(marker_set.length>0)
map.removeOverlay(marker_set.shift());}}
function addMarkerSearch(){var address=$("#searchAddress").val();if(geocoder){geocoder.getLatLng(address,function(point){if(!point){alert(_t("%s not found",address));}else{placeMarkerForm(point,10,'center');}});}
return false;}
function getTourDates(range){if(range){var fetchUrl='/dates/'+this_artist+'.json?fm='+range[0][0]+'&fy='+range[0][1]+'&tm='+range[1][0]+'&ty='+range[1][1];}else{var fetchUrl='/dates/'+this_artist+'.json';}
$.getJSON(fetchUrl,function(data){if(range){removeOverlays(tour_markers);removeOverlays(tour_polylines);}
var m=0;var last_point=null;$.each(data.lines,function(i,item){var points=[];$.each(item.points,function(j,pitem){points[j]=new GLatLng(parseFloat(pitem.lat),parseFloat(pitem.lng));if((i==0&&j==0&&!range)){var markerType=tourUpMarkerOptions;current_tour_marker=m;}else{if(item.type=='past'){var markerType=tourGreyMarkerOptions;}else{var markerType=tourBlueMarkerOptions;}}
tour_markers[m]=new GMarker(points[j],markerType);tour_markers[m].point=points[j];tour_markers[m].note_data=pitem;tour_markers[m].markerindex=m;tour_markers[m].point_id=pitem.id;tour_markers[m].type='date';createMarker(tour_markers[m]);m++;});tour_polylines[i]=GPolyline.fromEncoded({color:item.color,weight:item.width,points:item.encodedPoints,levels:item.encodedLevels,numLevels:item.encodedNumLevels,zoomFactor:item.encodedZoomFactor});if(tour_markers.length>1){map.addOverlay(tour_polylines[i]);}});setMapCenter();});}
function isWithinBounds(point){if(map.getBounds().contains(point)){return true;}else{return false;}}
function getUserMarkers(page,action){if(parseInt(page)>=0){var fetchUrl='/markers/'+this_artist+'.json?p='+parseInt(page);}else{var bounds=map.getBounds();var northEast=bounds.getNorthEast();var southWest=bounds.getSouthWest();var fetchUrl='/markers/'+this_artist+'.json?ne='+northEast.toUrlValue()+'&sw='+southWest.toUrlValue();}
$.getJSON(fetchUrl,function(data){if(action=='refresh')removeOverlays(user_markers);removeOverlays(user_markers);if(data.more=="false"){user_page=-1;}else if(data.more=="nomore"){user_page=-1;$("#viewMoreControl").hide();}else if(data.more=="more"){}
var points=[];$.each(data.points,function(i,item){points[i]=new GLatLng(item.lat,item.lng);if(item.photo==0){var markerType=noteMarkerOptions;}else{var markerType=photoMarkerOptions;}
user_markers[i]=new GMarker(points[i],markerType);user_markers[i].note_data=item;user_markers[i].markerindex=i;user_markers[i].point_id=item.id;user_markers[i].tour_id=item.tid;createMarker(user_markers[i]);});markers_set=true;});}
function refreshUserMarkers(){if(!search_results&&markers_set){getUserMarkers(null,'refresh');}}
function locationSearch(){var address=$("#location_q").val();if(address==_t("Zip-Code")||address=="")return false;if(geocoder){geocoder.getLatLng(address,function(point){if(!point){alert(_t("%s not found",address));}else{getSearchMarkers(point,address);}});}
return false;}
function getSearchMarkers(point,query){if(point&&query!=""){var fetchUrl='/markers/'+this_artist+'.json?lat='+point.lat()+'&lng='+point.lng();}else if(query!=""&&!point){var fetchUrl='/markers/'+this_artist+'.json?q='+query;}
$.getJSON(fetchUrl,function(data){var points=[];var bounds=new GLatLngBounds();if(data.points.length>0){if(map.getExtInfoWindow())map.closeExtInfoWindow();removeOverlays(user_markers);$.each(data.points,function(i,item){points[i]=new GLatLng(item.lat,item.lng);if(item.type=="note"){if(item.photo=='0'){var markerType=noteMarkerOptions;}else{var markerType=photoMarkerOptions;}}else{var markerType=tourBlueMarkerOptions;}
user_markers[i]=new GMarker(points[i],markerType);user_markers[i].note_data=item;user_markers[i].markerindex=i;user_markers[i].point_id=item.id;createMarker(user_markers[i]);bounds.extend(points[i]);});search_result_count=data.points.length;$("#resultCount").html(search_result_count);$("#searchTerm").html(query);$("#searchBar").slideDown();$("#viewMoreControl").hide();removeMarker();search_results=true;search_marker=0;map.setCenter(bounds.getCenter(),map.getBoundsZoomLevel(bounds));showSearchMarker(0);}else{alert(_t('Could not match any notes with your search.'));}});}
function showSearchMarker(marker){user_markers[marker].openExtInfoWindow(map,"markerWindow",jQuery.processTemplateToText(templates.markers,user_markers[marker].note_data,lang));}
function submitMarker(form){if(login_required){openLightbox('userLoginBox',false);}else{$(form).ajaxSubmit({beforeSubmit:validateMarker,success:addMarkerData});}
return false;}
function validateMarker(formData,jqForm,options){var missing=0;var is_photo=false;send_fb_feed=send_twitter=false;if($(jqForm[0]).find("input[name=facebook]:checked").val()&&using_facebook){send_fb_feed=true;}
if($(jqForm[0]).find("input[name=twitter]:checked").val()){send_twitter=true;}
$('input.text, input.file, textarea',jqForm[0]).each(function(){if(!$(this).val()&&this.name!='website'&&this.name!='photo'){$(this).addClass('inputError');missing++;}else if(this.name=='photo'&&!selected_flickr_photo){var image_types=new RegExp('\.jpg|gif|png$','i');if(!$(this).val().match(image_types)){$(this).addClass('inputError');missing++;}else{$(this).removeClass('inputError');}
is_photo=true;}else{$(this).removeClass('inputError');}});if(missing>0){return false;}else{var latlng=marker.getLatLng();if(!is_photo){formData.push({name:'lat',value:latlng.lat()},{name:'lng',value:latlng.lng()});if(selected_tour_date!=0){formData.push({name:'tid',value:selected_tour_date});if(set_tour_show)formData.push({name:'tid_show',value:true});}
if(selected_flickr_photo){formData.push({name:'flickr',value:selected_flickr_photo});}}else{if($("input[name=tid]"))$("input[name=tid]").remove();var lat_input=$('<input type="hidden" name="lat" />');lat_input.val(latlng.lat());$(jqForm[0]).append(lat_input);var lng_input=$('<input type="hidden" name="lng" />');lng_input.val(latlng.lng());$(jqForm[0]).append(lng_input);if(selected_tour_date!=0){var tid_input=$('<input type="hidden" name="tid" />');tid_input.val(selected_tour_date);$(jqForm[0]).append(tid_input);var tid_true_input=$('<input type="hidden" name="tid_show" value="true" />');$(jqForm[0]).append(tid_true_input);}}}}
function addMarkerData(responseText,statusText){if(responseText.indexOf("Error:")>-1){if(responseText.substr(7)=="login"){login_required=true;openLightbox('userLoginBox',false);}else{alert(responseText.substr(7));}}else{new_text=responseText;if(note_type=='note'){var marker_type=noteMarkerOptions;}else{var marker_type=photoMarkerOptions;}
if(marker.type!='date'){var new_marker=new GMarker(marker.getLatLng(),marker_type);GEvent.addListener(new_marker,'click',function(){new_marker.openExtInfoWindow(map,"markerWindow",new_text);});}
removeMarker(marker);if(marker.type!='date'){map.addOverlay(new_marker);setTimeout(function(){new_marker.openExtInfoWindow(map,"markerWindow",new_text)},10);}else{tourDataView('',selected_tour_date);resetTourDate();}
resetNoteFlickrPhoto();if(send_fb_feed){$.post("/share/facebook/",{aid:this_artist},function(responseText,statusText){$('body').append(responseText);});}
if(send_twitter&&!send_fb_feed){submit_twtter();}}}
function submit_fb_feed(bundle,template){setTimeout(function(){FB.ensureInit(function(){FB.Connect.showFeedDialog(bundle,template,null,null,null,FB.RequireConnect.promptConnect,submit_twtter);});},500);}
function submit_twtter(){if(twuser&&twpass){$("#sendTwitterBox").load("/share/twitter/",{twuser:twuser,twpass:twpass,aid:this_artist},function(){openLightbox('sendTwitterBox',false);});}else{openLightbox('sendTwitterBox','share/twitter/');}}
function removeMarker(marker){if(marker){if(marker.type!='date'){if(map.getExtInfoWindow())map.closeExtInfoWindow();map.removeOverlay(marker);}else{if(marker.tourWindowBody){$(marker.tourWindowBody).show();$(marker.tourWindowBody).parent().parent().find('.formBody').hide();map.getExtInfoWindow().resize();}}}
$("#markerBox li a").removeClass('buttonOpacity');$("#addMarkerBar").slideUp();note_type=null;allow_add=false;return false;}
function closeSearchBar(){$("#searchBar").slideUp();if(search_results){search_results=false;removeOverlays(user_markers);if(map.getExtInfoWindow())map.closeExtInfoWindow();getUserMarkers();}}
function toggleAddMarkerBar(type){if(!allow_add){$("#dataView").hide();$("#map").show();$("#addMarkerBar").slideDown();closeSearchBar();allow_add=true;}else{$("#addMarkerBar").slideUp();allow_add=false;}}
function toggleLoader(el){if(!$(el).hasClass("loader")){$(el).toggleClass("loader");}else{setTimeout(function(){$(el).toggleClass("loader")},200);}}
function openPhotoBox(photo){$("#photoBox").load("/data/photo/",{id:photo},function(){openLightbox('photoBox',false);});return false;}
function closePhotoBox(){$("#photoBox").hide();return false;}
var tmp_lightbox_content=null;var allow_lightbox_close=true;var open_lightbox=null;function openLightbox(id,ajax){if(ajax){if($("#"+id).length==0){var new_div=jQuery('<div></div>').addClass('hidden').attr('id',id);$('body').append(new_div);}
$("#"+id).load("/"+ajax,function(){openLightbox(id,false);});}else{var new_box=true;if(tmp_lightbox_content){resetLightboxContent();new_box=false;}
tmp_lightbox_content=$("#"+id).clone(true);$("#"+id).remove();var content=$('<div>'+tmp_lightbox_content.html()+'</div>').addClass('lightboxContainer').attr('id',id);var content_html=$('<div></div>').append(content).html();if(new_box){TINY.box.show(content_html,0,0,0,0);}else{TINY.box.fill(content_html,0,0,0,1);}
content=null;open_lightbox=$("#tinycontent");}
return false;}
function resetLightboxContent(){if(tmp_lightbox_content){tmp_lightbox_content.hide();$('body').append(tmp_lightbox_content);tmp_lightbox_content=null;}}
function closeLightbox(){if(allow_lightbox_close){if(tmp_lightbox_content)TINY.box.hide();resetLightboxContent();}
return false;}
function submitLogin(form){$(form).ajaxSubmit({beforeSubmit:validateLogin,dataType:'xml',success:loginResponse});return false;}
function submitFacebookLogin(){$.post("/user/login/",{aid:this_artist,fb:true},loginResponse);}
function validateLogin(formData,jqForm,options){var missing=0;formData[1].value=hex_md5(formData[1].value);$('input.text',jqForm[0]).each(function(){if(!$(this).val()){$(this).addClass('inputError');missing++;}else{$(this).removeClass('inputError');}});if(missing>0){return false;}else{return true;}}
function loginResponse(responseText,statusText){if($('error',responseText).text()){alert($('error',responseText).text());}else{login_required=false;if($('facebook',responseText).text()=="true"){using_facebook=true;}else{using_facebook=false;}
if($('missing_info',responseText).text()=="true"){allow_lightbox_close=false;open_lightbox.find('.title .close').hide();open_lightbox.find('.content').html($('message',responseText).text());}else{open_lightbox.find('.content').hide();open_lightbox.find("#userLoginMsg, #userSignupMsg").html($('message',responseText).text());open_lightbox.find("#userLoginMsg, #userSignupMsg").show();}
$("#account").fadeOut('normal',function(){$("#account").html($('status',responseText).text());$("#account").removeAttr('filter');$("#account").show();});$("#artistListContent").load('/user/maps/',{aid:this_artist});}}
function submitMissingInfo(form){$(form).ajaxSubmit({beforeSubmit:validateMissingInfo,dataType:'xml',success:missingInfoResponse});return false;}
function validateMissingInfo(formData,jqForm,options){var missing=0;$('input.text',jqForm[0]).each(function(){if(!$(this).val()){$(this).addClass('inputError');missing++;}else{$(this).removeClass('inputError');}});if(missing>0){return false;}
return true;}
function missingInfoResponse(responseText,statusText){if($('error',responseText).text()){alert($('error',responseText).text());}else{allow_lightbox_close=true;open_lightbox.find('.title .close').show();open_lightbox.find('.content').hide();open_lightbox.find("#userLoginMsg, #userSignupMsg").html($('message',responseText).text());open_lightbox.find("#userLoginMsg, #userSignupMsg").show();}}
function submitRegister(form){$(form).ajaxSubmit({beforeSubmit:validateRegister,dataType:'xml',success:registerResponse});return false;}
function validateRegister(formData,jqForm,options){var missing=0;$('input.text',jqForm[0]).each(function(){if(!$(this).val()){$(this).addClass('inputError');missing++;}else if(this.name=='confirm_password'&&$(this).val()!=jqForm[0].password.value){alert(_t('Error: Confirmation Password does not match.'))
$(this).addClass('inputError');missing++;}else{$(this).removeClass('inputError');}});if(missing>0){return false;}else{return true;}}
function registerResponse(responseText,statusText){if($('error',responseText).text()){alert($('error',responseText).text());}else{login_required=false;$("#userSignupBox .content").hide();$("#userSignupMsg").html($('message',responseText).text());$("#userSignupMsg").show();$("#account").fadeOut('normal',function(){$("#account").html($('status',responseText).text());$("#account").removeAttr('filter');$("#account").show();$("#artistListContent").load('/user/maps/',{aid:this_artist});});}}
function submitProfile(form){$(form).ajaxSubmit({beforeSubmit:validateEditProfile,dataType:'xml',success:profileResponse});return false;}
function validateEditProfile(formData,jqForm,options){var missing=0;$('input.text',jqForm[0]).each(function(){if(!$(this).val()&&this.name!='website'&&this.name!='password'&&this.name!='confirm_password'){$(this).addClass('inputError');missing++;}else if(this.name=='confirm_password'&&jqForm[0].password.value&&$(this).val()!=jqForm[0].password.value){alert(_t('Error: Confirmation Password does not match.'));$(this).addClass('inputError');missing++;}else{$(this).removeClass('inputError');}});if(missing>0){return false;}else{return true;}}
function profileResponse(responseText,statusText){if($('error',responseText).text()){alert($('error',responseText).text());}else{$("#editProfileResponse").html($('message',responseText).text());$("#editProfileResponse").show();setTimeout(function(){$("#editProfileResponse").hide();},2500);}}
function logout(){login_required=true;using_facebook=false;$("#account").load("/user/logout/",function(){$("#userLoginBox .content, #userSignupBox .content").show();$("#userLoginMsg, #userSignupMsg").hide();$("#account").hide();$("#account").fadeIn('normal');$("#account").removeAttr('filter');$("#artistListContent").load('/user/maps/',{aid:this_artist});});return false;}
function assign_artist_user(){$("#artistListContent").load("/user/assign/",{aid:this_artist});return false;}
function unassign_artist_user(id){if(confirm(_t('Are you sure you want to remove your account from this map?'))){$("#artistListContent").load("/user/unassign/",{aid:id},function(){$("#user_artist_"+id).fadeOut('normal',function(){$(this).remove();});});}
return false;}
function assignTourDate(id,str){selected_tour_date=id;if(str!=''){$("#dataView h3.heading small strong").html(str);$("#dataView h3.heading small").show();}
closeLightbox();return false;}
function selectTourDate(id,str){selected_tour_date=id;set_tour_show=true;$(".addMarkerContent .selectedDate em").html(str);$(".addMarkerContent .selectedDate").show();$(".addMarkerContent .note_show a.button").hide();closeLightbox();return false;}
function resetTourDate(){selected_tour_date=0;set_tour_show=false;$(".addMarkerContent .note_show a.button").show();$(".addMarkerContent .selectedDate").hide();return false;}
function setNoteFlickrPhoto(photo,id){selected_flickr_photo=id;$(".addMarkerContent .photoFlickPhoto .img").html('<img src="'+photo+'" width="40" height="40" />');$(".addMarkerContent .photoFlickPhoto").show();$(".addMarkerContent .photoUpload").hide();closeLightbox();return false;}
function resetNoteFlickrPhoto(){selected_flickr_photo=null;$(".addMarkerContent .photoUpload").show();$(".addMarkerContent .photoFlickPhoto").hide();return false;}
function tourDataView(date,id){assignTourDate(id,date);$("#dataBtn").addClass("active");$("#mapBtn").removeClass("active");$("#map, #photoBox, #busBtn").hide();$("#dataView").show();dv_first_open=true;$("#noteList").load("/data/notes/",{pid:this_artist,tid:selected_tour_date},function(responseText,textStatus,request){if($("#noteList li.next").html()!="1")$("#notePagination li.next").hide();fetchFirstDataNote();$(".notes .dataBody").show();});$("#photoList").load("/data/photos/",{pid:this_artist,tid:selected_tour_date},function(responseText,textStatus,request){if($("#photoList li.next").html()!="1")$("#photoPagination li.next").hide();$(".photos .dataBody").show();});return false;}
jQuery.preloadImages=function(){for(var i=0;i<arguments.length;i++){jQuery("<img>").attr("src","/inc/images/"+arguments[i]);}}
function popArtistList(){$("#artistListPop").show();$("#artistList p.button a").addClass('open');}
$.preloadImages('welcome.png','welcome-start.jpg','welcome-start-hover.jpg','legend-show.jpg','click-addmarker.jpg','location-addmarker.jpg','go-addmarker.jpg','search-arrow-left.jpg','search-arrow-right.jpg','sh-top.png','sh-middle2.png','sh-bottom.png');if(typeof _t=='undefined'){var _t=function(msgid){if(arguments.length>0){var args=Array.apply(null,arguments).slice(1);return $.vsprintf(msgid,args);}
return msgid;}}
var TINY={};function T$(i){return document.getElementById(i)}TINY.box=function(){var p,m,b,fn,ic,iu,iw,ih,ia,f=0;return{show:function(c,u,w,h,a,t){if(!f){p=document.createElement('div');p.id='tinybox';m=document.createElement('div');m.id='tinymask';b=document.createElement('div');b.id='tinycontent';document.body.appendChild(m);document.body.appendChild(p);p.appendChild(b);m.onclick=closeLightbox;window.onresize=TINY.box.resize;f=1}if(!a&&!u){p.style.width=w?w+'px':'auto';p.style.height=h?h+'px':'auto';p.style.backgroundImage='none';b.innerHTML=c}else{b.style.display='none';p.style.width=p.style.height='100px'}this.mask();ic=c;iu=u;iw=w;ih=h;ia=a;this.alpha(m,1,50,1);if(t){setTimeout(function(){TINY.box.hide()},1000*t)}},fill:function(c,u,w,h,a){if(u){p.style.backgroundImage='';var x=window.XMLHttpRequest?new XMLHttpRequest():new ActiveXObject('Microsoft.XMLHTTP');x.onreadystatechange=function(){if(x.readyState==4&&x.status==200){TINY.box.psh(x.responseText,w,h,a)}};x.open('GET',c,1);x.send(null)}else{this.psh(c,w,h,a)}},psh:function(c,w,h,a){if(a){if(!w||!h){var x=p.style.width,y=p.style.height;b.innerHTML=c;p.style.width=w?w+'px':'';p.style.height=h?h+'px':'';b.style.display='';w=parseInt(b.offsetWidth);h=parseInt(b.offsetHeight);p.style.width=x;p.style.height=y}else{b.innerHTML=c}this.size(p,w,h,4)}else{p.style.backgroundImage='none'}},hide:function(){TINY.box.alpha(p,-1,0,2)},resize:function(){TINY.box.pos();TINY.box.mask()},mask:function(){m.style.height=TINY.page.theight()+'px';m.style.width='';},pos:function(){var t=(TINY.page.height()/2)-(p.offsetHeight/2);t=t<10?10:t;p.style.top=(t+TINY.page.top())+'px';p.style.left=(TINY.page.width()/2)-(p.offsetWidth/2)+'px'},alpha:function(e,d,a,s){clearInterval(e.ai);if(d==1){e.style.opacity=0;e.style.filter='alpha(opacity=0)';e.style.display='block';this.pos()}e.ai=setInterval(function(){TINY.box.twalpha(e,a,d,s)},20)},twalpha:function(e,a,d,s){var o=Math.round(e.style.opacity*100);if(o==a){clearInterval(e.ai);if(d==-1){e.style.display='none';e==p?TINY.box.alpha(m,-1,0,2):b.innerHTML=p.style.backgroundImage=''}else{e==m?this.alpha(p,1,100,2.5):TINY.box.fill(ic,iu,iw,ih,ia)}}else{var n=o+Math.ceil(Math.abs(a-o)/s)*d;e.style.opacity=n/100;e.style.filter='alpha(opacity='+n+')'}},size:function(e,w,h,s){e=typeof e=='object'?e:T$(e);clearInterval(e.si);var ow=e.offsetWidth,oh=e.offsetHeight,wo=ow-parseInt(e.style.width),ho=oh-parseInt(e.style.height);var wd=ow-wo>w?-1:1,hd=(oh-ho>h)?-1:1;e.si=setInterval(function(){TINY.box.twsize(e,w,wo,wd,h,ho,hd,s)},20)},twsize:function(e,w,wo,wd,h,ho,hd,s){var ow=e.offsetWidth-wo,oh=e.offsetHeight-ho;if(ow==w&&oh==h){clearInterval(e.si);p.style.backgroundImage='none';b.style.display='block'}else{if(ow!=w){e.style.width=ow+(Math.ceil(Math.abs(w-ow)/s)*wd)+'px'}if(oh!=h){e.style.height=oh+(Math.ceil(Math.abs(h-oh)/s)*hd)+'px'}this.pos()}}}}();TINY.page=function(){return{top:function(){return document.body.scrollTop||document.documentElement.scrollTop},width:function(){return self.innerWidth||document.documentElement.clientWidth},height:function(){return self.innerHeight||document.documentElement.clientHeight},theight:function(){var d=document,b=d.body,e=d.documentElement;return Math.max(Math.max(b.scrollHeight,e.scrollHeight),Math.max(b.clientHeight,e.clientHeight))},twidth:function(){var d=document,b=d.body,e=d.documentElement;return Math.max(Math.max(b.scrollWidth,e.scrollWidth),Math.max(b.clientWidth,e.clientWidth))}}}();