

// Cross Browser DOM Functions used to create objects and get top / left coords
// copyright Stephen Chapman, 4th Jan 2005
// you may copy this code but please keep the copyright notice as well
var aDOM = 0, ieDOM = 0, nsDOM = 0
var stdDOM = document.getElementById;
if (stdDOM) aDOM = 1; else {
  ieDOM = document.all;
  if (ieDOM) aDOM = 1; else {
    var nsDOM = (
      (navigator.appName.indexOf('Netscape') != -1)
      && (parseInt(navigator.appVersion) ==4));
    if (nsDOM) aDOM = 1;
  }
}
function xDOM(objectId, withStyle) {
var st = ''; if (withStyle) st = '.style';
if (stdDOM) return (eval('document.getElementById(objectId)'+st));
if (ieDOM) return (eval('document.all[objectId]'+st));
if (nsDOM) return (document.layers[objectId]);
}

function NewArrayItem(strHtml){
	this.strHtml = strHtml
}

function displayContent(strHTML, objHTML){
	//alert(strHTML);
	objHTML.innerHTML = unescape(strHTML)
}



function PhotoPop(id){
	if(id!=""){
		var strURL = "/waphoto.asp?id=" + id
		var objPhotoWindow = window.open(strURL,'photo','height=500,width=550,left=10,top=10,directories=0,fullscreen=0,location=0,menubar=0,scrollbars=1,resizable=0,status=0,toolbar=0');
	}
}

function FlashPop(url){
	if(url!=""){
		var objPhotoWindow = window.open(url,'flashgame','height=630,width=890,left=10,top=10,directories=0,fullscreen=0,location=0,menubar=0,scrollbars=0,resizable=0,status=0,toolbar=0');
	}
}

function SendToFriend(id,section){
	if(id!=""){
		var strURL = "/waemailfriend.asp?id=" + id + "&section=" + section
		var objFriendWindow = window.open(strURL,'photo','height=450,width=550,left=10,top=10,directories=0,fullscreen=0,location=0,menubar=0,scrollbars=1,resizable=0,status=0,toolbar=0');
	}
}


function RotateBanner(intArrayCount,i){
	if(slides.length > 1 && i > 1 && parseInt(i) % 2 == 0){
		var s1 = intArrayCount-1==-1?slides.length - 1:intArrayCount-1; // Out
		var s2 = intArrayCount; // either the next or the first;
		fade(s1,0); // fade the old slide out!
		fade(s2,1); // fade the new slide in!		
		ChangeLogo();
		var intArrayNumber = s2+1==slides.length?0:s2+1;

	}else{
		ChangeLogo();	
		var intArrayNumber = intArrayCount;
	}
	var intArrayNumber;
	setTimeout("RotateBanner(" + intArrayNumber + "," + parseInt(i + 1) +")",3000);
}


function ChangeLogo(){
	var CurrLogo = xDOM('WAlogo',0).src;
	if(CurrLogo.indexOf("logo_wa.gif") > 0){
		xDOM('WAlogo',0).src = "/css/images/logo_force.gif";
	}else{
		xDOM('WAlogo',0).src = "/css/images/logo_wa.gif";
	}
	
}

function InitFadeImages(){

	var fadeBox = document.getElementById('WAHomeGraphic');
	// set up the actual images
	for(var i=0;i<slides.length;i++) {
		// hooray for the DOM
		var slide = document.createElement('img'); // a new image
		slide.src = slides[i]; // should show this image
		slide.useMap = '#mymap';
		slide.border = '0';
		slide.style.display = 'none';
		slide.style.position = 'absolute'; // important so images stay on top of each other
		slide.style.opacity = '0'; // init to transparent (CSS2)
		slide.style.filter = 'alpha(opacity:0)'; // init to transparent (MSIE)
		fadeBox.appendChild(slide); // put the image in the box
		slides[i] = slide; // reassign to same array for convenience
		// if it's the first image, let's show it now to avoid waiting
		if(i==0) { 
			fade(i,1); // fade it in!
		}
	}	
}



function fade(whoid,dir) {

	var slide = slides[whoid]; // get the slide element at index whoid
	var completed; // so we know when the fade is done
	var opac = parseFloat(slide.style.opacity,10); // get a reference value
	// increment if fading in, decrement if fading out
	if(dir > 0) { 
		slide.style.display = 'block';
		opac += .1; // more opaque
		if(opac >= 1) {
			// fade is at max! fade done!
			completed = true;
		}
	} else {
		opac -= .1; // less opaque
		if(opac <= 0) {
			// fade is at min! fade done!
			slide.style.display = 'none';
			completed = true;
		}
	}
	slide.style.opacity = opac; // set opacity (CSS2)
	slide.style.filter = 'alpha(opacity:'+(opac*100)+')'; // set opacity (MSIE)
	if(!completed) {
		// as long as the fade is not complete, keep doing this in 1/10 increments within fadeTimer seconds
		setTimeout("fade("+whoid+","+dir+")",70);
	}
}


/// Form validation functions
function strTrim(strText) {
		for (i=0; i<strText.length; ++i) {
			if (strText.charAt(i) != ' ') break;
		}
		if (i >= strText.length) return ('');
		if (i > 0) strText = strText.substring(i, strText.length);
		for (j=strText.length-1; j > i; --j) {
			if (strText.charAt(j) != ' ') break;
		}
		if (j < strText.length -1)
			strText = strText.substring(0, j+1);
		return strText;

}

/*
function ValidEmail(strEmail)
{
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	
	if (filter.test(strEmail))
		return true
	else
		return false
}
*/
function ValidEmail(email)
{
  var result = false
  var theStr = new String(email)
  var index = theStr.indexOf("@");
  if (index > 0)
  {
    var pindex = theStr.indexOf(".",index);
    if ((pindex > index+1) && (theStr.length > pindex+1))
	result = true;
  }
  if (theStr.indexOf(" ") > 0 )  return false;  
  if (theStr.indexOf("@", index + 1) > 0 ) return false;
  return result;
}

function isInteger(s)
{   var i;
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag){  
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++)
    {   
        // Check that current character isn't whitespace.
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function ValidPhone(strPhone, minDigitsInIPhoneNumber){
	var phoneNumberDelimiters = "()- ";
	var validWorldPhoneChars = phoneNumberDelimiters + "+";

	s=stripCharsInBag(strPhone, validWorldPhoneChars);
	return (isInteger(s) && s.length >= minDigitsInIPhoneNumber);
}

function ValidPhoneStripped(strPhone, minDigitsInIPhoneNumber){
	var phoneNumberDelimiters = "()- ";
	var validWorldPhoneChars = phoneNumberDelimiters + "+";

	s=stripCharsInBag(strPhone, validWorldPhoneChars);
	if ((isInteger(s) && s.length >= minDigitsInIPhoneNumber))
		return stripCharsInBag(strPhone, phoneNumberDelimiters);
	else
		return false;
}

function ValidText(strText, intMin){
	if (strText == "" || strText.length < intMin)
		return false;
	else
		return true;
}

function TextStartNumber(strText){   
	// Check if first character is a number
	if ((strText.charAt(0) < "0") || (strText.charAt(0) > "9"))
	{	
		return false;
	}
	else
	{
		return true;
	}
}	

function ValidChecked(objField) {
// This can be used for both checkboxes and radio buttons
	if(objField.length) {
		for (var i=0 ; i<objField.length ; i++) {
			if (objField[i].checked)
				return true;
		}
	} else {
		//only one item
		if(objField.checked)
			return true;
	}
}

function ValidateEmailForm(obj){
		var strAlert = "";
		strAlert = "______________________________________\n\nPlease\n\n";
		var isAlert = false;

		// trim the values of white space
		var strToEmail = strTrim(obj.emailTo.value);
		var strToName = strTrim(obj.nameTo.value);
		var strFromEmail = strTrim(obj.emailFrom.value);
		var strFromName = strTrim(obj.nameFrom.value);
		

		if (!ValidText(strToName,1)){
			strAlert += "- Enter name of recipient\n";
			isAlert = true;
		}
		
		if (!ValidText(strFromName,1)){
			strAlert += "- Enter your name\n";
			isAlert = true;
		}

		if (!ValidText(strToEmail,1)){
			strAlert += "- Enter an email address for recipient\n";
			isAlert = true;
		}else if (strToEmail != ""){
			if (!ValidEmail(strToEmail)){
				strAlert += "- Enter a valid email address for recipient\n";
				isAlert = true;
			}
		}
		
		if (!ValidText(strFromEmail,1)){
			strAlert += "- Enter your email address\n";
			isAlert = true;
		}else if (strFromEmail != ""){
			if (!ValidEmail(strFromEmail)){
				strAlert += "- Enter your valid email address\n";
				isAlert = true;
			}
		}

		if (isAlert == true){
			strAlert += "\n\n______________________________________";
			alert (strAlert);
			return false;
		}else{
			return true;
		}
	}

// ROTATING NEWS BANNER //
// Scripts for the Rotating News stuff....
var intSecondBetweenItems = 5
var intPreviousItem = 0
function DisplayContent(strID){	
	if(intPreviousItem!=0)SwapButton(intPreviousItem,"");
	SwapButton(strID,"newsNumbersOn");
	displayObj = xDOM("newsContent",0);
	displayObj.innerHTML = ""
	displayObj.innerHTML = unescape(arrHomeNews[strID].strHtml)	
	if(intTotalItems == parseInt(strID)){
		intNextNewsID = 1	
	}else{
		intNextNewsID = parseInt(strID) + 1	
	}		
	intPreviousItem = strID
}
var intSecondBetweenItems2 = 5
var intPreviousItem2 = 0
function DisplayContent2(strID) {
    if (intPreviousItem2 != 0) SwapButton2(intPreviousItem2, "");
    SwapButton2(strID, "eventsNumbersOn");
    displayObj = xDOM("eventsContent", 0);
    displayObj.innerHTML = ""
    displayObj.innerHTML = unescape(arrHomeEvents[strID].strHtml)
    if (intTotalItems2 == parseInt(strID)) {
        intNextEventsID = 1
    } else {
        intNextEventsID = parseInt(strID) + 1
    }
    intPreviousItem2 = strID
}

function cycleNewsItems(strID){
	if(blnCycleNews){
		DisplayContent(strID)
		setTimeout("cycleNewsItems(intNextNewsID)", intSecondBetweenItems2*1000)
	}
}
function cycleEventsItems(strID) {
    if (blnCycleEvents) {
        DisplayContent2(strID)
        setTimeout("cycleEventsItems(intNextEventsID)", intSecondBetweenItems * 1000)
    }
}

function DisplayNewsItem(strID){
	blnCycleNews = false
	DisplayContent(strID);
}
function DisplayEventsItem(strID) {
    blnCycleEvents = false
    DisplayContent2(strID);
}

function ToggleNews(){
	if(blnCycleNews){
		blnCycleNews = false
		xDOM('HomeNewsPlay',0).src = "/css/images/tilePlay.gif"
	}else{
		blnCycleNews = true
		xDOM('HomeNewsPlay',0).src = "/css/images/tilePause.gif"
		cycleNewsItems(intNextNewsID);
	}
}

function GoBackOne(){
	blnCycleNews = false
	xDOM('HomeNewsPlay',0).src = "/css/images/tilePlay.gif"
	intNextNewsID = intNextNewsID - 2
	if(intNextNewsID < 1){
		intNextNewsID = intNextNewsID + intTotalItems	
	}	
	DisplayContent(intNextNewsID);	
}
function GoForwardOne(){
	blnCycleNews = false
	xDOM('HomeNewsPlay',0).src = "/css/images/tilePlay.gif"
	DisplayContent(intNextNewsID);
}	
function initNews(){
	cycleNewsItems(1)
}
function initEvents() {
    cycleEventsItems(1)
}
function SwapButton(strID,strClass){
	objButton = xDOM("news_" + strID,0)
	objButton.className=strClass
}
function SwapButton2(strID, strClass) {
    objButton = xDOM("events_" + strID, 0)
    objButton.className = strClass
}

function lib_bwcheck(){ //Browsercheck (needed)
	this.ver=navigator.appVersion
	this.agent=navigator.userAgent
	this.dom=document.getElementById?1:0
	this.opera5=(navigator.userAgent.indexOf("Opera")>-1 && document.getElementById)?1:0
	this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom && !this.opera5)?1:0; 
	this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom && !this.opera5)?1:0;
	this.ie4=(document.all && !this.dom && !this.opera5)?1:0;
	this.ie=this.ie4||this.ie5||this.ie6
	this.mac=this.agent.indexOf("Mac")>-1
	this.ns6=(this.dom && parseInt(this.ver) >= 5) ?1:0; 
	this.ns4=(document.layers && !this.dom)?1:0;
	this.bw=(this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.opera5)
	return this
}
var bw=lib_bwcheck()
//If you want it to move faster you can set this lower, it's the timeout:
var speed = 60

//Sets variables to keep track of what's happening
var loop, timer

//Object constructor
function makeObj(obj,nest){
    nest=(!nest) ? "":'document.'+nest+'.'
	this.el=bw.dom?document.getElementById(obj):bw.ie4?document.all[obj]:bw.ns4?eval(nest+'document.'+obj):0;
  	this.css=bw.dom?document.getElementById(obj).style:bw.ie4?document.all[obj].style:bw.ns4?eval(nest+'document.'+obj):0;
	this.scrollHeight=bw.ns4?this.css.document.height:this.el.offsetHeight
	this.clipHeight=bw.ns4?this.css.clip.height:this.el.offsetHeight
	this.up=goUp;this.down=goDown;
	this.moveIt=moveIt; this.x=11; this.y=5;
    this.obj = obj + "Object"

    eval(this.obj + "=this")
    return this
}

// A unit of measure that will be added when setting the position of a layer.
var px = bw.ns4||window.opera?"":"px";

function moveIt(x,y){
	this.x = x
	this.y = y
	this.css.left = this.x+px
	this.css.top = this.y+px
}

//Makes the object go up
function goDown(move){
	if (this.y>-this.scrollHeight+oCont.clipHeight){
		this.moveIt(0,this.y-move)
			if (loop) setTimeout(this.obj+".down("+move+")",speed)
	}
}
//Makes the object go down
function goUp(move){
	if (this.y<5){
		this.moveIt(0,this.y-move)
		if (loop) setTimeout(this.obj+".up("+move+")",speed)
	}
}

//Calls the scrolling functions. Also checks whether the page is loaded or not.
function scroll(speed){
	if (scrolltextLoaded){
		loop = true;
		if (speed>0) oScroll.down(speed)
		else oScroll.up(speed)
	}
}

//Stops the scrolling (called on mouseout)
function noScroll(){
	loop = false
	if (timer) clearTimeout(timer)
}
//Makes the object
var scrolltextLoaded = false
function scrolltextInit(){
	oCont = new makeObj('LiveMatchComentary')
	oScroll = new makeObj('divText','LiveMatchComentary')
	oScroll.moveIt(0,0)
	oCont.css.visibility = "visible"
	scrolltextLoaded = true

}
//Call the init on page load if the browser is ok...

function ScrollUP(){
	scroll(10);
}
function ScrollDOWN(){
	scroll(-10);
	//setTimeout("noScroll()",250);
}
function ScrollStop(){
	noScroll()
}

function setRowColor(id, strColour){
	// -- get element (the table), TBODY tag, children of (TR tags)
	var r=document.getElementById(id).getElementsByTagName('tr');
	 // - total number of TR tags
	var l=r.length
	for (i=0;i<l;i++){
		if (i%2 == 0){r[i].style.backgroundColor=strColour;}
		else {}
	}
}
function DisplayPassword(){
	var obj = xDOM("forgotPassword",0);
	if(obj.style.height == "0px"){
		RevealPassword()
	}else{
		ClosePassword()
	}	

}
var intHeight = 0
var inTotal = 100
function RevealPassword(){
	var obj = xDOM("forgotPassword",0);
	if(intHeight == inTotal){
		//setTimeout("setPassFocus()",10);
	}else{
		intHeight = intHeight + 10	
		obj.style.height = intHeight + "px";
		setTimeout("RevealPassword()",1);
	}			
}
function ClosePassword(){
	var obj = xDOM("forgotPassword",0);
	if(intHeight == 0){

	}else{
		intHeight = intHeight - 10	
		obj.style.height = intHeight + "px";
		setTimeout("ClosePassword()",1);
	}			
}


function PopulateShipping(objCheckBox){
	var objForm = xDOM("CustomerRego",0)
	if(objCheckBox.checked){
		objForm.shipaddress.value = objForm.address.value;
		//objForm.shipaddress2.value = objForm.address2.value;
		objForm.shipsuburb.value = objForm.suburb.value;
		objForm.shipstate.value = objForm.state.value;
		objForm.shippostcode.value = objForm.postcode.value;
		objForm.shipcountry.value = objForm.country.value;
	}
	
}

function ValidateProfile(obj,blnCheckAddress,blnCheckPassword){
		var strAlert = "";
		strAlert = "______________________________________\n\nPlease\n\n";
		var isAlert = false;

		// trim the values of white space
		var strEmail = strTrim(obj.email.value);
		var strFirstName = strTrim(obj.firstname.value);
		var strLastName = strTrim(obj.lastname.value);
		if(blnCheckPassword){
			var strPassword = strTrim(obj.password.value);
			var strConfirmPassword = strTrim(obj.confirmpassword.value);
		}
		
		var strDayPhone = strTrim(obj.dayphone.value);
		var strAddress = strTrim(obj.address.value);
		var strSuburb = strTrim(obj.suburb.value);
		var strState = strTrim(obj.state.value);
		var strPostcode = strTrim(obj.postcode.value);
		var strCountry = strTrim(obj.country.value);
		
		var strShipAddress = strTrim(obj.shipaddress.value);
		var strShipSuburb = strTrim(obj.shipsuburb.value);
		var strShipState = strTrim(obj.shipstate.value);
		var strShipPostcode = strTrim(obj.shippostcode.value);
		var strShipCountry = strTrim(obj.shipcountry.value);

		if (!ValidText(strEmail,1)){
			strAlert += "- Enter your email address\n";
			isAlert = true;
		}else if (strEmail != ""){
			if (!ValidEmail(strEmail)){
				strAlert += "- Enter a valid email address\n";
				isAlert = true;
			}
		}
	
		if (!ValidText(strFirstName,1)){
			strAlert += "- Enter your first name\n";
			isAlert = true;
		}
		if (!ValidText(strLastName,1)){
			strAlert += "- Enter your last name\n";
			isAlert = true;
		}
		if(blnCheckPassword){
			if (!ValidText(strPassword,6)){
				strAlert += "- Enter a password of at least 6 characters\n";
				isAlert = true;
			}else if(strPassword!=strConfirmPassword){
				strAlert += "- Ensure your password and confirm password are the same\n";
				isAlert = true;			
			}
		}
		if (!ValidText(strDayPhone,5)){
			strAlert += "- Enter your day phone number\n";
			isAlert = true;
		}
		
		if(blnCheckAddress){
			// Mailing	
			if (!ValidText(strAddress,5)){
				strAlert += "- Enter your mailing address\n";
				isAlert = true;
			}
			if (!ValidText(strSuburb,1)){
				strAlert += "- Enter your mailing suburb \n";
				isAlert = true;
			}
			if (!ValidText(strState,1)){
				strAlert += "- Enter your mailing state\n";
				isAlert = true;
			}
			if (!ValidText(strPostcode,1)){
				strAlert += "- Enter your mailing postcode\n";
				isAlert = true;
			}
			if (!ValidText(strCountry,1)){
				strAlert += "- Enter your mailing country\n";
				isAlert = true;
			}
			// Delivery
			if (!ValidText(strShipAddress,5)){
				strAlert += "- Enter your shipping address\n";
				isAlert = true;
			}
			if (!ValidText(strShipSuburb,1)){
				strAlert += "- Enter your shipping suburb \n";
				isAlert = true;
			}
			if (!ValidText(strShipState,1)){
				strAlert += "- Enter your shipping state\n";
				isAlert = true;
			}
			if (!ValidText(strShipPostcode,1)){
				strAlert += "- Enter your shipping postcode\n";
				isAlert = true;
			}
			if (!ValidText(strShipCountry,1)){
				strAlert += "- Enter your shipping country\n";
				isAlert = true;
			}

		}

		if (isAlert == true){
			strAlert += "\n\n______________________________________";
			alert (strAlert);
			return false;
		}else{
			return true;
		}
	}

function ValidateForgottenForm(obj){
	
	var strAlert = "";
	strAlert = "______________________________________\n\nPlease\n\n";
	var isAlert = false;

	// trim the values of white space
	var strEmail = strTrim(obj.email.value);


	if (!ValidText(strEmail,1)){
		strAlert += "- Enter your email address\n";
		isAlert = true;
	}else if (strEmail != ""){
		if (!ValidEmail(strEmail)){
			strAlert += "- Enter a valid email address\n";
			isAlert = true;
		}
	}


	if (isAlert == true){
		strAlert += "\n\n______________________________________";
		alert (strAlert);
		return false;
	}else{
		return true;
	}
}	
	


function ValidateCompetition(obj){
		var strAlert = "";
		strAlert = "______________________________________\n\nPlease\n\n";
		var isAlert = false;

		// trim the values of white space

		var strFirstName = strTrim(obj.firstname.value);
		var strLastName = strTrim(obj.lastname.value);
		var strEmail = strTrim(obj.email.value);	
		//var strEmiratesMember = strTrim(obj.emiratesmember.value);
		var strDayPhone = strTrim(obj.dayphone.value);
		var strAfterHrPhone = strTrim(obj.afterhrphone.value);
		//var strEmailFormat = strTrim(obj.emailformat.value);
		var strAddress = strTrim(obj.address.value);
		var strSuburb = strTrim(obj.suburb.value);
		var strState = strTrim(obj.state.value);
		var strPostcode = strTrim(obj.postcode.value);
		var strCountry = strTrim(obj.country.value);	
		var strAnswer = strTrim(obj.answer.value);
		
		if (!ValidText(strFirstName,1)){
			strAlert += "- Enter your first name\n";
			isAlert = true;
		}
	
		if (!ValidText(strLastName,1)){
			strAlert += "- Enter your last name\n";
			isAlert = true;
		}
		if (!ValidText(strEmail,1)){
			strAlert += "- Enter your email address\n";
			isAlert = true;
		}else if (strEmail != ""){
			if (!ValidEmail(strEmail)){
				strAlert += "- Enter a valid email address\n";
				isAlert = true;
			}
		}	
		/*if (!ValidText(strEmiratesMember,1)){
			strAlert += " - Select whether you are an emirates western force member\n";
			isAlert = true;
		}*/
		
		if (!ValidText(strDayPhone,1)){
			strAlert += "- Enter your day phone number\n";
			isAlert = true;
		}
		if (!ValidText(strAfterHrPhone,1)){
			strAlert += "- Enter your after hours phone number\n";
			isAlert = true;
		}
		if (!ValidText(strAddress,1)){
			strAlert += "- Enter your address\n";
			isAlert = true;
		}
		if (!ValidText(strSuburb,1)){
			strAlert += "- Enter your suburb\n";
			isAlert = true;
		}
		if (!ValidText(strState,1)){
			strAlert += "- Enter your state\n";
			isAlert = true;
		}
		if (!ValidText(strPostcode,1)){
			strAlert += "- Enter your postcode\n";
			isAlert = true;
		}
		if (!ValidText(strCountry,1)){
			strAlert += "- Enter your country\n";
			isAlert = true;
		}
		if (!ValidText(strAnswer,1)){
			strAlert += "- Enter your answer\n";
			isAlert = true;
		}		
		

		if (isAlert == true){
			strAlert += "\n\n______________________________________";
			alert (strAlert);
			return false;
		}else{
			return true;
		}
	}
	
	
function ValidateContact(obj){
		var strAlert = "";
		strAlert = "______________________________________\n\nPlease\n\n";
		var isAlert = false;

		// trim the values of white space

		var strFirstName = strTrim(obj.firstname.value);
		var strLastName = strTrim(obj.lastname.value);
		var strTitle = obj.title.options[obj.title.options.selectedIndex].value;
		var strContactMethod = obj.contactmethod.options[obj.contactmethod.options.selectedIndex].value;
		var strDepartment = obj.department.options[obj.department.options.selectedIndex].value;
		var strEmail = strTrim(obj.email.value);		
		var strHomePhone = strTrim(obj.homephone.value);
		var strMobilePhone = strTrim(obj.mobile.value);		
		var strFeedback = strTrim(obj.feedback.value);
		if (!ValidText(strTitle,1)){
			strAlert += "- Select your title\n";
			isAlert = true;
		}
		if (!ValidText(strFirstName,1)){
			strAlert += "- Enter your first name\n";
			isAlert = true;
		}
		if (!ValidText(strLastName,1)){
			strAlert += "- Enter your last name\n";
			isAlert = true;
		}
		if(strContactMethod=="email"){
			if (!ValidText(strEmail,1)){
				strAlert += "- Enter your email address\n";
				isAlert = true;
			}else if (strEmail != ""){
				if (!ValidEmail(strEmail)){
					strAlert += "- Enter a valid email address\n";
					isAlert = true;
				}
			}	
		}else if(strContactMethod=="home"){
			if (!ValidText(strHomePhone,1)){
				strAlert += "- Enter your home phone number\n";
				isAlert = true;
			}			
		}else if(strContactMethod=="mobile"){
			if (!ValidText(strMobilePhone,1)){
				strAlert += "- Enter your mobile phone number\n";
				isAlert = true;
			}					
		}else{
				strAlert += "- Select your prefered method of contact\n";
				isAlert = true;			
		}
		if (!ValidText(strDepartment,0)){
			strAlert += "- Select a department to send this enquiry to\n";
			isAlert = true;
		}		
		if (!ValidText(strFeedback,1)){
			strAlert += "- Enter your feedback\n";
			isAlert = true;
		}		
		

		if (isAlert == true){
			strAlert += "\n\n______________________________________";
			alert (strAlert);
			return false;
		}else{
			return true;
		}
	}	
	
function ValidateProduct(quantity){
	//alert(quantity)
	if(isNaN(quantity) || quantity == 0){
		alert("Please enter a valid quantity.");
		return false;	
	}else{
		return true;	
	}
}
	
function ValidateAtendee(obj,strAttendeeType,intCount){
	var strAlert = "";
	strAlert = "______________________________________\n\nPlease\n\n";
	var isAlert = false;


	for (i=1;i<=intCount;i++){
		//alert(i)	
		if(strAttendeeType=='Standard'){
			if (!ValidText(obj["firstname" + i].value,1)){
				strAlert += "- Enter attendee " + i + "'s first name\n";
				isAlert = true;
			}	
			if (!ValidText(obj["lastname" + i].value,1)){
				strAlert += "- Enter attendee " + i + "'s last name\n";
				isAlert = true;
			}
		}else if(strAttendeeType=='Brief'){
			if (!ValidText(obj["firstname" + i].value,1)){
				strAlert += "- Enter attendee " + i + "'s first name\n";
				isAlert = true;
			}	
			if (!ValidText(obj["lastname" + i].value,1)){
				strAlert += "- Enter attendee " + i + "'s last name\n";
				isAlert = true;
			}
			/*
			if (!ValidText(obj["position" + i].value,1)){
				strAlert += "- Enter attendee " + i + "'s position\n";
				isAlert = true;
			}			
			if (!ValidText(obj["company" + i].value,1)){
				strAlert += "- Enter attendee " + i + "'s company\n";
				isAlert = true;
			}				
			if (!ValidText(obj["dayphone" + i].value,1)){
				strAlert += "- Enter attendee " + i + "'s daytime phone number\n";
				isAlert = true;
			}						
			*/
		}else{
			if (!ValidText(obj["firstname" + i].value,1)){
				strAlert += "- Enter attendee " + i + "'s first name\n";
				isAlert = true;
			}	
			if (!ValidText(obj["lastname" + i].value,1)){
				strAlert += "- Enter attendee " + i + "'s last name\n";
				isAlert = true;
			}	
		}
	}
	if (isAlert == true){
		strAlert += "\n\n______________________________________";
		alert (strAlert);
		return false;
	}else{
		return true;
	}
}

function CheckPayment(objForm){
	var strAlert = "";
	strAlert = "______________________________________\n\nPlease\n\n";
	var isAlert = false;

	var paymentMethod = objForm.paymentType.options[objForm.paymentType.selectedIndex].value;	
	var intCreditCard = strTrim(objForm.ccnumber.value)
	var intCreditCardName = strTrim(objForm.nameoncard.value)
	if(paymentMethod==""){
		strAlert += "- Please select a payment method.\n";
		isAlert = true;		
	}else if(paymentMethod.substring(0,1) == '1'){ // Its a credit card
		if (intCreditCardName==""){
			strAlert += "- Please enter the name on your Credit Card\n";
			isAlert = true;
		}
		if (intCreditCard==""){
			strAlert += "- Please enter a valid Credit Card number\n";
			isAlert = true;
		}		
	}
	if (isAlert == true){
		strAlert += "\n\n______________________________________";
		alert (strAlert);
		return false;
	}else{
		return true;
	}	
	
}

var strPrevId = ""
function TogglePoll(id) {
	if(xDOM(id,1).display=="block"){
		xDOM(id,1).display="none";
	}else{
		if(strPrevId != ""){
			xDOM(strPrevId,1).display="none";
		}
		
		xDOM(id,1).display="block";
		strPrevId = id
	}

}




/* MENU */
// Copyright 2006-2007 javascript-array.com

var timeout	= 500;
var closetimer	= 0;
var ddmenuitem	= 0;

// open hidden layer
function mopen(id)
{	
	// cancel close timer
	mcancelclosetime();

	// close old layer
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';

	// get new layer and show it
	ddmenuitem = document.getElementById(id);
	ddmenuitem.style.visibility = 'visible';

}
// close showed layer
function mclose()
{
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';
}

// go close timer
function mclosetime()
{
	closetimer = window.setTimeout(mclose, timeout);
}

// cancel close timer
function mcancelclosetime()
{
	if(closetimer)
	{
		window.clearTimeout(closetimer);
		closetimer = null;
	}
}

// close layer when click-out
document.onclick = mclose; 




/* Home Features */

function DisplayItem(obj1, obj2, obj3)
{
	document.getElementById(obj1).style.display='block';
	document.getElementById(obj2).style.display='none';
	document.getElementById(obj3).style.display='none';
	document.getElementById(obj1+"_link").className='title_on';
	document.getElementById(obj2+"_link").className='title_off';
	document.getElementById(obj3+"_link").className='title_off';
}

function DisplayItem2(obj1, obj2) {
    if(document.getElementById(obj1))
	document.getElementById(obj1).style.display = 'block';
	
	if(document.getElementById(obj2))
    document.getElementById(obj2).style.display = 'none';
	
	if(document.getElementById(obj1 + "_link"))
    document.getElementById(obj1 + "_link").className = 'title_on';
	
	if(document.getElementById(obj2 + "_link"))
    document.getElementById(obj2 + "_link").className = 'title_off';
}

function DisplayItem3(obj1) {
    var i;
    
    for (i = 1; i <= 3; i++) {
        if (document.getElementById('Items1_' + i)) {
            document.getElementById('Items1_' + i).style.display = 'none';
            document.getElementById('Items1_' + i + "_link").className = 'titles_off';
        }
    }
    document.getElementById(obj1).style.display = 'block';
    document.getElementById(obj1 + "_link").className = 'titles_on';

}
function DisplayItem4(obj1) {
    var i;

    for (i = 1; i <= 3; i++) {
        if (document.getElementById('Items2_' + i)) {
            document.getElementById('Items2_' + i).style.display = 'none';
            document.getElementById('Items2_' + i + "_link").className = 'titles_off';
        }
    }
    document.getElementById(obj1).style.display = 'block';
    document.getElementById(obj1 + "_link").className = 'titles_on';

}

function DisplayPhotoGallery(obj1) {
    var i;

    for (i = 1; i <= 4; i++) {
        if (document.getElementById('pGallery' + i)) {
            document.getElementById('pGallery' + i).style.display = 'none';
            document.getElementById('pGallery' + i + "_link").className = 'title_off';
        }
    }
    document.getElementById(obj1).style.display = 'block';
    document.getElementById(obj1 + "_link").className = 'title_on';

}

function SwapImage(id,pPos) {
    var i;
    for (i = 1; i <= 9; i++) {
        if (document.getElementById('large_'+pPos+'_' + i)) {
            document.getElementById('large_' + pPos + '_' + i).style.display = 'none';
            document.getElementById('thumb_on_' + pPos + '_' + i).style.display = 'none';
            document.getElementById('thumb_' + pPos + '_' + i).style.display = 'block';
        }
    }
    document.getElementById('large_' + pPos + '_' + id).style.display = 'block';
    document.getElementById('thumb_' + pPos + '_' + id).style.display = 'none';
    document.getElementById('thumb_on_' + pPos + '_' + id).style.display = 'block';
}

function DisplaySplash(obj,version,boxHeight,boxWidth)
{
	Shadowbox.open({
		content:    document.getElementById(obj).innerHTML,
		player:     "html",
		title:      "&nbsp;",
		height:     boxHeight,
		width:      boxWidth
	});
	return false;
}
