function ajaxCollection(){$("#colladdlink").click(function(a){a.preventDefault();$("#colladdlink").toggle();$("#addcoll").toggle()});$("#collcancellink").click(function(a){a.preventDefault();$("#colladdlink").toggle();$("#addcoll").toggle()});$("#addcoll").submit(function(c){c.preventDefault();var b=$("#coll-feature-id").val();var a=$("#coll-label").val();$("#coll-button").val("adding..").attr("disabled","yes");$.ajax({type:"POST",url:"/ajax/addcollection.php",data:{feature_id:b,label:a},success:function(d){if(d=="error"){alert("Sorry, an error occured")}else{$("#collectionlist").html(d);$("#nocollections").hide()}$("#coll-button").val("add").removeAttr("disabled");$("#colladdlink").toggle();$("#addcoll").toggle()}});$("#tag-text").val("");return false})}function ajaxTagging(){$("#addtaglink").click(function(a){a.preventDefault();$("#addtaglink").toggle();$("#addtags").toggle();$("#tag-text").focus()});$("#tagcancellink").click(function(a){a.preventDefault();$("#addtaglink").toggle();$("#addtags").toggle()});$("#addtags").submit(function(c){c.preventDefault();var b=$("#tag-feature-id").val();var a=$("#tag-text").val();$("#tag-button").val("adding..").attr("disabled","yes");$.ajax({type:"POST",url:"/ajax/addtags.php",data:{feature_id:b,tagtext:a},success:function(d){if(d=="error"){alert("Sorry, an error occured")}else{$("ul.taglist").html(d);enableTagDeleteHover();$("#notags").hide()}$("#tag-button").val("add").removeAttr("disabled");$("#addtaglink").toggle();$("#addtags").toggle()}});$("#tag-text").val("");return false})}function enableTagDeleteHover(){$(".tagdelete").mouseover(function(){$(this).attr("src","/i/x-red.png")});$(".tagdelete").mouseout(function(){$(this).attr("src","/i/x-light-blue.png")});$(".tagdelete").click(function(c){c.preventDefault();var b=$("#tag-feature-id").val();var a=$(this).parent().prev("a").html();$.ajax({type:"POST",url:"/ajax/deletetag.php",data:{feature_id:b,label:a},success:function(d){if(d=="error"){alert("Sorry, an error occured")}else{$("ul.taglist").html(d);enableTagDeleteHover();$("#notags").hide()}}})})}function commentable(){$("#commentform").submit(function(c){c.preventDefault();var b=$("#comment-feature-id").val();var a=$("#comment-content").val();$("#comment-button").attr("disabled","disabled");$.ajax({type:"POST",url:"/ajax/featurecomment.php",data:{feature_id:b,content:a},success:function(d){if(d=="error"){alert("Sorry, an error occured while commenting")}else{$("#nocomments").remove();$(".feature-comment:last").after(d)}$("#comment-button").removeAttr("disabled")}});$("#comment-content").val("");return false})}function dropDownInit(){$(".dropdownlink").click(function(c){c.preventDefault();var b=$("#"+$(this).attr("id")+"-content");var a=b.css("display");$(".drop-content").hide();if(a=="none"){$("#"+$(this).attr("id")+"-content").show()}});$("#osm-poster-form").submit(function(a){var b=($("#osmpost-feature-id").val());a.preventDefault();$("#drop-osm-content").html("<p><img src='/i/ajax-arrows.gif' width='16' height='16' alt='posting...'/> Posting track to OpenStreetmap...</p>");$.ajax({type:"POST",url:"/ajax/osmpost.php",data:{feature_id:b},success:function(c){$("#drop-osm-content").html(c)},error:function(c){$("#drop-osm-content").html("<p class='notify'>sorry, an error occured while posting. Please wait a few minutes and retry.</p>")}})})}function makeCollectionEditable(a){$("#collection-name-"+a).addClass("editable").editable("/ajax/editcollname.php",{submit:"save",indicator:"<span class='note'>Saving...</span>",style:"display: inline"});$("#collection-name-"+a).hover(function(){$(this).addClass("edithover")},function(){$(this).removeClass("edithover")});$("#collection-name-"+a).click(function(){$(this).removeClass("edithover")});$("#collection-desc-"+a).addClass("editable").editable("/ajax/editcolldescription.php",{submit:"save",type:"textarea",rows:6,cols:34,indicator:"<span class='note'>Saving...</span>"});$("#collection-desc-"+a).hover(function(){$(this).addClass("edithover")},function(){$(this).removeClass("edithover")});$("#collection-desc-"+a).click(function(){$(this).removeClass("edithover")});$("ul.feature-list li").hover(function(){$(this).find(".fl-menubutton").show()},function(){$(this).find(".fl-menubutton").hide()})}function makeEditable(a){$("#feature-title-"+a).addClass("editable").editable("/ajax/edittitle.php",{submit:"save",indicator:"<span class='note'>Saving...</span>"});$("#feature-title-"+a).hover(function(){$(this).addClass("edithover")},function(){$(this).removeClass("edithover")});$("#feature-title-"+a).click(function(){$(this).removeClass("edithover")});$("#feature-desc-"+a).addClass("editable").editable("/ajax/editdescription.php",{submit:"save",type:"textarea",rows:6,cols:34,indicator:"<span class='note'>Saving...</span>"});$("#feature-desc-"+a).hover(function(){$(this).addClass("edithover")},function(){$(this).removeClass("edithover")});$("#feature-desc-"+a).click(function(){$(this).removeClass("edithover")})}function profileswitch(){$("#timespeedlink").click(function(a){a.preventDefault();showTimeSpeed()});$("#elevationlink").click(function(a){a.preventDefault();showElevation()});showElevation()}function showTimeSpeed(){var a=$("#profileimage").attr("src");a=a.replace("elevation-","time-speed-");$("#profileimage").attr("src",a);$("#timespeedlink").html("time/speed");$("#elevationlink").html("<a href='#'>distance/elevation</a>")}function showElevation(){var a=$("#profileimage").attr("src");a=a.replace("time-speed-","elevation-");$("#profileimage").attr("src",a);$("#elevationlink").html("distance/elevation");$("#timespeedlink").html("<a href='#'>time/speed</a>")}function initStatus(a,c){fetchStatus(a,c);var b='fetchStatus("'+a+'", "'+c+'")';setInterval(b,4000)}function fetchStatus(b,c){var a="#status-update-"+b+"-"+c;$.ajax({type:"GET",dataType:"text",url:"/ajax/jobstatus.php",data:{object_type:b,object_id:c},success:function(d){$(a).html(d)},error:function(){alert("ajax error");stopInterval()}})};
