var cKeywords = function(){
	
	this.init = function(){

	/*
		$.plugin('keywords',{
			files: [ROOT + 'libs/js/jquery/tooltip.1.3.0.pack.js',
			        ROOT + 'themes/tooltip.css'],
			selectors:	['body'],
			cache:		(DEBUG == true)?false:true
		});
		*/
		
		this.createFox();
		
//		$.plugin('keywords', function(){
			$('#text_box a[rel^=keyword]').each(function(){
				$(this).addClass('keyword');
				var url = $(this).attr('href');
				var _rel = $(this).attr('rel');
				var tmp = _rel.split('|');
//				console.log(tmp[1]);
				if (typeof tmp[1] != 'undefined') {
					$(this).tooltip({
						bodyHandler: function() {
							var _rel = $(this).attr('rel');
							var tmp = _rel.split('|');
							$.post(tmp[1], function(data){
								  $('#tooltip div').html($(data).find('#slovnicek .popis').html());
							});
					    	return '<img src="/themes/images/cms/throbber.gif"/>';
					   	},
					   	showURL: false,
					   	track: true
					});
				};
				/*
				$(this).bind('click', function(){
					var _rel = $(this).attr('rel');
					var tmp = _rel.split('|');
					slovnicekPlayMp3All(tmp[2]);
				});
				*/
			});
//		});	
	};
	
	this.createFox = function(){
	
		return;
	
		$('<div id="mluvici-liska-all">&nbsp;</div>').appendTo(document.body);
		$('#mluvici-liska-all').css({
			'position': 'absolute',
			'top': '0px',
			'left': '0px',
			'width': '100px',
			'height': '50px',
			'border': '1px solid black',
			'visibility': 'hidden'
		});
	
		var so1 = new SWFObject(ROOT + "data/swf/liska.swf", "fox_can_talk_all", "1", "1", "8", "#ffffff");
		so1.addParam('allowScriptAccess', 'always');
		so1.addParam("scale", "noscale");
		so1.addParam("play", "false");
		so1.addParam('salign', 'lt');
		so1.write("mluvici-liska-all");
		//alert({$PAGE->params[0]});
	};
	
};

var slovnicekPlayMp3All = function(url) {
	log(typeof thisMovie("fox_can_talk_all").playMp3);
	if (typeof thisMovie("fox_can_talk_all") == 'undefined' || typeof thisMovie("fox_can_talk_all").playMp3 == 'undefined') {
		setTimeout(function(){
			slovnicekPlayMp3All(url);
		}, 100);
	} else {
		thisMovie("fox_can_talk_all").playMp3(url);
	}
    void(0);
};

$(function(){
	if (typeof userInfo == 'undefined') {
		var keywords = new cKeywords();
		keywords.init();
	}
});
