// This should run on loading a page. If it is embedded in a frame then it should "de-frame".
// This is to ensure that Spicer consulting web pages aren't embedded in anyone else's pages.
if(top != self)
{
	top.location = self.location
}

// Pre-load the images for the navigation bar at the top of the page
var services_img = new Image(66, 24)
services_img.src = "HeaderImages/Services.gif"
var servicesOver_img = new Image(66, 24)
servicesOver_img.src = "HeaderImages/ServicesOver.gif"
var distributors_img = new Image(155, 24)
distributors_img.src = "HeaderImages/Distributors.gif"
var distributorsOver_img = new Image(155, 24)
distributorsOver_img.src = "HeaderImages/DistributorsOver.gif"
var profile_img = new Image(122, 24)
profile_img.src = "HeaderImages/Profile.gif"
var profileOver_img = new Image(122, 24)
profileOver_img.src = "HeaderImages/ProfileOver.gif"
var downloads_img = new Image(83, 24)
downloads_img.src = "HeaderImages/Downloads.gif"
var downloadsOver_img = new Image(83, 24)
downloadsOver_img.src = "HeaderImages/DownloadsOver.gif"
var home_img = new Image(74, 26)
home_img.src = "HeaderImages/Home.gif"
var homeOver_img = new Image(74, 26)
homeOver_img.src = "HeaderImages/HomeOver.gif"
var contact_img = new Image(112, 18)
contact_img.src = "HeaderImages/Envelope.gif"
var contactOver_img = new Image(112, 18)
contactOver_img.src = "HeaderImages/EnvelopeOver.gif"

// Images for the drop down product menu
var SC11off = new Image(215, 24)
SC11off.src = "HeaderImages/SC11Off.gif"
var SC11on = new Image(215, 24)
SC11on.src = "HeaderImages/SC11On.gif"
var SC2022off = new Image(215, 24)
SC2022off.src = "HeaderImages/SC2022Off.gif"
var SC2022on = new Image(215, 24)
SC2022on.src = "HeaderImages/SC2022On.gif"

// Function to hide the products menu
function hideMenu()
{
	if (document.getElementById)
		document.getElementById("menuDiv").style.visibility = "hidden"
	else if (document.all)
		document.all["menuDiv"].style.visibility = "hidden"
	else if (document.layers)
		document.layers["menuDiv"].visibility = "hidden"
}

// Function to show the products menu
function showMenu()
{
	var winWidth
	var menuLeft
	if (window.innerWidth != null)
	{
		winWidth =  window.innerWidth - 18
	}
	else
	{
		winWidth = document.body.clientWidth
	}
	if (winWidth >= 770)
	{
		menuLeft =  (winWidth / 2) - 375
	}
	else
	{
		menuLeft =  (770 / 2) - 375
	}

	if (document.getElementById)
	{
		document.getElementById("menuDiv").style.top =  75
		document.getElementById("menuDiv").style.visibility = "visible"
		document.getElementById("menuDiv").style.left =  menuLeft
	}
	else if (document.all)
	{
		document.all["menuDiv"].style.top =  83
		document.all["menuDiv"].style.visibility = "visible"
		document.all["menuDiv"].style.left =  menuLeft
	}
	else if (document.layers)
	{
		document.layers["menuDiv"].top =  83
		document.layers["menuDiv"].visibility = "visible"
		document.layers["menuDiv"].left =  menuLeft
	}
}

// Function to write the date string in the navigation bar
function writeDate()
{
	var myNow = new Date()
	document.write(myNow.getDate() + " ")
	switch(myNow.getMonth())
	{
		case 0:
			document.write("Jan ")
			break
		case 1:
			document.write("Feb ")
			break
		case 2:
			document.write("Mar ")
			break
		case 3:
			document.write("Apr ")
			break
		case 4:
			document.write("May ")
			break
		case 5:
			document.write("Jun ")
			break
		case 6:
			document.write("Jul ")
			break
		case 7:
			document.write("Aug ")
			break
		case 8:
			document.write("Sep ")
			break
		case 9:
			document.write("Oct ")
			break
		case 10:
			document.write("Nov ")
			break
		case 11:
			document.write("Dec ")
	}
	if(myNow.getYear() < 2000)
		document.write(myNow.getYear() + 1900)
	else
		document.write(myNow.getYear())
}

// Function to validate an e-mail address.
// Note: this only checks that it doesn't break the rules. Not that it actually works!
function ValidEmail(eMail)
{
	var eMailGood = true
// minimum length for an e-mail address is 5 (char + @ + char + . + char)
	if(eMail .length < 5)
	{
		eMailGood = false
	}
// Get the positions of the "@" and the last "."
	var atLocation = eMail.indexOf("@")
	var dotLocation = eMail.lastIndexOf(".")
// Check there is an "@" and a dot and the dot is after the "@"
	if((atLocation == -1) || (dotLocation == -1) || (atLocation > dotLocation))
	{
		eMailGood = false
	}
// Check the "@" isn't the first character
	if(atLocation == 0)
	{
		eMailGood = false
	}
// Check there is a character between the "@" and the dot
	if((dotLocation - atLocation) <= 1)
	{
		eMailGood = false
	}
// Check there is a character after the dot
	if((eMail.length - dotLocation) <= 1)
	{
		eMailGood = false
	}
	return eMailGood
}

// Load a "chromeless" window to display the contact form.
	function LoadMailWindow(pageName)
	{
		window.open(pageName, "RequestCD")//, "width=800,scrollbars,resizable")
	}

