	var  fuggIt = {
		init: function(){
			fuggIt.wl = watchList;
			fuggIt.startListener();
		},
		pushItem: function(wl,od){
		
			if(typeof((wl.wId))=="object"){
					for(var n=0,l=wl.wId.length; n<l; n++){
						if(document.getElementById(wl.wId[n])){
							 od.push(wl.val);
							 return;	 
						}
					}
			} else {		
				if(document.getElementById(wl.wId)){
						 od.push(wl.val);
					 
				}
			}		
		
		},
		requestData: function(){
			var od = [];
			for(var i in this.wl){
	
					this.pushItem(this.wl[i],od);					
				
			}
			if(od.length>0){
				new Ajax.Request("/web/ping.php?wItems=" + od.join(','), {onComplete: function(parts){fuggIt.collectData(eval(parts.responseText))}});
				//var req = new Json.Remote("/iphone/ping.php?wItems=" + od.join(','), {onComplete: function(parts){fuggIt.collectData(parts)}}).send({});
				//sendRequest("wItems=" + ,);
				
			}
		},
		collectData: function(parts){
			for(var i=0,l=parts.length; i<l; i++){				
				if(parts[i].html)
					this.renderPart(parts[i]);
				if(parts[i].callback)
					eval(parts[i].callback);					
				
			}
		},
		renderPart: function(part){
			
			if(!part.pId || ! part.html) 
				return false;
			if(typeof(part.pId)=="object"){
				for(var i=0,l=part.pId.length; i<l; i++){
					if($(part.pId[i]) != undefined){
						if($(part.pId[i]).innerHTML != part.html)
							$(part.pId[i]).innerHTML = part.html;
					}
				}
			} else {			
				document.getElementById(part.pId).innerHTML = part.html;
			}
			 
		},
		startListener: function(){
			this.currentPage = document.location;
			if(this.checkData)  clearInterval(this.checkData);
			fuggIt.requestData();
			this.checkData = setInterval(fuggIt.startListener, 8000);
			
		},
		stopListener: function(){
			if(this.checkData)  clearInterval(this.checkData);
		},
		addToWatch: function(obj){
			watchList[obj.val] = obj;
		},
		removeFromWatch: function(){
		
		}
	};
	

var fugg_chat = {
	init: function(msgCont,userId){
		this.msgCont = $(msgCont);
		this.autoScroll = false;
		this.userId = userId;
		var self = this;
	//	Event.observe(this.msgCont,'mousedown',self.mouseDown,false);
	//	Event.observe(this.msgCont,'mouseup',self.mouseUp,false);
		fuggIt.addToWatch({val: 'ml-' + userId,wId: msgCont});

	
	},
	renderMessages: function(){
		if(this.autoScroll)
			this.msgCont.scrollTop = this.msgCont.scrollHeight;
	},
	sendMessage: function(){	
		new Ajax.Request("/message/actions/", {parameters: Form.serialize('send-message-form') + '&action=send_msg&uId=' + this.userId, method:'post', onComplete: function(r){$('messageInput').value =''; fuggIt.startListener();}});
	},
	mouseDown: function(){
		this.autoScroll = false;
	},
	mouseUp: function(){
		this.autoScroll = true;
	}
};

function toggleNav(ele){
	
	Effect.toggle(ele,'appear');
	
}

function getElementsByClassName(oElm, strTagName, strClassName){
	var arrElements = (strTagName == "*" && oElm.all)? oElm.all : oElm.getElementsByTagName(strTagName);
	var arrReturnElements = new Array();
	strClassName = strClassName.replace(/\-/g, "\\-");
	var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
	var oElement;
	for(var i=0; i<arrElements.length; i++){
		oElement = arrElements[i];
		if(oRegExp.test(oElement.className)){
		//	alert(oElement.tagName);
			arrReturnElements.push(oElement);
		}
	}
	//alert(arrReturnElements);
	return (arrReturnElements)
}


var miniGal = function(cont,type,keyId){
	this.contId = cont;
	
	this.cont = document.getElementById(cont);
	this.type = type;
	this.keyId = keyId;
}

miniGal.prototype.open = function(){
	this.cont.appear({ duration: 1.0 });
}

miniGal.prototype.close = function(){
	this.cont.fade({ duration: 1.0});
}

miniGal.prototype._getImages = function(){
	this.open();	
}

miniGal.prototype.getImages = function(){
	var self = this;
	new Ajax.Updater(self.cont, "/gallery/minigal/?key_id=" + self.keyId + "&mgt="+ self.type, {evalScripts: true, onComplete: function(r){self._getImages();}});

}