$(document).ready(function() {
	//setupInputs('body');
	$('a.tooltip').tooltip({showURL: false, delay: 200});
	
	$('a.youtubewrapper').click( function() {
		var ytid = $(this).metadata().ytid;
		var playerid = $(this).metadata().playerid;
		var replaceid = $(this).parent().attr("id");
		
		swfobject.embedSWF("http://www.youtube.com/v/" + ytid + "&enablejsapi=1&playerapiid=" + playerid, replaceid, "200", "166", "8", null, null, { allowScriptAccess: "always" }, { id: playerid });
		$('#' + playerid).css("visibility", "visible");
		return false;
	});
	
});


/**
 * Prepare input fields
 */
setupInputs = function(scope) {
	//$(scope + ' input.text').attr('autocomplete', 'off');
	$(scope + ' input.text').each( function() {
		if (!$(this).data('firstValue')) {
			$(this).data('firstValue', $(this).val());
		}
		
		$(this).bind('blur focus', function(event) {
			if ($(this).val() == $(this).data('firstValue')) {
				$(this).val("");
			} else
			if ($(this).val() == '') {
				$(this).val($(this).data('firstValue'));
			}
			event.stopPropagation();
		});
	});
}

/**
 * YouTube player ready event.
 */
onYouTubePlayerReady = function(playerId) {
	ytplayer = document.getElementById(playerId);
	if (ytplayer) {
		ytplayer.playVideo();
	}
}