
$(function($){

	var defClass = $('#nxtfrm_btn').attr('class');

	// 確認ボタン
	$('#nxtfrm_btn').click(function(){
		$('#nxtfrm').submit();
	})
	.hover(function(){
	  $(this).removeClass(defClass)
	         .addClass(defClass + '_on');
	},function(){
	  $(this).removeClass(defClass + '_on')
	         .addClass(defClass);
	});

	// resizetext 指定
	$('textarea.resizetext').resizetext({minline:15});

	// resizetext 指定
	$('textarea.resdoc').resizetext({minline:5});

	// adwide width 100% のリサイズ調整
	$('input.adwide, textarea.adwide').adwide();
});

/**
 *
 *  adwide width 100% のリサイズ調整
 *
 *
 *
 *
 **/

  jQuery.fn.adwide = function(){
    var alpha = 4;
    var elem = jQuery(this);
    
    if(elem.length == 0) return;
    
        elem.css('width',elem.width() + alpha);

     jQuery(window).resize(function(event){
         elem.css('width','100%')
             .css('width', elem.width() + alpha);
     });
     return this;
  }



/**
 *
 *  resizetext のリサイズ調整
 *
 *
 *
 *
 **/

  jQuery.fn.resizetext = function(opt){
    var el = $(this);
    if(el.length == 0) return;
    
    
        el.css('overflow','hidden');
    var f = el.css('font-size');
        el.css('line-height', (parseInt(f) + 2) + 'px');
        
    opt = $.extend({ 'minline': 5}, opt || {});
        
        el.keyup(function(e){
				  var elem,v,lines;
					  elem = $(this);
					  v = elem.val();
					  lines = 1;
					  
					  if(v){
						  for(var i=0, l= v.length; i < l; i++){
							  if(v.charAt(i) == '\n') lines ++;
							}
							lines = (lines < opt.minline) ? opt.minline : lines + 1;
							
							elem.attr('rows', lines);
					  }else{
						  elem.attr('rows', opt.minline);
						}
				});
	  
	  if(opt.init){
		  el.keyup();
		}
	   return this;
  }
  

