function clearErrors()
{
  $(".errortext").html("*");
  $("[id^='err_']").html("");
}

function writeError(error)
{
  clearErrors();
  $.each(error, function(key, val){
    $("#err_"+key).html("<div style=\"color:red\">* "+val+"</div>")
  });  
}

function submitFrm(frmId, button)
{
  var params = {}; 
  
  $(button).attr("disabled",true);
  
  $("#"+frmId)
  .find("input[checked], input[type='text'], input[type='hidden'], input[type='password'], input[type='submit'], option[selected], textarea") 
  .each(function() { 
    params[ this.name || this.id || this.parentNode.name || this.parentNode.id ] = this.value; 
  });
  
  $.ajax({ 
    'url' : $("#"+frmId).attr("action"),
    'type': 'post',
    'data': params,
    'dataType' : 'json',
    'success' : function(data){
         
        if( data['redirect'] ){
          window.location.href=data['redirect'];
        }                
        else if(data['error']){   
          writeError(data['error'])
        }
        $(button).attr("disabled",false);
      }
  });

}


function getCommentFrm(eid)
{
	var tmp ='<form method="post" onsubmit=""><textarea name="txt" style="height:20px; width:80%;"></textarea>'
			+'<div><input type="submit" value="kaydet" /> | <input type="reset" value="iptal" />'
			+'</div></form>';
	
	
}
