/**
* navigation.js 
* Author: Christian Müller
* Email: christian.mueller@impigra.de
* URL: http://www.impigra.de
* Version: 0.0.1a
* No License available, but feel free to contact me for a solution.
*
* Used with the new generation CMS airando
**/

/**
 * Replace the link text in standardNavigation with dynamical generated background image and css sprite hover state.
 *
 * @example jQuery(".scroll-pane").jScrollPane();   !!! No Example available right now...
 *
 * @name jHeadline
 * @type jQuery
 * @param Object	settings	hash with options, described below.  !!! No Values available now...
 *								Option	-	Description
 * @return jQuery
 * @cat Custom/Plugin
 * @author Christian MÃ¼ller | impigra media | christian.mueller@impigra.de
 */

 
(function($){
	$.fn.jHeadline = function(options) {
		return this.each(function() {
			var obj = $(this);
				var Text = escape(obj.text()); // HTML Text des Elements
				var Col = escape(obj.css('color'));
				if (Text!='') {
					obj.html('');	// Inhalt Ausgabe entfernen
					obj.append('<span class="hide">'+unescape(Text)+'</span>');
					var path = 'images/text2png.php/text.png?text='+Text+'&col='+Col;  // zu testen!!
					//alert(path);
					var iPath = new Image();
					iPath.onload = function() {						
						var iPathWidth = iPath.width;
						obj.addClass("dynHeadline");
						obj.css({
							"background-image" : "url("+path+")",
							"width" : iPathWidth+"px"
						});
					}
					iPath.src = path;
				}
				else {
					// error output
					alert('kein HTML Inhalt im Link ' +obj.attr('href')); 
				}
		});
	};
})(jQuery);
