var loadComplete;

function preloadImages(){
	if (!document.images) return;

	document.brochures_on = new Image(); document.brochures_on.src = "../images/header/brochures_on.gif";
	document.brochures_off = new Image(); document.brochures_off.src = "../images/header/brochures_off.gif";

	document.contact_on = new Image(); document.contact_on.src = "../images/header/contact_on.gif";
	document.contact_off = new Image(); document.contact_off.src = "../images/header/contact_off.gif";

	document.search_on = new Image(); document.search_on.src = "../images/nav/go_on.gif";
	document.search_off = new Image(); document.search_off.src = "../images/nav/go_off.gif";

	loadComplete = 1;
};

function rollover(imgDocID,ImgObjName){
	if (document.images && loadComplete) document.images[imgDocID].src = eval("document." + ImgObjName +".src");
}

// Create a cookie with the specified name and value.
function SetCookie(sName, sValue)
{
  document.cookie = sName + "=" + escape(sValue) + ";";
}

// Retrieve the value of the cookie with the specified name.
function GetCookie(sCookie)
{
  // cookies are separated by semicolons
  var aCookie = document.cookie.split("; ");
  for (var i=0; i < aCookie.length; i++)
  {
	// a name/value pair (a crumb) is separated by an equal sign
	var aCrumb = aCookie[i].split("=");
	if (aCrumb[0] == sCookie)
	  return unescape(aCrumb[1]);
  }

  // a cookie with the requested name does not exist
  return null;
}

function brochurecheck(strBrochure, strDivID)
{

	//see if we can retrieve that cookie
	if (GetCookie("rodwellbrochurecookie") == null)
	{
		//if no cookie get details
		window.open("brochure_capture.asp?brochure=" + strBrochure + "&divid=" + strDivID, null,"titlebar=no, status=yes,toolbar=no,menubar=no,location=no,resizable=no,width=450,height=270'");
		
		//SetCookie("rodwellbrochurecookie","true");
		//Once window is closed try and get cookie again
		if (GetCookie("rodwellbrochurecookie") == null)
		{
			return false;
		}
		else
		{
			return true;
		}
	}
	else
	{
		return true;
	}
}

function brochurevalidate()
{
	var objForm = document.forms[0];
	
	if (objForm.bname.value == '')
	{
		alert('Please enter your name');
		return false;
	}

	if (objForm.bemail.value == '')
	{
		alert('Please enter your email');
		return false;
	}

}