		
		function getTimeZoneOffset() {
		  var curDateTime = new Date()
		  return curDateTime.getTimezoneOffset();
		}
		
	function DEPRECATEDdynamicRequest(url, resetFn) {
		if (window.XMLHttpRequest) {
			req = new XMLHttpRequest();
			req.open("GET", url, true);
			req.onreadystatechange = resetFn;
			req.send(null);
			return req;
		} else if (window.ActiveXObject) {
			req = new ActiveXObject("Microsoft.XMLHTTP");
			if (req) {
				req.open("GET", url, true);
				req.onreadystatechange = resetFn;
				req.send();
				return req;
			}else {
				return null;
			}
		}else {
			return null;
		}
	}
	
	function resetDiv(divName, req) {
		if(req == null || typeof req == undefined) {
			return -1;
		}
		if (req.readyState == 4) {
	        if (req.status == 200) {
	        	div = document.getElementById(divName);
	        	//alert(div.innerHTML);
	        	//alert(req.responseText);
				div.innerHTML = req.responseText;
				//alert(div.innerHTML);
			}
			return req.status;
	    }
	}

	function dynamicRequestReturnCode(req) {
		if(req == null || typeof req == undefined) {
			return 'NONE';
		}
		if (req.readyState == 4) {
	        if (req.status == 200) {
	        	return 'OK';
			}
			return 'ERROR';
	    }
	    return 'PROCESS';
	}
		
	function attemptEncode(url) {
		if(typeof encodeURIComponent == 'function') {
			return encodeURIComponent(url);
		} else {
			return escape(url);
		}
     }
     
     function isAjaxSuccess(req) {
     	var wasSuccess = false;
     	if (dynamicRequestReturnCode(req) == 'OK')
     	{
	     	if (req != null && req != undefined && req.responseXML != undefined && req.responseXML != null) {
	     		var theResponseRoot = req.responseXML.documentElement;
	     		wasSuccess = theResponseRoot.nodeName == 'ok';
	     	}
	    }
     	return wasSuccess;
     }
     
      function hat_off() {
     	DEPRECATEDdynamicRequest('hatless.jspa?name=DONT_SHOW_HAT&value=true', nothing);
     }
     
     	function nothing() {
			//a kludge to keep the address tag from going anywhere
			//use "javascript:void(nothing())" intead of "#" in dummy <a> tags
		}
	
	function blastProfileBlock(user) {
		var query = "userId=" + attemptEncode(user);

		var errorCallback = function(request) {
			alert("There was a problem blocking " + user);
		}
		
		var successCallback = function(request) {	
			document.getElementById('block').style.display='block';
			document.getElementById('unblock').style.display='none';
		}
		
		var request = new Ajax.Request(
			'xml.block.jspa', 
			{
				method: 'get', 
				parameters: query, 
				onComplete: successCallback,
				onError: errorCallback
			});
	}

	function blastProfileUnblock(user) {
		var query = "userId=" + attemptEncode(user);

		var errorCallback = function(request) {
			alert("There was a problem unblocking " + user);
		}
		
		var successCallback = function(request) {	
			document.getElementById('block').style.display='none';
			document.getElementById('unblock').style.display='block';
		}
		
		var request = new Ajax.Request(
			'xml.unblock.jspa', 
			{
				method: 'get', 
				parameters: query, 
				onComplete: successCallback,
				onError: errorCallback
			});
	}
		
	function doBlock(user) {
		var blockURL = "xml.block.jspa?userId=" + attemptEncode(user);
		
		var callbackfunction = function() {
			if (dynamicRequestReturnCode(req) == 'OK')
			{
				if (isAjaxSuccess(req))
				{
					layer('block_confirmed');
					var blockDiv = document.getElementById("block_" + user);
					if (blockDiv == undefined) {
						blockDiv = document.getElementById("block_user");
					}
					var unBlockDiv = document.getElementById("unblock_" + user);
					if (unBlockDiv == undefined) {
						unBlockDiv = document.getElementById("unblock_user");
					}
					blockDiv.style.display = 'none';
					unBlockDiv.style.display = 'block';
				}  else
				{
					netoalert("There was a problem blocking " + user);
				}
			} else if (dynamicRequestReturnCode(req) == 'ERROR')  {
				netoalert("There was a problem blocking " + user);
			}
		}
		
		var req = DEPRECATEDdynamicRequest(blockURL, callbackfunction);
	}
	
	function doUnblock(user) {
		var unblockURL = "xml.unblock.jspa?userId=" + attemptEncode(user);
		var callbackfunction = function() {
			if (dynamicRequestReturnCode(req) == 'OK')
			{
				if (isAjaxSuccess(req))
				{
					layer('unblock_confirmed');
					var blockDiv = document.getElementById("block_" + user);
					if (blockDiv == undefined) {
						blockDiv = document.getElementById("block_user");
					}
					var unBlockDiv = document.getElementById("unblock_" + user);
					if (unBlockDiv == undefined) {
						unBlockDiv = document.getElementById("unblock_user");
					}
					blockDiv.style.display = 'block';
					unBlockDiv.style.display = 'none';
				} else
				{
					netoalert("There was a problem unblocking " + user);
				}
			} else if (dynamicRequestReturnCode(req) == 'ERROR')  {
				netoalert("There was a problem unblocking " + user);
			}
		}
		DEPRECATEDdynamicRequest(unblockURL, callbackfunction);
	}
	
	function addContact(user) {
		var addContactURL = "xml.contacts.add.jspa?userId=" + attemptEncode(user);
		
		var errorCallback = function(request) {
			netoalert("There was a problem adding " + user);
		}
		
		var successCallback = function(request) {	
			layer('contacts');
			var addDiv = document.getElementById("add_contact");
			if (addDiv != undefined) {
				addDiv.style.display = "none";
			}
			var alreadyDiv = document.getElementById("already_contact");

			if (alreadyDiv != undefined) {
				alreadyDiv.style.display = "block";
			}
		}
		
		var query = 'userId=' + attemptEncode(user);
		var request = new Ajax.Request(
			'xml.contacts.add.jspa', 
			{
				method: 'get', 
				parameters: query, 
				onComplete: successCallback,
				onError: errorCallback
			});
	}

	function dumpStyleInfo(object_to_dump) {
		var message="";
		for(n in object_to_dump.style) { 
			message=message+n+" "+object_to_dump.style[n]+";";
		};
		alert(message);
	}

	function findPosition(obj) {
		var pos = {x:0, y:0};
		while (obj) {
				pos.x += obj.offsetLeft;
				pos.y += obj.offsetTop;
				obj = obj.offsetParent;
		}
		return pos;
	}
	
	//if one arg, it's an element to relocate the given element relative to
	//if two argumsnts, they are x, y co-ords
	function relocate(element, x, y) {
		if(x) {
			if(y) {
				//alert('location: ' + x + 'x' + y);
				//alert('element: ' + element.offsetWidth + 'x' + element.offsetHeight);
				element.style.left = x - (element.offsetWidth);
				element.style.top = y - element.offsetHeight;
			} else {
				var pos = findPosition(x);
				//pos.x -= element.offsetWidth/2;
				pos.y -= element.offsetHeight/2;
				element.style.left = pos.x + 'px';
				element.style.top = pos.y + 'px';
			}
			//dumpStyleInfo(element);
		}
	}
	
	function netoalert(message, x, y) {
		this.document.getElementById('netoalertText').innerHTML = message;
		this.document.getElementById('netoalert').style.display = 'block';
		relocate(this.document.getElementById('netoalert'), x, y);
	}

	function endNetoalert() {
		this.document.getElementById('netoalert').style.display = 'none';
	}
		
	function isArray(obj) {
 		if (obj.constructor.toString().indexOf("Array") == -1)
 			return false;
 		else
 			return true;
	}
	
	String.prototype.trim = function() {
		var x=this;
		x=x.replace(/^\s*(.*)/, "$1");
		x=x.replace(/(.*?)\s*$/, "$1");
		return x;
	}
	
        function isEmailValid(checkThisEmail, fieldName) {
            var myEMailIsValid = true;
            var myAtSymbolAt   = checkThisEmail.indexOf('@');
            var myLastDotAt    = checkThisEmail.lastIndexOf('.');
            var mySpaceAt      = checkThisEmail.indexOf(' ');
            var myLength       = checkThisEmail.length;


            // at least one @ must be present and not before position 2
            // @yellow.com : NOT valid
            // x@yellow.com : VALID

            if(myAtSymbolAt < 1) {
                myEMailIsValid = false;
            }


            // at least one . (dot) afer the @ is required
            // x@yellow : NOT valid
            // x.y@yellow : NOT valid
            // x@yellow.org : VALID

            if(myLastDotAt < myAtSymbolAt) {
                myEMailIsValid = false;
            }

            // at least two characters [com, uk, fr, ...] must occur after 
            // the last . (dot)
            // x.y@yellow. : NOT valid
            // x.y@yellow.a : NOT valid
            // x.y@yellow.ca : VALID

            if(myLength - myLastDotAt <= 2) {
                myEMailIsValid = false;
            }


            // no empty space " " is permitted (one may trim the email)
            // x.y@yell ow.com : NOT valid
            if(mySpaceAt != -1) {
                myEMailIsValid = false;
            }

            return myEMailIsValid;
        }
        
        function viewChannelUrl(owner, hub) {
        	return 'viewchannel.jspa?ownerId=' + attemptEncode(owner) + '&hub=' + attemptEncode(hub);
        }
        
        function viewChannel(owner, hub, pageSize, viewStart) {
         	var url = viewChannelUrl(owner, hub) + '&pageSize=' + pageSize;
        	if(viewStart != null && typeof viewStart != undefined) {
        		url = url + '&viewStart=' + viewStart;
        	}
        	location.href = url;
        }
        
        function previewChannel(owner, hub, pageSize, viewStart) {
         	var url = 'pre' + viewChannelUrl(owner, hub) + '&pageSize=' + pageSize;
        	if(viewStart != null && typeof viewStart != undefined) {
        		url = url + '&viewStart=' + viewStart;
        	}
        	location.href = url;
        }
        
        function viewEntryUrl(owner, hub, entry, viewOffset) {
        	var url = 'viewentry.jspa?owner=' + attemptEncode(owner) + '&hub=' + attemptEncode(hub);
        	if(entry != null && typeof entry != undefined) {
        		url = url + '&entry=' + entry;
        	}
        	if(viewOffset != null && typeof viewOffset != undefined) {
        		url = url + '&viewOffset=' + viewOffset;
        	}
        	return url;
        }
        
		function viewEntry(owner, hub, entry, viewOffset) {
			location.href = viewEntryUrl(owner, hub, entry, viewOffset);
		}
		
		function viewEntryComments(owner, hub, entry, viewOffset) {
			location.href = viewEntryUrl(owner, hub, entry, viewOffset) + '#comments';
		}
		
		function viewProfileUrl(loginId) {
			return 'viewprofile.jspa?user=' + attemptEncode(loginId);
		}
		
		function viewProfile(loginId) {
			location.href = viewProfileUrl(loginId);
		}
		
		function changeMood() {
			var mood = document.getElementById('moodEntry').value;
			
			document.getElementById('mood_text').innerHTML= mood;

			var query = 'mood=' + mood;
			var moodRequest = new Ajax.Request(
				'xml.changeMood.jspa', 
				{
					method: 'get', 
					parameters: query, 
					onError: moodError
				});
			
			if(mood.trim().length > 0) {			
				layer('mood_form');
			} else {
				layer('mood_unedit_blank');
			}
		}
		
		function moodError(moodRequest) {
			document.getElementById('moodDisplay').innerHTML= 'sorry!  An error occurred in your mood!';
		}
		
		function getParam( name ) {
		    var url = document.URL;
		    var markStart = url.indexOf( name );
		    if (markStart < 0) {
		    	return "";
		    } else {
				var markEnd = url.indexOf( ";", markStart ) - 1;
				if (markEnd < 0) {
				    markEnd = url.indexOf( "&", markStart ) - 1;
				    if (markEnd < 0) { 
						markEnd = url.length - 1;
				    }
				}
				return url.substring( markStart+name.length+1, markEnd+1 );
			}
		 }
		 
		function limitTextArea(field, counterfield, max_length) {
			if (field.value.length > max_length) {
				field.value = field.value.substring(0, max_length);
			} else {
				document.getElementById(counterfield).innerHTML = max_length - field.value.length;
			}
		}
		
		function wipeInitialText(field) {
			if (!field["clicked_on"]) {
				field.value = '';
				field["clicked_on"] = true;
			}
		}
	
		function refreshCaptcha(key) {
			var capSrc = "Captcha.jpg?rand=" + new Date().getTime();
			if (key) {
				capSrc += "&key=" + key;
			}
			document.getElementById(key).src = capSrc;
		}
		
		function toCamelCase(s){
		  for(	var exp=/-([a-z])/; exp.test(s); s=s.replace(exp,RegExp.$1.toUpperCase()));
		  return s;
		};
		
		// credit to http://www.ruzee.com/blog/2006/07/retrieving-css-styles-via-javascript/
		function getElementStyle(e,a){
		  var v=null;
		  if(document.defaultView && document.defaultView.getComputedStyle){
		    var cs=document.defaultView.getComputedStyle(e,null);
		    if(cs && cs.getPropertyValue) v=cs.getPropertyValue(a);
		  }
		  if(!v && e.currentStyle) v=e.currentStyle[toCamelCase(a)];
		  return v;
		};
		
		function toHexColor(decimalColor) {
			var re = /rgb\((\d+),\s?(\d+),\s?(\d+)\)/;
			var isMatch = decimalColor.match(re);
			if (!isMatch) {
				return decimalColor;
			} else {
				return "#" + parseInt(isMatch[1]).toString(16) + parseInt(isMatch[2]).toString(16) + parseInt(isMatch[3]).toString(16);
			}
		}