
var WRInitTime=(new Date()).getTime();

loginVisible = false;
counter=1;
function nextMessage(messageNum){
        messageScrollClicked = true;
        elementOld = "mainMessage"+ (counter);
        counter ++;
        
        if (counter == 4){ // Number is number of messages + 1
            counter = 1;
        }
        
        elementNew = "mainMessage"+ (counter);
        Effect.SlideUp(elementOld, { queue: 'end'});
        Effect.SlideDown(elementNew, { queue: 'end'});
        messageScrollClicked =false;
}

function replaceSubstring(inputString, fromString, toString) {
   // Goes through the inputString and replaces every occurrence of fromString with toString
   var temp = inputString;
   if (fromString == "") {
      return inputString;
   }
   if (toString.indexOf(fromString) == -1) { // If the string being replaced is not a part of the replacement string (normal situation)
      while (temp.indexOf(fromString) != -1) {
         var toTheLeft = temp.substring(0, temp.indexOf(fromString));
         var toTheRight = temp.substring(temp.indexOf(fromString)+fromString.length, temp.length);
         temp = toTheLeft + toString + toTheRight;
      }
   } else { // String being replaced is part of replacement string (like "+" being replaced with "++") - prevent an infinite loop
      var midStrings = new Array("~", "`", "_", "^", "#");
      var midStringLen = 1;
      var midString = "";
      // Find a string that doesn't exist in the inputString to be used
      // as an "inbetween" string
      while (midString == "") {
         for (var i=0; i < midStrings.length; i++) {
            var tempMidString = "";
            for (var j=0; j < midStringLen; j++) { tempMidString += midStrings[i]; }
            if (fromString.indexOf(tempMidString) == -1) {
               midString = tempMidString;
               i = midStrings.length + 1;
            }
         }
      } // Keep on going until we build an "inbetween" string that doesn't exist
      // Now go through and do two replaces - first, replace the "fromString" with the "inbetween" string
      while (temp.indexOf(fromString) != -1) {
         var toTheLeft = temp.substring(0, temp.indexOf(fromString));
         var toTheRight = temp.substring(temp.indexOf(fromString)+fromString.length, temp.length);
         temp = toTheLeft + midString + toTheRight;
      }
      // Next, replace the "inbetween" string with the "toString"
      while (temp.indexOf(midString) != -1) {
         var toTheLeft = temp.substring(0, temp.indexOf(midString));
         var toTheRight = temp.substring(temp.indexOf(midString)+midString.length, temp.length);
         temp = toTheLeft + toString + toTheRight;
      }
   } // Ends the check to see if the string being replaced is part of the replacement string or not
   return temp; // Send the updated string back to the user
} // Ends the "replaceSubstring" function

		function showLogin(){
		if (!loginVisible) {
			Effect.BlindUp("currentLoginStatus", { queue: 'end'});
			Effect.BlindDown("loginSlideDown", { queue: 'end'});
			loginVisible = true;
		} else {
			Effect.BlindUp("loginSlideDown", { queue: 'end'});
			Effect.BlindDown("currentLoginStatus", { queue: 'end'});
			loginVisible = false;
		}
	}
	
	function loginNow(locID){
    	if(locID=='1'){
            uNameLoc = $('loginUserName').value;
            pWordLoc = $('loginPassword').value;  
        } else {
            uNameLoc = $('emailAddress2').value;
            pWordLoc = $('password2').value;  
        }
      
		new Ajax.Request('/registration/login.php', {
		method: 'post',
			parameters: {userName:uNameLoc,password:pWordLoc},
			onSuccess: function(transport){
				var response = transport.responseText;
				loginStatus(response);},
			onFailure: function(){ alert('There has been an error. Please Try again.')}
		});
	}
	
	function loginStatus(text){
		if(text.length!=0){
			$("loginError").style.display = "block";
			$("loginError").innerHTML = text;
		} else {
			location.reload(true);
		}
	}
	
	<!--
function submitenter(myfield,e){
	var keycode;
	if (window.event) keycode = window.event.keyCode;
	else if (e) keycode = e.which;
	else return true;

	if (keycode == 13){
	   loginNow('1');
	   return false;
	} else
	   return true;
	}
//-->
		
