//////////////////////////////////////////////////////////////////////////
// MENU STUFF

function SetStyle(item,style) 
{
	if (document.getElementById(item).className == "link1hon")
	{
	}
	else
	{
	    document.getElementById(item).className = style;
	}
}

function SetStyle2(item,style) 
{
	if (document.getElementById(item).className == "sidebar")
	{
	}
	else if (document.getElementById(item).className == "side-three-on")
	{
	}
	else
	{
	    document.getElementById(item).className = style;
	}
}

function Toggle(layer) 
{
	if (document.getElementById(layer).style.visibility == "hidden") 
	{
    	document.getElementById(layer).style.visibility = "visible";
	}
	else
	{
	    document.getElementById(layer).style.visibility = "hidden";
    }
}

//////////////////////////////////////////////////////////////////////////
// IMAGE ROTATE STUFF

var image_list = new Array();
var random_display = 1; // 0 = no, 1 = yes
var number_of_image = 0;
var interval = 4; // delay between rotating images (in seconds)

function InitializeRotate()
{
  interval *= 1000;

  var image_index = 0;
  image_list[image_index++] = new imageItem("/images/header1.jpg");
  image_list[image_index++] = new imageItem("/images/header2.jpg");
  image_list[image_index++] = new imageItem("/images/header3.jpg");
  image_list[image_index++] = new imageItem("/images/header4.jpg");
  image_list[image_index++] = new imageItem("/images/header5.jpg");
  image_list[image_index++] = new imageItem("/images/header6.jpg");
  image_list[image_index++] = new imageItem("/images/header7.jpg");

  number_of_image = image_list.length;
}
function imageItem(image_location) 
{
  this.image_item = new Image();
  this.image_item.src = image_location;
}
function get_ImageItemLocation(imageObj) 
{
  if (imageObj == null || imageObj.image_item == null) return;
  return(imageObj.image_item.src)
}
function generate(x, y) 
{
  var range = y - x + 1;
  return Math.floor(Math.random() * range) + x;
}

function getNextImage() 
{
  if (random_display) 
  {
   image_index = generate(0, number_of_image-1);
  }
  else 
  {
  image_index = (image_index+1) % number_of_image;
  }
  var new_image = get_ImageItemLocation(image_list[image_index]);
  return(new_image);
}

function rotateImage(place) 
{
  var new_image = getNextImage();
  document[place].src = new_image;
  var recur_call = "rotateImage('"+place+"')";
  setTimeout(recur_call, interval);
}

//////////////////////////////////////////////////////////////////////////


 function ActionEmailValidate()
{
var email = document.actionForm.email.value;


var emailRegxp = /^([\w]+)(.[\w]+)*@([\w]+)(.[\w]{2,3}){1,2}$/;

if (emailRegxp.test(email) != true)
{
alert("Email address appears to be incorrect");
document.actionForm.redirect="action.aspx";
}
else {
checkfirstname();
 }

}

function checkfirstname()
{

var firstName=document.actionForm.firstname.value;
var fnameRegxp = /^([a-zA-Z]+)$/;
if(fnameRegxp.test(firstName)!= true)
{
alert("First name appears to be incorrect");

}
else
{
 checklastname();
}

}

function checklastname()
{
var lastName=document.actionForm.lastname.value;
var fnameRegxp = /^([a-zA-Z]+)$/;
if(fnameRegxp.test(lastName)!= true)
{
alert("Last name appears to be incorrect");

}
else
{
 document.actionForm.action="gdform.asp";
 document.actionForm.redirect="thankyou.aspx";

 
}

}
///////////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////
// Controls

function OnClick_tbxEmail(tbx)
{
    tbx.value = "";
    tbx.style.color = "black";
    tbx.style.fontStyle = "normal";
}

//////////////////////////////////////////////////////////////////////////
// INITIALIZE (Called from header.html on startup)

function InitializeScript()
{
	InitializeRotate();
	checkCookie();
}

