var pID = 0;

window.addEvent('domready', function(){
	$('n1').addEvents({		
		'mouseenter': function(){
			// Always sets the duration of the tween to 1000 ms and a bouncing transition
			// And then tweens the height of the element
			this.src = "images/nav/workwearb.jpg";
		},
		'mouseleave': function(){
			if (pID != 1) {
				this.src = "images/nav/workweara.jpg";
			}
		}
	});
	$('n2').addEvents({		
		'mouseenter': function(){
			// Always sets the duration of the tween to 1000 ms and a bouncing transition
			// And then tweens the height of the element
			this.src = "images/nav/sportswearb.jpg";
		},
		'mouseleave': function(){
			if (pID != 2) {		
				this.src = "images/nav/sportsweara.jpg";
			}
		}
	});
	$('n3').addEvents({		
		'mouseenter': function(){
			// Always sets the duration of the tween to 1000 ms and a bouncing transition
			// And then tweens the height of the element
			this.src = "images/nav/funandeventb.jpg";
		},
		'mouseleave': function(){
			if (pID != 3) {		
				this.src = "images/nav/funandeventa.jpg";
			}
		}
	});
	$('n4').addEvents({		
		'mouseenter': function(){
			// Always sets the duration of the tween to 1000 ms and a bouncing transition
			// And then tweens the height of the element
			this.src = "images/nav/hospitalityb.jpg";
		},
		'mouseleave': function(){
			if (pID != 4) {
				this.src = "images/nav/hospitalitya.jpg";
			}
		}
	});
	$('n5').addEvents({		
		'mouseenter': function(){
			// Always sets the duration of the tween to 1000 ms and a bouncing transition
			// And then tweens the height of the element
			this.src = "images/nav/koolartb.jpg";
		},
		'mouseleave': function(){
			if (pID != 5) {	
				this.src = "images/nav/koolarta.jpg";
			}
		}
	});
	$('n6').addEvents({		
		'mouseenter': function(){
			// Always sets the duration of the tween to 1000 ms and a bouncing transition
			// And then tweens the height of the element
			this.src = "images/nav/onlinebrochureb.jpg";
		},
		'mouseleave': function(){
			if (pID != 6) {
				this.src = "images/nav/onlinebrochurea.jpg";
			}
		}
	});
	$('n7').addEvents({		
		'mouseenter': function(){
			// Always sets the duration of the tween to 1000 ms and a bouncing transition
			// And then tweens the height of the element
			this.src = "images/nav/storeb.jpg";
		},
		'mouseleave': function(){
			if (pID != 7) {
				this.src = "images/nav/storea.jpg";
			}
		}
	});
	$('n8').addEvents({		
		'mouseenter': function(){
			// Always sets the duration of the tween to 1000 ms and a bouncing transition
			// And then tweens the height of the element
			this.src = "images/nav/aboutusb.jpg";
		},
		'mouseleave': function(){
			if (pID != 8) {
				this.src = "images/nav/aboutusa.jpg";
			}
		}
	});
	$('n9').addEvents({		
		'mouseenter': function(){
			// Always sets the duration of the tween to 1000 ms and a bouncing transition
			// And then tweens the height of the element
			this.src = "images/nav/findusb.jpg";
		},
		'mouseleave': function(){
			if (pID != 9) {
				this.src = "images/nav/findusa.jpg";
			}
		}
	});
	$('n10').addEvents({		
		'mouseenter': function(){
			// Always sets the duration of the tween to 1000 ms and a bouncing transition
			// And then tweens the height of the element
			this.src = "images/nav/contactb.jpg";
		},
		'mouseleave': function(){
			if (pID != 10) {
				this.src = "images/nav/contacta.jpg";
			}
		}
	});		


	$('submitButton').addEvent('click', function(e) {
		// You often will need to stop propagation of the event
		e.stop();		
		checkForm();
	});
});

function echeck(str) {
	var at="@"
	var dot="."
	var lat=str.indexOf(at)
	var lstr=str.length
	var ldot=str.indexOf(dot)
	if (str.indexOf(at)==-1){
		alert("You have the email address in the wrong format")
		return false
	}

	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		alert("You have the email address in the wrong format")
		return false
	}

	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		alert("You have the email address in the wrong format")
		return false
	}

	if (str.indexOf(at,(lat+1))!=-1){
		alert("You have the email address in the wrong format")
		return false
	}

	if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		alert("You have the email address in the wrong format")
		return false
	}

	if (str.indexOf(dot,(lat+2))==-1){
		alert("You have the email address in the wrong format")
		return false
	}

	if (str.indexOf(" ")!=-1){
		alert("You have the email address in the wrong format")
		return false
	}
	return true
}

function checkForm() {
	if (document.form1.nam.value == "") {
		alert("You have not filled in your name");
		return false;
	}
	if (document.form1.telephone.value == "") {
		alert("You have not entered your telephone number");
		return false;
	}

	var strEmail = document.form1.eaddress.value;
	if (!echeck(strEmail)) {
		return false;
	}

	if (document.form1.comments.value == "") {
		alert("You have not entered a comment or question");
		return false;
	}
	document.form1.Ctype.value = "true";
	document.form1.submit();
	return true;
}
