/*

Page Layout for div based Layout.  Redraws each sector of the page to fit with the content and the size of the window.

*/


var xIE4Up=false;
var xNN4=false;
var xOp5or6=false;
var xOp7=false;
var xVersion='3.14.1';

var xUA=navigator.userAgent.toLowerCase();

var xOriginalsSet = false;
var xcHeight = 0;
var xlHeight = 0;
var xrHeight = 0;

if( window.onload == null )
	window.onload = layout_onload;

function layout_onload()
{
	xcHeight = xHeight("content");  
	if( xGetElementById("sidebar-left") )
		xlHeight = xHeight("sidebar-left"); 
	if( xGetElementById("sidebar-right") )
		xrHeight = xHeight("sidebar-right");	

	xAddEventListener(window, "resize", adjustLayout, false);  
	xAddEventListener(xGetElementById("content"), "resize", adjustLayout, false);  
	adjustLayout();  
}

function xWidth(e)
{

	if( !xGetElementById(e) )
	{
		return 0;
	}
	else
	{
		return xGetElementById(e).offsetWidth;
	}

}

function adjustLayout()  
{  

var leftWidth = 0;
var rightWidth = 0;

	if( xGetElementById("sidebar-left") )	
		leftWidth = xWidth("sidebar-left");

	if( xGetElementById("sidebar-right") )	
		rightWidth = xWidth("sidebar-right");

	xGetElementById("content").style.width = xClientWidth() -leftWidth - rightWidth;

	if( xGetElementById("banner") )
		xGetElementById("banner").style.width = xWidth("content") + leftWidth + rightWidth;

	if( xGetElementById("footer") )
	{
		xGetElementById("footer").style.width = xWidth("banner")
	}

	var sHeight = xClientHeight() - (xHeight("footer") + xHeight("banner"))
	var cHeight = xHeight("content");  
	var lHeight = xHeight("sidebar-left");  
	var rHeight = xHeight("sidebar-right");  

	var maxHeight = 0;

	if( sHeight > Math.max(xcHeight, Math.max(xlHeight, xrHeight)) )
	{
		maxHeight = sHeight;
	}

	if( Math.max(cHeight, Math.max(lHeight, rHeight)) > maxHeight )
	{
		maxHeight = Math.max(cHeight, Math.max(lHeight, rHeight));
	}

	xHeight("content", maxHeight);  
	xHeight("sidebar-left", maxHeight);  
	xHeight("sidebar-right", maxHeight);  
 
	if( xGetElementById("footer") ) 
	{
		xGetElementById("footer").style.top = maxHeight + xGetElementById("banner").offsetHeight;
		xShow("footer");  
	}

 
}

function xAddEventListener(e,eventType,eventListener,useCapture) 
{

	if(!(e=xGetElementById(e)))
		return;
  
	eventType=eventType.toLowerCase();
	
	if((!xIE4Up && !xOp7) && e==window) 
	{
		if(eventType=='resize') 
		{ 
			window.xPCW=xClientWidth(); 
			window.xPCH=xClientHeight(); 
			window.xREL=eventListener; 
			xResizeEvent(); 
			return; 
		}
		
		if(eventType=='scroll') 
		{
			window.xPSL=xScrollLeft();
			window.xPST=xScrollTop();
			window.xSEL=eventListener;
			xScrollEvent(); 
			return; 
		}
		
	}
	var eh='e.on'+eventType+'=eventListener';
	
	if(e.addEventListener) 
		e.addEventListener(eventType,eventListener,useCapture);
	else 
	{
		if(e.attachEvent) 
			e.attachEvent('on'+eventType,eventListener);
		else
		{
			if(e.captureEvents) 
			{
				if(useCapture||(eventType.indexOf('mousemove')!=-1)) 
				{
					e.captureEvents(eval('Event.'+eventType.toUpperCase())); 
				}
				eval(eh);
			}
			else 
				eval(eh);
		}
	}
}

function xClientHeight() 
{

  var h=0;

	if(xOp5or6) 
		h=window.innerHeight;
	else 
	{
		if(!window.opera && document.documentElement && document.documentElement.clientHeight)
			h=document.documentElement.clientHeight;
		else
		{ 
			if(document.body && document.body.clientHeight)
				h=document.body.clientHeight;
			else
			{
				if(xDef(window.innerWidth,window.innerHeight,document.width)) 
				{
					h=window.innerHeight;
					if(document.width>window.innerWidth) 
						h-=16;
				}
			}
		}
	}
	
  return h;
  
}

function xClientWidth() 
{

  var w=0;

	if(xOp5or6) 
		w=window.innerWidth;
	else 
	{
		if(!window.opera && document.documentElement && document.documentElement.clientWidth)
			w=document.documentElement.clientWidth;
		else 
		{
			if(document.body && document.body.clientWidth)
				w=document.body.clientWidth;
			else 
			{
				if(xDef(window.innerWidth,window.innerHeight,document.height)) 
				{
					w=window.innerWidth;
					if(document.height>window.innerHeight) 
						w-=16;
				}
			}
		}
	}
	
	return w;
  
}

function xDef() 
{
	for(var i=0; i<arguments.length; ++i)
	{
		if(typeof(arguments[i])=='undefined') 
			return false;
	}
	
	return true;
	
}

function xGetElementById(e) 
{
	if(typeof(e)!='string') 
		return e;
		
	if(document.getElementById) 
		e=document.getElementById(e);
	else
	{ 
		if(document.all) 
			e=document.all[e];
		else 
		{
			if(document.layers) 
				e=xLayer(e);
			else 
				e=null;
		}
	}	
	return e;
}

function xHeight(e,uH) 
{

	if(!(e=xGetElementById(e))) 
		return 0;

	if (xNum(uH)) 
	{
		if (uH<0) 
			uH = 0;
		else 
			uH=Math.round(uH);
	}
	else 
		uH=0;

	var css=xDef(e.style);

	if(css && xDef(e.offsetHeight) && xStr(e.style.height)) 
	{
		if(uH) 
			xSetCH(e, uH);
			
		uH=e.offsetHeight;
	}
	else if(css && xDef(e.style.pixelHeight)) {
	
		if(uH) 
			e.style.pixelHeight=uH;
			
		uH=e.style.pixelHeight;
	}
	else 
	if(xDef(e.clip) && xDef(e.clip.bottom)) 
	{
    
		if(uH) 
			e.clip.bottom=uH;
		
		uH=e.clip.bottom;
		
	}
	return uH;
}

function xNum(n) {

	return typeof(n)=='number';
	
}

function xResizeEvent() { 
  
	if (window.xREL) 
		setTimeout('xResizeEvent()', 250);
	
	var cw = xClientWidth()
	var ch = xClientHeight();
	
	if (window.xPCW != cw || window.xPCH != ch) 
	{ 
		window.xPCW = cw; 
		window.xPCH = ch; 
		if (window.xREL) 
			window.xREL(); 
	}

}

function xSetCH(ele,uH){

	var pt=0,pb=0,bt=0,bb=0;
  
	if(xDef(document.defaultView) && xDef(document.defaultView.getComputedStyle))
	{
		pt=xGetCS(ele,'padding-top');
		pb=xGetCS(ele,'padding-bottom');
		bt=xGetCS(ele,'border-top-width');
		bb=xGetCS(ele,'border-bottom-width');
	}
	else if(xDef(ele.currentStyle,document.compatMode))
	{
		if(document.compatMode=='CSS1Compat')
		{
			pt=parseInt(ele.currentStyle.paddingTop);
			pb=parseInt(ele.currentStyle.paddingBottom);
			bt=parseInt(ele.currentStyle.borderTopWidth);
			bb=parseInt(ele.currentStyle.borderBottomWidth);
		}
	}
	else if(xDef(ele.offsetHeight,ele.style.height))
	{ 
		ele.style.height=uH+'px';
		pt=ele.offsetHeight-uH;
	}
	
	if(isNaN(pt)) 
		pt=0; 
		
	if(isNaN(pb)) 
		pb=0; 
		
	if(isNaN(bt)) 
		bt=0; 
		
	if(isNaN(bb)) 
		bb=0;
		
	var cssH=uH-(pt+pb+bt+bb);
  
	if(isNaN(cssH)||cssH<0) 
		return;
	else 
		ele.style.height=cssH+'px';
		
}

function xShow(e) 
{
	if(!(e=xGetElementById(e))) 
		return;
		
	if(e.style && xDef(e.style.visibility)) 
		e.style.visibility='visible';
	else
	{
		if(xDef(e.visibility)) 
			e.visibility='show';
	}
	
}

function xStr(s) 
{
  return typeof(s)=='string';
}

function ltrim(str)
{
   var whitespace = new String(" \t\n\r");

   var s = new String(str);

   if (whitespace.indexOf(s.charAt(0)) != -1) {

      var j=0, i = s.length;
      while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
         j++;

      s = s.substring(j, i);
   }
   return s;
}

function rtrim(str)
{
   var whitespace = new String(" \t\n\r");

   var s = new String(str);

   if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {
      var i = s.length - 1;    
      while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
         i--;
      s = s.substring(0, i+1);
   }

   return s;
}
function trim(str)
{
   return rtrim(ltrim(str));
}


 
var _browser = new Browser();
var _activeButton = null;

function Browser() {
	this.isIE = false;
	this.isNS = false;
	this.version = null;
	this.platform = navigator.platform.substr(0, 3);
	var browserName;
	browserName = "MSIE";
	var index = navigator.userAgent.indexOf(browserName);
	if (index >= 0) {
		this.isIE = true;
		this.version = parseFloat(navigator.userAgent.substr(index + browserName.length));
		return;
	}
	browserName = "Netscape6/";
	index = navigator.userAgent.indexOf(browserName)
	if (index >= 0) {
		this.isNS = true;
		this.version = parseFloat(navigator.userAgent.substr(index + browserName.length));
		return;
	}
	browserName = "Gecko";
	index = navigator.userAgent.indexOf(browserName)
	if (index >= 0) {
		this.isNS = true;
		this.version = 6.1;
		return;
	}
}
function buttonClick(event, menuId) {
	var button;
	if (_browser.isIE) {
		button = window.event.srcElement;
	} else {
		button = event.currentTarget;
	}
	button.blur();
	if (button.menu == null) {
		button.menu = document.getElementById(menuId);
		if (button.menu.isInitialized == null) {
			menuInit(button.menu);
		}
	}
	if (button.onmouseout == null) {
		button.onmouseout = menuMouseout;
	}
	if (button == _activeButton) {
		return false;
	}
	if (_activeButton != null) {
		resetButton(_activeButton);
	}
	if (button != _activeButton) {
		depressButton(button);
		_activeButton = button;
	} else {
		_activeButton = null;
	}
	return false;
}
function buttonMouseover(event, menuId) {
	if (_activeButton == null) {
		buttonClick(event, menuId);
		return;
	}
	var button = null;
	if (_browser.isIE) {
		button = window.event.srcElement;
	} else {
		button = event.currentTarget;
	}
	if (_activeButton != null && _activeButton != button) {
		buttonClick(event, menuId);
	}
}
function depressButton(button) {
	if (button.onmouseout == null) {
		button.onmouseout = menuMouseout;
	}
	if (button.menu.onmouseout == null) {
		button.menu.onmouseout = menuMouseout;
	}
	var x = getPageOffsetLeft(button);
	var y = getPageOffsetTop(button) + button.offsetHeight - 2;
	if (_browser.isIE) {
		x += button.offsetParent.clientLeft;
		y += button.offsetParent.clientTop;
	}
	button.menu.style.left = x + "px";
	button.menu.style.top  = y + "px";
	var buttonMenuAnchors = button.menu.getElementsByTagName("A");
	if (buttonMenuAnchors.length > 0) {
		button.menu.style.visibility = "visible";
		if (_browser.isIE) {
			hideElement(button.menu);
		}
	}
}
function resetButton(button) {
	if (button.menu != null) {
		closeSubMenu(button.menu);
		button.menu.style.visibility = "hidden";
		if (_browser.isIE) {
			showElement();
		}
	}
}
function menuMouseover(event) {
	var menu;
	if (_browser.isIE) {
		menu = getContainer(window.event.srcElement, "DIV", "menu");
	} else {
		menu = event.currentTarget;
	}
	if (menu.activeItem != null) {
		closeSubMenu(menu);
	}
}
function menuItemMouseover(event, menuId) {
	var item;
	if (_browser.isIE) {
		item = getContainer(window.event.srcElement, "A", "menuItem");
	} else {
		item = event.currentTarget;
	}
	var menu = getContainer(item, "DIV", "menu");
	if (menu.activeItem != null) {
		closeSubMenu(menu);
	}
	menu.activeItem = item;
	if (item.subMenu == null) {
		item.subMenu = document.getElementById(menuId);
		if (item.subMenu.isInitialized == null) {
			menuInit(item.subMenu);
		}
	}
	if (item.subMenu.onmouseout == null) {
		item.subMenu.onmouseout = menuMouseout;
	}
	var x = getPageOffsetLeft(item) + item.offsetWidth;
	var y = getPageOffsetTop(item);
	var maxX = 0;
	var maxY = 0;
	if (_browser.isNS) {
		maxX = window.scrollX + window.innerWidth;
		maxY = window.scrollY + window.innerHeight;
	}
	if (_browser.isIE) {
		if (_browser.platform != "Mac") {
			maxX = Math.max(document.documentElement.scrollLeft, document.body.scrollLeft) + (document.documentElement.clientWidth != 0 ? document.documentElement.clientWidth : document.body.clientWidth);
			maxY = Math.max(document.documentElement.scrollTop, document.body.scrollTop) + (document.documentElement.clientHeight != 0 ? document.documentElement.clientHeight : document.body.clientHeight);
		} else {
			maxX = document.body.scrollLeft + document.body.clientWidth;
			maxY = document.body.scrollTop + document.body.clientHeight;
		}
	}
	maxX -= item.subMenu.offsetWidth;
	maxY -= item.subMenu.offsetHeight;
	if (_browser.isIE && _browser.platform == "Mac") {
		x -= 11;
	}
	if (x > maxX) {
		x = Math.max(0, x - item.offsetWidth - item.subMenu.offsetWidth + (menu.offsetWidth - item.offsetWidth));
	}
	y = Math.max(0, Math.min(y, maxY));
	item.subMenu.style.left = x + "px";
	item.subMenu.style.top  = y + "px";
	item.subMenu.style.visibility = "visible";
	if (_browser.isIE) {
		hideElement(item.subMenu);
	}
	if (_browser.isIE) {
		window.event.cancelBubble = true;
	} else {
		event.stopPropagation();
	}
}
function closeSubMenu(menu) {
	if (menu == null || menu.activeItem == null) {
		return;
	}
	if (menu.activeItem.subMenu != null) {
		closeSubMenu(menu.activeItem.subMenu);
		menu.activeItem.subMenu.style.visibility = "hidden";
		menu.activeItem.subMenu = null;
	}
	menu.activeItem = null;
}
function menuMouseout(event) {
	var el;
	if (_activeButton == null) {
		return;
	}
	if (_browser.isIE) {
		el = window.event.toElement;
	} else if (event.relatedTarget != null) {
		el = (event.relatedTarget.tagName ? event.relatedTarget : event.relatedTarget.parentNode);
	}
	if (getContainer(el, "DIV", "menu") == null) {
		resetButton(_activeButton);
		_activeButton = null;
	}
}
function menuInit(menu) {
	var anchorList = menu.getElementsByTagName("A");
	if (anchorList.length <= 0) {
		return;
	}
	if (_browser.isIE) {
		if (_browser.platform != "Mac") {
			var menuWidth = anchorList[0].offsetWidth;
			anchorList[0].style.width = menuWidth + "px";
			var calculatedWidth = anchorList[0].offsetWidth - menuWidth;
			menuWidth -= calculatedWidth;
			anchorList[0].style.width = menuWidth + "px";
		} else {
			menu.style.width = "200px";
			menu.style.whiteSpace = "nowrap";
		}
	}
	if (_browser.isIE) {
		menu.style.lineHeight = "12px";
		var spanList = menu.getElementsByTagName("SPAN");
		for(var i = 0; i < spanList.length; i++) {
			if (hasClassName(spanList[i], "menuItemArrow")) {
				spanList[i].style.fontFamily = "Webdings";
				spanList[i].firstChild.nodeValue = "4";
			}
		}
	}
	menu.isInitialized = true;
}
function getContainer(node, tagName, className) {
	while(node != null) {
		if (node.tagName != null && node.tagName == tagName && hasClassName(node, className)) {
			return node;
		}
		node = node.parentNode;
	}
	return node;
}
function hasClassName(el, name) {
	var list;
	list = el.className.split(" ");
	for(var i = 0; i < list.length; i++) {
		if (list[i] == name) {
			return true;
		}
	}
	return false;
}
function getPageOffsetLeft(el) {
	var x = el.offsetLeft;
	if (el.offsetParent != null) {
		x += getPageOffsetLeft(el.offsetParent);
	}
	return x;
}
function getPageOffsetTop(el) {
	var y = el.offsetTop;
	if (el.offsetParent != null) {
		y += getPageOffsetTop(el.offsetParent);
	}
	return y;
}
function hideElement(button) {
	var element = "SELECT";
	var currentElement = null;
	for (i = 0; i < document.all.tags(element).length; i++) {
		currentElement = document.all.tags(element)[i];
		if (((elementTop(currentElement) > parseInt(button.style.top) + button.offsetHeight) || 
			(elementLeft(currentElement) > parseInt(button.style.left) + button.offsetWidth) ||
			(elementLeft(currentElement) + currentElement.offsetWidth < parseInt(button.style.left)) || 
			(elementTop(currentElement) + currentElement.offsetHeight < parseInt(button.style.top))) && _activeButton == null) {
			currentElement.style.visibility = "";
		} else {
			currentElement.style.visibility = "hidden";
		}
	}
}
function showElement() {
	var element = "SELECT";
	var currentElement = null;
	for (i = 0; i < document.all.tags(element).length; i++) {
		currentElement = document.all.tags(element)[i];
		currentElement.style.visibility = "";
	}
}
function elementTop(elementSource) {
	var top = 0;
	while (elementSource.tagName.toUpperCase() != "BODY") {
		top += elementSource.offsetTop;
		elementSource = elementSource.offsetParent;
	}
	return top;
}
function elementLeft(elementSource) {
	var left = 0;
	while (elementSource.tagName.toUpperCase() != "BODY") {
		left += elementSource.offsetLeft;
		elementSource = elementSource.offsetParent;
	}
	return left;
}var currentValue;
function ReOrderSectionRank(n, v, selectName) 
{
	var f = document.Form1;
	

	for (i = 0; i < f.length; i++) 
	{
		if (f.elements[i].type == "select-one" && f.elements[i].id.indexOf(selectName) > -1 && f.elements[i].id.indexOf("Rank") > -1 && f.elements[i].name != n && f.elements[i].value == v) 
		{
			f.elements[i].value = currentValue;
		}
	}
}

function ReOrderRank(n, v, selectName) 
{
	var f = document.Form1;
	

	for (i = 0; i < f.length; i++) 
	{
		if (f.elements[i].type == "select-one" && f.elements[i].id.indexOf(selectName) > -1 && f.elements[i].id.indexOf("Rank") > -1 && f.elements[i].name != n && f.elements[i].value == v) 
		{
			f.elements[i].value = currentValue;
		}
	}
}function CMXRequiredFieldValidatorEvaluateIsValid(source, arguments) 
{
	if( typeof( source.initialvalue ) == "undefined" )
		source.initialvalue = "";

	arguments.IsValid = (ValidatorTrim(ValidatorGetValue(source.clientsidecontroltovalidate)) != ValidatorTrim(source.initialvalue));

	var textFieldLabel = new cmxElement();
	textFieldLabel.setId( source.controltovalidatelabel );
    
    if( arguments.IsValid ) 
    {	
		if( textFieldLabel.element.className == "requiredlabel" )
		{
			textFieldLabel.element.className="";
		}
		else
		{
			if( textFieldLabel.element.className.indexOf(" requiredlabel") > 0 )
			{
				textFieldLabel.element.className = textFieldLabel.element.className.substring(0, textFieldLabel.element.className.indexOf(" requiredlabel"));
			}
		}
	}
	else
	{
		if( textFieldLabel.element.className == "" )
			textFieldLabel.element.className = "requiredlabel";
		else
			textFieldLabel.element.className = textFieldLabel.element.className + " requiredlabel";
	}
		
    return arguments.IsValid;
}

function cmxElement()
{
	//Private variables
	var _isInitialized = false;
	
	//Public properties
	this.backgroundColor = '';
	this.backgroundImage = '';
	this.bottom = '';
	this.clipBottom = '';
	this.clipHeight = '';
	this.clipLeft = '';
	this.clipRight = '';
	this.clipTop = '';
	this.clipValues = '';
	this.clipWidth = '';
	this.element = null;
	this.height = '';
	this.id = '';
	this.left = '';
	this.right = '';
	this.style = null;
	this.top = '';
	this.visibility = '';
	this.width = '';
	this.zIndex = '';

	//Private methods
	function _backgroundColor(el)
	{
		if (cmxbrowser.supportsLayers)
			return el.bgColor;
			
		if (cmxbrowser.ie || cmxbrowser.supportsDOM)
			return el.style.backgroundColor;
	}

	function _backgroundImage(el)
	{
		if (cmxbrowser.supportsLayers)
			return el.background.src;
			
		if (cmxbrowser.ie || cmxbrowser.supportsDOM)
			return el.style.backgroundImage;
	}

	function _bottom(el)
	{
		if (cmxbrowser.supportsLayers)
			return el.top + el.height;
		else if (cmxbrowser.ie || cmxbrowser.supportsDOM)
			return parseInt(el.style.top) + parseInt(el.height);
			
		return -1;
	}

	function _clipBottom(el)
	{
		if (cmxbrowser.supportsLayers)
			return !isNaN(el.clip.bottom) ? el.clip.bottom : "auto";
			
		if (cmxbrowser.ie || cmxbrowser.supportsDOM)
		{
			var str =  el.style.clip;

			if (!str)
				return !isNaN(el.style.height) ? el.style.height : "auto";
				
			var clip = _clipValues(el.style.clip);
			
			return !isNaN(clip[2]) ? clip[2] : "auto";
		}
		
		return -1;
	}

	function _clipHeight(el)
	{
		if (cmxbrowser.supportsLayers)
			return !isNaN(el.clip.height) ? el.clip.height : "auto";
			
		if (cmxbrowser.ie || cmxbrowser.supportsDOM)
		{
			var str =  el.style.clip;
			
			if (!str)
				return !isNaN(el.style.height) ? el.style.height : "auto";
				
			var clip = _clipValues(el.style.clip);
			
			return !isNaN(clip[2] - clip[0]) ? clip[2] - clip[0] : "auto";
		}
		
		return -1;
	}
	
	function _clipLeft(el)
	{
		if (cmxbrowser.supportsLayers)
			return !isNaN(el.clip.left) ? el.clip.left : "auto";
			
		if (cmxbrowser.ie || cmxbrowser.supportsDOM)
		{
			var str =  el.style.clip;
			
			if (!str)
				return 0;
				
			var clip = _clipValues(el.style.clip);
			
			return !isNaN(clip[3]) ? clip[3] : "auto";
		}
		
		return -1;
	}

	function _clipRight(el)
	{
		if (cmxbrowser.supportsLayers)
			return !isNaN(el.clip.right) ? el.clip.right : "auto";
			
		if (cmxbrowser.ie || cmxbrowser.supportsDOM)
		{
			var str =  el.style.clip;
			
			if (!str)
				return !isNaN(el.style.width) ? el.style.width : "auto";
				
			var clip = _clipValues(el.style.clip);
			
			return !isNaN(clip[1]) ? clip[1] : "auto";
		}
		
		return -1;
	}

	function _clipTop(el)
	{
		if (cmxbrowser.supportsLayers)
			return !isNaN(el.clip.top) ? el.clip.top : "auto";
			
		if (cmxbrowser.ie || cmxbrowser.supportsDOM)
		{
			var str = el.style.clip;
			
			if (!str)
				return 0;
				
			var clip = _clipValues(el.style.clip);
			
			return !isNaN(clip[0]) ? clip[0] : "auto";
		}
		
		return -1;
	}

	function _clipValues(el)
	{
		var clip = new Array();
		var str = el.style.clip;
		var i;

		i = str.indexOf("(");
		clip[0] = parseInt(str.substring(i + 1, str.length), 10);
		
		i = str.indexOf(" ", i + 1);
		clip[1] = parseInt(str.substring(i + 1, str.length), 10);
		
		i = str.indexOf(" ", i + 1);
		clip[2] = parseInt(str.substring(i + 1, str.length), 10);
		
		i = str.indexOf(" ", i + 1);
		clip[3] = parseInt(str.substring(i + 1, str.length), 10);

		return clip;
	}

	function _clipWidth(el)
	{
		if (cmxbrowser.supportsLayers)
			return !isNaN(el.clip.width) ? el.clip.width : "auto";
			
		if (cmxbrowser.ie || cmxbrowser.supportsDOM)
		{
			var str = el.style.clip;
			
			if (!str)
				return !isNaN(el.style.width) ? el.style.width : "auto";
				
			var clip = _clipValues(el.style.clip);
			
			return !isNaN(clip[1] - clip[3]) ? clip[1] - clip[3] : "auto";
		}
		
		return -1;
	}

	function _height(el)
	{
		if (cmxbrowser.supportsLayers)
		{
			if (this.element.document.height)
				return el.document.height;
			else
				return el.clip.bottom - el.clip.top;
		}
		
		if (cmxbrowser.ie || cmxbrowser.supportsDOM)
			return parseInt(el.offsetHeight);
		
		return -1;
	}

	function _left(el)
	{
		if (cmxbrowser.supportsLayers)
			return el.left;
			
		if (cmxbrowser.ie || cmxbrowser.supportsDOM)
			return parseInt(el.style.left);
			
		return -1;
	}

	function _right(el)
	{
		if (cmxbrowser.supportsLayers)
			return el.left + el.width;
			
		if (cmxbrowser.ie || cmxbrowser.supportsDOM)
			return parseInt(el.style.left) + parseInt(el.width);
			
		return -1;
	}

	function _top(el)
	{
		if (cmxbrowser.supportsLayers)
			return el.top;
			
		if (cmxbrowser.ie || cmxbrowser.supportsDOM)
			return parseInt(el.style.top);
			
		return -1;
	}

	function _visibility(el)
	{
		var returnValue = '';
		
		if (cmxbrowser.supportsLayers)
		{
			if (el.visibility == "show")
				returnValue = "visible";

			if (el.visibility == "hide")
				returnValue = "hidden";

			returnValue = el.visibility == '' ? "visible" : el.visibility
		}
		
		if (cmxbrowser.ie || cmxbrowser.supportsDOM)
			returnValue = el.style.visibility == '' ? "visible" : el.style.visibility;
			
		return returnValue;
	}

	function _width(el)
	{
		if (cmxbrowser.supportsLayers)
		{
			if (el.document.width)
				return el.document.width;
			else
				return el.clip.right - el.clip.left;
		}
		
		if (cmxbrowser.ie || cmxbrowser.supportsDOM)
			return parseInt(el.offsetWidth);
		
		return -1;
	}

	function _zIndex(el)
	{
		if (cmxbrowser.supportsLayers)
			return el.zIndex;
			
		if (cmxbrowser.ie || cmxbrowser.supportsDOM)
			return el.style.zIndex;

		return -1;
	}

	//Initialization
	this.initialize = function()
		{
			if (!_isInitialized)
			{
				if (this.element == null)
				{
					if (this.id != '')
					{
						if (cmxbrowser.supportsDOM)
							this.element = document.getElementById(this.id);
						else if (cmxbrowser.supportsLayers)
							this.element = this.findLayer(this.id, document);
						else if (cmxbrowser.ie)
							this.element = eval('document.all.' + this.id);
						
						_isInitialized = true;
					}
				}
				else
				{
					this.id = this.element.id != '' ? this.element.id : '';
					_isInitialized = true;
				}
			}
			
			if (this.element != null)
			{
				if (cmxbrowser.supportsDOM)
					this.style = this.element.style;
				else if (cmxbrowser.supportsLayers)
					this.style = this.element;
				else if (cmxbrowser.ie)
					this.style = this.element.style;

				if (this.height == '')
					this.height = _height(this.element);

				if (this.width == '')
					this.width = _width(this.element);
				
				if (this.visibility == '')
					this.visibility = _visibility(this.element);
					
				if (this.left == '')
					this.left = _left(this.element);
					
				if (this.top == '')
					this.top = _top(this.element);
					
				if (this.right == '')
					this.right = _right(this.element);
					
				if (this.bottom == '')
					this.bottom = _bottom(this.element);
				
				if (this.zIndex == '')
					this.zIndex = _zIndex(this.element);
					
				if (this.clipLeft == '')
					this.clipLeft = _clipLeft(this.element);
				
				if (this.clipTop == '')
					this.clipTop = _clipTop(this.element);
				
				if (this.clipRight == '')
					this.clipRight = _clipRight(this.element);
				
				if (this.clipBottom == '')
					this.clipBottom = _clipBottom(this.element);
				
				if (this.clipWidth == '')
					this.clipWidth = _clipWidth(this.element);
				
				if (this.clipHeight == '')
					this.clipHeight = _clipHeight(this.element);
				
				if (this.clipValues == '')
					this.clipValues = _clipValues(this.element);
				
				if (this.backgroundColor == '')
					this.backgroundColor = _backgroundColor(this.element);
				
				if (this.backgroundImage == '')
					this.backgroundImage = _backgroundImage(this.element);
			}
		};
	
	//Public methods
	this.absoluteLeft = function(el)
	{
		this.initialize();

		if (el.offsetParent == null) 
			return el.offsetLeft;
		else 
			return el.offsetLeft + this.absoluteLeft(el.offsetParent);
	};

	this.absoluteTop = function(el)
	{
		this.initialize();

		if (el.offsetParent == null)
			return el.offsetTop;
		else 
			return el.offsetTop + this.absoluteTop(el.offsetParent);
	};

	this.clip = function(top, right, bottom, left)
	{
		this.initialize();

		if (cmxbrowser.supportsLayers)
		{
			this.element.clip.top = top;
			this.element.clip.right = right;
			this.element.clip.bottom = bottom;
			this.element.clip.left = left;
		}
		
		if (cmxbrowser.ie || cmxbrowser.supportsDOM)
			this.style.clip = "rect(" + top + " " +  right + " " + bottom + " " + left +")";
	};

	this.findLayer = function(name, doc)
	{
		var layer;

		for (var i = 0; i < doc.layers.length; i++)
		{
			layer = doc.layers[i];
			
			if (layer.name == name)
				return layer;
				
			if (layer.document.layers.length > 0)
			{
				layer = this.findLayer(name, layer.document);

				if (layer != null)
					return layer;
			}
		}
		
		return null;
	};

	this.getElementById = function(id)
	{
		this.id = id;
		this.initialize();
		
		return this.element;
	};

	this.hide = function()
	{
		this.initialize();

		if (cmxbrowser.supportsLayers)
			this.element.visibility = "hide";
			
		if (cmxbrowser.ie || cmxbrowser.supportsDOM)
			this.style.visibility = "hidden";
	};

	this.inherit = function() 
	{
		this.initialize();

		if (cmxbrowser.supportsLayers)
			this.element.visibility = "inherit";
			
		if (cmxbrowser.ie || cmxbrowser.supportsDOM)
			this.style.visibility = "inherit";
	};

	this.isVisible = function()
	{
		this.initialize();

		if (cmxbrowser.supportsLayers && this.element.visibility == "show")
			return true;
		
		if (cmxbrowser.ie || cmxbrowser.supportsDOM && this.style.visibility == "visible")
			return true;

		return false;
	};

	this.moveBy = function(x, y)
	{
		this.initialize();

		if (cmxbrowser.supportsLayers)
			this.element.moveBy(x, y);
			
		if (cmxbrowser.ie || cmxbrowser.supportsDOM)
		{
			this.style.left = parseInt(this.style.left) + x;
			this.style.top = parseInt(this.style.top) + y;
		}
	};

	this.moveTo = function(x, y)
	{
		this.initialize();

		if (cmxbrowser.supportsLayers)
			this.element.moveTo(x, y);
			
		if (cmxbrowser.ie || cmxbrowser.supportsDOM)
		{
			this.style.left = x;
			this.style.top = y;
		}
	};

	this.pageLeft = function()
	{
		this.initialize();

		if (cmxbrowser.supportsLayers)
			return this.element.pageX;
			
		if (cmxbrowser.ie || cmxbrowser.supportsDOM)
			return this.element.offsetLeft;
			
		return -1;
	};

	this.pageTop = function()
	{
		this.initialize();

		if (cmxbrowser.supportsLayers)
			return this.element.pageY;
			
		if (cmxbrowser.ie || cmxbrowser.supportsDOM)
			return this.element.offsetTop;
			
		return -1;
	};

	this.setElement = function(el)
	{
		this.element = el;
		this.initialize();
	};

	this.setId = function(id)
	{
		this.id = id;
		this.initialize();
	};
	
	this.show = function()
	{
		this.initialize();

		if (cmxbrowser.supportsLayers)
			this.element.visibility = "show";
			
		if (cmxbrowser.ie || cmxbrowser.supportsDOM)
			this.style.visibility = "visible";
	};

	this.scrollTo = function(x, y, bound)
	{
		this.initialize();

		var dx = this.clipLeft() - x;
		var dy = this.clipTop() - y;

		this.scrollBy(-dx, -dy, bound);
	};

	this.scrollBy = function(x, y, bound)
	{
		this.initialize();

		var cl = this.clipLeft();
		var ct = this.clipTop();
		var cr = this.clipRight();
		var cb = this.clipBottom();

		if (bound)
		{
			if (cl + x < 0)
				x = -cl;
			else if (cr + x > this.width)
				x = this.width - cr;
				
			if (ct + y < 0)
				y = -ct;
			else if (cb + y > this.height)
				y = this.height - cb;
		}

		this.clip(cl + x, ct + y, cr + x, cb + y);
		this.moveBy(-x, -y);
	};

	this.swapStyle = function(className, useAlternateClassName)
	{
		this.initialize();

		if (useAlternateClassName)
		{
			this.element.setAttribute('temporaryClassName', this.element.className);
			this.element.className = className;
		}
		else
			this.element.className = this.element.getAttribute('temporaryClassName');
	};
}var cmxbrowser = new cmxBrowser();

function cmxBrowser()
{
	//Private variables
	var _userAgent = navigator.userAgent.toLowerCase();

	//Public properties
	this.flash = new _Flash();
	this.ie = (_userAgent.indexOf("msie") != -1);	
	this.ie5 = (this.ie && (this.major == 4) && (_userAgent.indexOf("msie 5.0") != -1));
	this.ie5mac = (this.mac && (_userAgent.indexOf("msie") != -1) && (this.major > 3));
	this.ie6 = (this.ie && (this.major == 4) && (_userAgent.indexOf("msie 6.0") != -1));
	this.mac = (_userAgent.indexOf("mac") != -1);
	this.major = parseInt(navigator.appVersion);
	this.minor = parseFloat(navigator.appVersion);
	this.nav = ((_userAgent.indexOf('mozilla') != -1) 
		&& (_userAgent.indexOf('spoofer') == -1) 
		&& (_userAgent.indexOf('compatible') == -1) 
		&& (_userAgent.indexOf('opera') == -1) 
		&& (_userAgent.indexOf('webtv') == -1) 
		|| (_userAgent.indexOf('netscape') != -1));
	this.nav4 = (this.nav && (this.major == 4));
	this.nav4up = (this.nav && (this.major >= 4));
	this.nav6 = (this.nav && (this.major == 5));
	this.opera = (_userAgent.indexOf("opera") != -1);
	this.supportsDOM = (document.all || document.getElementById);
	this.supportsLayers = (document.layers);
	this.webtv = (_userAgent.indexOf("webtv") != -1);

	//Private functions
	function _Flash()
	{
		var _hasPlugin = false;

		this.installed = false;
		this.version = 0;
	
		try 
		{
			if (navigator.plugins && navigator.plugins.length) 
			{
				_hasPlugin = navigator.plugins["Shockwave Flash"];
				
				if (_hasPlugin) 
				{
					this.installed = true;
					
					if (_hasPlugin.description) 
					{
						var pluginDescription = _hasPlugin.description;
						this.version = pluginDescription.charAt(pluginDescription.indexOf('.') -1);
					}
				}
				else
					this.installed = false;
					
				if (navigator.plugins["Shockwave Flash 2.0"]) 
				{
					this.installed = true;
					this.version = 2;
				}
			}
			else if (navigator.mimeTypes && navigator.mimeTypes.length) 
			{
				_hasPlugin = navigator.mimeTypes['application/x-shockwave-flash'];
				
				if (_hasPlugin && _hasPlugin.enabledPlugin)
					this.installed = true;
				else
					this.installed = false;
			}
			else
			{
				for (var i = 0; i <= 7; i++) 
				{
					try 
					{
						var flash = new ActiveXObject("ShockwaveFlash.ShockwaveFlash." + i);
						this.version = i;															
					}
					catch(e) {}
				}
				
				if (this.version != 0)
					this.installed = true;
				else
					this.installed = false;
			}
		}
		catch(e) {}
	}
}
