// gom.js version 4.01 from 2007-11-07 by Jason C. Moses
//-----------------------------------------------------------------
function MM_swapImgRestore() {
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) 
x.src=x.oSrc;
}
//-----------------------------------------------------------------
function MM_prelosplashImages() {
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
	var i,j=d.MM_p.length,a=MM_prelosplashImages.arguments; for(i=0; i<a.length; 
i++)
	if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
//-------------------------------------------------------------------------------------
function MM_swapImage() {
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; 
for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) 
x.oSrc=x.src; x.src=a[i+2];}
}
// Form validation script-----------------------------------------------------------------------------
function validName(contactName) {
        invalidChars = "/:,;"
// cannot be empty
        if (contactName == "" || contactName == "contact name*") {
                alert("Please enter your name")
                return false
        }
// does it contain any invalid characters?
        for (i=0; i<invalidChars.length; i++) {
                badChar = invalidChars.charAt(i)
                if (contactName.indexOf(badChar,0) > -1) {
                alert("You've entered an invalid character")
                        return false
        }
// must be at least one space after the second character
        spacePos = contactName.indexOf(" ",2)
        if (spacePos == -1) {
                alert("Please enter first and last names")
                return false
        }
// must be at least 2 characters after the space
        if (spacePos+3 > contactName.length)    {
                alert("Please enter first and last names")
                return false
        }
}
        return true
}
function validPhone(contactTel) {
		alphaChars = "qwertyuiopasdfghjklzxcvbnm/QWERTYUIOPASDFGHJKLZXCVBNM\!@#$%^&*_=|}{[];:,.<>/?'"
		
		// cannot be empty
		if (contactTel == "" || contactTel == "phone*") {
			alert("Please enter a contact phone number")
			return false
		}
		// does it contain any invalid characters?
		for (i=0; i<alphaChars.length; i++) {
			nonNum = alphaChars.charAt(i)
			if (contactTel.indexOf(nonNum,0) > -1) {
			alert("Numbers only, please")
				return false
			}
	}
	return true
}

function submitIt(serviceForm) {

		// check that he or she enters a company name
		if	(serviceForm.companyName.value == "" || serviceForm.companyName.value == "company name*") {
			alert("Please enter your company name")
			serviceForm.companyName.focus()
			serviceForm.companyName.select()
			return false
		}
		// check that he or she enters a company address
		if	(serviceForm.address.value == "" || serviceForm.address.value == "company address*") {
			alert("Please enter your company address")
			serviceForm.address.focus()
			serviceForm.address.select()
			return false
		}
		// check to see whether the name's valid
		if (!validName(serviceForm.contactName.value)) {
			serviceForm.contactName.focus()
			serviceForm.contactName.select()
			return false
		}
		// check to see whether the contact telephone's valid
		if (!validPhone(serviceForm.contactTel.value)) {
			serviceForm.contactTel.focus()
			serviceForm.contactTel.select()
			return false
		}
		// If we made it to here, everything's valid, so return true
		return true
}
function submitIt(salesForm) {

		// check that he or she enters a company name
		if	(salesForm.companyName.value == "" || salesForm.companyName.value == "company name*") {
			alert("Please enter your company name")
			salesForm.companyName.focus()
			salesForm.companyName.select()
			return false
		}
		// check that he or she enters a company address
		if	(salesForm.address.value == "" || salesForm.address.value == "company address*") {
			alert("Please enter your company address")
			salesForm.address.focus()
			salesForm.address.select()
			return false
		}
		// check to see whether the name's valid
		if (!validName(salesForm.contactName.value)) {
			salesForm.contactName.focus()
			salesForm.contactName.select()
			return false
		}
		// check to see whether the contact telephone's valid
		if (!validPhone(salesForm.contactTel.value)) {
			salesForm.contactTel.focus()
			salesForm.contactTel.select()
			return false
		}
		// check that he or she enters a machine type
		if	(salesForm.equip.value == "") {
			alert("Please choose equipment type")
			salesForm.equip.focus()
			return false
		}
		// If we made it to here, everything's valid, so return true
		return true
}
// End form validation script--------------------------------------------

// Start form field clearing--> 

function clearField(field) { 
    if (field.value == field.defaultValue) { 
        field.value = ''; 
    } 
} 
function resetField(field) { 
    if (field.value == '') { 
        field.value = field.defaultValue; 
    } 
} 
//---End form field clearing----------

//---Start splash image rotation-----
splashImages = new Array("images/splashOne.png","images/splashTwo.png","images/splashThree.png")
splashURL = new Array("service.html","consumables.html","sales.html")
thisSplash = 0
imgCt = splashImages.length

function rotate() {
	if (document.images) {
		if (document.splashBanner.complete) {
			thisSplash++
			if (thisSplash == imgCt) {
				thisSplash = 0
			}
			document.splashBanner.src=splashImages[thisSplash]
		}
		setTimeout("rotate()", 5 * 1000)
	}
}

function newLocation() {
	document.location.href = "http://www.gom.com.au/" + splashURL[thisSplash]
}
//---End splash image rotation------
