//combine .js files into one file
//start dragdrop2.js 

function Draggable(element) {
	// initialize drag variable
	var x = 0, y = 0, oldMouseMove, oldMouseUp;
 
	// get style properties of element
	var computedStyle;
	if (typeof document.defaultView != "undefined" && typeof document.defaultView.getComputedStyle != "undefined")
		computedStyle = document.defaultView.getComputedStyle(element, "");
	else if (typeof element.currentStyle != "undefined")
		computedStyle = element.currentStyle;
	else
		computedStyle = element.style;

	// prep element for dragging
	if (computedStyle.position == "static" || computedStyle.position == "")
		element.style.position = "relative";
	if (computedStyle.zIndex == "auto" || computedStyle.zIndex == "")
		element.style.zIndex = 1;
	element.style.left = isNaN(parseInt(computedStyle.left)) ? "0" : computedStyle.left;
	element.style.top  = isNaN(parseInt(computedStyle.top )) ? "0" : computedStyle.top;

	// default event listeners
	function onstart(event) {
		event.dragTarget = element;
		x = event.clientX;
		y = event.clientY;

		// Override preventDefault
		event.preventDefault = (function(original) {
			return function() {
				element.ownerDocument.onmousemove = oldMouseMove;
				element.ownerDocument.onmouseup = oldMouseUp;
				original.call(event);
			}
		})(event.preventDefault || function() {});

		if (element.onstart) element.onstart(event);
	}
	function ondrag(event, draggableObj) {
		event.dragTarget = element;
		var minLeftValue;
		var maxLeftValue;
		if (draggableObj.range)
		{
			minLeftValue =  draggableObj.minLeft>draggableObj.range[0]?draggableObj.minLeft:draggableObj.range[0];
			maxLeftValue = draggableObj.maxLeft<draggableObj.range[1]?draggableObj.maxLeft:draggableObj.range[1];
		}
		var elemLeft = parseInt(element.style.left) + event.clientX - x;
		//if (draggableObj.minLeft)
		{
			if (elemLeft < minLeftValue)
			{
				elemLeft = minLeftValue;
			}
		}
		//if (draggableObj.maxLeft)
		{
			if (elemLeft > maxLeftValue)
			{
				elemLeft = maxLeftValue;
			}
		}
		element.style.left = elemLeft + "px";
		//element.style.top  = parseInt(element.style.top)  + event.clientY - y + "px";
		x = event.clientX;
		y = event.clientY;
		Droppable.query(event);
		
		if (element.ondrag) element.ondrag(event);
	}
	function onstop(event) {
		event.dragTarget = element;
		Droppable.query(event);
		
		if (element.onstop) element.onstop(event);
	}

	// make listeners active
	element.onmousedown = (function(oldMouseDown, draggableObj) {
		return function() {
			// Call old listener
			//if (oldMouseDown) oldMouseDown.apply(this, arguments);

			// Store old event handlers
			oldMouseMove = this.ownerDocument.onmousemove;
			oldMouseUp   = this.ownerDocument.onmouseup;


			var count4MouseMove = 2;  //Fix too much move will fill the event;
			// Setup events
			this.ownerDocument.onmousemove = function (){

				if (count4MouseMove > 0)
				{
					count4MouseMove--;
					return false;
				}
				count4MouseMove = 2;
				// Call old listener
				//if (oldMouseMove) oldMouseMove.apply(this, arguments);

				// Call ondrag
				ondrag.call(element, arguments[0] || event, draggableObj);

				return false;
			}
			this.ownerDocument.onmouseup = function() {
				// Call old listener
				//if (oldMouseUp) oldMouseUp.apply(this, arguments);
				
				// Call onstop
				onstop.call(element, arguments[0] || event);
				// Restore old event listeners
				this.onmousemove = null;
				this.onmouseup   = null;
				element.blur();
				return false;
			}

			// Call onstart
			onstart.call(this, arguments[0] || event);

			return false;
		}
	})(element.onmousedown, this);

	// override event attachers
	if (element.addEventListener)
		element.addEventListener = (function(original) {
			return function(event, listener, useCapture) {
				switch (event) {
					case "start":
						onstart = (function(old) {
							return function(event) { old.call(element,event); listener.call(element,event); }
						})(onstart);
						break;
					case "drag":
						ondrag = (function(old) {
							return function(event) { old.call(element,event); listener.call(element,event); }
						})(ondrag);
						break;
					case "stop":
						onstop = (function(old) {
							return function(event) { old.call(element,event); listener.call(element,event); }
						})(onstop);
						break;
					default:
						original.call(element, event, listener, useCapture);
				}
			}
		})(element.addEventListener);
	
	if (element.attachEvent)
		element.attachEvent = (function(original) {
			return function(event, listener) {
				switch (event) {
					case "onstart":
						onstart = (function(old) {
							return function(event) { old.call(element,event); listener.call(element,event); }
						})(onstart);
						break;
					case "ondrag":
						ondrag = (function(old) {
							return function(event) { old.call(element,event); listener.call(element,event); }
						})(ondrag);
						break;
					case "onstop":
						onstop = (function(old) {
							return function(event) { old.call(element,event); listener.call(element,event); }
						})(onstop);
						break;
					default:
						original.call(element, event, listener);
				}
			}
		})(element.attachEvent);
		
		
		if (window.attachEvent)
			window.attachEvent("onbeforeunload", function() {
				onstart = ondrag = onstop = null;
				if (element != null)
				{
					element.onmousedown = element.addEventListener = element.attachEvent = null;
				}
				element = null;
			});	

}


// initialize Droppable in the global scope
var Droppable;

(function() {
	if (document.getBoxObjectFor) {
		function getOffset(element) {
			var box = document.getBoxObjectFor(element);
			return { x: box.x, y: box.y };
		}
	}
	else if (document.all && navigator.appName == "Microsoft Internet Explorer" && !window.opera) {
		function getOffset(element) {
			var range = document.body.createTextRange();
			range.moveToElementText(element);
			var rect = range.getBoundingClientRect();
			return { x: rect.left, y: rect.top };
		}
	}
	else {
		function getOffset(element) {
			var accumulator = arguments[1] || { x: 0, y: 0 };
			if (element && element != document.body) {
				accumulator.x += element.offsetLeft;
				accumulator.y += element.offsetTop;
				return getOffset(element.offsetParent, accumulator);
			}
			else {
				return accumulator;
			}
		}
	}

	// initialize private pointers to current target information
	var cTarget = null, cHover = null, cUnhover = null, cDrop = null;
	function hotSpots(x,y) {
		cTarget = cHover = cUnhover = cDrop = null;
	}

	// declare Droppable within the private scope
	Droppable = function(element) {
		// Calculate offset
		var offset = getOffset(element);

		// Calculate other edge offset
		var edge = { x: offset.x + element.offsetWidth, y: offset.y + element.offsetHeight };

		// Assign a finder function
		hotSpots = (function(old) {
			return function(x,y) {
				if (offset.x <= x && x <= edge.x && offset.y <= y && y <= edge.y) {
					cTarget  = element;
					cHover   = onhover;
					cUnhover = onunhover;
					cDrop    = ondrop;
				}
				else {
					old(x,y);
				}
			}
		})(hotSpots);

		// default event listeners
		function onhover(event) {
			event.dropTarget = element;
			if (element.onhover) element.onhover(event);
		}
		function onunhover(event) {
			event.dropTarget = element;
			if (element.onunhover) element.onunhover(event);
		}
		function ondrop(event) {
			event.dropTarget = element;
			if (element.ondrop) element.ondrop(event);
		}

		// override event attachers
		if (element.addEventListener)
			element.addEventListener = (function(original) {
				return function(event, listener, useCapture) {
					switch (event) {
						case "hover":
							onhover = (function(old) {
								return function(event) { old.call(element,event); listener.call(element,event); }
							})(onhover);
							break;
						case "unhover":
							onunhover = (function(old) {
								return function(event) { old.call(element,event); listener.call(element,event); }
							})(onunhover);
							break;
						case "drop":
							ondrop = (function(old) {
								return function(event) { old.call(element,event); listener.call(element,event); }
							})(ondrop);
							break;
						default:
							original.call(element, event, listener, useCapture);
					}				
				}
			})(element.addEventListener);

		if (element.attachEvent)
			element.attachEvent = (function(original) {
				return function(event, listener) {
					switch (event) {
						case "onhover":
							onhover = (function(old) {
								return function(event) { old.call(element,event); listener.call(element,event); }
							})(onhover);
							break;
						case "onunhover":
							onunhover = (function(old) {
								return function(event) { old.call(element,event); listener.call(element,event); }
							})(onunhover);
							break;
						case "ondrop":
							ondrop = (function(old) {
								return function(event) { old.call(element,event); listener.call(element,event); }
							})(ondrop);
							break;
						default:
							original.call(element, event, listener);
					}				
				}
			})(element.attachEvent);
	
	
		if (window.attachEvent)
			window.attachEvent("onbeforeunload", function() {
				hotSpots = onhover = onunhover = ondrop = element.addEventListener = element.attachEvent = cTarget = cHover = cUnhover = cDrop = null;
				element = null;
			});
	}

	// Setup a query method
	Droppable.query  = function(event) {	
		var oTarget  = cTarget,
		    oHover   = cHover,
		    oUnhover = cUnhover,
		    oDrop    = cDrop;

		var scrollLeft = document.documentElement.scrollLeft || document.body.scrollLeft,
		    scrollTop  = document.documentElement.scrollTop  || document.body.scrollTop;
		

		hotSpots(event.clientX + scrollLeft, event.clientY + scrollTop);

		switch (event.type) {
			case "mousemove": // onhover & onunhover
				if (oTarget != null && oTarget != cTarget)
					oUnhover.call(oTarget, event);
				if (oTarget == null && cTarget != null)
					cHover.call(cTarget, event);
				break;
			case "mouseup": // ondrop
				if (cTarget != null) {
					cUnhover.call(cTarget, event);
					cDrop.call(cTarget, event);
				}
				break;
		}
	}
	
	Droppable.reset = function() {
		hotSpots = function(x,y) {
			cTarget = cHover = cUnhover = cDrop = null;
		}
		hotSpots();
	}
})();

// Fix the function prototype for IE5/Mac
if (typeof Function.prototype.apply == "undefined")
	Function.prototype.apply = function(scope, args) {
		if (!args) args = [];
		var index = 0, result;
		do { -- index } while (typeof scope[index] != "undefined");
		scope[index] = this;
	
		switch (args.length) {
			case 0:
				result = scope[index]();
				break;
			case 1:
				result = scope[index](args[0]);
				break;
			case 2:
				result = scope[index](args[0], args[1]);
				break;
			case 3:
				result = scope[index](args[0], args[1], args[2]);
				break;
			case 4:
				result = scope[index](args[0], args[1], args[2], args[3]);
				break;
			default:
				result = scope[index](args[0], args[1], args[2], args[3], args[4]);
				break;
		}
	
		delete scope[index];
		return result;
	}

if (typeof Function.prototype.call == "undefined")
	Function.prototype.call = function(scope) {
		var args = new Array(Math.max(arguments.length-1, 0));
		for (var i = 1; i < arguments.length; i++)
			args[i-1] = arguments[i];
		return this.apply(scope, args);
	}
	
function DoubleSlider(contain, leftRange, rightRange, points, initPoints,rangePoints, pointWidth, handlerWidth, pointImg) {
	this.lenPerStep = parseInt(contain.style.width)/(rangePoints[1]-rangePoints[0]);
	this.lenPerStepHalf = this.lenPerStep/2;	
	this.points = points;
	this.pointsPos = new Array();
	
	this.pointWidth = pointWidth;	
	this.handlerWidth = 0;
	this.pointWidthL = 0;//1 
	this.pointWidthR = pointWidth - 1;//1 
	this.rangePoints = rangePoints;
	this.curPointsPos = initPoints;


	var nodes = contain.getElementsByTagName("DIV");
	
	for (var i=0; i<points.length; i++)
	{
		this.pointsPos.push(this.lenPerStep * points[i]);
		nodes[3].innerHTML = nodes[3].innerHTML + "<span style='position:absolute;float:left;left:"+ this.pointsPos[i] + "px;'><img src='" + pointImg + "' border=0></span>";
	}
	//Appen first and last point
	nodes[3].innerHTML = nodes[3].innerHTML + "<span style='position:absolute;float:left;left:0px;'><img src='" + pointImg + "' border=0></span>"
			+ "<span style='position:absolute;float:left;left:" + (this.rangePoints[1] * this.lenPerStep) + "px;'><img src='" + pointImg + "' border=0></span>";
			
	this.spaceBetweenSlider = nodes[1];
	nodes[0].style.left = this.pointsPos[0] - this.pointWidthL + "px";
	nodes[2].style.left = this.pointsPos[points.length-1] - this.pointWidthR+ "px";
	this.leftSlider = new Draggable(nodes[0]);
	this.rightSlider = new Draggable(nodes[2]);
	this.leftSlider.minLeft = rangePoints[0]*this.lenPerStep - this.pointWidthL;
	this.leftSlider.maxLeft = initPoints[1]*this.lenPerStep - this.lenPerStep - this.pointWidthL;
	this.leftSlider.range = [leftRange[0]*this.lenPerStep - this.pointWidthL, leftRange[1]*this.lenPerStep - this.pointWidthL];

	this.rightSlider.minLeft = initPoints[0]*this.lenPerStep + this.lenPerStep - this.pointWidthR;	
	this.rightSlider.maxLeft = rangePoints[1]*this.lenPerStep -this.pointWidthR;
	this.rightSlider.range = [rightRange[0]*this.lenPerStep - this.pointWidthR, rightRange[1]*this.lenPerStep -this.pointWidthR];
   	nodes[0].style.left = initPoints[0]*this.lenPerStep  - this.pointWidthL + "px";
	nodes[2].style.left = initPoints[1]*this.lenPerStep - this.pointWidthR + "px";
	
	this.calPos = function(elemLeft, isLeftSlider)
	{
		var res, minPos, maxPos, curPos;
		if (isLeftSlider)
		{
			maxPos = this.curPointsPos[1]-1;
			minPos = this.rangePoints[0];
			curPos = this.curPointsPos[0];
			res = this.rangePoints[0];
		}
		else
		{
			maxPos = this.rangePoints[1];
			minPos = this.curPointsPos[0] + 1;
			curPos =  this.curPointsPos[1];
			res = this.rangePoints[1];
		}
		do{
			if (elemLeft > this.lenPerStep*curPos)
			{
				minPos = curPos + 1;
				if (maxPos <=minPos)
				{
					minPos = maxPos-1;
				}
				if (elemLeft < this.lenPerStep*minPos - this.lenPerStepHalf)
				{
					res  = minPos;
					break;
				}
			}
			else if (elemLeft < this.lenPerStep*curPos)
			{
				maxPos = curPos - 1;
				if (maxPos <=minPos)
				{
					maxPos = minPos+1;
				}
				if (elemLeft > this.lenPerStep*maxPos + this.lenPerStepHalf)
				{
					res  = maxPos;
					break;
				}
			}
			else
			{
				break;
			}
			for (var i=maxPos; i>=minPos; i--)
			{
				
				if (elemLeft >= i*this.lenPerStep - this.lenPerStepHalf)
				{
					res = i;
															
					break;
				}
			}
		}while(0);
		return res;
	};
		
	
	this.adjustSpace = function(pos)
	{
		if (pos == this.rangePoints[0] || pos == this.rangePoints[0] + 1)
		{
			var elemLeft = parseInt(nodes[0].style.left);
			if (elemLeft<this.pointWidthL-this.handlerWidth)
			{
				this.spaceBetweenSlider.style.left = (this.pointWidthL-this.handlerWidth) + "px";
				this.spaceBetweenSlider.style.width = (parseInt(this.spaceBetweenSlider.style.width) 
					- this.pointWidthL +this.handlerWidth + elemLeft + 1 ) +"px";
			}
		}
		
		/*
		else if (pos == this.maxValue || pos == this.maxValue -1)
		{
			var elemLeft = parseInt(nodes[2].style.left);			
			var maxLen = this.maxValue*this.lenPerStep;
			if (elemLeft>maxLen)
			{
				this.spaceBetweenSlider.style.left = this.pointWidthL + "px";
				this.spaceBetweenSlider.style.width = (maxLen - this.spaceBetweenSlider.style.left) +"px";
			}
		}*/
	}
	
	this.spaceBetweenSlider.style.left = nodes[0].style.left;
	this.spaceBetweenSlider.style.width = parseInt(nodes[2].style.left) - parseInt(nodes[0].style.left) + 1  + "px";
	contain.style.visibility = "visible";
	
	nodes[0].ondrag = (function(nodes, doubleSlider) {
		return function() {
			var elemLeft = parseInt(nodes[0].style.left) + doubleSlider.pointWidthL;
			var curPos = doubleSlider.calPos(elemLeft, true);
			if (doubleSlider.onchanging)
			{
				doubleSlider.onchanging(curPos, doubleSlider.curPointsPos[1]);
			}
			doubleSlider.spaceBetweenSlider.style.left = nodes[0].style.left;
			doubleSlider.spaceBetweenSlider.style.width = parseInt(nodes[2].style.left) - parseInt(nodes[0].style.left) + 1  + "px";
			doubleSlider.adjustSpace(curPos);
			return false;
		}
	})(nodes, this);
	nodes[2].ondrag = (function(nodes, doubleSlider) {
		return function() {
			var elemLeft = parseInt(nodes[2].style.left) + doubleSlider.pointWidthR;
			var curPos = doubleSlider.calPos(elemLeft, false);
			if (doubleSlider.onchanging)
			{
				doubleSlider.onchanging(doubleSlider.curPointsPos[0],curPos);
			}
			
			//doubleSlider.spaceBetweenSlider.style.left = nodes[0].style.left;
			doubleSlider.spaceBetweenSlider.style.width = (parseInt(nodes[2].style.left) - parseInt(doubleSlider.spaceBetweenSlider.style.left) + 1  )+ "px";	
			doubleSlider.adjustSpace(curPos);
			return false;
		}
	})(nodes, this);

	nodes[0].onstop = (function(nodes, doubleSlider) {
		return function() {
			var elemLeft = parseInt(nodes[0].style.left) + doubleSlider.pointWidthL;
			var oldPos = doubleSlider.curPointsPos[0] ;
			doubleSlider.curPointsPos[0] = doubleSlider.calPos(elemLeft, true);		
			if (oldPos != doubleSlider.curPointsPos[0])
			{
				nodes[0].style.left = doubleSlider.curPointsPos[0]*doubleSlider.lenPerStep - doubleSlider.pointWidthL + "px";
				doubleSlider.rightSlider.minLeft = (doubleSlider.curPointsPos[0]+0.7)*doubleSlider.lenPerStep;
				
				doubleSlider.spaceBetweenSlider.style.left = nodes[0].style.left;
				doubleSlider.spaceBetweenSlider.style.width = parseInt(nodes[2].style.left) - parseInt(nodes[0].style.left) + 1  + "px";

				if (doubleSlider.onchanging)
				{
					doubleSlider.onchanging(doubleSlider.curPointsPos[0],doubleSlider.curPointsPos[1]);
				}
				if (doubleSlider.onchange)
				{

					doubleSlider.onchange(doubleSlider);
				}
				doubleSlider.adjustSpace(doubleSlider.curPointsPos[0]);
			}
			 

			return false;
		}
	})(nodes, this);
	nodes[2].onstop = (function(nodes, doubleSlider) {
		return function() {
			var elemLeft = parseInt(nodes[2].style.left) + doubleSlider.pointWidthR;
			var oldPos = doubleSlider.curPointsPos[1] ;
			doubleSlider.curPointsPos[1] = doubleSlider.calPos(elemLeft, false);
			if (oldPos != doubleSlider.curPointsPos[1])
			{				
				nodes[2].style.left = doubleSlider.curPointsPos[1]*doubleSlider.lenPerStep - doubleSlider.pointWidthR + "px";
				doubleSlider.leftSlider.maxLeft = (doubleSlider.curPointsPos[1]-1)*doubleSlider.lenPerStep - doubleSlider.pointWidthL;
				doubleSlider.spaceBetweenSlider.style.width = parseInt(nodes[2].style.left) - parseInt(doubleSlider.spaceBetweenSlider.style.left) + 1 + "px";
	
				if (doubleSlider.onchanging)
				{
					doubleSlider.onchanging(doubleSlider.curPointsPos[0],doubleSlider.curPointsPos[1]);
				}


				if (doubleSlider.onchange)
				{
					doubleSlider.onchange(doubleSlider);
				}
				doubleSlider.adjustSpace(doubleSlider.curPointsPos[1]);
			}
			 
			return false;
		}
	})(nodes, this);
}
                              
//end dragdrop2.js

//start options.js

//global variable
var	gHMgraph;
var gTimespan;

//test volatility 
//<script language="javascript">
HeatMap = function(){
this.title = "Total Market";
this.timestamp = ' ';
this.symbolTbl=['$MSTAR','$MVAL','$MCOR','$MGRO','$MLCP','$MLVL','$MLCR','$MLGR','$MMCP','$MMVL','$MMCR','$MMGR','$MSCP','$MSVL','$MSCR','$MSGR'];
this.volatilityTbl=[];//[20.11,20.11,20.11,20.11,30.22,30.22,30.22,30.22,40.33,40.33,40.33,40.33,50.44,50.44,50.44,50.44,null];
this.dayChangeTbl=[];//[1.11,1.11,1.11,1.11,2.22,2.22,2.22,2.22,3.33,3.33,3.33,3.33,4.44,4.44,4.44,4.44,null];
this.bgColorTbl=[];//['#3399ff','#3399ff','#3399ff','#3399ff','#6bb5ff','#6bb5ff','#6bb5ff','#6bb5ff','#99ccff','#d9d9d9','#ffcc66','#fea430','#fb8232','#fb8232','#fb8232','#fb8232',null ];
this.tdTbl=['hmC0','hmC1','hmC2','hmC3','hmC4','hmC5','hmC6','hmC7','hmC8','hmC9','hmC10','hmC11','hmC12','hmC13','hmC14','hmC15'];};
heatMap = new HeatMap();
//</script>

// this function gets the cookie, if it exists
function Get_Cookie( name ) {
	var start = document.cookie.indexOf( name + "=" );
	var len = start + name.length + 1;
	if ( ( !start ) &&
	( name != document.cookie.substring( 0, name.length ) ) )
	{
	return null;
	}
	if ( start == -1 ) return null;
	var end = document.cookie.indexOf( ";", len );
	if ( end == -1 ) end = document.cookie.length;
	return unescape( document.cookie.substring( len, end ) );
}

function collapseNav(leftId) 
{

	 if (!document.getElementById) return false;	
	 if (!document.getElementById(leftId + "Title")) return false;	  
	 if (!document.getElementById(leftId)) return false;
	 
	 //this part changes the navarrow when collapse left nav
	 var node;
	 var classN;
	 var idx;
	 node = document.getElementById(leftId + "Title");
	 classN = node.className;
	 idx= classN.indexOf("off");
	 if (idx >=0)
	 	classN = classN.substring(0,idx);
	 else
	 	classN = classN + "off";
	 node.className = classN;

	//this part collapses left nav
	 node = document.getElementById(leftId);	 
	 if (node.childNodes.length > 0) {
	  for (var i=0; i<node.childNodes.length; i++) {
	   var child = node.childNodes[i];
	   if (child.nodeName == "a" || child.nodeName == "A") {
		 if (child.style.display == "") {
		  child.style.display = "none";
		 } else {
		  child.style.display = "";
		 }
	   }
	  }
	 }
}

function hideLeftNav()
{
	collapseNav("LeftNews");
	collapseNav('LeftLearn');
	collapseNav('LeftDiscuss');
	collapseNav('LeftNewsLetter');
	collapseNav('LeftBooks');			
}

function ClearTicker()
{
	document.optionchainForm.optionchainTicker.value = "";
}

function submitOptionChainForm()
{
	var ticker = document.optionchainForm.optionchainTicker.value;
	
        if (ticker == "" || ticker == "Enter ticker") {
	     alert("Please Enter Ticker.");
		 return;
	}
	
	document.optionchainForm.action = "http://quote.morningstar.com/Option/Options.aspx?Ticker=" + ticker;
	document.optionchainForm.submit();	
}

getPosition=function(elem)
{
	var offsetTrail = elem;
	var offsetLeft = 0;
	var offsetTop = 0;
	while (offsetTrail) {
		offsetLeft += offsetTrail.offsetLeft;
		offsetTop += offsetTrail.offsetTop;
		offsetTrail = offsetTrail.offsetParent;
	}

	var res = {"left":offsetLeft,"top":offsetTop};

	return res;
	
};


QT_OverLay_Close = function()
{
	document.getElementById("defOL").style.display="none";
};

function showDef(id)
{
	var odefOL;
	odefOL = document.getElementById("defOL");
	document.getElementById("defContent").innerHTML = def[id]; 
	var temp = getPosition(document.getElementById("positionBase"));
	odefOL.style.left = temp["left"];
	odefOL.style.top = temp["top"] + 35;
	var title = document.getElementById("defTitle" + id).innerHTML; 
	document.getElementById("defTitle").innerHTML = title.replace(/<br>/gi," ")
	odefOL.style.display = "block";
}
			

var def = new Array();	

def[1] = 'Buy Bearish option investment strategies are used when fundamental research shows that the underlying security (stock) is overvalued (expensive) and implied volatility is low relative to the potential move in the stock (volatility is cheap).  '
		+ '<p>The "buy" in "buy bearish" refers to buying options (the net of the option strategy is the purchase of options). The reason to be a buyer of options is that the implied volatility is low (cheap) relative to the potential move in the stock price. </p>'
		+ '<p>The "bearish" in "buy bearish" refers to a strategy where the position makes money when the underlying security (stock) goes down in price. The reason to buy a bearish position is that you think the underlying security is overvalued, and therefore more likely to move down than up.  </p>'
		+ '<p>Buying a put is the simplest example of buying a bearish position.</p>';
def[2] = 'Bearish investment strategies are used when fundamental research says that the underlying security (stock) is overvalued (expensive) and implied volatility is fairly valued relative to the potential move in the stock (volatility is fairly priced). '
		+ '<p>Because the analysis of the stock is bearish, but the options are fairly valued, an investor who owned the stock would consider selling it. Also, depending on the level of conviction that the stock is overvalued and the understanding of the potential timing of the stock price correction, the investor could either pay a fair price for a put option strategy or sell the stock short.  </p>'
		+ '<p>Shorting a stock is the simplest example of taking a bearish position.</p>';
def[3] = 'Sell Bearish option investment strategies are used when fundamental research shows that the underlying security (stock) is overvalued (expensive) and implied volatility is high relative to the potential move in the stock (volatility is expensive).  '
		+ '<p>The "sell" in "sell bearish" refers to selling options (the net of the option strategy is the sale of options). The reason to be a seller of options is that the implied volatility is high (expensive) relative to the potential move in the stock price.  </p>'
		+ '<p>The "bearish" in "sell bearish" refers to a strategy where the position makes money when the underlying security (stock) goes down in price. The reason to sell a bearish position is that you think the underlying security is overvalued, and therefore more likely to move down than up. </p>'
		+ '<p>Selling a call is the simplest example of selling a bearish position.</p>'
def[4] = 'Buy Neutral option investment strategies are used when fundamental research shows that the underlying security (stock) is fairly valued and implied volatility is low relative to the potential move in the stock (volatility is cheap). '  
		+ '<p>The "buy" in "buy neutral" refers to buying options (the net of the option strategy is the purchase of options). The reason to be a buyer of options is that the implied volatility is low (cheap) relative to the potential move in the stock price. </p>' 
		+ '<p>The "neutral" in "buy neutral" refers to a strategy where the position makes money when the underlying security changes price, regardless of direction. The reason to buy a neutral position is that you think the underlying security is fairly valued, but may make a large move in either direction. </p>'
		+ '<p>Buying a straddle is the simplest example of buying a neutral position.</p>';

def[5] = 'Volatility Structure investment strategies are used when fundamental research says that the underlying security is fairly valued (priced right) and implied volatility is fairly valued relative to the potential move in the stock (volatility is priced right), but fundamental research says that the distribution of potential outcomes of the stock differ significantly from the distribution of potential outcomes priced into the options market. In other words, implied volatility is too high at some strike prices relative to other strike prices, or implied volatility is too high at one option expiration relative to another expiration.'
		+ '<p>Volatility structure refers to the way volatility varies over time and across strike prices.</p>' 
		+ '<p>The simplest example of a volatility structure investment is a time spread. In a time spread, investors buy an option with an expiration where the implied volatility is low, and sell an option with the same strike price, but with an expiration where the implied volatility is high. As time passes, assuming the large change in uncertainty is unwarranted, the two implied volatilities converge, and a profit is realized.</p>' 
def[6] = 'Sell Neutral option investment strategies are used when fundamental research shows that the underlying security (stock) is fairly valued and implied volatility is high relative to the potential move in the stock (volatility is expensive). '
		+ '<p>The "sell" in "sell neutral" refers to selling options (the net of the option strategy is the sale of options). The reason to be a seller of options is that the implied volatility is high (expensive) relative to the potential move in the stock price. </p>' 
		+ '<p>The "neutral" in "sell neutral" refers to a strategy where the position makes money when the underlying security does not change in price, regardless of direction. The reason to sell a neutral position is that you think the underlying security is fairly valued, and is unlikely to make a large move in either direction. </p>' 
		+ '<p>Selling a straddle is the simplest example of selling a neutral position.</p>' 

def[7] = 'Buy Bullish option investment strategies are used when fundamental research shows that that the underlying security (stock) is undervalued (cheap) and implied volatility is low relative to the potential move in the stock (volatility is cheap). '
		+ '<p>The "buy" in "buy bullish" refers to buying options (the net of the option strategy is the purchase of options). The reason to be a buyer of options is that the implied volatility is low (cheap) relative to the potential move in the stock price.  </p>'
		+ '<p>The "bullish" in "buy bullish" refers to a strategy where the position makes money when the underlying security (stock) goes up in price. The reason to buy a bullish position is that you think the underlying security is undervalued, and therefore more likely to move up than down. </p>' 
		+ '<p>Buying a call is the simplest example of buying a bullish position.</p>';

def[8] = 'Bullish investment strategies are used when fundamental research says that the underlying security (stock) is undervalued (cheap) and implied volatility is fairly valued relative to the potential move in the stock (volatility is priced right). '
		+ '<p>Because the analysis of the stock is bullish, but the options are fairly valued, an investor would buy the stock. Also, depending on the level of conviction that the stock is undervalued and the understanding of the potential timing of the stock price correction, the investor could either pay a fair price for a call option strategy or other bullish option strategy. </p>' 
		+ '<p>Buying the stock is the simplest example of taking a bullish position.</p>' 
def[9] = 'Sell Bullish option investment strategies are used when fundamental research shows that the underlying security (stock) is undervalued (cheap) and implied volatility is high relative to the potential move in the stock (volatility is expensive).  '
		+ '<p>The "sell" in "sell bullish" refers to selling options (the net of the option strategy is the sale of options). The reason to be a seller of options is that the implied volatility is high (expensive) relative to the potential move in the stock price.  </p>'
		+ '<p>The "bullish" in "sell bullish" refers to a strategy where the position makes money when the underlying security (stock) goes up in price. The reason to sell a bullish position is that you think the underlying security is undervalued, and therefore more likely to move up than down.  </p>'
		+ '<p>Selling a put is the simplest example of selling a bullish position.</p>'


function supersectorChg()
{
	var superSec
	superSec = document.getElementById("supersector").value;
	
	var idx = document.getElementById("supersector").selectedIndex;
	heatMap.title = document.getElementById("supersector").options[idx].text;
	
	//if not total market
	if (superSec != "0")
	{
		loadOptions("sector", superSec);
		document.getElementById("sectors").disabled = false;
	}
	else
	{
		document.getElementById("sectors").options.length = 1;
		document.getElementById("sectors").disabled = true;
	}
	document.getElementById("industries").options.length = 1;
	document.getElementById("industries").disabled = true;	
	
	reloadHeatmapData();	
}			

function sectorChg()
{
	var sectorVal;
	sectorVal = document.getElementById("sectors").value;
	
	//if not total market
	if (sectorVal != "")
	{
		var idx = document.getElementById("sectors").selectedIndex;
		if (idx != 0)
		{
			heatMap.title = document.getElementById("sectors").options[idx].text;
		}
		else
		{
			idx = document.getElementById("supersector").selectedIndex;
			heatMap.title = document.getElementById("supersector").options[idx].text;
		}	
		loadOptions("industries", sectorVal);		
		document.getElementById("industries").disabled = false;			
	} 
	else 
	{	
		document.getElementById("industries").options.length = 1;	
		document.getElementById("industries").disabled = true;
	}
	
	reloadHeatmapData();	

}			
			
function industryChg()
{
	var idx = document.getElementById("industries").selectedIndex;
	if (idx != 0)
	{
		heatMap.title = document.getElementById("industries").options[idx].text;
	}
	else
	{
		idx = document.getElementById("sectors").selectedIndex;
		heatMap.title = document.getElementById("sectors").options[idx].text;
	}		
	
	reloadHeatmapData();
}			
		
function durationChg(stimespan)
{
	gTimespan = stimespan;
	
	for (var i = 1; i < 5; i++)
	{
		document.getElementById("dur" + i).className = "LL10";				
	}
	if (gTimespan == 'M1')	document.getElementById("dur1").className = "LL10on";
	else if (gTimespan == 'M3')	document.getElementById("dur2").className = "LL10on";
	else if (gTimespan == 'Y1')	document.getElementById("dur3").className = "LL10on";
	else if (gTimespan == '')	document.getElementById("dur4").className = "LL10on";		
		
	reloadHeatmapData();	
}
			
function addOption(theSel, theText, theValue)
{
  var newOpt = new Option(theText, theValue);
  var selLength = theSel.length;
  theSel.options[selLength] = newOpt;
}
			
function loadOptions(area, val)
{
	if (area == "sector")
	{
		var oSelect = document.getElementById("sectors");
		oSelect.options.length = 1;

		for (var i = 0; sectorIndustry.sectorTbl[i] != null; i++) 
		{
			if (sectorIndustry.sectorTbl[i][0] == val)
			{
				addOption(oSelect, sectorIndustry.sectorTbl[i][2], sectorIndustry.sectorTbl[i][1]);
			}				
		}
		
	}
	else if (area == "industries")
	{
		var oSelect = document.getElementById("industries");		
		oSelect.options.length = 1;
		for(var i=0; sectorIndustry.sectorIndustryTbl[i]!=null; i++)
		{
			if (sectorIndustry.sectorIndustryTbl[i][0] == val)
			{
				addOption(oSelect, sectorIndustry.sectorIndustryTbl[i][2], sectorIndustry.sectorIndustryTbl[i][1]);
			}
		}
	}
	
}	

var regularLoadDataTimerId;
var regularLoadDataTime = 5*60*1000;


function reloadHeatmapData()
{

	window.clearTimeout(regularLoadDataTimerId);
	//hide heatmap for data downloading
	gHMgraph = document.getElementById("MAPX").innerHTML;
	document.getElementById("MAPX").innerHTML = "<img src='http://tools.morningstar.com/webgraphs/LoadingScreenAnimation.gif'>";

	// reload heatmap data
	var qs = getHMparam();
	getHMContent("/Cover/DBOption.aspx" + qs +getRangeInfo() + "&t1="+Math.random( ));
}

function updHeatmap()
{
	for (var i=0; i<16; i++)
	{
		var td = document.getElementById(heatMap.tdTbl[i]);
		td.style.backgroundColor = heatMap.bgColorTbl[i];
		td.innerHTML = heatMap.volatilityTbl[i];
	}
	//document.getElementById("hmValue").innerHTML = heatMap.volatilityTbl[0];
	document.getElementById("hmTitle").innerHTML = heatMap.title;	
}

function chgVolatilityValue(i)
{
	
	document.getElementById("hmValue").innerHTML = heatMap.volatilityTbl[i];
}

function getXMLHTTP()
{
	var A=null;
	try{
		A=new ActiveXObject("Msxml2.XMLHTTP")
	}
	catch(e){
		try{
			A=new ActiveXObject("Microsoft.XMLHTTP")
		}
		catch(oc){
			A=null
		}
	}
	if(!A && typeof XMLHttpRequest != "undefined") {
		A=new XMLHttpRequest()
	}
	return A
}
		
function getHMContent(url)
{
	var xmlhttp=getXMLHTTP();
	xmlhttp.onreadystatechange=function() {
			if (xmlhttp.readyState==4) 
			{	
				var str = xmlhttp.responseText;	
				var str2 = str.split(";");	
				
				var vol = str2[1].split(",");
				var chg = str2[2].split(",");
				var color = str2[3].split(",");
				
				//var idxPrice = str2[4].split(",");
				//var idxVol = str2[5].split(",");
				
				setRangeInfo(doubleSlider.curPointsPos[0], doubleSlider.curPointsPos[1]);
				
				for (var i=0; i<16; i++)		
				{	
					if (vol[i] == '--')
					{
						heatMap.volatilityTbl[i] = '---';
					}
					else
					{
						heatMap.volatilityTbl[i] = Math.round(Number(vol[i]));
					}
					heatMap.dayChangeTbl[i] = chg[i];
					heatMap.bgColorTbl[i] = color[i];					
				}
				document.getElementById("MAPX").innerHTML = gHMgraph;
				updHeatmap();
					/*						
				for (var i=0; i<4; i++)
				{
					idxTable.price[i] = idxPrice[i];
					idxTable.volatility[i] = idxVol[i];					
					document.getElementById("idxPrice" + i).innerHTML = idxTable.price[i];	
					document.getElementById("idxVolatility" + i).innerHTML = idxTable.volatility[i];						
				}*/
				 regularLoadDataTimerId = window.setTimeout("reloadHeatmapData()", regularLoadDataTime);
			}
		}
	xmlhttp.open("GET",url,true);		
	xmlhttp.send(null);
}

function getHMparam()
{
	return ("?super=" + document.getElementById("supersector").value + "&sector=" + document.getElementById("sectors").value + "&industry=" + document.getElementById("industries").value + "&stocktype=" + document.getElementById("stocktype").value + "&time=" + gTimespan);
}
//default of heatmap is for total market

var posFor2YrMore = [25, 27, 30, 36, 48, 60,72,84, 99];
function adjust2yrMore(pos)
{
	if (pos > 24)
	{
		return posFor2YrMore[pos-25];
	}
	return pos;
}
function setRangeInfo(start, end)
{
	if (start < 10)
	{
		start = " " + start;
	}
	if (end < 10)
	{
		end = " " + end;
	}
	else
	{
		end = adjust2yrMore(end);
	}
	document.getElementById("timestamp").innerHTML = start + "mo~" + end + "mo";
}
function getRangeInfo()
{
	return "&startExp=" + doubleSlider.curPointsPos[0] + "&endExp=" 
		+ adjust2yrMore(doubleSlider.curPointsPos[1]) + "&getRange=yes"
}

var doubleSlider;
function reset()
{
	document.getElementById("supersector").options[0].selected = true;
	document.getElementById("stocktype").options[0].selected = true;	
	gTimespan = "";
	
	var one = document.getElementById("Slider1_railElement");
	doubleSlider = new DoubleSlider(one, [0, 24],[1,33], [1, 3, 6, 12, 24], [0, 33], [0,33], 5, 3, 'http://im.morningstar.com/im/point.gif');
	doubleSlider.onchange = reloadHeatmapData;
	doubleSlider.onchanging = setRangeInfo;	

	//initialize heatmap with market data
	regularLoadDataTimerId = window.setTimeout("reloadHeatmapData()", 1);
}

//test sector industry information
/*
<script language="javascript">
SectorIndustry = function(){
this.sectorTbl=[[2,6,'Business Services'],[3,9,'Industrial Materials'],[3,8,'Consumer Goods'],[2,4,'Healthcare'],[2,5,'Consumer Services'],[1,2,'Media'],[3,10,'Energy'],[1,1,'Hardware'],[1,0,'Software'],[3,11,'Utilities'],[2,7,'Financial Services'],[1,3,'Telecommunication'],null];
this.sectorIndustryTbl=[[6,20819065,'Advertising'],[9,31030099,'Aerospace & Defense'],[9,31032102,'Agricultural Machinery'],[9,31036119,'Agriculture'],[9,31031100,'Agrochemical'],[6,20822077,'Air Transport'],[8,30926091,'Alcoholic Drinks'],[9,31035112,'Aluminum'],[8,30923081,'Apparel Makers'],[4,20508025,'Assisted Living'],[8,30925086,'Audio/Video Equipment'],[8,30924084,'Auto Makers'],[9,31032110,'Auto Parts'],[5,20717052,'Auto Retail'],[8,30926092,'Beverage Mfg.'],[4,20507022,'Biotechnology'],[2,10305014,'Broadcast TV'],[9,31033110,'Building Materials'],[6,20819067,'Business Support'],[2,10305015,'Cable TV'],[9,31031101,'Chemicals'],[5,20717053,'Clothing Stores'],[10,31141129,'Coal'],[1,10204011,'Components'],[1,10202005,'Computer Equipment'],[6,20820074,'Business/Online Services'],[9,31032103,'Construction Machinery'],[6,20819068,'Consultants'],[1,10202006,'Contract Manufacturers'],[1,10203007,'Data Networking'],[6,20820075,'Data Processing'],[5,20717054,'Department Stores'],[0,10101002,'Development Tools'],[4,20509030,'Diagnostics'],[5,20717055,'Discount Stores'],[6,20821076,'Distributors'],[9,31034111,'Diversified'],[4,20507023,'Drugs'],[5,20714047,'Education'],[9,31032104,'Electric Equipment'],[11,31240126,'Electric Utilities'],[5,20717056,'Electronics Stores'],[6,20819069,'Employment'],[6,20819070,'Engineering & Construction'],[0,10101003,'Entertainment/Education Media'],[6,20819071,'Environmental Control'],[2,10305016,'Film & TV Production'],[7,20611036,'Finance'],[8,30926093,'Food Mfg.'],[5,20717058,'Food Wholesale'],[9,31036118,'Forestry/Wood'],[8,30927095,'Appliance & Furniture Makers'],[5,20717059,'Furniture Retail'],[5,20718062,'Gambling/Hotel Casinos'],[9,31035113,'Gold & Silver'],[5,20717057,'Groceries'],[4,20508027,'Managed Care'],[5,20715049,'Home Building'],[4,20508028,'Home Health'],[5,20715050,'Home Supply'],[4,20508026,'Hospitals'],[5,20718063,'Hotels'],[8,30927094,'Household & Personal Products'],[7,20612040,'Insurance (General)'],[7,20612041,'Insurance (Life)'],[7,20612042,'Insurance (Property)'],[7,20612043,'Insurance (Title)'],[7,20610033,'International Banks'],[8,30925087,'Jewelry/Accessories'],[6,20822078,'Land Transport'],[9,31032105,'Machinery'],[9,31032106,'Manufacturing - Misc.'],[2,10305017,'Media Conglomerates'],[4,20509031,'Medical Equipment'],[4,20509032,'Medical Goods & Services'],[9,31035114,'Metal Products'],[9,31035115,'Mining (Nonferrous & Nonmetals)'],[7,20611037,'Money Management'],[11,31240127,'Natural Gas Utilities'],[9,31032107,'Office Equipment'],[10,31137122,'Oil & Gas'],[10,31137123,'Oil/Gas Products'],[10,31138124,'Oil & Gas Services'],[5,20717060,'Online Retail'],[1,10203008,'Optical Equipment'],[8,30928097,'Packaging'],[8,30927096,'Paints/Coatings'],[9,31036117,'Paper'],[5,20714048,'Personal Services'],[4,20508029,'Physicians'],[10,31139125,'Pipelines'],[9,31036120,'Plastics'],[6,20819066,'Printing'],[2,10305018,'Publishing'],[2,10305019,'Radio'],[7,20613045,'Real Estate'],[8,30925088,'Photography & Imaging'],[8,30925089,'Recreation'],[7,20610034,'Regional Banks'],[7,20612044,'Reinsurance'],[7,20613046,'REITS'],[5,20716051,'Rental & Repair Services'],[4,20507024,'Research Services'],[5,20718064,'Restaurants'],[9,31036121,'Rubber Products'],[7,20611038,'Savings & Loans'],[7,20611039,'Securities'],[6,20819072,'Security Services'],[1,10204012,'Semiconductor Equipment'],[1,10204013,'Semiconductors'],[8,30923082,'Shoes'],[0,10101001,'Business Applications'],[5,20717061,'Specialty Retail'],[9,31035116,'Steel/Iron'],[7,20610035,'Super Regional Banks'],[0,10101004,'Systems & Security'],[3,10406020,'Telecommunication Services'],[8,30923083,'Textiles'],[8,30929098,'Tobacco'],[8,30925090,'Toys/Hobbies'],[6,20822079,'Transportation - Misc'],[9,31032108,'Transport Equipment'],[9,31032109,'Truck Makers'],[6,20819073,'Waste Management'],[6,20822080,'Water Transport'],[11,31240128,'Water Utilities'],[1,10203009,'Wireless Equipment'],[3,10406021,'Wireless Service'],[1,10203010,'Wireline Equipment'],null];};
sectorIndustry = new SectorIndustry();</script>
*/
//end options.js

//start mjx.js

	<!------ OAS SETUP begin ------>
	var l_usertype;
	l_usertype = Get_Cookie( "PSI" );
	
	if (l_usertype == "S")
		{OAS_listpos = 'Top1,Top,Bottom,Left,Left2,Left3,Right,x43,Position1,Position2,Position3,Position4,Bottom1,Bottom2,x23';}
	else
		{OAS_listpos = 'Top1,TopLeft,Bottom,Left,Left2,Left3,Right,x07,x08,x30,Position1,Position2,Position3,Position4,Bottom1,Bottom2,x23';}

OAS_query = 'area=OPTIONS';	
OAS_sitepage = 'www.morningstar.com/options';
	
	//configuration
	OAS_query = '';	
	OAS_sitepage = 'www.morningstar.com/options';
	
	OAS_url ='http://ads.morningstar.com/RealMedia/ads/';
	//end of configuration
	OAS_version = 10;
	OAS_rn = '001234567890'; OAS_rns = '1234567890';
	OAS_rn = new String (Math.random()); OAS_rns = OAS_rn.substring (2, 11);
	
	function OAS_NORMAL(pos) { 
		document.write('<A HREF="' + OAS_url + 'click_nx.ads/' + OAS_sitepage + '/1' + OAS_rns + '@' + OAS_listpos + '!' + pos + '?' + OAS_query + '" TARGET=_top>');
		document.write('<IMG SRC="' + OAS_url + 'adstream_nx.ads/' + OAS_sitepage + '/1' + OAS_rns + '@' + OAS_listpos + '!' + pos + '?' + OAS_query + '" BORDER=0></A>');
	}
	
	OAS_version = 11;
	if ((navigator.userAgent.indexOf('Mozilla/3') != -1) || (navigator.userAgent.indexOf('Mozilla/4.0 WebTV') != -1))
	OAS_version = 10;
	if (OAS_version >= 11)
	document.write('<SCR'+ 'IPT LANGUAGE=JavaScript1.1 SRC="' + OAS_url + 'adstream_mjx.ads/' + OAS_sitepage + '/1' + OAS_rns + '@' + OAS_listpos + '?' + OAS_query + '"><\/SCRIPT>');
	 
	 document.write('');
	
	function OAS_AD(pos) {
		if (OAS_version >= 11)
		OAS_RICH(pos);
		else
		OAS_NORMAL(pos);
	}
	
	<!------ OAS SETUP end ------>
//end mjx.js
//start AC_RunActiveContent.js
//v1.7
// Flash Player Version Detection
// Detect Client Browser type
// Copyright 2005-2007 Adobe Systems Incorporated.  All rights reserved.
var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;

function ControlVersion()
{
	var version;
	var axo;
	var e;

	// NOTE : new ActiveXObject(strFoo) throws an exception if strFoo isn't in the registry

	try {
		// version will be set for 7.X or greater players
		axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
		version = axo.GetVariable("$version");
	} catch (e) {
	}

	if (!version)
	{
		try {
			// version will be set for 6.X players only
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
			
			// installed player is some revision of 6.0
			// GetVariable("$version") crashes for versions 6.0.22 through 6.0.29,
			// so we have to be careful. 
			
			// default to the first public version
			version = "WIN 6,0,21,0";

			// throws if AllowScripAccess does not exist (introduced in 6.0r47)		
			axo.AllowScriptAccess = "always";

			// safe to call for 6.0r47 or greater
			version = axo.GetVariable("$version");

		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 4.X or 5.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = axo.GetVariable("$version");
		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 3.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = "WIN 3,0,18,0";
		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 2.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
			version = "WIN 2,0,0,11";
		} catch (e) {
			version = -1;
		}
	}
	
	return version;
}

// JavaScript helper required to detect Flash Player PlugIn version information
function GetSwfVer(){
	// NS/Opera version >= 3 check for Flash plugin in plugin array
	var flashVer = -1;
	
	if (navigator.plugins != null && navigator.plugins.length > 0) {
		if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
			var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
			var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
			var descArray = flashDescription.split(" ");
			var tempArrayMajor = descArray[2].split(".");			
			var versionMajor = tempArrayMajor[0];
			var versionMinor = tempArrayMajor[1];
			var versionRevision = descArray[3];
			if (versionRevision == "") {
				versionRevision = descArray[4];
			}
			if (versionRevision[0] == "d") {
				versionRevision = versionRevision.substring(1);
			} else if (versionRevision[0] == "r") {
				versionRevision = versionRevision.substring(1);
				if (versionRevision.indexOf("d") > 0) {
					versionRevision = versionRevision.substring(0, versionRevision.indexOf("d"));
				}
			}
			var flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
		}
	}
	// MSN/WebTV 2.6 supports Flash 4
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
	// WebTV 2.5 supports Flash 3
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
	// older WebTV supports Flash 2
	else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
	else if ( isIE && isWin && !isOpera ) {
		flashVer = ControlVersion();
	}	
	return flashVer;
}

// When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available
function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision)
{
	versionStr = GetSwfVer();
	if (versionStr == -1 ) {
		return false;
	} else if (versionStr != 0) {
		if(isIE && isWin && !isOpera) {
			// Given "WIN 2,0,0,11"
			tempArray         = versionStr.split(" "); 	// ["WIN", "2,0,0,11"]
			tempString        = tempArray[1];			// "2,0,0,11"
			versionArray      = tempString.split(",");	// ['2', '0', '0', '11']
		} else {
			versionArray      = versionStr.split(".");
		}
		var versionMajor      = versionArray[0];
		var versionMinor      = versionArray[1];
		var versionRevision   = versionArray[2];

        	// is the major.revision >= requested major.revision AND the minor version >= requested minor
		if (versionMajor > parseFloat(reqMajorVer)) {
			return true;
		} else if (versionMajor == parseFloat(reqMajorVer)) {
			if (versionMinor > parseFloat(reqMinorVer))
				return true;
			else if (versionMinor == parseFloat(reqMinorVer)) {
				if (versionRevision >= parseFloat(reqRevision))
					return true;
			}
		}
		return false;
	}
}

function AC_AddExtension(src, ext)
{
  if (src.indexOf('?') != -1)
    return src.replace(/\?/, ext+'?'); 
  else
    return src + ext;
}

function AC_Generateobj(objAttrs, params, embedAttrs) 
{ 
  var str = '';
  if (isIE && isWin && !isOpera)
  {
    str += '<object ';
    for (var i in objAttrs)
    {
      str += i + '="' + objAttrs[i] + '" ';
    }
    str += '>';
    for (var i in params)
    {
      str += '<param name="' + i + '" value="' + params[i] + '" /> ';
    }
    str += '</object>';
  }
  else
  {
    str += '<embed ';
    for (var i in embedAttrs)
    {
      str += i + '="' + embedAttrs[i] + '" ';
    }
    str += '> </embed>';
  }

  document.write(str);
}

function AC_FL_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_SW_RunContent(){
  var ret = 
    AC_GetArgs
    (  arguments, ".dcr", "src", "clsid:166B1BCA-3F9C-11CF-8075-444553540000"
     , null
    );
  AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
  var ret = new Object();
  ret.embedAttrs = new Object();
  ret.params = new Object();
  ret.objAttrs = new Object();
  for (var i=0; i < args.length; i=i+2){
    var currArg = args[i].toLowerCase();    

    switch (currArg){	
      case "classid":
        break;
      case "pluginspage":
        ret.embedAttrs[args[i]] = args[i+1];
        break;
      case "src":
      case "movie":	
        args[i+1] = AC_AddExtension(args[i+1], ext);
        ret.embedAttrs["src"] = args[i+1];
        ret.params[srcParamName] = args[i+1];
        break;
      case "onafterupdate":
      case "onbeforeupdate":
      case "onblur":
      case "oncellchange":
      case "onclick":
      case "ondblclick":
      case "ondrag":
      case "ondragend":
      case "ondragenter":
      case "ondragleave":
      case "ondragover":
      case "ondrop":
      case "onfinish":
      case "onfocus":
      case "onhelp":
      case "onmousedown":
      case "onmouseup":
      case "onmouseover":
      case "onmousemove":
      case "onmouseout":
      case "onkeypress":
      case "onkeydown":
      case "onkeyup":
      case "onload":
      case "onlosecapture":
      case "onpropertychange":
      case "onreadystatechange":
      case "onrowsdelete":
      case "onrowenter":
      case "onrowexit":
      case "onrowsinserted":
      case "onstart":
      case "onscroll":
      case "onbeforeeditfocus":
      case "onactivate":
      case "onbeforedeactivate":
      case "ondeactivate":
      case "type":
      case "codebase":
      case "id":
        ret.objAttrs[args[i]] = args[i+1];
        break;
      case "width":
      case "height":
      case "align":
      case "vspace": 
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
      case "tabindex":
        ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
        break;
      default:
        ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
    }
  }
  ret.objAttrs["classid"] = classid;
  if (mimeType) ret.embedAttrs["type"] = mimeType;
  return ret;
}

//end AC_RunActiveContent.js
