				var action 					=	$('#main_action').val();
				var types 					=	$('#main_type').val(); 
				if((action=="edit" || action=="view")&& types=="buyer_profile"){
					load_buyer_profile();
				}
//SAVING BUYER PROFILE
function save_buyer_profile(){
				var mods 					=	$('#main_page').val();
				var types 					=	$('#main_type').val(); 
				var action 					=	$('#main_action').val();
				var mainid					=	$('#main_id').val();
				var myform 					=	$('#buyer_profile_form');

				myform.find('select:disabled').removeAttr('disabled');
				myform.find(':input:disabled').removeAttr('disabled');
				var buyer_profile_details	=	$('#buyer_profile_form').serialize(); 
				var dataString		=	buyer_profile_details+"&action="+encodeURIComponent(action)+"&mainid="+encodeURIComponent(mainid);
						$.post('./ajax/buyer_profile.php', dataString, function(msg){
								var obj	= $.parseJSON(msg);
								if(obj.output==true){
									bootbox.alert("Successfully Saved ..."); 
									window.setTimeout(function() { window.location.href = 'index.php?pg='+mods+'&type='+types; }, 1000);
								}else{
									bootbox.alert("Failed in saving.");
								}
						});
}

  
function delete_buyer_profile(id){
		var transaction		=	"reference";
		var mods 			=	$('#main_page').val();
		var types 			=	$('#main_type').val(); 
		var dataString		=	"mainid="+encodeURIComponent(id)+"&transaction="+encodeURIComponent(transaction)+"&types="+encodeURIComponent(types);
						$.post('./ajax/delete_transaction.php', dataString, function(msg){
								var obj	= $.parseJSON(msg);
								if(obj.output==true){
									bootbox.alert("Successfully Deleted ..."); 
									window.setTimeout(function() { window.location.href = 'index.php?pg='+mods+'&type='+types; }, 1000);
								}	
						});
} 


//LOADING BUYER PROFILE  
function load_buyer_profile(){
				var mods 			=	$('#main_page').val();
				var types 			=	$('#main_type').val(); 
				var action 			=	$('#main_action').val();
				var mainid			=	$('#main_id').val(); 
				var dataString		=	"action="+encodeURIComponent(action)+"&mainid="+encodeURIComponent(mainid); 
						$.post('./ajax/load_buyer_profile.php', dataString, function(msg){ 
								var obj	= $.parseJSON(msg);
								var buyer_profile				=	obj.data[0].buyer_profile; 
						   
								$('#buyer_profile').val(buyer_profile);  
								
								if(action=="view"){
									$('input').attr("disabled", true);
									$('textarea').attr("disabled", true);
									$('select').attr("disabled", true); 
									$('.glyphicon-trash').hide();
									$('.glyphicon-plus').hide();  
								}								 
						});						
}