//function to add scripts when the page loads
//This function was written by Simon Willison - http://simonwillison.net/2004/May/26/addLoadEvent/
function addLoadEvent(func) {
	//This stores the existing window.onload as a variable.
  var oldonload = window.onload;
	//If there isn't already function attached, this adds the new function.
  if (typeof window.onload != 'function') 
		{
    window.onload = func;
  	}
	//If a function is already attached, this adds the new function afterwards. 
	else 
		{
    window.onload = function() {
      			if (oldonload) 
						{
        		oldonload();
      			}
      func();
    	}
  	}
}

//Glam name generator
function getGlamName(myForm) 
{
	
firstName = new Array("Razzle", "Roxy", "Foxxi", "Rusti", "CC", "DD", "Lipsi", "LA", "Chip", "Cherry", "Dixie", "Tiger", "Kitten", "JD", "Spike", "Janie", "Ty", "JJ", "Kizzi", "Ky", "ZZ", "Miki", "Jizzy", "Dana", "Taime", "Bam"
)
lastName1 = new Array("Glama", "Thunder", "Dazzle", "Axl", "Pistol", "Love", "Slapper", "Devil", "Glitter", "Glitzy", "Sparkle", "Leather", "Lion",  "Lightening", "Electric", "Black", "Galactic", "Sex", "Angel", "Sleaze", "Spankf", "Dream", "Odin", "Skid", "Super", "Over"
)
lastName2 = new Array("shot", "rocket", "kill", "meister", "chopz", "stixx", "legz", "kixx", "cat", "trash", "toy", "heart", "star", "rod", "rose", "god", "spam", "pork", "planet", "whisky", "lipz", "demon", "whip", "fire", "lord", "lixx"
)	
	
firstNm = myForm.fName.value.toUpperCase()
lastNm = myForm.lName.value.toUpperCase()

	if (firstNm != "") 
	{
	firstNum = firstNm.charCodeAt(0) - 65
	
		if (firstNum >= 0 && firstNum <=25)
		{
			if (lastNm != "")
			{
			lastNum1 = lastNm.charCodeAt(0) - 65
			lastNum2 = lastNm.charCodeAt((lastNm.length-1)) - 65
		
				if (lastNum1 >= 0 && lastNum1 <= 25 && lastNum2 >= 0 && lastNum2 <= 25)
				{
				glamName = firstName[firstNum] + " " + lastName1[lastNum1] + lastName2[lastNum2]
				alert("Your glam name is " + glamName);
				return false;
				}
			}
			alert ("That's not a valid last name");
			myForm.lName.focus();
			myForm.lName.select();
			return false;
		}
		alert ("That's not a valid first name");
		myForm.fName.focus();
		myForm.fName.select();
	}
}

//GLAM QUIZ FUNCTIONS
//function to put the cursor in the name box
function toForm() 
{
document.quiz.yourname.focus();
}

//function to validate the entry
function checkquiz() 
{
yourname = document.quiz.yourname.value;
question1a = document.quiz.question1[0].checked
question1b = document.quiz.question1[1].checked
question1c = document.quiz.question1[2].checked
question2a = document.quiz.question2[0].checked
question2b = document.quiz.question2[1].checked
question2c = document.quiz.question2[2].checked
question3a = document.quiz.question3[0].checked
question3b = document.quiz.question3[1].checked
question3c = document.quiz.question3[2].checked
question4a = document.quiz.question4[0].checked
question4b = document.quiz.question4[1].checked
question4c = document.quiz.question4[2].checked
question5a = document.quiz.question5[0].checked
question5b = document.quiz.question5[1].checked
question5c = document.quiz.question5[2].checked
question6a = document.quiz.question6[0].checked
question6b = document.quiz.question6[1].checked
question6c = document.quiz.question6[2].checked
question7a = document.quiz.question7[0].checked
question7b = document.quiz.question7[1].checked
question7c = document.quiz.question7[2].checked

if (yourname == "") 
	{
	alert('Please enter your name!');
	toForm();
	return false;
	}
else
	{
	if  ((!question1a  && !question1b && !question1c) || (!question2a  && !question2b && !question2c) || (!question3a  && !question3b && !question3c) || (!question4a  && !question4b && !question4c) || (!question5a  && !question5b && !question5c) || (!question6a  && !question6b && !question6c) || (!question7a  && !question7b && !question7c))
		{
		alert('You haven\'t answered all the questions, you muppet!');
		return false;
		}
	else 
		{
		return true;
		}
	}	
}


//function to say when the page was last modified
//This script is adapted from a free script from http://javascript.internet.com
function pagemodified()
{
var days = new Array(8);
days[1] = "Sunday";
days[2] = "Monday";
days[3] = "Tuesday";
days[4] = "Wednesday";
days[5] = "Thursday";
days[6] = "Friday";
days[7] = "Saturday";
var months = new Array(13);
months[1] = "January";
months[2] = "February";
months[3] = "March";
months[4] = "April";
months[5] = "May";
months[6] = "June";
months[7] = "July";
months[8] = "August";
months[9] = "September";
months[10] = "October";
months[11] = "November";
months[12] = "December";
var dateObj = new Date(document.lastModified)
var wday = days[dateObj.getDay() + 1]
var lmonth = months[dateObj.getMonth() + 1]
var date = dateObj.getDate()
var fyear = dateObj.getYear()
if (fyear < 2000) 
fyear = fyear + 1900
//Create a message saying when the page was last modified
var message = "This page was last modified: " + wday + " " + date + " " + lmonth + " " + fyear

//Create a paragraph to put the message into - THIS NEEDS TO BE ALTERED TO SUIT THE NEW HOME PAGE
var modifiedpara = document.createElement("p");
modifiedpara.setAttribute("class","modified");
//Put the message in the paragraph
var paratext = document.createTextNode(message);
modifiedpara.appendChild(paratext);
//Insert the paragraph into the footer, before the bumf text at the bottom
var footer = document.getElementById("footer");
var bumf = document.getElementById("bumf");
footer.insertBefore(modifiedpara,bumf);

}

//addLoadEvent(pagemodified);

