 (function($) { 
 
	 // define plugin
	 jQuery.fn.textImageCreator = function(options) {
	 
	 // set default parameters
	 var parameters	 = jQuery.extend({
		//Setting the values of posturl for creating image
		postUrl : "dynamic_menu.php",
		// parameter of the url
		dt : "menuText",
		
		widthUrl : "background_width.php"
		
	}, options);
	 
	 // get each a tag with classname dynamicMenu and get text in that tag and convert into an image
	 return this.each(function(i) {
	 
			/*	
			 *	---------------------------------------------------
			 *	1. INITIATION
			 *	GIV PARAMETER TO IMAGE CREATOR FILE
			 *	---------------------------------------------------
			 */
				// simplfy parameters
				p = parameters;
				
				$id = this.id;
				
				// put the reference in a variable $img
				$tagVar = $(this);
				
				// get the text in that tag
				$tagText = escape($tagVar.text());
				//$tagVar.text(" ");
				
				if(i==0)
				imgPaddingLeft=0;
				else
				imgPaddingLeft=10;
				
				// make a src attribute for that tag	
				srcImg= p.postUrl+'?'+p.dt+'='+$tagText+'&imgPaddingLeft='+imgPaddingLeft;
				//srcImg1= 'img_wh.php?'+p.dt+'='+$tagText;
				//alert(srcImg);

				// assigning css for that a tag
				$tagVar.css({
					// define background img
					backgroundImage : 'url("'+srcImg+'")',
					
				}); // close a tag.css
			
				//alert('menuText='+p.dt+'&menuId='+$id+'&imgPaddingLeft='+imgPaddingLeft);
				 jQuery.ajax({
					   url: p.widthUrl,
					   type:'POST',
					   data:'menuText='+$tagText+'&menuId='+$id+'&imgPaddingLeft='+imgPaddingLeft,
					   success: function(res) 
					   {
						   //alert(res);
									 
						   resArr=res.split("####");
			
						   jQuery("#"+resArr[2]).css("width", resArr[0]+"px");			
			
					},
					error: function (){ alert('something went wrong');}
					 });
					
					jQuery("#"+$id).css({textIndent : -10000+'px'	}); // close a tag.css
				//document.getElementById(this.id).style.textIndent=-10000+'px';
				
		 }); // close this.each
	}
 
})(jQuery);
 
 
/* jQuery(document).ready(function()
{
	
	jQuery(".dynamicMenu a").each(function(i)
	 {
								

		menuText=this.text;					
		menuId=this.id;
	//	menuText=jQuery("#"+this.id).next().text();
	
//	jQuery(this).css("background",'url("dynamic_menu.php?menuText='+menuText+'") no-repeat');
	//alert(menuText);
	src='dynamic_menu.php?menuText='+menuText;
	
//	jQuery(this).css('backgroundImage','url(' + src +')');

	//alert('backgroundImage url(' + src +')');
	presentId=this.id;


	document.getElementById(this.id).style.backgroundImage='url("dynamic_menu.php?menuText='+menuText+'")';
	
	 jQuery.ajax({
		   url: "background_width.php",
		   type:'POST',
		   data:'menuText='+menuText+'&menuId='+menuId,
		   success: function(res) 
		   {
			   
			 
			   resArr=res.split("####");

			   //alert("width"+resArr[0]+"height"+resArr[1]+'Id'+resArr[2]);
	//		   document.getElementById(this.id).style.width=resArr[0]+"px";
		//		alert(menuId);
			   jQuery("#"+resArr[2]).css("width", resArr[0]+"px");
			//   jQuery("#"+resArr[2]).css("height", resArr[1]+"px");
		   

   		},
   		error: function (){ alert('something went wrong');}
		 });
	  
	//jQuery(this).append('<img id="img'+i+'" src="dynamic_menu.php?menuText='+menuText+'" />');
//	alert(jQuery("#img"+i).width());
	
	//document.getElementById(this.id).style.backgroundImage='url("dynamic_menu.php?menuText='+menuText+'")';
	
//	alert(jQuery(this));
	//document.getElementById(this.id).style.width=123+"px";
	//alert(document.getElementById(this.id).style.backgroundImage.width);
	document.getElementById(this.id).style.textIndent=-2000+'px';

	
	
										
											   
	 });
	
	
	jQuery(".dynamicMenu a").hover(function()
	 {
																						

//		alert(this.id);									
	//document.getElementById(this.id).style.backgroundPosition=-30+"px";	
	//jQuery(this).animate({backgroundPosition: '(0px 50%)'});

										   
	 },
	 function () { //.wrapperBox mouseout
        
		//alert(this);
		//jQuery(this).animate({backgroundPosition: '(0px 0%)'});
		
      });
	




	
});
*/

