// JavaScript Document
function saveInform(){
	
   var refId = $("#refId").val();
   var option = $("#option").val();
   $.ajax({
		url:'modules/inform/formInfoDel.php',
		cache: false,
		data:{'refId':refId, 'option':option},
		type:'POST',
		success:function(data){
         if(data == -50){
             sessionTimeout();
         }else{
               $("#divReqdel").empty().append(data);
        	   blockUI(data);

		   }//end if
        }

	});

}

function chkOther(){

   if( $('#chkOther').is(':checked') ){
   		$('#txtOther').val('').removeAttr("disabled").focus();
   }else{
   		$('#txtOther').val('').attr("disabled", true);
   }
}
function reqdelSub(){
   $('#trerrmsgInform').hide();
   var err = true;
   var msg = "";
   			
   if( $('#chkOther').is(':checked') ){
   
   		if( !$('#txtOther').val() ){
			
			err = false;
		}
		
   }else{
   	    $('#errTxt').empty();
		err = true;
   }
	    		
   if( $('#chkReq1').is(':checked') )
   		msg += "-&nbsp;" + $('#chkReq1').val() + "<br/>";
		
   if( $('#chkReq2').is(':checked') )
   		msg += "-&nbsp;" + $('#chkReq2').val() + "<br/>";
		
   if( $('#chkReq3').is(':checked') )
   		msg += "-&nbsp;" + $('#chkReq3').val() + "<br/>";
		
   if( $('#chkReq4').is(':checked') )
   		msg += "-&nbsp;" + $('#chkReq4').val() + "<br/>";
		
   if( $('#chkOther').is(':checked') ) 
   		msg += "-&nbsp;" + $('#txtOther').val();
   
   if(err == false){
   		$('#errmsg').empty().append("กรุณากรอกข้อมูลในช่องเหตุผลอื่นๆ ด้วยค่ะ");
        $('#trerrmsgInform').fadeIn('slow');
   }else if(msg == ""){
   		$('#errmsg').empty().append("กรุณาเลือกเหตุผลที่ต้องการแจ้งลบด้วยค่ะ");
        $('#trerrmsgInform').fadeIn('slow');
   }else if(err==true && msg!=""){
        $('#errmsg').empty();
        $('#trerrmsgInform').fadeOut('slow');
   	$('#ReqdelVal').val(msg);
	  var text = $('#ReqdelVal').val();
      var refId = $("#refId").val();
      var option = $("#option").val();
      var currUrl = $("#currUrl").val();
	  
		$.ajax({
				url:'modules/inform/formInfoDelSub.php',
				cache: false,
				data:{'refId':refId, 'option':option,'text':text, 'currUrl':currUrl },
				type:'POST',
				success:function(data){
                
				   if(data == 1){              
                       msgSuccess('บันทึกข้อมูลเรียบร้อยแล้วคะ');
                   }else if(data==-50){
                       sessionTimeout();
                   }else{
                       alert(data);
                   }
                   
				}
		});
   }//E-else
   
}//E-func

