//---------------------------------------------------------------------
function storeNewContact (pid)
 {
  var country_value = document.getElementById('country_id');
  var title_value = document.getElementById('person_title_id');
  var firstname_value = document.getElementById('firstname_id');
  var surname_value = document.getElementById('surname_id');
  var email_value = document.getElementById('email_id');
  var web_value = document.getElementById('web_id');
  var aw_category_value = document.getElementById('aw_category_id');
  var aw_position_value = document.getElementById('aw_position_id');
  var institution_value = document.getElementById('institution_id');
  var web1_value = document.getElementById('web1_id');
  var department_value = document.getElementById('department_id');
  var position_value = document.getElementById('position_id');
  var street_value = document.getElementById('street_id');
  var zip_value = document.getElementById('zip_id');
  var city_value = document.getElementById('city_id');
  var tel_value = document.getElementById('tel_id');
  var tel2_value = document.getElementById('tel2_id');
  var fax_value = document.getElementById('fax_id');
  var email2_value = document.getElementById('email2_id');
  var photo_name_value = document.getElementById('photo_name_id');
  
   var opt = {
    method: "post",
    asynchronous: true,
    parameters: {    
    ajax_action: "storeNewContact", title:title_value.value, 
    firstname:firstname_value.value, surname:surname_value.value,
    email:email_value.value, web:web_value.value, aw_category:aw_category_value.value,
    aw_position:aw_position_value.value, institution:institution_value.value,
    web1:web1_value.value, department:department_value.value, position:position_value.value,
    street:street_value.value, zip:zip_value.value, city:city_value.value,
    tel:tel_value.value, tel2:tel2_value.value, fax:fax_value.value, 
    email2:email2_value.value, country:country_value.value, photo:photo_name_value.value },   
   onSuccess: function(t) 
    {     

    },
 onFailure: function(t) {  }

 }
 new Ajax.Updater('add_record_box', 'index.php?id='+pid ,opt); 
}
//---------------------------------------------------------------------

//---------------------------------------------------------------------
function cancelAdd(pid)
 {
  var addBox = document.getElementById('add_record_box');
  addBox.innerHTML = "<a href='javascript:void(0);' onclick=\"javascript:addContact("+pid+");\"><img src='fileadmin/template/img/add_item.gif' border='0'/>&nbsp;&nbsp;Add new record</a>";
 }
//---------------------------------------------------------------------

//---------------------------------------------------------------------
function addContact (pid)
 {
 var opt = {
  method: "post",
  asynchronous: true,
  parameters: {
   ajax_action: "addContact" },   
   onSuccess: function(t) 
    {     

    },
 onFailure: function(t) {  }

 }
 new Ajax.Updater("add_record_box", 'index.php?id='+pid ,opt); 
}
//---------------------------------------------------------------------

//---------------------------------------------------------------------
function editContact (pid, contactID)
 {
 var opt = {
  method: "post",
  asynchronous: true,
  parameters: {
   ajax_action: "editContact", contact_id:contactID },   
   onSuccess: function(t) 
    {     

    },
 onFailure: function(t) {  }

 }
 new Ajax.Updater("contact_"+contactID, 'index.php?id='+pid ,opt); 
}
//---------------------------------------------------------------------

//---------------------------------------------------------------------
function storeContact (pid, contactID)
 {
  var title_value = document.getElementById('person_title_id');
  var firstname_value = document.getElementById('firstname_id');
  var surname_value = document.getElementById('surname_id');
  var email_value = document.getElementById('email_id');
  var web_value = document.getElementById('web_id');
  var aw_category_value = document.getElementById('aw_category_id');
  var aw_position_value = document.getElementById('aw_position_id');
  var institution_value = document.getElementById('institution_id');
  var web1_value = document.getElementById('web1_id');
  var department_value = document.getElementById('department_id');
  var position_value = document.getElementById('position_id');
  var street_value = document.getElementById('street_id');
  var zip_value = document.getElementById('zip_id');
  var city_value = document.getElementById('city_id');
  var tel_value = document.getElementById('tel_id');
  var tel2_value = document.getElementById('tel2_id');
  var fax_value = document.getElementById('fax_id');
  var email2_value = document.getElementById('email2_id');
  
   var opt = {
    method: "post",
    asynchronous: true,
    parameters: {    
    ajax_action: "storeContact", contact_id:contactID, title:title_value.value, 
    firstname:firstname_value.value, surname:surname_value.value,
    email:email_value.value, web:web_value.value, aw_category:aw_category_value.value,
    aw_position:aw_position_value.value, institution:institution_value.value,
    web1:web1_value.value, department:department_value.value, position:position_value.value,
    street:street_value.value, zip:zip_value.value, city:city_value.value,
    tel:tel_value.value, tel2:tel2_value.value, fax:fax_value.value, 
    email2:email2_value.value },   
   onSuccess: function(t) 
    {     

    },
 onFailure: function(t) {  }

 }
 new Ajax.Updater("contact_"+contactID, 'index.php?id='+pid ,opt); 
}
//---------------------------------------------------------------------

//---------------------------------------------------------------------
function startCallback() 
 {
			// make something useful before submit (onStart)
			return true;
 }
//---------------------------------------------------------------------

//--------------------------------------------------------------------- 
function completeCallback(response) 
 {
  upload_cont = document.getElementById('file_upload_id');
  //upload_cont.value = '';
  temp_response = response.split("_");
  if (temp_response.length>1)
   {
    response = temp_response[0];
    photo_value = temp_response[1];
   }
  if ((response!='0') && (response!='-1'))
   {
     contactID = response;
     var opt = {
      method: "post",
      asynchronous: true,
      parameters: {
      ajax_action: "showPhoto", contact_id:contactID },   
       onSuccess: function(t) 
        {     

         },
       onFailure: function(t) {  }

         }
     new Ajax.Updater("image_"+contactID, 'index.php?id=91' ,opt);
   }
    else if (response=='-1')
     {
       var photo_name_value = document.getElementById('photo_name_id');
       photo_name_value.value = photo_value;
       
           var opt = {
       method: "post",
       asynchronous: true,
       parameters: {
       ajax_action: "showPhoto", photo_name:photo_value },   
       onSuccess: function(t) 
        {     

         },
       onFailure: function(t) {  }

         }
      new Ajax.Updater("image_new", 'index.php?id=91' ,opt);
     }
      else
       {
       
       }
 }
//---------------------------------------------------------------------