var lastLink;



function contentLoader(link)  {

  var xmlHttp;



  // Circumvent repeat calls

  if(link==null || link==lastLink)  {

    return;

  }



  // Revert previous selection

  if (lastLink!=null)  {

  }



  try  {

    // Firefox, Opera 8.0+, Safari

    xmlHttp=new XMLHttpRequest();

  }

  catch (e)  {

    // Internet Explorer

    try  {

      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");

    }

    catch (e)  {

      try  {

        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");

      }

      catch (e)  {

        alert("Your browser does not support XMLHttpRequest!");

        return false;

      }

    }

  }



  xmlHttp.onreadystatechange=function()  {

    if(xmlHttp.readyState==4)  {

      document.getElementById('CONTENT').innerHTML=xmlHttp.responseText;

      lastLink = link;

    }

  }



  xmlHttp.open("GET","content/"+link.id+".html",true);

  xmlHttp.send(null);

}





function galleryFrame(id, direction)  {

  var img=document.getElementById(id);

  var pos=document.getElementById('pos_'+id);

  var max=document.getElementById('max_'+id);



  set=parseInt(pos.innerHTML)+parseInt(direction);

  if (set>max.innerHTML)  {

    set = 1;

  }

  if (set<1)  {

    set = max.innerHTML;

  }



  img.src='images/'+id+'_'+set+'.jpg';

  pos.innerHTML=set;

}





function galleryEnlarge(id)  {

  var img=document.getElementById(id);

  var pos=document.getElementById('pos_'+id);



  top.gallery=window.open('','gallery','width=640,height=427,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0,top=100,left=60');

  top.gallery.document.write('<CENTER><IMG SRC=images/'+id+'_'+pos.innerHTML+'_large.jpg></CENTER>');

  top.gallery.document.close();

}





function toggleDropdown(id)  {

  var block=document.getElementById(id);



  if (block.style.display=='')  {

    try  {

      block.style.display='table-row';

    }

    catch(e)  {

      block.style.display='block';

    }

  }

  else  {

    block.style.display='';

  }

}





function validateFormContact()  {

  var errors = '';

  var i;



  // "property" validation

  for (i=0; i < document.FormContact.property.length; i++)  {

    if (document.FormContact.property[i].checked)  {

      break;

    }

  }

  if (i >= document.FormContact.property.length)  {

    errors += "- You must select one of our locations.\n";

  }



  // "service" validation

  for (i=0; i < document.FormContact.service.length; i++)  {

    if (document.FormContact.service[i].checked)  {

      break;

    }

  }

  if (i >= document.FormContact.service.length)  {

    errors += "- You must select a service.\n";

  }



  // "message" validation

  if (document.FormContact.message.value == '')  {

    errors += "- You must provide a comment, question, or suggestion.\n";

  }



  if (errors != '')  {

    alert("We apologize, but your response cannot be submitted due to the following errors:\n\n" + errors);

    return;

  }



  document.FormContact.submit();

}