// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults
var map;

$(function($) {
	$("#tabs").tabs();
});

$(function($) {
	$('.mp3').click(function(e){
		e.preventDefault();
		return false;
	});
	insertButtonMp3Players();
});



$(function($) {
//	console.log('text');
// 	$('ul#gallery.imgPreviewContainer li a').imgPreview({
// 	    containerID: '#gallery',
// 	    imgCSS: {
// 	        // Limit preview size:
// 	        // height: 200
// 	    },
// 	    // When container is shown:
// 	    onShow: function(link){
// //	        $('<span>' + $(link).text() + '</span>').appendTo(this);
// 	        $('<span>' + '' + '</span>').appendTo(this);
// 	    },
// 	    // When container hides: 
// 	    onHide: function(link){
// 	        $('span', this).remove();
// 	    }
// 	});	
});


$(function($) {
	// $('#slideshow').cycle({ 
	//     fx: 'shuffle' ,
	//   	random:  1 
	// });
});

function update_user_box() { 
	var user_box = $("#user")[0]; 
	// add in some XFBML. note that we set useyou=false so it doesn't display "you" 
	user_box.innerHTML = "<span>" + "<fb:profile-pic uid=loggedinuser facebook-logo=true></fb:profile-pic>" + "  Welcome, <fb:name uid=loggedinuser useyou=false></fb:name>. You are signed in with your Facebook account." + "</span>"; 
	// because this is XFBML, we need to tell Facebook to re-process the document 
	FB.XFBML.Host.parseDomTree();
} 

$(document.body).unload(function() {
	if (GBrowserIsCompatible()) {
		GUnload();
	}
});

function processMarkers(markers) {
     // note: markers is an array of LocalResult
     var table = document.createElement('table');
     var tbody = document.createElement('tbody');
     table.appendChild(tbody);
     document.getElementById("results").appendChild(table);
     getDirections(markers, tbody, 0);
   }

   function getDirections(markers, tbody, num) {
     var lat = markers[num].result.lat;
     var lng = markers[num].result.lng;
     var dir = new GDirections();
     GEvent.addListener(dir, "load", function() {
       var tr = document.createElement('tr');
       var td = document.createElement('td');
       td.appendChild(document.createTextNode(markers[num].result.titleNoFormatting));
       tr.appendChild(td);
       var td = document.createElement('td');
       td.innerHTML = dir.getDistance().html;
       tr.appendChild(td);
       tbody.appendChild(tr);
       if ((num+1) < markers.length) getDirections(markers, tbody, (num+1));
     });
     dir.load("from: " + start.lat() + "," + start.lng()  + " to: " + lat + "," + lng);
   }

