function scroll_top_old()
{
	if (self.pageYOffset) // all except Explorer
	{
		return self.pageYOffset;
	}
	else if (document.documentElement && document.documentElement.scrollTop)
		// Explorer 6 Strict
	{
		return  document.documentElement.scrollTop;
	}
	else if (document.body) // all other Explorers
	{
		return  document.body.scrollTop;
	}
}
function scroll_left_old()
{
	if (self.pageYOffset) // all except Explorer
	{
		return self.pageXOffset;
	}
	else if (document.documentElement && document.documentElement.scrollTop)
		// Explorer 6 Strict
	{
		return document.documentElement.scrollLeft;
	}
	else if (document.body) // all other Explorers
	{
		return document.body.scrollLeft;
	}
}
function window_height_old()
{
	var test1 = document.body.scrollHeight;
	var test2 = document.body.offsetHeight
	if (test1 > test2) // all but Explorer Mac
	{
		return document.body.scrollHeight;
	}
	else 
	{
	// Explorer Mac;
    //would also work in Explorer 6 Strict, Mozilla and Safari
		return document.body.offsetHeight;
	}
	
}
function window_width_old()
{
	var test1 = document.body.scrollHeight;
	var test2 = document.body.offsetHeight;
	if (test1 > test2) // all but Explorer Mac
	{
		return document.body.scrollWidth;
	}
	else // Explorer Mac;
		//would also work in Explorer 6 Strict, Mozilla and Safari
	{
		return document.body.offsetWidth;
	}
}

function window_height()
{
	if( typeof( window.innerWidth ) == 'number' )
	{
		//Non-IE
		return window.innerHeight;
	}
	else if (document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) )
	{
		//IE 6+ in 'standards compliant mode'
		return document.documentElement.clientHeight;
	}
	else if(document.body && ( document.body.clientWidth || document.body.clientHeight ) )
	{
		//IE 4 compatible
		return document.body.clientHeight;
	}
}

function window_width()
{
	if( typeof( window.innerWidth ) == 'number' )
	{
		//Non-IE
		return window.innerWidth;
	}
	else if (document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) )
	{
		//IE 6+ in 'standards compliant mode'
		return document.documentElement.clientWidth;
	}
	else if(document.body && ( document.body.clientWidth || document.body.clientHeight ) )
	{
		//IE 4 compatible
		return document.body.clientWidth;
	}
}

// cross browser total height of an element
function inner_size(el,dir)
{
	var size;
	if (dir == 'height')
		size = number_from_px(get_style(el,'height'));
	else
	{
		size = number_from_px(get_style(el,'width'));
//	el.style.scrollTop
	}
	if (size > 0)
	{
		if (isIE)
			size = size - measurement(el,dir,'border');
		size = size - measurement(el,dir,'padding');
	}
	
	return size;
}
// cross browser total height of an element
function size_from(parent,child,dir)
{
	if (child == null)
		return 0;
	else if (child == parent || !isIE && child.parentNode == parent)
		return 0;
	else
		return child["offset" + dir] + size_from(parent,child.offsetParent,dir);
}
function outer_size(el,dir)
{
	var height;
	if (dir == 'height')
		size = el.offsetHeight;
	else
		size = el.offsetWidth;
	
	size = size + measurement(el,dir,'margin');
	return size;
}

function set_size(el,dir,size)
{
	if (size <= 0) 	return;

	if (!isIE) 
	{
		size = size - measurement(el,dir,'border');
		size = size - measurement(el,dir,'padding');
	}
	size = size - measurement(el,dir,'margin');

	var current;
	if (dir == 'height')
		current = number_from_px(el.style.height);
	else
		current = number_from_px(el.style.width);
	if (current != size)
	{
		if (size < 0) size = 0;
		if (dir == 'height')
			el.style.height = size;
		else
			el.style.width = size;
		return true;
	}
	return false;
}
function measurement(el,dir,type)
{
	var start,end;
	if (dir == 'height')
	{
		start = 'top';
		end = 'bottom';
	}
	else
	{
		start = 'left';
		end = 'right';
	}
	switch (type)
	{
		case 'border':
			start = 'border-' + start + '-width';
			end = 'border-' + end + '-width';
			break;
		case 'padding':
			start = 'padding-' + start;
			end = 'padding-' + end;
			break;
		case 'margin':
			start = 'margin-' + start;
			end = 'margin-' + end;
			break;
	}
	return number_from_px(get_style(el,start)) + number_from_px(get_style(el,end));
}
// get number from style
function number_from_px(a)
{
	if (right(a,2) == 'px')
		a = a.removeEnd(2);
	else if (a == 'auto')
		a = '0';	
	return Number(a); 
}
function right(str, n)
{
    if (n <= 0)
       return '';
    else if (n > str.length)
       return str;
    else 
    {
       var iLen = str.length;
       return str.substring(iLen, iLen - n);
    }
}
function get_style(el, cssproperty)
{
	if (el.currentStyle)
		return el.currentStyle[convert_style_name(cssproperty)];
	else if (window.getComputedStyle)
	{
		var elstyle=window.getComputedStyle(el, "");
		return elstyle.getPropertyValue(cssproperty);
	}
	return '';
}
function convert_style_name(name)
{
	var new_name = new String();
	for (var i=0;i < name.length; i++)
	{
		if (name.charAt(i) == '-')
			new_name = new_name + name.charAt(++i).toUpperCase();
		else
			new_name = new_name + name.charAt(i);
	}
	return new_name;
}
function NumberAsText(num,size)
{
	var strNum = new String(num);
	if (strNum.length < size)
	{
		for (var i = 0;i < size - strNum.length; i++)
		{
			strNum = '0' + strNum;
		}
	}
	return strNum;
}
