				var action 					=	$('#main_action').val();
				var types 					=	$('#main_type').val(); 
				if((action=="edit" || action=="view")&& types=="position"){
					load_position();
				}
//SAVING POSITION
function save_position(){
				var mods 					=	$('#main_page').val();
				var types 					=	$('#main_type').val(); 
				var action 					=	$('#main_action').val();
				var mainid					=	$('#main_id').val();
				var myform 					=	$('#position_form');

				myform.find('select:disabled').removeAttr('disabled');
				myform.find(':input:disabled').removeAttr('disabled');
				var agent_details	=	$('#position_form').serialize(); 
				var dataString		=	agent_details+"&action="+encodeURIComponent(action)+"&mainid="+encodeURIComponent(mainid);
						$.post('./ajax/position.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_position(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);
								}else{
									bootbox.alert("Failed in Deleting ..."); 
									window.setTimeout(function() { window.location.href = 'index.php?pg='+mods+'&type='+types; }, 1000);
								}	
						});
} 


//LOADING POSITION  
function load_position(){
				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_position.php', dataString, function(msg){ 
								var obj	= $.parseJSON(msg);
								var position			=	obj.data[0].position;   
								$('#position').val(position);  
								if(action=="view"){
									$('input').attr("disabled", true);
									$('textarea').attr("disabled", true);
									$('select').attr("disabled", true); 
									$('.glyphicon-trash').hide();
									$('.glyphicon-plus').hide();  
								}
						});						
}