

/*
  <link rel="stylesheet" href="style/textarea_Resize.css" type="text/css">
<div id="Home_Create_For_q_text" class="Home_Create_For_Textarea">
 <div >
<textarea name="q_text" id="q_text" rel="textarea_Resize" rows="5" cols="50" style="border:dotted 1px #000000" ></textarea>
 </div>
</div><!--  <div id="Home_Create_For_q_text" class="Home_Create_For_Textarea">  -->
*/

(function($) {

	// jQuery plugin definition
	$.fn.TextAreaExpander = function(minHeight, maxHeight) {

		var hCheck = !($.browser.msie || $.browser.opera);

		// resize a textarea
		function ResizeTextarea(e) {

			// event or initialize element?
			e = e.target || e;

			// find content length and box width
			var vlen = e.value.length, ewidth = e.offsetWidth;
			if (vlen != e.valLength || ewidth != e.boxWidth) {

				if (hCheck && (vlen < e.valLength || ewidth != e.boxWidth)) e.style.height = "0px";
				var h = Math.max(e.expandMin, Math.min(e.scrollHeight, e.expandMax));

				e.style.overflow = (e.scrollHeight > h ? "auto" : "hidden");
				e.style.height = h + "px";

				e.valLength = vlen;
				e.boxWidth = ewidth;
			}

			return true;
		};

		// initialize
		this.each(function() {

			// is a textarea?
			if (this.nodeName.toLowerCase() != "textarea") return;

			// set height restrictions
			var p = this.className.match(/expand(\d+)\-*(\d+)*/i);
			this.expandMin = minHeight || (p ? parseInt('0'+p[1], 10) : 0);
			this.expandMax = maxHeight || (p ? parseInt('0'+p[2], 10) : 99999);

			// initial resize
			ResizeTextarea(this);

			// zero vertical padding and add events
			if (!this.Initialized) {
				this.Initialized = true;
				$(this).css("padding-top", 0).css("padding-bottom", 0);
				$(this).bind("keyup", ResizeTextarea).bind("focus", ResizeTextarea);
			}
		});

		return this;
	};

})(jQuery);

 


 
 

function textarea_Val($this_id)// ����� ������ ����� ���
{
/*	
	var text = $("textarea#textarea_Create_"+$this_id).val();   
//var lines = text.split(/\r|\r\n|\n/);
var lines =text.split("\n");
var count = lines.length;
//console.log(count); // Outputs 4

$("div#home_keyCode").html('lines= ' +lines+'<br>count= ' +count); 
*/
//alert($("textarea#textarea_Create_"+$this_id).width())
var OPJ_Str = $("textarea#textarea_Create_"+$this_id);	
var str = OPJ_Str.val();
var text_val ='';
var text_val_R ='';
//32  ��� �������
//10  ��� ����� ����
for(var i=0;i<str.length;i++){
 if(str.charCodeAt(i) == 10)
  {
	  text_val +='<br>';
 	  
    text_val_R +=str.charAt(i)+'<br>';
  }
 else 
 {
	 text_val +=str.charAt(i);
	 text_val_R +=str.charAt(i);
 }
 }//for(var i=0;i<str.length;i++){
 
 $("textarea#"+$this_id).val(text_val_R);
 
return text_val;
}//function textarea_Val()




function textarea_Resize_frst($this_id)
{	
$("textarea#textarea_Create_"+$this_id).css({ width: 400+"px"}).val('');
   $("textarea#"+$this_id).css({ width: 400+"px"}).val('');
  $("textarea#"+$this_id).hide();


$("div#Customer_Msg").find("textarea#textarea_Create_"+$this_id).css({ width: 150+"px"}).val('');
   $("div#Customer_Msg").find("textarea#"+$this_id).css({ width: 150+"px"}).val('');
   $("div#Customer_Msg").find("textarea#"+$this_id).hide();
  
  
  $("div#Home_Create_For_"+$this_id+" .home_textarea").css({ width: ($("textarea#textarea_Create_"+$this_id).width())+"px"});
 $("div#Home_Create_For_"+$this_id+" .home_textarea").hide();
 
}//function textarea_Resize_frst()


function textarea_Resize_START()
{	
$("textarea[rel=textarea_Resize]").each(function(i){
 //###################################################################// 
  var home_textarea = $('<div id=Home_Div_Create_"'+this.id+' class="home_textarea""></div>');
  var textarea_home = $('<textarea name="textarea_Create_'+this.id+'" id="textarea_Create_'+this.id+'"  class="class_auto_resize" onfocus="this.select();" onmouseover="this.select();"  ></textarea> ');
 $("div#Home_Create_For_"+this.id).append(home_textarea);
  $("div#Home_Create_For_"+this.id+" div:first").append(textarea_home); 
  
 jQuery("textarea[id=textarea_Create_"+this.id+"]").TextAreaExpander(60);
  textarea_Resize_frst(this.id);
 //###################################################################//
$("textarea#textarea_Create_"+this.id).keyup( function(event) { 								   
var home_val_R_id = this.id.replace('textarea_Create_', ''); 	
 text_val_R = textarea_Val(home_val_R_id);
$("div#Home_Create_For_"+home_val_R_id+" .home_textarea").html(text_val_R);
 } );// $("textarea#textarea_Create_"+this.id).keyup( function(event) { 
 
});
 
}//function textarea_Resize_START()



 $(document).ready(function(){
 textarea_Resize_START();

});// $(document).ready(function(){
/**************************************textarea************************/
/* function Asc(String)
{

	return String.charCodeAt(0);

}

function Chr(AsciiNum)
{

	return String.fromCharCode(AsciiNum)

}
*/

