function elementHasClass(element, className)
{
	return element.className && element.className.match( new RegExp( "\\b"+className+"\\b" ) )	;
}

function getElementsByClassName(className, parentElement)
{
	var elements = new Array ();
	var parent = ( typeof parentElement == 'object' ) ? parentElement : window.document;

	if(!parent)
	{
	return elements;
	}

	var children = parent.getElementsByTagName( "*" );

	for ( var i = 0; i < children.length; i++ )
	{
		if ( elementHasClass(children[i], className) )
		{
			elements[elements.length] = children[i];
		}
	}
	return elements;
}

function findPos(obj) 
{
	var curleft = curtop = 0;
	if (obj.offsetParent) {
					curleft = obj.offsetLeft
					curtop = obj.offsetTop
					while (obj = obj.offsetParent) {
						curleft += obj.offsetLeft
						curtop += obj.offsetTop
					}
				}
				return [curleft,curtop];
}

function addEvent(obj, evType, fn)
{ 
				if(typeof fn == "undefined")
				{
					return false;
				}
			 if (obj.addEventListener){ 
			   obj.addEventListener(evType, fn, true); 
			   return true; 
			 } else if (obj.attachEvent){ 
			   var r = obj.attachEvent("on"+evType, fn, true); 
			   return r; 
			 } else { 
			   return false; 
			 } 
}

//
// getPageSize()
// Returns array with page width, height and window width, height
// Core code from - quirksmode.org
// Edit for Firefox by pHaez
// grabbed from http://www.huddletogether.com/projects/lightbox/lightbox.js
//
function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}


	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}
//
// getPageScroll()
// Returns array with x,y page scroll values.
// Core code from - quirksmode.org
// grabbed from http://www.huddletogether.com/projects/lightbox/lightbox.js
//
function getPageScroll(){

	var yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
	}

	arrayPageScroll = new Array('',yScroll) 
	return arrayPageScroll;
}


function getStyle(el,styleProp)
{
	if(typeof el != "object" )
	{
		if(document.getElementById(el))
		{
			var obj = document.getElementById(el);
		}
		else
		{
			return false;
		}
	}
	else
	{
		var obj = el;
	}
	
	var ret = false;

	
	// Handle "float" property as a special case
	if (styleProp=="float") 
	{
		ret = getStyle(obj,"cssFloat");
		if (ret==null) 
		{
			ret = getStyle(obj,"styleFloat");
		}
		
		return ret;
	}
	
	
	if(obj.style && obj.style[toCamelCase(styleProp)])
	{
		ret = obj.style[toCamelCase(styleProp)];
	}
	else if (obj.currentStyle && obj.currentStyle[toCamelCase(styleProp)])
		ret = obj.currentStyle[toCamelCase(styleProp)];
	else if (window.getComputedStyle)
		ret = document.defaultView.getComputedStyle(obj,null).getPropertyValue(styleProp);
		
	return ret;
}

/** toCamelCase(input)
 * Converts string input to a camel cased version of itself.
 * For example:
 * toCamelCase("z-index"); // returns zIndex
 * toCamelCase("border-bottom-style"); // returns borderBottomStyle.
 */
function toCamelCase(s) {
	for(var exp = toCamelCase.exp; 
		exp.test(s); s = s.replace(exp, RegExp.$1.toUpperCase()) );
	return s;
}
toCamelCase.exp = /-([a-z])/;






window.onload_actions = new Array();

function add_onload_action(evalstring)
{
	window.onload_actions.push(evalstring);
}

function onload_action()
{
	for(i=0; i<window.onload_actions.length; i++)
	{
		try
		{
			eval(window.onload_actions[i]);
		}
		catch(e)
		{
			alert('onload action "'+window.onload_actions[i]+'" failed:'+e);			
		}
	}
}


addEvent(window, "load", onload_action);