jQuery.sifrSettings = function(settings) {

	/* == Sets Settings == */
	arguments.callee.settings = jQuery.extend(
		{
			/* Absolute Offset X ...... */ absoluteOffsetX: null, aoX: 0,
			/* Absolute Offset Y ...... */ absoluteOffsetY: null, aoY: 0,
			/* Relative Offset X ...... */ relativeOffsetX: null, roX: 0,
			/* Relative Offset Y ...... */ relativeOffsetY: null, roY: 0,
			/* Font Path .............. */ path: '/fonts/',
			/* Font File .............. */ font: null,
			/* Font Size .............. */ fontSize: null,
			/* Text Color ............. */ color: null,
			/* Text Underline ......... */ underline: null,
			/* Text Transform ......... */ textTransform: null,
			/* Text Link Color ........ */ link: null,
			/* Text Hover Color ....... */ hover: null,
			/* Background Color ....... */ backgroundColor: null,
			/* Text Align on X ........ */ textAlign: null,
			/* Text Align on Y ........ */ verticalAlign: null,
			/* Content ................ */ content: null,
			/* Width .................. */ width: null,
			/* Height ................. */ height: null
		},
		arguments.callee.settings,
		settings
	);

	/* == Returns Settings == */
	return arguments.callee.settings;

};

jQuery.fn.sifr = function(settings) {

	/* == Converts color to HEX == */
	var hex = function(N) {
		if(N==null) return "00";
		N = parseInt(N);
		if(N==0 || isNaN(N)) return "00";
		N = Math.max(0, N);
		N = Math.min(N, 255);
		N = Math.round(N);
		return "0123456789ABCDEF".charAt((N - N%16) / 16) + "0123456789ABCDEF".charAt(N%16);
	};

	/* == Converts colors to HEX == */
	var hexed = function(color) {
		if(!color) { return false; }
		if(color.search('rgb') > -1) {
			color = color.substr(4,color.length-5).split(', ');
			color = hex(color[0]) + hex(color[1]) + hex(color[2]);
		}
		color = color.replace('#','');
		if(color.length < 6) {
			color = color.substr(0, 1) + color.substr(0, 1) + color.substr(1, 1) + color.substr(1, 1) + color.substr(2, 1) + color.substr(2, 1);
		}
		return color;
	};
	
	/* == Executes Function == */
	return this.each(function() {

		var o = jQuery(this);
		if((o.attr('class')) && o.attr('class').search('sifr') > -1) {
			o.unsifr();
		}
		o.flash(
			{},
			{ update: false },
			function(htmlOptions) {

				/* == Collect Settings == */
				var s = jQuery.extend({},jQuery.sifrSettings(), settings);

				/* == Evaluates Sifr Settings == */
				/* Add Sifr Class ......... */ o.addClass('sifr');
				/* Font File .............. */ s.font = s.font || o.css('fontFamily').split(',')[0].replace(/\"|\'/gm , '');
				/* Font Color ............. */ s.color = s.color || o.css('color'); s.color = hexed(s.color);
				/* Font Underline ......... */ s.underline = s.underline ||(o.css('textDecoration')=='underline');
				/* Background Color ....... */ s.backgroundColor = s.backgroundColor || o.css('backgroundColor'); s.background = hexed(s.background);
				/* Text Align on X ........ */ s.textAlign = s.textAlign || o.css('textAlign') || 'left';
				/* Text Align on Y ........ */ s.verticalAlign = s.verticalAlign || o.css('verticleAlign') || 'top';
				/* Text Part 1 ............ */ o.html('<span style="display:inline;margin:0;padding:0;float:none;width:auto;height:auto;font-weight:inherit;">' + o.html() + '</span>');
				/* Text Part 2 ............ */ var oc = jQuery(this.firstChild);
				/* Text Transform ......... */ s.textTransform = s.textTransform || o.css('textTransform');
					if (s.textTransform=='uppercase')
					{
							s.content = oc.html().toUpperCase();
					}
					if (s.textTransform=='lowercase')
					{
							s.content = oc.html().toUpperCase();
					}
					if (s.textTransform=='capitalize')
					{
							var ochtml = oc.html().split(/\s/);
							for (var i = 0; i < ochtml.length; i++) {
								ochtml[i] = ochtml[i].charAt(0).toUpperCase() + ochtml[i].substring(1);
							}
							s.content = ochtml.join(' ');
					}
				/* Content ................ */ s.content = s.content || oc.html();
				/* Width .................. */ s.width = s.width || oc.width();
				/* Height ................. */ s.height = s.height || oc.height();
				/* Relative Offset X ...... */ s.aoX = (s.aoX || 0) + ((s.width / 100) * (s.roX || 0));
				/* Relative Offset Y ...... */ s.aoY = (s.aoY || 0) + ((s.height / 100) * (s.roY || 0));

				/* == Hide == */
				oc.hide();

				/* == Evaluates Flash Settings == */
				htmlOptions.style = 'vertical-align:' + s.verticalAlign + ';';
				htmlOptions.wmode = 'transparent';
				htmlOptions.src = s.path + s.font + '.swf';
				htmlOptions.flashvars.txt = s.content;
				htmlOptions.width = s.width;
				htmlOptions.height = s.height;
				htmlOptions.flashvars.w = s.width;
				htmlOptions.flashvars.h = s.height;
				htmlOptions.flashvars.textalign = s.textAlign;
				if(s.aoX!=0) { htmlOptions.flashvars.offsetLeft = s.aoX; }
				if(s.aoY!=0) { htmlOptions.flashvars.offsetTop = s.aoY; }
				if(s.color) { htmlOptions.flashvars.textcolor = s.color; }
				if(s.link) { htmlOptions.flashvars.linkColor = s.link; }
				if(s.hover) { htmlOptions.flashvars.hoverColor = s.hover; }
				if(s.underline) { htmlOptions.flashvars.underline = s.underline; }
				if(s.backgroundColor) { htmlOptions.flashvars.bgColor = s.backgroundColor; }

				/* == Append Sifr Element == */
				o.append(jQuery.fn.flash.transform(htmlOptions));

			}
		);
	});

};

jQuery.fn.unsifr = function() {

	return this.each(function() {
		var o = jQuery(this);
		var oc = jQuery(this.firstChild);

		/* == Check for Existing Sifr Presence == */
		if((o.attr('class')) && o.attr('class').search('sifr')>-1) {
			o.html(oc.html());
			o.removeClass('sifr');
		}

	});

};