/**
* 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 jStdNav
 * @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.jMainNav = function(options) {
		return this.each(function() {
			var obj = $(this);
				var linkText = escape(obj.html()); // HTML Text des Elements
				if (linkText!='') {
					obj.html('');	// Inhalt Ausgabe entfernen
					obj.append('<span class="hide">'+unescape(linkText)+'</span>');
					var path = 'images/mainnav.php/text.png?text='+linkText;  // zu testen!!
					var iPath = new Image();
					iPath.onload = function() {						
						var iPathWidth = iPath.width;
						obj.addClass("dynMainNav");
						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);
