function closeAll()
{
    // Nav items
    document.getElementById('liAbout').className='';
    document.getElementById('liTrailer').className='';
    document.getElementById('liPurchase').className='';
    document.getElementById('liContact').className='';
    
    // Lightboxes
    document.getElementById('about').className = 'hidden';
    document.getElementById('trailer').className = 'hidden';
    document.getElementById('purchase').className = 'hidden';
    document.getElementById('contact').className = 'hidden';
    document.getElementById('aboutcompany').className = 'hidden';
    
    // Misc
    document.getElementById('logotext').style.position = 'static';
    document.getElementById('footer').style.position = 'static';
}        

function fadeOutObject(obj)
{
    fadeOut(obj,75);
}

function validate_required(field,alerttxt)
{
with (field)
{
if (value==null||value=="")
  {alert(alerttxt);return false}
else {return true}
}
}

function validate_form()
{

nameObj = document.getElementById('name');

if (validate_required(nameObj,"Name cannot be left blank.")==false)
  {nameObj.focus();return false}

if (nameObj.value.length < 3 || nameObj.value.length > 255) {
    alert("Name must be between 3 and 255 characters.");
    nameObj.focus();
    return false
}

emailObj = document.getElementById('email');

if (validate_required(emailObj,"Email address cannot be left blank.")==false)
    {emailObj.focus();return false}

if (emailObj.value.length < 7 || emailObj.value.length > 255) {
    alert("Email must be between 7 and 255 characters.");
    emailObj.focus();
    return false
}

if (emailObj.value.indexOf('@') == -1 || emailObj.value.indexOf('.') == -1){
    alert("Email must be in the format name@example.com.");
    emailObj.focus();
    return false
}

bodyObj = document.getElementById('bodytext');

if (validate_required(bodyObj,"Message body cannot be left blank.")==false)
  {bodyObj.focus();return false}

if (bodyObj.value.length < 8 || bodyObj.value.length > 1024) {
    alert("Message body must be between 8 and 1024 characters.");
    bodyObj.focus();
    return false
}

// Submit form
ajaxSubmit();
}

function setOpacity(obj, opacity) {
  opacity = (opacity == 100)?99.999:opacity;
  
  // IE/Win
  obj.style.filter = "alpha(opacity:"+opacity+")";
  
  // Safari<1.2, Konqueror
  obj.style.KHTMLOpacity = opacity/100;
  
  // Older Mozilla and Firefox
  obj.style.MozOpacity = opacity/100;
  
  // Safari 1.2, newer Firefox and Mozilla, CSS3
  obj.style.opacity = opacity/100;
}


function ajaxSubmit()
{
var xmlhttp;
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else if (window.ActiveXObject)
  {
  // code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
else
  {
  alert("Your browser does not support XMLHTTP!");
  }
xmlhttp.onreadystatechange=function()
{
if(xmlhttp.readyState==4)
  {
  document.getElementById('contactarea').innerHTML = xmlhttp.responseText;
  }
}

                xmlhttp.open('POST', 'contactsubmit.php', true);
                var params = 'name=' + escape(document.getElementById('name').value) + '&email=' + escape(document.getElementById('email').value) + '&bodytext=' + escape(document.getElementById('bodytext').value);
        
                // Send the proper header information along with the request
                xmlhttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
                xmlhttp.setRequestHeader('Content-length', params.length);
                xmlhttp.setRequestHeader('Connection', 'close');
                xmlhttp.send(params);
}

