
function __doExternalPost(targetUrl) {
   theForm.__VIEWSTATE.value = "";
   theForm.encoding = "application/x-www-form-urlencoded";
   theForm.action = targetUrl;
   theForm.submit();
}
function getCookie(sName) {
	var cookie = "" + document.cookie;
	var start = cookie.indexOf(sName);
	if (cookie == "" || start == -1) 
		return "";
	var end = cookie.indexOf(';',start);
	if (end == -1)
		end = cookie.length;
	return unescape(cookie.substring(start+sName.length + 1,end));
}
function setCookie(sName, value) {
	document.cookie = sName + "=" + escape(value) + ";path=/;expires=Fri, 1 Jan 2010 00:00:00 GMT;";
}
function ShowEditBlock(block) {block.className = "EditableContentBorderOn";}
function HideEditBlock(block) {block.className = "EditableContentBorderOff";}
var doneredirect = false;
function EditContent(name) {if (doneredirect==false){doneredirect=true;location='editpage.aspx?contentname=' + name;}}
function PopIt(url) {return PopItEx(url,250,400);}
function PopItEx(url,w,h) {newwindow=window.open(url,'name','height='+h+',width='+w+',resizable=1,status=0,toolbar=0,location=0,scrollbars=0,menubar=0');if (window.focus) {newwindow.focus()}	return false;}
function toggleDiv(divid){
   if(document.getElementById(divid).style.display == 'none'){
      document.getElementById(divid).style.display = 'block';
   }else{
      document.getElementById(divid).style.display = 'none';
   }
}
function toggleDivVisibility(divid)
{
   if(document.getElementById(divid).style.visibility == 'visible'){
      document.getElementById(divid).style.visibility = 'hidden';
   }else{
      document.getElementById(divid).style.visibility = 'visible';
   }
}
//
String.prototype.startsWith = function(str){return (0==this.indexOf(str));}
function addLoadEvent(func) { 
  var oldonload = window.onload; 
  if (typeof window.onload != 'function') { 
    window.onload = func; 
  } else { 
    window.onload = function(){if (oldonload) {oldonload();}func();} 
  } 
} 
addLoadEvent(findJakes);
function findJakes(){
	var Jakes = document.getElementsByTagName('span');
	if(Jakes.length > 0){
		for(var i=0;i<Jakes.length;i++){
		    if (Jakes[i].className.startsWith('Jake')) {
		        Jakes[i].onmouseout = JakeMouseOut;
		        Jakes[i].onmouseover = JakeMouseOver;
		        Jakes[i].onclick = JakeClick;
		    }
		}
	}
}
function JakeMouseOver(){this.className = 'Jake-hover';}
function JakeMouseOut(){this.className = 'Jake';}
function JakeClick(){var u=this.getAttribute('dest');if(!u.startsWith('/') && !u.startsWith('http'))u='/'+u;window.location=u;}
//CC_Popup.js
function CC_Popup (varName, cssClass, position, zIndex, onPanelShowFunction, onPanelHideFunction, hideOnDocumentClick, initialContent)
{
	this._variableName = varName;
	this.CssClass = cssClass;
	this.Position = position;
	this.OnPanelShowFunction = onPanelShowFunction;
	this.OnPanelHideFunction = onPanelHideFunction;
	this.ZIndex = zIndex;
	this._isShown = false;
	this._initialized = false;
	this._lastPosition = null;
	this._initialContent = initialContent;
	this._panel = null;
	this._panelMask = null;
	this._animationHandle = null;
	this._originalDocumentOnClick = null;
	this._isOpening = false;
	this._hiddenSelects = null;
	this._checkForScrollResizeHandle = null;
	this._lastWindowInfo = null;
	
	this._panelMask = document.createElement('div');
	this._panelMask.style.position = 'absolute';
	this._panelMask.style.display = 'none';
	
	this._panel = document.createElement('div');
	this._panel.style.position = 'absolute';
	this._panel.style.display = 'none';
	this._panel.className = this.CssClass;
	
	this._panelMask.appendChild(this._panel);
	
	if (hideOnDocumentClick)
	{
		if (document.onclick)
			this._originalDocumentOnClick = document.onclick;
		
		document.onclick = new Function(this._variableName + '._documentOnClick();');
	}
}

CC_Popup.prototype.IsShown = function()
{
	return this._isShown;
}

CC_Popup.prototype._getElementInfo = function(element)
{
	var curleft = 0;
	var curtop = 0;
	var obj = element;		
	if (obj)
	{
		while (obj)
		{
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
			obj = obj.offsetParent;
		}
	}
	else
	{
		if (obj.x)
			curleft += obj.x;
			
		if (obj.y)
			curtop += obj.y;
	}
	
	var elementInfo = new Object();
	elementInfo.Left = curleft;
	elementInfo.Top = curtop;
	elementInfo.Width = element.offsetWidth;
	elementInfo.Height = element.offsetHeight;
	
	return elementInfo;
}

CC_Popup.prototype.ShowAtElement = function(element, ignoreHideAndAnimation)
{
	var elementInfo = this._getElementInfo(element);
		
	this.Show(elementInfo.Left, elementInfo.Top, elementInfo.Width, elementInfo.Height, ignoreHideAndAnimation);
}

CC_Popup.prototype._getWindowInfo = function()
{
	var scrollX = 0, scrollY = 0, width = 0, height = 0;

	if (typeof(window.pageXOffset) == 'number') 
	{
		//Netscape compliant
		scrollX = window.pageXOffset;
		scrollY = window.pageYOffset;
	} 
	else if (document.body && (document.body.scrollLeft || document.body.scrollTop)) 
	{
		//DOM compliant
		scrollX = document.body.scrollLeft;
		scrollY = document.body.scrollTop;
	} 
	else if (document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)) 
	{
		//IE6 standards compliant mode
		scrollX = document.documentElement.scrollLeft;
		scrollY = document.documentElement.scrollTop;
	}
	
	if (typeof(window.innerWidth) == 'number') 
	{
		//Non-IE
		width = window.innerWidth;
		height = window.innerHeight;
	} 
	else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) 
	{
		//IE 6+ in 'standards compliant mode'
		width = document.documentElement.clientWidth;
		height = document.documentElement.clientHeight;
	} 
	else if (document.body && (document.body.clientWidth || document.body.clientHeight)) 
	{
		//IE 4 compatible
		width = document.body.clientWidth;
		height = document.body.clientHeight;
	}
	
	var rect = new Object();
	rect.ScrollX = scrollX;
	rect.ScrollY = scrollY;
	rect.Width = width;
	rect.Height = height;
	
	return rect;
}

CC_Popup.prototype.Show = function (x, y, positionWidth, positionHeight, ignoreHideAndAnimation)
{
	if (!this._initialized)
		this._initialize();

	if (!ignoreHideAndAnimation && this._isShown)
		this.Hide();
	else if (this._hiddenSelects)
	{
		for (var i = 0; i < this._hiddenSelects.length; i++)
		{
			if (this._hiddenSelects[i].Element.style.visibility == 'hidden')
				this._hiddenSelects[i].Element.style.visibility = this._hiddenSelects[i].Visibility;
		}
			
		this._hiddenSelects = null;
	}

	this._panelMask.style.position = 'absolute';
	this._panelMask.style.zIndex = this.ZIndex;
	this._panelMask.style.display = 'block';
	this._panelMask.style.visibility = 'hidden';
	this._panelMask.style.overflow = 'visible';
	
	this._panel.style.position = 'absolute';
	this._panel.style.display = 'block';
	this._panel.style.visibility = 'hidden';
	this._panel.className = this.CssClass;
	this._panel.style.left = '0px';
	this._panel.style.top = '0px';
	
	this._panelMask.style.width = this._panel.offsetWidth + 'px';
	this._panelMask.style.height = this._panel.offsetHeight + 'px';
	
	// retrieve the window info
	this._lastWindowInfo = this._getWindowInfo();
	
	// width/height of panel
	var panelWidth = this._panel.offsetWidth;
	var panelHeight = this._panel.offsetHeight;
	var animatePropertyName, animateTargetValue, animateNextValue;
	
	if (this.Position.indexOf('left') > -1 || this.Position.indexOf('right') > -1)
	{
		// position left/right
	
		if ((this.Position.indexOf('right') > -1 && this.Position.indexOf('left') == -1) || ((this._lastWindowInfo.Width + this._lastWindowInfo.ScrollX) - (x + positionWidth) > x - this._lastWindowInfo.ScrollX))
		{
			// position right
			this._panelMask.style.left = (x + positionWidth) + "px";
			animatePropertyName = 'style.left';
			animateTargetValue = 0;
			animateNextValue = -panelWidth;
		}
		else
		{
			// position left
			this._panelMask.style.left = (x - panelWidth) + "px";
			animatePropertyName = 'style.left';
			animateTargetValue = 0;
			animateNextValue = panelWidth;
		}
		
		if ((this.Position.indexOf('down') > -1 && this.Position.indexOf('up') == -1) || ((this._lastWindowInfo.Height + this._lastWindowInfo.ScrollY) - (y) > (y + positionHeight) - this._lastWindowInfo.ScrollY))
		{
			// position down
			this._panelMask.style.top = y + "px";
		}
		else
		{
			// position up
			this._panelMask.style.top = (y + positionHeight - panelHeight) + "px";
		}
	}
	else
	{
		// position up/down
		
		if ((this.Position.indexOf('right') > -1 && this.Position.indexOf('left') == -1) || ((this._lastWindowInfo.Width + this._lastWindowInfo.ScrollX) - (x) > (x + positionWidth) - this._lastWindowInfo.ScrollX))
		{
			// position right
			this._panelMask.style.left = x + "px";
		}
		else
		{
			// position left
			this._panelMask.style.left = (x + positionWidth - panelWidth) + "px";
		}
		
		if ((this.Position.indexOf('down') > -1 && this.Position.indexOf('up') == -1) || ((this._lastWindowInfo.Height + this._lastWindowInfo.ScrollY) - (y + positionHeight) > (y - this._lastWindowInfo.ScrollY)))
		{
			// position down
			this._panelMask.style.top = (y + positionHeight) + "px";
			animatePropertyName = 'style.top';
			animateTargetValue = 0;
			animateNextValue = -panelWidth;
		}
		else
		{
			// position up
			this._panelMask.style.top = (y - panelHeight) + "px";
			animatePropertyName = 'style.top';
			animateTargetValue = 0;
			animateNextValue = panelWidth;
		}
	}
			
	this._panel.style.visibility = 'visible';
	this._panelMask.style.visibility = 'visible';
	this._panelMask.style.overflow = 'hidden';
	
	// detect and hide select boxes
	if (this._panelMask.getClientRects)
	{
		var selectBoxes = document.getElementsByTagName('select');
		var maskLeft = parseInt(this._panelMask.style.left, 10) - this._lastWindowInfo.ScrollX;
		var maskTop = parseInt(this._panelMask.style.top, 10) - this._lastWindowInfo.ScrollY;
		var maskRight = maskLeft + this._panelMask.offsetWidth;
		var maskBottom = maskTop + this._panelMask.offsetHeight;
		this._hiddenSelects = new Array();
		for (var i = 0; i < selectBoxes.length; i++)
		{
			if (selectBoxes[i].getClientRects)
			{
				var rects = selectBoxes[i].getClientRects();
				for (var j = 0; j < rects.length; j++)
				{
					if (rects[j].top < maskBottom && maskTop < rects[j].bottom && rects[j].left < maskRight && maskLeft < rects[j].right)
					{
					    var inPanel = false;
					    var selectParent = selectBoxes[i].offsetParent;
					    while (selectParent != null)
					    {
					        if (selectParent == this._panel)
					        {
					            inPanel = true;
					            break;
					        }
					        
					        selectParent = selectParent.offsetParent;
					    }
					
					    if (!inPanel)
					    {
						    this._hiddenSelects[this._hiddenSelects.length] = { Element: selectBoxes[i], Visibility: selectBoxes[i].style.visibility };
						    selectBoxes[i].style.visibility = 'hidden';
						}
						
						break;
					}
				}
			}
		}
	}
	
	this._isOpening = true;
	if (ignoreHideAndAnimation)
		this._animationHandle = window.setTimeout(new Function(this._variableName + '._animate(\'' + animatePropertyName + '\',' + animateTargetValue + ',' + animateTargetValue + ',0,0);'), 9);
	else
		this._animate(animatePropertyName, animateTargetValue, animateNextValue, animateNextValue > animateTargetValue ? -((animateNextValue - animateTargetValue) / 3) : ((animateTargetValue - animateNextValue) / 3), .67);
	
	if (!this._isShown)
	{
		this._isShown = true;
		this._lastPosition = { X : x, Y : y, Width : positionWidth, Height: positionHeight };
		
		if (this.OnPanelShowFunction)
			this.OnPanelShowFunction();
	}
}

CC_Popup.prototype._checkForScrollResize = function()
{
	if (this._checkForScrollResizeHandle)
		window.clearTimeout(this._checkForScrollResizeHandle);

	if (this._isShown && !this._isOpening && this._lastWindowInfo)
	{
		var windowInfo = this._getWindowInfo();
		
		// did check: windowInfo.ScrollX != this._lastWindowInfo.ScrollX || windowInfo.ScrollY != this._lastWindowInfo.ScrollY ||	
		if (windowInfo.Width != this._lastWindowInfo.Width || windowInfo.Height != this._lastWindowInfo.Height)
			this.Hide();
		else
			this._checkForScrollResizeHandle = window.setTimeout(new Function('window.' + this._variableName + '._checkForScrollResize();'), 999);
	}
}

CC_Popup.prototype.Hide = function()
{
	if (this._isShown)
	{
		if (!this._initialized)
			this._initialize();
	
		this._panel.style.position = 'absolute';
		this._panel.style.display = 'none';
		this._panelMask.style.position = 'absolute';
		this._panelMask.style.display = 'none';
		
		this._isShown = false;
		this._lastPosition = null;
		
		if (this._hiddenSelects)
		{
			for (var i = 0; i < this._hiddenSelects.length; i++)
			{
				if (this._hiddenSelects[i].Element.style.visibility == 'hidden')
					this._hiddenSelects[i].Element.style.visibility = this._hiddenSelects[i].Visibility;
			}
				
			this._hiddenSelects = null;
		}
			
		if (this.OnPanelHideFunction)
			this.OnPanelHideFunction();
	}
}

CC_Popup.prototype.ClearPanelContent = function()
{
	while (this._panel.childNodes.length > 0)
		this._panel.removeChild(this._panel.childNodes[0]);
}

CC_Popup.prototype.SetPanelContent = function(html)
{
	this.ClearPanelContent();
	this._panel.innerHTML = html;
	this.Refresh();
}

CC_Popup.prototype.AddNodeToPanel = function(node)
{
	this._panel.appendChild(node);
	this.Refresh();
}

CC_Popup.prototype.RemoveNodeFromPanel = function(node)
{
	this._panel.removeChild(node);
	this.Refresh();
}

CC_Popup.prototype.GetPanelNodes = function()
{
	return this._panel.childNodes;
}

CC_Popup.prototype.Refresh = function()
{
	if (this._animationHandle)
		window.clearTimeout(this._animationHandle);
	
	if (this._isShown && this._lastPosition)
		this.Show(this._lastPosition.X, this._lastPosition.Y, this._lastPosition.Width, this._lastPosition.Height, true);
}

CC_Popup.prototype._initialize = function()
{
	document.body.appendChild(this._panelMask);
	this._initialized = true;
	if (this._initialContent)
		this.SetPanelContent(this._initialContent);
}

CC_Popup.prototype.Dispose = function()
{
	if (this._initialized)
	{
		if (document && document.body)
			document.body.removeChild(this._panelMask);
	}
}

CC_Popup.prototype._animate = function(propertyName, targetValue, nextValue, step, acceleration)
{
	if (this._animationHandle)
		window.clearTimeout(this._animationHandle);
	
	var currValue = parseInt(eval('this._panel.' + propertyName));
	if ((step < 0 && currValue < targetValue) || (step > 0 && currValue > targetValue) || Math.abs(step) < 1)
	{
		// complete	
		if (this._hiddenSelects)
		{
			for (var i = 0; i < this._hiddenSelects.length; i++)
				this._hiddenSelects[i].Element.style.visibility = 'hidden';
		}
	
		eval('this._panel.' + propertyName + ' = targetValue + \'px\'');
		this._panel.style.position = 'static';
		this._panelMask.style.overflow = 'visible';
		this._animationHandle = null;
		this._isOpening = false;
		
		this._lastWindowInfo = this._getWindowInfo();
		this._checkForScrollResizeHandle = window.setTimeout(new Function('window.' + this._variableName + '._checkForScrollResize();'), 999);
	}
	else
	{
		// continue animation
		
		eval('this._panel.' + propertyName + ' = nextValue + \'px\'');
		
		nextValue = nextValue + step;
		if (step > 0 && nextValue > targetValue)
			nextValue = targetValue;
		else if (step < 0 && nextValue < targetValue)
			nextValue = targetValue;
		
		step = step * acceleration;
		
		this._animationHandle = window.setTimeout(new Function(this._variableName + '._animate(\'' + propertyName + '\',' + targetValue + ',' + nextValue + ',' + step + ',' + acceleration + ');'), 19);
	}
}

CC_Popup.prototype._documentOnClick = function()
{
	if (this._isShown && !this._isOpening)
		this.Hide();
	
	if (this._originalDocumentOnClick)
		this._originalDocumentOnClick();
}

// CC_Overlay.js
function CC_Overlay (varName, overlayCssClass, footerHtml, nodeName, attributeName)
{
	this._variableName = varName;
	this._popupPanel = null;
	this._overlayCssClass = overlayCssClass;
	this._footerHtml = footerHtml;
	this._currentElement = null;
	this._initialized = false;
	this._currentElementInfo = null;
	this._bodyOnMouseMove = null;
	this._nodeName = nodeName;
	this._attributeName = attributeName;
	
	var nodes = document.getElementsByTagName(this._nodeName);
		for (var i = 0; i < nodes.length; i++)
	{
		if (nodes[i].getAttribute(this._attributeName) != null)
			nodes[i].onmouseover = new Function(this._variableName + '.Show(this);');
	}
}

CC_Overlay.prototype.Show = function(element)
{
	if (element == this._currentElement)
		return;

	if (!this._initialized)
		this._initialize();
		
	if (this._popupPanel.IsShown())
		this._hide();

	this._currentElement = element;
	this._currentElementInfo = this._popupPanel._getElementInfo(element);
	var highlightNode = this._popupPanel.GetPanelNodes()[0];
	
	var left = this._currentElementInfo.Left - parseInt(this._getCurrentStyle(highlightNode, "border-left-width", "borderLeftWidth"));
	var top = this._currentElementInfo.Top - parseInt(this._getCurrentStyle(highlightNode, "border-top-width", "borderTopWidth"));
	
	highlightNode.style.width = this._currentElementInfo.Width + 'px';
	highlightNode.style.height = this._currentElementInfo.Height + 'px';
	
	this._popupPanel.Show(left, top, 0, 0, true);	
	this._popupPanel.Refresh();
}

CC_Overlay.prototype._onClick = function()
{
	if (this._currentElement && this._currentElement.onclick)
		this._currentElement.onclick();
}

CC_Overlay.prototype._ondblclick = function()
{
	if (this._currentElement && this._currentElement.ondblclick)
		this._currentElement.ondblclick();
}

CC_Overlay.prototype._onMouseMove = function(event)
{
	if (this._initialized && this._currentElementInfo != null)
	{
		if (!event)
			event = window.event;
		
		var x = event.pageX ? event.pageX : (event.clientX + document.documentElement.scrollLeft);
		var y = event.pageY ? event.pageY : (event.clientY + document.documentElement.scrollTop);
		
		if (x < this._currentElementInfo.Left || x > this._currentElementInfo.Left + this._currentElementInfo.Width || y < this._currentElementInfo.Top || y > this._currentElementInfo.Top + this._currentElementInfo.Height)
			this._hide();
	}
	
	if (this._bodyOnMouseMove)
		this._bodyOnMouseMove(event);
}

CC_Overlay.prototype._hide = function()
{
	if (this._initialized && this._popupPanel.IsShown())
	{
		this._popupPanel.Hide();
		this._currentElement = null;
		this._currentElementInfo = null;
	}
}

CC_Overlay.prototype._initialize = function()
{
	this._popupPanel = new CC_Popup(this._variableName + '._popupPanel', '', 'rightdown', 100, null, null, false, '<div class="' + this._overlayCssClass + '" onClick="' + this._variableName + '._onclick();" onDblClick="' + this._variableName + '._ondblclick();">&nbsp;</div>' + this._footerHtml);
	this._popupPanel._initialize();
	
	if (document.documentElement.onmousemove != null)
		this._bodyOnMouseMove = document.documentElement.onmousemove;
		
	document.documentElement.onmousemove = new Function('event', this._variableName + "._onMouseMove(event);");
	
	this._initialized = true;
}

CC_Overlay.prototype._getCurrentStyle = function(element, styleRule, jsStyleRule)
{
	if(document.defaultView && document.defaultView.getComputedStyle)
		return document.defaultView.getComputedStyle(element, "").getPropertyValue(styleRule);
	else if(element.currentStyle)
		return element.currentStyle[jsStyleRule];
	
	return "";
}

