var aObjects = new Array();

 function showTab(x)
 {
	for(i=1;i<=3;i++)
	{
      if(document.getElementById('tabheader'+i)!=null)
      {
         document.getElementById('tabheader'+i).className='tab-header'+i+'disable'
         document.getElementById("tabcontent"+i).style.display="none";
      }
	}
   if(document.getElementById('tabheader'+x)!=null)
   {
      document.getElementById('tabheader'+x).className='tab-header'+x;
      document.getElementById("tabcontent"+x).style.display="block";
    }
 }
function InitForm()
{
   showTab(1);
   allElements = document.forms[0].elements;
   for(i = 0; i < allElements.length; i++)
   {
      if (allElements[i].value!="")
         allElements[i].defaultValue=allElements[i].value
   }
}


function formatField(obj)
{
   lFound = false;
   for(i=0;i < aObjects.length;i++)
   {
      // check if id is already used
      if (aObjects[i].id == obj.id )
      {
         lFound = true;
      }
   }
   // console.debug("found = " + lFound)
   if (!lFound)
   {
      var ArrayField = aObjects.length;
      // console.debug("Add object = " + ArrayField)
    
      //alert (" Vul Object "  + ArrayField )
      aObjects[ArrayField] = obj;
      aObjects[ArrayField].defaultValue = obj.value;
   }
   // format Object
   for(i=0;i < aObjects.length;i++)
   {
      // check if id is already used
      if (aObjects[i].id == obj.id )
      {
         // console.debug("Change object = " + i + " Change Object Id = " + aObjects[i].id)
         if (aObjects[i].value == aObjects[i].defaultValue)
         {
            aObjects[i].value = "";
            return;
         }
         if (aObjects[i].value =="")
         {
            // exceptions
            aArray = new Array()
            aArray[aArray.length] = 'client_lastname_prefix';
            aArray[aArray.length] = 'partner_lastname_prefix';
            aArray[aArray.length] = 'address_housenumber_suffix';
            lFound = false;
            for(y=0;y<aArray.length;y++)
            {
               if (aObjects[i].id == aArray[y])
                  lFound = true;
            }
            if (!lFound)
            {
               aObjects[i].value = aObjects[i].defaultValue;
            }
            return;
         }
      }
   }
}
