var YF = window.YF || {};

var uid = new Date().getTime();

var flashProxy = new FlashProxy(uid, '/gfx/flashgateway.swf');

var flashtag = new FlashTag('/gfx/mp3player.swf', 322, 89); // last two arguments are height and width

flashtag.setFlashvars('lcId='+uid);


/* Call player within Flash */
YF.playMP3 = function(file, title, artist)
{
	document.getElementById('mp3player').SetVariable('player:jsUrl', file); 
	document.getElementById('mp3player').SetVariable('player:jsPlay', '');
	
}
YF.stopMP3 = function()
{
	document.getElementById('mp3player').SetVariable('player:jsStop', '');
}

YF.winPop = function( url, width, height, xpos, ypos, toolbar, scrollbar, resizable, name )
{
    var wspec = "width="  + width  + ",";
    var hspec = "height=" + height + ",";
    var xspec = "screenX=" + xpos + ",left=" + xpos + ",";
    var yspec = "screenY=" + ypos + ",top="  + ypos + ",";

    var toolspec   = (toolbar)   ? "toolbar=yes,"    : "toolbar=no,";
    var scrollspec = (scrollbar) ? "scrollbars=yes," : "scrollbars=no,";
    var resizspec  = (resizable) ? "resizable=yes,"  : "resizable=no,";

    var specs  = wspec + hspec + xspec + yspec;
    specs += toolspec + scrollspec + resizspec;
    specs += "status=no,titlebar=no,directories=no";

    var popper = window.open(url,name,specs);
    if (window.focus) popper.focus();
}

YF.doDelete = function( title, obj_class, obj_id, row_id )
{
	// give confirmation alert
	var yes=confirm(str_delete_confirm+" «" + title + "»?");
	if(yes){
		var uri = uri_internal_json+'?where='+obj_class+'&action=delete&obj_id='+obj_id;
		$.getJSON(uri,function(json) {
			$("#"+row_id).Highlight(1000, '#d41111').animate({opacity:'hide'}, 750);
		});
        return true;
	} else {
        return false;
	}
}

YF.filter_help_open = Array();

YF.showFilterHelp = function(classname, inputname)
{
	var origin = $('#'+classname+'_'+inputname);
	var buttontxt = $("#filterhelpbutton"+inputname+" a");
	buttontxt.html(str_loading);

	$("#filterhelpcontent"+inputname).load(uri_textfilter, function() { 
		var ypos = origin.offset().top+8;
		$("#filterhelpcontent"+inputname).css('top', ypos+"px");
		var width = origin.css('width').substr(0, 3);
		width = width-0;
		var xpos = origin.offset().left+width+6;
		$("#filterhelpcontent"+inputname).css('left', xpos+"px");
		$("#filterhelpcontent"+inputname+" tr:nth-child(even)").addClass("minieven");
		$("#filterhelpcontent"+inputname).fadeIn("fast");
		buttontxt.html(str_hide_formatting);
		YF.filter_help_open[classname+'_'+inputname] = true;
	});	
}

YF.toggleFilterHelp = function(classname, inputname)
{
	if(YF.filter_help_open[classname+'_'+inputname]) {
		$("#filterhelpcontent"+inputname).fadeOut("slow");
		var buttontxt = $("#filterhelpbutton"+inputname+" a");
		buttontxt.html(str_show_formatting);
		YF.filter_help_open[classname+'_'+inputname] = false;
	} else {
		YF.showFilterHelp(classname, inputname);
	}
}

/* do sitewide effects */
$(document).ready(function(){
    $("tr:nth-child(even)").addClass("alternate");

	if (disable_tooltip != true){
		// modify global settings
		$.extend($.fn.Tooltip.defaults, {
			track: true,
			delay: 0,
			showURL: false,
			showBody: " - "
		});
		$('span.tooltip').Tooltip();
	}

});