// JavaScript Document

no_of_images=6;

function rotate_image() {
	imageId = 'header_right';
	num=Math.ceil(Math.random()*no_of_images);
	document.getElementById(imageId).src="../images/header_right_" + num + ".jpg";
	image = document.getElementById(imageId);
	setOpacity(image, 0);
	image.style.visibility = 'visible';
	fadeIn(imageId,0);
}


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 fadeIn(objId,opacity) {
  if (document.getElementById) {
    obj = document.getElementById(objId);
    if (opacity <= 100) {
      setOpacity(obj, opacity);
      opacity += 10;
      window.setTimeout("fadeIn('"+objId+"',"+opacity+")", 50);
    }
  }
}
function show_squareL1(img) {
	document.getElementById(img).src="../images/one.gif";
	
}
function hide_squareL1(img) {
	document.getElementById(img).src="../images/shim.gif";
	
}
function show_squareL2(img) {
	document.getElementById(img).src="../images/two.gif";
	
}
function hide_squareL2(img) {
	document.getElementById(img).src="../images/shim.gif";
	
}
function show_squareL3(img) {
	document.getElementById(img).src="../images/three.gif";
	
}
function hide_squareL3(img) {
	document.getElementById(img).src="../images/shim.gif";
	
}
function validate(type) {	
	if(document.email_form.name.value=='' || document.email_form.name.value=='Please enter your name.') {
		document.email_form.name.value="Please enter your name.";
		document.email_form.name.style.borderColor="red";
		document.email_form.name.focus(); 
		return false;
	}
	if(document.email_form.email.value.length == 0) { 
		document.email_form.email.focus();
		document.email_form.email.style.borderColor="red";
		document.getElementById('email_error').innerHTML="Please enter your email."; 
		return false; 
	}
	if(document.email_form.email.value.indexOf("@")== -1) { 
		document.email_form.email.focus(); 
		document.email_form.email.style.borderColor="red";
		document.getElementById('email_error').innerHTML="Your email must have a '@'."; 
		return false; 
	}
	if(document.email_form.email.value.indexOf(",") != -1) { 
		document.email_form.email.focus();
		document.email_form.email.style.borderColor="red";
		document.getElementById('email_error').innerHTML="Your email must not have a ',' in it"; 
		return false; 
	}
	if(document.email_form.email.value.indexOf("#") != -1) { 
		document.email_form.email.focus(); 
		document.email_form.email.style.borderColor="red";
		document.getElementById('email_error').innerHTML="Your email must not have an '#' in it."; 
		return false; 
	}
	if(document.email_form.email.value.indexOf("!") != -1) { 
		document.email_form.email.focus(); 
		document.email_form.email.style.borderColor="red";
		document.getElementById('email_error').innerHTML="Your email must not have a '!' in it."; 
		return false; 
	}
	if(document.email_form.email.value.indexOf(" ") != -1) { 
		document.email_form.email.focus(); 
		document.email_form.email.style.borderColor="red";
		document.getElementById('email_error').innerHTML="Your email must not have a space in it."; 
		return false; 
	}
	if(document.email_form.email.value.length == (document.email_form.email.value.indexOf("@")+1) ) {
		document.email_form.email.focus();
		document.email_form.email.style.borderColor="red";
		document.getElementById('email_error').innerHTML="Your email must have a domain name after the '@'.";
		return false;
	}
	if (type == "comment") {
		if(document.email_form.comment.value == 0 || document.email_form.comment.value == "Please enter a comment.") { 
		document.email_form.comment.focus();
		document.email_form.comment.style.borderColor="red";
		document.email_form.comment.value="Please enter a comment."; 
		return false; 
		}
	} else if(document.email_form.prov.value == "Select a State or Province" || document.email_form.prov.value == "-- PROVINCES --" || document.email_form.prov.value == "-- STATES --") {
		document.email_form.prov.focus();
		document.email_form.prov.style.borderColor="red";
		document.getElementById('prov_error').innerHTML="Please select your province or state.";
		return false;
	} else if(document.email_form.country.value == "Select a Country") {
		document.email_form.country.focus(); 
		document.email_form.country.style.borderColor="red";
		document.getElementById('country_error').innerHTML="Please select your country.";
		return false;
	}	
}
