var intDrawingBoxIndex = 1
var intPhotoBoxIndex = 1
var intFormGroupIndex = 1

function externalLinks() 
{ 
   var anchor;

   if (!document.getElementsByTagName) { return; }

   var anchors = document.getElementsByTagName("a");
 
   for (var i = 0; i < anchors.length; i++) 
   { 
      anchor = anchors[i]; 
      
      if (anchor.getAttribute("href") && anchor.getAttribute("rel") === "external") 
      {
         anchor.target = "_blank"; 
      }
   } 
} 



function contactformSubmit()
{
   if (Validate('contactform'))
   {
      document.contactform.submit();
   }
}

function callmenowformSubmit()
{
   if (Validate('callmenowform'))
   {
      document.callmenowform.submit();
   }
}

function addFavorite(strName)
{
   window.external.AddFavorite(document.location.href,strName)
}

function addDrawingBox()
{
   Show('drawingBox' + intDrawingBoxIndex, true);
   intDrawingBoxIndex++;

   if (intDrawingBoxIndex == 5)
   {
      Hide('drawingBoxMore', true);
   }
}

function addPhotoBox()
{
   Show('photoBox' + intPhotoBoxIndex, true);
   intPhotoBoxIndex++;

   if (intPhotoBoxIndex == 5)
   {
      Hide('photoBoxMore', true);
   }
}

function previousPage()
{
   Hide('group' + intFormGroupIndex, true);
   intFormGroupIndex--;
   Show('group' + intFormGroupIndex, true);
}

function nextPage()
{
   if (Validate('offerteaanvragenform', intFormGroupIndex))
   {
      Hide('group' + intFormGroupIndex, true);
      intFormGroupIndex++;
      Show('group' + intFormGroupIndex, true);
   }
}

function offerteAanvraagSubmit()
{
   if (Validate('offerteaanvragenform', 2))
   {
      document.offerteaanvragenform.submit();
   }
}

function changeMaterial()
{
   var objSelector = document.getElementById('materialtype')
   var objOverig = document.getElementById('materialextensionfield')

   var strMaterial = objSelector.options[objSelector.selectedIndex].value;

   if (strMaterial == 'Overig')
   {
      Show('materialExtension', true);
      objOverig.value = new String('');
   }
   else
   {
      Hide('materialExtension', true);
      objOverig.value = new String('');
   }
} 

window.onload = externalLinks;