// JavaScript Document
$(document).ready(function(e) {
	
	
	
    $("#supplier").select2().change( function() {
		
		
			
	  var theselectedvalue = $(this).val();
	  
		
											
			
												
			if(theselectedvalue == "-2")
			{   
				//e.preventDefault();
		
				var elemposition = $(this).data('position');
				$("#myModal1").find(".savemodel1").attr('data-position', elemposition);
				$('#myModal1').modal('show');
			}
					
					
					else
					{
						
						  $("#debt").html('<img src="../views/default/images/6.gif" alt="">');	
							  
	  $('#debt').load(''+supplierpagename+'?do=getclientdebt&clientid='+theselectedvalue+'',function() {


			document.getElementById("hidden_debt").value = $('#debt').html(); 
			
			$("#tempclientName").val($("#supplier option[value='"+theselectedvalue+"']").text());
			
			////////////add by sara//////////////////
			therestofdebt();
		  	//$("#editdebt").css("display", "block");
			
			
			if(theselectedvalue == "1")
			{
				 $('#genpay').attr('readonly', true);
			}
			else
			{
				 $('#genpay').attr('readonly', false);
			}


	  					}); 
					}
												
								
					return false;
					
		

	});
	
});