//<script language="JavaScript" type="text/javascript">
var menu_t, Menu_Showing, Drop_Menu;
String.prototype.Replace = function (o, n) {
	return this.split(o).join(n);
};

function getElmPos(elm) {
	var t = elm.offsetTop;
	var l = elm.offsetLeft;
	while ((elm = elm.offsetParent) != null) {
		t += elm.offsetTop;
		l += elm.offsetLeft;
	};
	return [l, t];
};

function getElmHeight(elm) {
	return elm.offsetHeight;
};

function getElmWidth(elm)
{
	if (elm.clientWidth == 0)
		return elm.offsetWidth;
	return elm.clientWidth;
};

function get_menu_object(o) {
	while (o && o.parentNode && o.nodeName != "BODY") {
		if (o.Menu || (o.obj && (o.obj.Name || '') == 'Co_DropMenu')) return o;
		o = o.parentNode;
	}
	return null;
}
/*
if (typeof(window.onbeforeunload) == 'function') window.__onbeforeunload = window.onbeforeunload;
window.onbeforeunload = function () {

	if (typeof(window.__onbeforeunload) == 'function') window.__onbeforeunload();
	if (typeof(Co_Menu) == 'object') return;
	Co_Menu.Close();
	Co_Menu = null;
}
*/
var DropMenu = function (o) {
	this.Name = "Co_DropMenu";
	this.TextAlign = "Left";
	this.Dir = "ltr";
	this.__Initialized = false;
	this.Use_Iframe = ((navigator.userAgent.toLowerCase().indexOf('msie') != -1));
	this.obj = o;
	this.current = null;
	this.previous = null;
	this.link_url = '';
	this.menu_hover_class = '';
	this.do_not_select_parent = false;
	this.position = 'bottom';
	this.parent = null;
	this.wrapper_top = '';
	this.wrapper_bottom = '';
	this.divider = '';
	this.content = '';
	this.show_name = false;
	this.Menus = [];
	if (!this.Use_Iframe) this.Init();
	else Co_Tools.AddEventListener(window, "load", this.Init, null, this);
};
DropMenu.prototype.Init = function () {
	this.InitBehaviors();
	this.__Initialized = true;
	this.GetMenu();
};
DropMenu.prototype.Add = function (o) {
	this.Menus[this.Menus.length] = o;
};
DropMenu.prototype.GetMenu = function () {
	if (this.obj) return this.obj;
	
	var topWindow = window.parent ;
	/* custom code - added by mls */
	var lastTopWindow = topWindow ;
	/* end custom code */
	while ( topWindow.parent && topWindow.parent != topWindow )
	{
		try
		{
			if ( topWindow.parent.document.domain != document.domain )
				break ;
			/* custom code - modified by mls
				original: if ( topWindow.parent.document.getElementsByTagName( 'frameset' ).length > 0 )
					break;
			 */
			if ( topWindow.parent.document.getElementsByTagName( 'frameset' ).length > 0 )
			{
				topWindow = topWindow.parent;
				continue;
			}
			/* end custom code */
		}
		catch ( e )
		{
			break ;
		}
		topWindow = topWindow.parent ;
		/* custom code - added by mls */
		lastTopWindow = topWindow ;
		/* end custom code */
	}
	/* custom code - added by mls */
	if (lastTopWindow != topWindow)
		topWindow = lastTopWindow;
	/* end custom code */
	
	this.obj = this.obj || topWindow.document.body.appendChild(document.createElement("DIV"));
	this.Window = window;
	if (this.obj) {
		if (this.Use_Iframe) {
			if (window.parent != window && window.parent.document.body.nodeName != "FRAMESET")
			{
				this.Window = window.parent;	
				
				this.obj = this.Iframe = window.parent.document.createElement("IFRAME");
			} else {
				this.obj = this.Iframe = document.createElement("IFRAME");
			}
			this.Iframe.src = '/blank.html';
			this.obj.style.display = "none";
			this.Iframe.scrolling = 'no';
			this.Iframe.frameBorder = '0';
			this.Iframe.style.position = 'absolute';
			this.Iframe.style.zIndex = 10000;
			this.Iframe.width = 175;
			this.Iframe.height = 100;
			this.Iframe.marginWidth = this.Iframe.marginHeight = 0;
			this.Iframe.ownerDocument.body.appendChild(this.Iframe);
			this.Doc = this.Iframe.contentWindow.document;
			this.Iframe.__Initialized = false;
		} else {
			this.obj.style.zIndex = 10000;
			this.obj.style.position = 'absolute';
			this.obj.style.width = '175px';
			// 6/29/2011 3:50PM, Bug: #1258, Issue: setting height = '1px' doesn't get changed in ff and chrome, Resolution: comment out line below
			//this.obj.style.height = '1px';
			this.obj.style.top = '-1px'; // otherwise, it extends the page in chrome.
			this.Doc = topWindow.document;
			this.Window = topWindow;
		};
		this.obj.obj = this;
		this.obj.className = "co_menu_container";
	};
	return this.obj;
}
DropMenu.prototype.SetHTML = function (s) {
	var o = this.GetMenu();
	if (this.Use_Iframe) { //		try {
		if (!this.Iframe.__Initialized) {
			this.AppendStyles();
			this.Doc.body.obj = this;
			this.Doc.body.dir = this.Dir;
			this.Doc.body.onclick = Menu_OnClick;
			this.Doc.body.appendChild(this.Doc.createElement("DIV"));
			this.Iframe.__Initialized = true;
		}
		this.Doc.body.firstChild.innerHTML = s;
		o.style.display = "";
		o.width = this.Doc.body.firstChild.offsetWidth;
		o.height = this.Doc.body.firstChild.offsetHeight; //		}
		//		catch(e){}
	} else {
		this.AppendStyles();	
		o.innerHTML = s;
	}
}
DropMenu.prototype.Hide = function (o, e) {
	//this.CompleteHide();
	this.CancelHide();Drop_Menu=this;menu_t=window.setTimeout(function(){if(Drop_Menu)Drop_Menu.CompleteHide(this);Drop_Menu=null;}, 5);
}
DropMenu.prototype.CancelHide = function () {
	if(menu_t)window.clearTimeout(menu_t);menu_t=null;Drop_Menu=null;
}
DropMenu.prototype.CompleteHide = function () {
	if(menu_t)window.clearTimeout(menu_t);menu_t=null;Drop_Menu=null;
	Menu_Showing = false;
	if (this.current != null) this.current.MenuWidth = getElmWidth(this.obj);
	this.obj.style.display = 'none';
	if (!this.current) return;
	if (typeof(this.current.parent._Real_OnMouseOut) == 'function') this.current.parent._Real_OnMouseOut();
	if (this.current.parent._Real_ClassName) this.current.parent.className = this.current.parent._Real_ClassName;
		
	this.current.IsOpen = false;
	this.previous = this.current;
	this.current = null;
}
DropMenu.prototype.InitBehaviors = function () {
	this.GetMenu().onmouseover = Menu_OnMouseOver;
	this.obj.onmouseout = Menu_OnMouseOut;
	this.obj.onclick = Menu_OnClick;
	/*for(var i=0;i<this.Menus.length;i++)this.Menus[i].InitBehaviors();*/
}
DropMenu.prototype.Close = function () {
	for (var i = 0; i < this.Menus.length; i++) this.Menus[i] = null;
	this.Doc = null;
	this.Iframe = null;
}
DropMenu.prototype.AppendStyles = function () {//rewritten for ff compatibility
	if (typeof(this.Style_Array) == "undefined") return;
	if (!this.Use_Iframe) {
		var a = this.Style_Array;
		var styles = this.Doc.createElement("STYLE");
		this.Doc.getElementsByTagName("head")[0].appendChild(styles);
		this.styles = this.Doc.styleSheets[this.Doc.styleSheets.length-1];
		for (var i = 0; i < a.length; i++) {
			if (a[i][1] == "") continue;
			this.styles.insertRule(a[i][0]+"{"+a[i][1]+"}",this.styles.cssRules.length);
		};
	} else {
		this.styles = this.Doc.createStyleSheet();
		var a = this.Style_Array;
		for (var i = 0; i < a.length; i++) {
			if (a[i][1] == "") continue;
			this.styles.addRule(a[i][0], a[i][1]);
		};
	}
}
DropMenu.prototype.get_styleTags = function () {
	var styleSheets = document.styleSheets;
	var i, s, r = [];
	for (i = 0; i < styleSheets.length; i++) {
		r.push(styleSheets[i]);
	};
	s = styleSheets = null;
	return r;
}
DropMenu.prototype.getCssTextByClassName = function (className) {
	if (typeof(this.styleSheets) == "undefined") this.styleSheets = this.get_styleTags();
	className = className.toLowerCase();
	var s = this.styleSheets,
		r, rl, x, i, return_str = "";
	for (i = 0, sl = s.length; i < sl; i++) {
		if (s[i].cssText.toLowerCase().indexOf(className) > -1) {
			r = s[i].rules;
			for (x = 0, rl = r.length; x < rl; x++) {
				if (r[x].selectorText.toLowerCase() == className) return_str += r[x].style.cssText + ";";
			}
		}
	};
	return return_str;
}
var Menu = function (elm, Name, obj) {
	this.obj = (obj || Co_Menu);
	this.IsOpen = false;
	if (typeof(elm) == 'string') elm = document.getElementById(elm);
	this.Name = Name;
	this.menuItems = [];
	
	this.parent = elm;
	if (elm == null)
		return;
	this.id = this.parent.id;
	
	this.parent.Menu = this;
	this.parent._Real_OnMouseOver = this.parent.onmouseover;
	this.parent._Real_OnMouseOut = this.parent.onmouseout;
	this.obj.Add(this);
	this.InitBehaviors();
}
Menu.prototype.GetPosition = function () {
	this.position = getElmPos(this.parent);
	if (this.obj.Window != window) {
		var t = getElmPos(window.frameElement);
		this.position[0] += t[0];
		this.position[1] += t[1];
	}
	switch (this.obj.position.toLowerCase()) {
	case "right":
		this.position[0] += getElmWidth(this.parent);
		break;
	case "bottom":
		this.position[1] += getElmHeight(this.parent);
		this.Menu.style.display = "block";
		if (this.obj.Dir == "rtl") this.position[0] -= ((this.MenuWidth || getElmWidth(this.Menu)) - getElmWidth(this.parent));
		this.Menu.style.display = "none";
		break;
	};
}
Menu.prototype.AddItem = Menu.prototype.addItem = function (menu_text, menu_link, target) {
	this.menuItems[this.menuItems.length] = {
		Text: menu_text,
		Link: menu_link,
		Target: (target ? target : "_self")
	};
};
Menu.prototype.Show = function (o, e) {
	if (!this.obj.__Initialized && this.obj.Use_Iframe) {
		if (document.readyState == "complete") this.obj.Init();
		else return;
	}
	if (this.obj.current && this.obj.current != this) {
		if (typeof(this.obj.current.parent._Real_OnMouseOut) == 'function') this.obj.current.parent._Real_OnMouseOut();
	}
	if (!this.obj) return;
	this.obj.current = this;
	this.obj.CancelHide();
	this.Menu = this.obj.GetMenu();
	if (this.obj.Use_Iframe) {
		if (this.obj.Doc.readyState != 'complete') return;
	};
	this.Generate();
	/*if (!this.position)*/
	this.GetPosition();
	this.Menu.style.top = this.position[1] + "px";
	this.Menu.style.left = this.position[0] + "px";
	this.Menu.style.display = '';
	Menu_Showing = this.obj;
	this.IsOpen = true;
	/* 3/2/2011 1:50PM, Bug: #1167 (unrelated)
	Issue: Menu items are not being deslected properly
	Resolution: moved to MenuParent_OnMouseOver so we catch the class of the tab before it becomes highlighted. by dd
	Old Code: 
	if (this.obj.menu_hover_class != '' && !this.obj.do_not_select_parent) {
		this.parent._Real_ClassName = this.parent.className;
		this.parent.className = this.obj.menu_hover_class;
	};
*/	if (this.obj.Iframe) {
		var o = this.obj.Doc.body;
		while (o = o.firstChild) if (o.clientWidth > 0) break;
		if (o) this.obj.Iframe.width = o.clientWidth;
	}
}
Menu.prototype.InitBehaviors = function () {
	this.parent.onmouseover = MenuParent_OnMouseOver;
	this.parent.onmouseout = MenuParent_OnMouseOut;
}
Menu.prototype.ItemClick = function (o, e) {
	var item_clicked = e.target || e.srcElement;
	if (item_clicked.nodeName == "A") {
		if (this.obj.Iframe) {
			if (item_clicked.target == "" && item_clicked.href != "#" && item_clicked.href.indexOf("javascript:") == -1) {
				document.location.href = item_clicked.href;
				return false;
			}
		};
		return;
	};
	item_clicked = this.GetMenuItem(item_clicked);
	if (item_clicked == null) return;
	if (item_clicked.firstChild.nodeName == "A" && typeof(item_clicked.firstChild.click) == 'function') {
		item_clicked.firstChild.click();
		return;
	};
	var OnClickAction = item_clicked.onclick || item_clicked.firstChild.onclick;
	var href = item_clicked.href || item_clicked.firstChild.href;
	var target = item_clicked.target || item_clicked.firstChild.target;
	if (typeof(OnClickAction) == 'function') {
		OnClickAction();
		return;
	};
	if (typeof(href) == 'string') window.open(href, (target && target != '' ? target : '_self'));
}
Menu.prototype.GetMenuItem = function (o) {
	var menu_item = o;
	while (o && o != this.obj.obj && o.nodeName != "BODY") {
		if (o.nodeName == "DIV") return o;
		if (o.nodeName == "TABLE") return menu_item;
		o = o.parentNode;
	};
	return null;
}
Menu.prototype.IsOpened = function () {
	return this.IsOpen;
}
Menu.prototype.Generate = function () {
	var s_html = '';
	if (!this.content) {
		s_html = this.obj.wrapper_top.Replace('MENU_ID', this.id);
		var content_html = '';
		var style_suffix = '';
		if (this.parent) if (this.parent.getAttribute("style_suffix") != "") style_suffix = this.parent.getAttribute("style_suffix");
		var menu_wrapper = this.obj.content.Replace('MENU_ID', this.id);
		var MenuItems = this.menuItems;
		for (var i = 0; i < MenuItems.length; i++) {
			if (MenuItems[i].Text != '' && typeof(MenuItems[i]) != 'function') {
				content_html += menu_wrapper.Replace('ITEM_LINK', this.obj.link_url + MenuItems[i].Link);
				content_html = content_html.Replace('MENU_TEXT', MenuItems[i].Text);
				content_html = content_html.Replace('ITEM_TARGET', MenuItems[i].Target);
			}
			if (i < MenuItems.length - 1) content_html += this.obj.divider;
		}
		MenuItems = null;
		s_html += content_html;
		s_html += this.obj.wrapper_bottom;
		s_html = s_html.Replace("<<STYLE_SUFFIX>>", style_suffix);
		this.content = s_html;
	}
	this.obj.SetHTML(this.content);
}

function MenuParent_OnMouseOver(e) {
	/* 3/2/2011 1:50PM, Bug: #1167 (unrelated)
	Issue: Menu items are not being deslected properly
	Resolution: code moved here from Menu.prototype.Show to catch the class of the tab before it becomes highlighted. by dd*/
	if (this.Menu.obj.menu_hover_class != '' && !this.Menu.obj.do_not_select_parent) {
		this._Real_ClassName = this.className;
		this.className = this.Menu.obj.menu_hover_class;
	};
	
	if (typeof(this._Real_OnMouseOver) == 'function') this._Real_OnMouseOver();
	if (!e) e = window.event || this.document.parentWindow.event;

	this.Menu.Show(this, e);
}

function MenuParent_OnMouseOut(e) {
	if (typeof(this.Menu) == "object" && !this.Menu.obj.__Initialized) {
		if (typeof(this._Real_OnMouseOut) == 'function') this._Real_OnMouseOut();
	}
	if (Menu_Showing) Menu_Showing.Hide();
	/*if(!e)e=window.event;this.Menu.Hide(this,e);*/
}

function Menu_OnMouseOver(e) {
	if (this.obj && this.obj.current) this.obj.CancelHide();
}

function Menu_OnMouseOut(e) {
	if (!e) e = window.event || this.document.parentWindow.event;
	if (Co_Menu.Use_Iframe) {
		this.contentWindow.document.body.obj.Hide(this, e);
	} else {
		if (Menu_Showing) Menu_Showing.Hide();
	}
}

function Menu_OnClick(e) {
	if (!e) e = window.event || this.document.parentWindow.event;
	if (typeof(this.obj) != 'undefined' && this.obj.current) this.obj.current.ItemClick(this, e);
}
var Co_Menu = new DropMenu();


//</script>

