//---------------------------------------------------------------------
function storeTypeLink (pid, link_id)
 {
  var type_id_value = document.getElementById('type_id_id');
  var edit_tool = document.getElementById('edit_tool_'+link_id);  
  var value_value = document.getElementById('link_item_'+link_id);  
  
   var opt = {
    method: "post",
    asynchronous: true,
    parameters: {    
    ajax_action: "storeTypeLink", link:link_id, type_id:type_id_value.value, value:value_value.value },   
   onSuccess: function(t) 
    {     
     edit_tool.innerHTML = "<a href='javascript:void(0);' onclick=\"javascript:editTypeLink('"+pid+"','"+link_id+"')\" title=''><img src='fileadmin/template/img/pencil.gif' border='0'/></a>";
     //------------------------------------------------------------------------------
         var opt = {
	    method: "post",
	    asynchronous: true,
	    parameters: {    
	    ajax_action: "refreshCode", type_id:type_id_value.value },   
	     onSuccess: function(t) 
	      {     	     
     
              },
	     onFailure: function(t) {  }

               }
       new Ajax.Updater('code_id', 'index.php?id='+pid+'&source=pi2' ,opt); 
     //------------------------------------------------------------------------------     
    },
 onFailure: function(t) {  }

 }
 new Ajax.Updater('link_'+link_id, 'index.php?id='+pid+'&source=pi2' ,opt); 
}
//---------------------------------------------------------------------

//---------------------------------------------------------------------
function editTypeLink(pid, link_id)
 {
  var type_id_value = document.getElementById('type_id_id');
  var edit_tool = document.getElementById('edit_tool_'+link_id);  
  var opt = {
    method: "post",
    asynchronous: true,
    parameters: {    
    ajax_action: "editTypeLink", link: link_id, type_id:type_id_value.value },   
   onSuccess: function(t) 
    {     
     edit_tool.innerHTML = "<a href='javascript:void(0);' onclick=\"javascript:storeTypeLink('"+pid+"','"+link_id+"')\" title=''><img src='fileadmin/template/img/floppy.gif' border='0'/></a>";
    },
 onFailure: function(t) {  }
 }
 new Ajax.Updater('link_'+link_id, 'index.php?id='+pid+'&source=pi2' ,opt);
 }
//---------------------------------------------------------------------

//---------------------------------------------------------------------
function cancelEdit(pid, link_id)
 {
  var opt = {
    method: "post",
    asynchronous: true,
    parameters: {    
    ajax_action: "cancel", link: link_id },   
   onSuccess: function(t) 
    {     

    },
 onFailure: function(t) {  }

 }
 new Ajax.Updater('edit_links_id', 'index.php?id='+pid+'&source=pi2' ,opt); 
 }
//---------------------------------------------------------------------

//---------------------------------------------------------------------
function storeCountryLinks (pid, link_id)
 {
  var home_value = document.getElementById('home_page_id');
  var country_profile_value = document.getElementById('country_profile_id');
  var ministry_value = document.getElementById('ministry_id');
  var faonc_value = document.getElementById('faonc_id');
  var information_centres_value = document.getElementById('information_centres_id');
  var research_centres_value = document.getElementById('research_centres_id');
  var education_value = document.getElementById('education_id');
  var ngos_value = document.getElementById('ngos_id');
  var agromarketing_value = document.getElementById('agromarketing_id');
  var eu_integration_value = document.getElementById('eu_integration_id');
  var food_nutrition_value = document.getElementById('food_nutrition_id');
  var veterinary_medicine_value = document.getElementById('veterinary_medicine_id');
  var farmnet_value = document.getElementById('farmnet_id');
  var forestry_value = document.getElementById('forestry_id');
  var fishery_value = document.getElementById('fishery_id');
  var other_information_value = document.getElementById('other_information_id');
  var angr_value = document.getElementById('angr_id');
  var working_group_value = document.getElementById('working_group_id');
  var faw_value = document.getElementById('faw_id');
  var ncdn_value = document.getElementById('ncdn_id');
  
   var opt = {
    method: "post",
    asynchronous: true,
    parameters: {    
    ajax_action: "storeCountryLinks", link:link_id, home:home_value.value, country_profile: country_profile_value.value,
    ministry: ministry_value.value, faonc:faonc_value.value, information_centres: information_centres_value.value,
    research_centres:research_centres_value.value, education:education_value.value, ngos:ngos_value.value,
    agromarketing:agromarketing_value.value, eu_integration:eu_integration_value.value,
    food_nutrition:food_nutrition_value.value, veterinary_medicine:veterinary_medicine_value.value, 
    farmnet:farmnet_value.value, forestry:forestry_value.value, fishery:fishery_value.value, 
    other_information:other_information_value.value, angr:angr_value.value, working_group:working_group_value.value,
    faw:faw_value.value, ncdn:ncdn_value.value },   
   onSuccess: function(t) 
    {     

    },
 onFailure: function(t) {  }

 }
 new Ajax.Updater('edit_links_id', 'index.php?id='+pid+'&source=pi2' ,opt); 
}
//---------------------------------------------------------------------

//---------------------------------------------------------------------
function editCountryLinks (pid, link_id)
 {  
   var opt = {
    method: "post",
    asynchronous: true,
    parameters: {    
    ajax_action: "editCountryLinks", link: link_id },   
   onSuccess: function(t) 
    {     

    },
 onFailure: function(t) {  }

 }
 new Ajax.Updater('edit_links_id', 'index.php?id='+pid+'&source=pi2' ,opt); 
}
//---------------------------------------------------------------------