$(document).ready(function(){

  $('.showhide:checked').filter(function () {
    $($(this).attr('title')).hide(800);
  });

  $('.showhide').change(function(){
    if ($(this).attr('checked'))
      $($(this).attr('title')).hide(800);
    else
      $($(this).attr('title')).show(800);
  });

  $('#cl_ct_all').change(function(){
    if ($(this).attr('checked')){
      $('#cl_fs_html').show(800);
      $('#cl_fs_xml').show(800);
    }else{
      if ($('#cl_ct_html').attr('checked')){
        $('#cl_fs_html').show(800);
      }else{
        $('#cl_fs_html').hide(800);
      }
      if ($('#cl_ct_xml').attr('checked')){
        $('#cl_fs_xml').show(800);
      }else{
        $('#cl_fs_xml').hide(800);
      }
    }
  });

  $('#cl_ct_html').change(function(){
    if ($('#cl_ct_html').attr('checked')){
      $('#cl_fs_html').show(800);
    }else{
      $('#cl_fs_html').hide(800);
    }
  });

  $('#cl_ct_xml').change(function(){
    if ($('#cl_ct_xml').attr('checked')){
      $('#cl_fs_xml').show(800);
    }else{
      $('#cl_fs_xml').hide(800);
    }
  });
  $('textarea.string-val').each(function(){
    var val = $(this).val();
    var lines = val.split("\n");
    var cols = 0;
    for (i in lines){
      if (cols < lines[i].length) cols = lines[i].length;
    }
    $(this).attr('cols',cols+1).css({overflow:'hidden',whiteSpace:'pre',margin:0});
    if (lines.length < 3){
      $(this).height((lines.length==1)?'1.4em':'2.6em');
    }else{
      $(this).height('').attr('rows',lines.length);
    }
  }).keyup(function(){
    var val = $(this).val();
    var lines = val.split("\n");
    var cols = 0;
    for (i in lines){
      if (cols < lines[i].length) cols = lines[i].length;
    }
    $(this).attr('cols',cols+1);
    if (lines.length < 3){
      $(this).height((lines.length==1)?'1.4em':'2.6em');
    }else{
      $(this).height('').attr('rows',lines.length);
    }
  });
  $('input.int-val, input.float-val, input.array-val, input.object-val').css('font-family','monospace');
  
  $('.el-add').click(function(e){
	var isarr = $(this).parent().parent().find('select.is-array');
	if (isarr){
		
	}else{
	}
	$(this).prev('span.el').clone().insertAfter($(this).prev('span.el'));
    e.preventDefault();
  });
  $('.el-del').click(function(e){
    var elname = $(this).parent('span').slideUp(500,function(){
      $(this).remove();
    });
    e.preventDefault();
  });
  //$('.var-type').width('3em');

});