// Thaana plugin for jQuery
// Mohamed Afzal Amir [[email protected]] [twitter.com/afxal]
// RC 1 June 20 2010
// thaana.jQuery.js
// Usage / Read Me :
// Paste the following in to the '<head>' tag for reference 
// <script type="text/javascript" src="thaana.jQuery.js"></script>
// Calling the function : $('your-dom-object').Thaana()
// There are 4 states in this plugin.
// [0] non-unicode text
// [1] unicode text
// [2] non-unicode reverse text
// [3] unicode reverse text
// EX : $('your-dom-object').Thaana(1)
(function($) {
	$.fn.Thaana = function(r) {
 	this.each(function() {
            var $tObj = $(this);
            var oText = $tObj.text();
			var rText = oText;
			if(r==1){				
				$tObj.css("font-family","Faruma, \"MV Elaaf Normal\"");
				$tObj.css("text-align","right");
			}
		    else if(r==2){
				rText = oText.split("").reverse().join("");
				$tObj.css("font-family","A_Ilham, A_Randhoo, A_Faruma, A_Waheed");
				$tObj.css("unicode-bidi","bidi-override");
			}
			else if(r==3){
				rText = oText.split("").reverse().join("");
				$tObj.css("font-family","Faruma, \"MV Elaaf Normal\"");
				$tObj.css("text-align","right");
			}
			else{
			rText = oText;			
				$tObj.css("font-family","A_Ilham, A_Randhoo, A_Faruma, A_Waheed");
				$tObj.css("unicode-bidi","bidi-override");
			}
			$tObj.css("direction","rtl");
			$tObj.text(rText);
        });
        return this;
    };
})(jQuery);