// verify contact form in siderbar
function submitsideContactForm() {
  var missing = '';
  var invalid = '';
            
  if (document.sideContactForm.Name.value == '' || document.sideContactForm.Name.value == document.sideContactForm.Name.defaultValue) {
    missing += (missing != '') ? ', "Name"' : '"Name"';
  }
  
  if (document.sideContactForm.email == '' || document.sideContactForm.email.value == document.sideContactForm.email.defaultValue) {
    missing += (missing != '') ? ', "E-mail"' : '"E-mail"';
  }
  if (document.sideContactForm.phone == '' || document.sideContactForm.phone.value == document.sideContactForm.phone.defaultValue) {
    missing += (missing != '') ? ', "Phone"' : '"Phone"';
  }
  
          var emailFilter=/^.+@.+\..+$/;
  var illegalChars= /[\(\)\<\>\,\;\:\\\/\[\]]/;
  var addr = document.sideContactForm.email.value;
  if (!(emailFilter.test(addr)) || addr.match(illegalChars)) {
       invalid += "Please enter a valid email address.\n\n";
  }
  
    if (document.sideContactForm.Message.value == '' || document.sideContactForm.Message.value == document.sideContactForm.Message.defaultValue) {
    missing += (missing != '') ? ', "Message"' : '"Message"';
  }
  
        
  if (missing != '') {
    alert("Required fields missing: " + missing);
    return false;
  } else if (invalid != '') {
    alert("Error: \n" + invalid);
    return false;
  } else if (document.sideContactForm.Agree.checked == false) {
			alert("You must read and understand the site disclaimer.");
			document.sideContactForm.Agree.focus();
			return false;
} else {

    document.sideContactForm.action ;

    return true;
  }

  return false;

}

// bookmarks

function bookmarks() {
	
var agt=navigator.userAgent.toLowerCase();
if (agt.indexOf("opera") != -1) {
	alert ('Please use CTRL+T to bookmark this site');
	} else if(agt.indexOf("firefox") != -1) {
	alert ('Please use CTRL+D to bookmark this site');
	} else if (agt.indexOf("msie") != -1){
	window.external.AddFavorite( 'http://www.heavenslaw.com', 'Heavens Law Offices');
	}
}

// clear form values
function remove(el) {
  if (el.defaultValue==el.value) el.value = "";
}

var theImages = new Array()
theImages[0] = 'images/heavens_law_16_1.jpg'
theImages[1] = 'images/heavens_law_16_2.jpg'
theImages[2] = 'images/heavens_law_16_3.jpg'
theImages[3] = 'images/heavens_law_16_4.jpg'
theImages[4] = 'images/heavens_law_16_5.jpg'
theImages[5] = 'images/heavens_law_16_6.jpg'
theImages[6] = 'images/heavens_law_16_7.jpg'

var j = 0
var p = theImages.length;
var preBuffer = new Array()
for (i = 0; i < p; i++){
   preBuffer[i] = new Image()
   preBuffer[i].src = theImages[i]
}
var whichImage = Math.round(Math.random()*(p-1));
function showImage(){
document.write('<img src="'+theImages[whichImage]+'" alt="Heavens Law Offices" title="Heavens Law Offices" width="918" height="254">');
};
// contact form
function submitContactForm() {
		if(document.ContactForm.Name.value.length < 1) {
			alert("Your Name Is Required.");
			document.ContactForm.Name.focus();
			return;
		} else if(document.ContactForm.email.value.length < 1) {
			alert("Your Email Address Is Required.");
			document.ContactForm.email.focus();
			return;
		} else if(document.ContactForm.Message.value.length < 1) {
			alert("A Message Is Required.");
			document.ContactForm.Message.focus();
			return;
		} else if(document.ContactForm.Agree.checked == false) {
			alert("You must read and understand the site disclaimer.");
			document.ContactForm.Agree.focus();
			return;
		} document.ContactForm.submit();
}