addLoadEvent(function() {
	var elements = getElementsByClass("signUpField");
	for(var i = 0; i < elements.length;i++){
		
		if(elements[i].type == "password"){
			var textElem;
			textElem = $(elements[i].id + "text");
			// if passwordtext value and title are not the same then a password was entered so 
			// only show password field with password entered
			if(textElem.value == textElem.title){	
				elements[i].style.display = "none";
				textElem.style.display = "inline";
			}else{
				elements[i].value = textElem.value;
			}
			
			// set onclick and onfocus for users to tab thru fields
			textElem.onfocus = function() {passwordFocus(this) };
			textElem.onclick = function() {passwordFocus(this) };
			
			elements[i].onblur = function(){passwordBlur(this) };
			elements[i].onclick = function(){passwordBlur(this) };
			
		}else if(elements[i].id.indexOf("text") == -1){
				elements[i].onclick = function(){
					this.value = "";
				};
				elements[i].onblur = function(){
					if(this.value == ""){
						this.value = this.title;
					}
				};
		}
	}
});

function passwordBlur(elem){
	if(elem.value == ""){
		elem.style.display = "none";
		var textElem = $(elem.id + "text");
		textElem.style.display = "inline";
		textElem.value = textElem.title;
	}
}
function passwordFocus(elem){
	elem.value = "";
				
	if(elem.type == "text"){
		elem.style.display = "none";
		var textElem = $(elem.id.replace("text",""));
		textElem.style.display = "inline";
		textElem.focus();
	}
}

addLoadEvent(function(){
	var error = false;
	if($("viewFriends")){
		$("viewFriends").onclick = function(){
			$("sendEmail").style.display =  "none";				
			$("friendsList").style.display = "block";
		}
	}
	if($("preview")){
		$("preview").onclick = function(){
			var messageBody = $("emailMessage").value;
			var emailAddress =  $("friendEmailAddress").value;
			
			if(emailAddress == ""){
				alert("You must enter an email address.");
				error = true;
			}
			if(messageBody == "" && error == false){
				alert("You must enter a message body.");
				error = true;
			}
	
			if(!error){
				$("messageBody").innerHTML =  messageBody.replace(/\n/g,"<br>");
				$("messagePreview").style.display = "block";
			}
		}
	}
	if($("sendBtn")){
		$("sendBtn").onclick = function(){
			document.form2.submit();
		}
	}
});

addLoadEvent(function(){
		if($("viewrules")){
			var viewrules = $("viewrules");
			viewrules.onclick = function(){ toggleEl("rulesPopup");}
		}
		if($("officalRules")){
			var officalRules = $("officalRules");
			officalRules.onclick = function(){ toggleEl("rulesPopup");}
		}
	}
);

addLoadEvent(function() {
	
	AllRolloverImages();
});
			 
function AllRolloverImages(){
var allRollovers = getElementsByClass('rollover')
var PreloadImages = new Array();
		for (var i = 0; i < allRollovers.length; i++) {
			var rollover = allRollovers[i];
			if (rollover.className && (' ' + rollover.className + ' ').indexOf(' rollover ') != -1) {
				if (rollover.src !== 'undefined'){
					PreloadImages[i] = new Image();
					PreloadImages[i].src = rollover.src;
					rollover.onmouseover = function(){
						this.src = this.src.replace(/OVER(\.[^.]+)$/, '$1');
						 // reaply the img
						this.src = this.src.replace(/(\.[^.]+)$/, 'OVER$1');
						};//rollover.onmouseover
					rollover.onmouseout = function(){
						this.src = this.src.replace(/OVER(\.[^.]+)$/, '$1');
					};//rollover.onmouseout
				 };//if (rollover.src !== 'undefined')
			};//if (rollover.className && (' ' + rollover.className + ' ').indexOf(' rollover ') != -1)
		};	//for (var i = 0; i < allRollovers.length; i++) {
			
	};//End Function



