	/**
	 * 
	 * Javascript functions for the dom
	 * 
	 * @author Vincent Cantin Bellemare
	 * @since 2006-07-06
	 * @version 2.1.1
	 * @package reptileframework
	 * 
	 * 
	 */

	function $$(name)
	{
		return(document.getElementsByName(name));
	}
	
	function $$_iefix(tag, name)
	{
		var elem = document.getElementsByTagName(tag);
		var arr = new Array();
		
		for(i = 0,iarr = 0; i < elem.length; i++)
		{
			att = elem[i].getAttribute("name");
			
			if(att == name) 
			{
				arr[iarr] = elem[i];
				iarr++;
			}
		}
		
		return arr;
	}
	
	function $(id)
	{
		return(document.getElementById(id));
	}
	
	function hide(id)
	{
		if ((div = $(id)))
		{
			div.style.display = "none";
			div.style.visibility = "hidden";
		}
	}
	
	function show(id)
	{
		if ((div = $(id)))
		{
			div.style.display = "block";
			div.style.visibility = "visible";
		}
	}
	
	function update(id, content)
	{
		if ((div = $(id)))
		{
			div.innerHTML = content;
		}
	}
	
	function rename(id, newId)
	{
		if ((div = $(id)))
		{
			div.id = newId;
		}
	}
	
	function showHide(id)
	{
		if ((div = $(id)))
		{
			if (div.style.display == "block" || div.style.visibility == "visible")
			{
				hide(id);
				return(false);
			}
			else
			{
				show(id);
				return(true);
			}
		}
	}
	
	function iff(statement, trueValue, falseValue)
	{
		if (statement)
		{
			return(trueValue);
		}
		else
		{
			return(falseValue);
		}
	}
	
	function src(id, path)
	{
		if ((img = $(id)))
		{
			img.src = path;
		}
	}
	
	function center(id, width, height)
	{
		if ((div = $(id)))
		{
			div.style.width = width + "px";
			div.style.height = height + "px";
			div.style.top = posTop() + ((pageHeight() - height) / 2) + "px";
			div.style.left = ((pageWidth() - width) / 2) + "px";
			show(id);
		}
	}
	
	function newWindow(url, name, width, height, props)
	{
		var winl = (screen.width - w) / 2;
		var wint = (screen.height - h) / 2;
	
		winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+','+props
		win = window.open(mypage, myname, winprops)
	
		if (parseInt(navigator.appVersion) >= 4)
		{
			win.window.focus(); 
		}
		
		return(win);
	}
	
	function selectEmpty(field)
	{
		if (typeof(field) != "undefined" && typeof(field.length) != "undefined")
		{
			var length = field.length;
			
			for (i = 0; i < length; i++)
			{
				field.options[0] = null;
			}
		}
	}
	
	function selectAddOption(field, text, value, selected)
	{
		if (typeof(field) != "undefined" && typeof(field.options) != "undefined")
		{
			field.options.add(new Option(text, value));
			
			if (selected)
			{
				field.value = value;
			}
		}
	}
	
	function pageWidth() 
	{
		return window.innerWidth != null? window.innerWidth: document.documentElement && document.documentElement.clientWidth ? document.documentElement.clientWidth:document.body != null? document.body.clientWidth:null;
	}
	
	function pageHeight() 
	{
		return window.innerHeight != null? window.innerHeight: document.documentElement && document.documentElement.clientHeight ? document.documentElement.clientHeight:document.body != null? document.body.clientHeight:null;
	}
	
	function posLeft() 
	{
		return typeof window.pageXOffset != 'undefined' ? window.pageXOffset:document.documentElement && document.documentElement.scrollLeft? document.documentElement.scrollLeft:document.body.scrollLeft? document.body.scrollLeft:0;
	
	}
	
	function posTop() 
	{
		return typeof window.pageYOffset != 'undefined' ? window.pageYOffset:document.documentElement && document.documentElement.scrollTop? document.documentElement.scrollTop: document.body.scrollTop?document.body.scrollTop:0;
	}
	
	function posRight() 
	{
		return posLeft()+pageWidth();
	}
	
	function posBottom() 
	{
		return posTop()+pageHeight();
	}
