




	
	
// classic.

function $(obj) {
	
	return document.getElementById(obj);
	
}


	







/*
	functions dealing with object positionning
												*/


	function findPos(obj) {
		var curleft = curtop = 0;
		if (obj.offsetParent) {
			
			do {
				curleft += obj.offsetLeft;
				curtop += obj.offsetTop;
			} while (obj = obj.offsetParent);
			
			return [curleft,curtop];
		}
	}
	
	
	function getObjPos(obj) {
		
		this.inner = { //content and padding; gives 0 for inline elements (you can use scrollWidth/Height if it's inline)
			width: obj.clientWidth,
			height: obj.clientHeight
		};
		
		this.outer = { //everything (content, padding, scrollbar, border)
			width: obj.offsetWidth,
			height: obj.offsetHeight
		};
		
		this.scroll = {
			//width & height of entire content field (including padding), visible or not
			//incorrect in Opera; it doesn't include the padding
			width: obj.scrollWidth,
			//if there are no scrollbars, IE gives the actual height of the content instead of the height of the element
			height: obj.scrollHeight<obj.clientHeight ? obj.clientHeight : obj.scrollHeight,
			//scroll position of content & padding
			left: obj.scrollLeft,
			top: obj.scrollTop
		};
		
		//position of element from the top-left corner of the document
		var tmp = obj;
		this.left = this.top = 0;
		while(tmp.offsetParent) {
			this.left += tmp.offsetLeft;
			this.top += tmp.offsetTop;
			tmp = tmp.offsetParent;
		}
	}
	
	function getEventObj(e) {
		var targ;
		if (!e) var e = window.event;
		if (e.target) targ = e.target;
		else if (e.srcElement) targ = e.srcElement;
		if (targ.nodeType == 3) { targ = targ.parentNode; }
		return targ;
	}
	
	
	
	
	
	function isChildOf(ele, parent) {
		if (ele.parentNode === null) {
			return false;
		} else if (ele.parentNode === parent) {
			return true;
		} else {
			return isChildOf(ele.parentNode, parent);
		}
	}

	
	
	
	/*
	for(i in this.closers) {
		trigger[this.closers[i]] = function(e) {
			this.related = (!e) ? window.event.toElement : e.relatedTarget;
			if(!this.contains(this.related)) {
				if(!iskde) {
					trigger.link.className = trigger.link.className.replace(/[ ]?rollover/g, '');
				}
				if(trigger.menu != null) {
					trigger.menu.style[(trigger.ishoriz ? 'left' : 'top')] = trigger.ishoriz ? '-10000px' : '-100em';
				}
			}
		};
	}
	if(!isie){
		trigger.contains = function(node) {
			if (node == null) {
				return false;
			}
			if (node == this) {
				return true;
			} else {
				return this.contains(node.parentNode);
			}
		};
	}
	*/
	
	
	
	
	
	
	
	
	
	
	/* STRING FUNCTIONS */
	



	// function to retrieve arguments from a url
	//
	// This could be used in the case of a specific IMG tag's file to dynamically resize, when using thumb.php ?
	// (used in cunjunction with addImgResizeHook -> getURLVar(img.src, "file") ?
	
	function getURLVar(url, variable) {
	// fix this to check and return after '?'
	  if (url.indexOf("?") != -1) { url = url.substr(url.indexOf("?")+1); }
	  var query = url;
	  var vars = query.split("&");
	  for (var i=0;i<vars.length;i++) {
		var pair = vars[i].split("=");
		if (pair[0] == variable) {
		  return pair[1];
		}
	  }
	  return false;
	} 





	
		// text cleaning / encoding 
		function cleanText(str) {
			if (str) { 
				return str.replace(/\\/g, "");
			} else { return ""; }
		}
		
		// returns a string safe for code/forms use, provided it's to be enclosed in ""
		function codeSafe(str) {
			if (str) { 
				str = cleanText(str);
				return str.replace(/\"/g, "&quot;");
			} else { return ""; }
		}
		
		// returns a string safe for url use
		function urlSafe(str) {
			if (str) { 
				str = cleanText(str);
				return URIencode(str, "UTF8");
			} else { return ""; }
		}
		
		



 
function trim (str) {
	// is this a string ?
	if (typeof(str) == "string") {
		str = str.replace(/^\s+/, '');
		for (var i = str.length - 1; i >= 0; i--) {
			if (/\S/.test(str.charAt(i))) {
				str = str.substring(0, i + 1);
				break;
			}
		}
		return str;
	}
}

	
	
	
	
	
	
	
	// return current time in a string
	
	function timeStr() {
		var currentTime = new Date()
		var hours = currentTime.getHours()
		var minutes = currentTime.getMinutes()
		
		var seconds = currentTime.getSeconds()
		
		if (seconds < 10) { seconds = "0"+seconds; }
		
		if (minutes < 10){
		minutes = "0" + minutes
		}
		
		var str = "";
		
		str = hours + ":" + minutes + ":"+seconds;
		if(hours > 11){
		str +="PM"
		} else {
		str +="AM"
		}
		return str;
	}
	
