/*'''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Name: SetChecked()
Author: Jgreen
Use: checks or unchecks all checkboxes
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''*/		
function SetChecked(blnVal) 
{
	var sForm 	= document.frmCompare;
	var sLength = sForm.elements.length;

	for(var i = 0; i < sLength; i++) 
	{
		var sElement = sForm.elements[i];
		if (sElement.name.substr(0,4) == 'comp') 
			sElement.checked = blnVal;
	}
}

/*'''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Name: ValidateChart()
Author: Jgreen
Use: Function Validates that Intraday Times and Frequencies
     are only charted vs. each other.
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''*/			
function ValidateChart(me)
{
	var sFreq = me.control_freq.options[me.control_freq.selectedIndex].value;
	var sTime = me.control_time.options[me.control_time.selectedIndex].value;
	var iTime = 1;
	var iFreq = 1;
	
	var sTimeSubstr = sTime.substr(sTime.length - 2,2);
	if ((sTimeSubstr == "hr") || (sTimeSubstr == "dy"))
		iTime = 0;
	
	var sFreqSubstr = sFreq.substr(sFreq.length - 2,2);
	if ((sFreqSubstr == "mi" ) || (sFreqSubstr == "hr" )) 
		iFreq = 0;
	
	var iCount = iFreq + iTime;
	if (iCount == 1)
	{
		alert("Intraday Times and Frequencies must be charted together");
		return false;
	}
	else
	{
		return true;
	}
}

/* *****************************************
added by Paul McGeehan
takes into account all necessary CCBN javascript
******************************************** */
function openCapsule(url, name, prop)
					{
				sizedWindow = window.open(url, name, prop);
					{
					setTimeout('sizedWindow.focus();', 250);
					}
				}
			

function go(where) {
				if (where != "-") {
				self.location = where;
				
			}
		}
			 
			function navigate(obj) {
			    idx = obj.selectedIndex;
			    url = obj.options[idx].value;
			
			    if (url == "URL") {
			        str = obj.options[idx].text;
			        i = 0;
			        finished = false;
			
			        while (!finished) {
			            if (((str.charAt(i) > "A") && (str.charAt(i) < "z")) || i >= str.length)
			                finished = true;
			            else
			                i++;
			        }
			
			        url = window.location.protocol+'//'+window.location.host+"http:/" + str.substring(i,str.length);
			    }
			
			    if (url != "") {
			        window.location = url;
			    }
			}

/*'''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Author: JDelia
Use: For use with News Navigation
1) write the select drop-down to the page and; 
2) handle the changing of the page when an new option is selected
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''*/
function ccbnGetQS(){
  var theLocation = self.location;
  var ccbn_i, qString = theLocation.search.substr(1);
  var queryString = new Object();
  if (qString.length > 0) {
    var params = qString.replace(/\+/g, " ").split("&");
	for (ccbn_i = 0; ccbn_i < params.length; ccbn_i++) {
	  params[ccbn_i] = unescape(params[ccbn_i]).split("=");
	  queryString[params[ccbn_i][0]] = params[ccbn_i][1];
	}
  }
  return queryString;
 }

function ccbnWriteOption(nyo, year){
  var queryString = ccbnGetQS();
  document.write('<option value="' + nyo + '"');
  if(nyo==queryString["nyo"]){
      document.write(' selected="selected"');
  }
  document.write('>' + year + '</option>');
}

function ccbnNewsGo(theSelect){
  var yearOffset = theSelect.options[theSelect.selectedIndex].value;
  var theLocation = self.location;  
  var tempLocation;
  var queryString = ccbnGetQS();
   if(yearOffset==-1) return
   if(queryString["nyo"]){
     var currentNYO="&nyo=" + queryString["nyo"];
     var replaceNYO="&nyo=" + yearOffset;
         tempLocation = theLocation.href.replace(currentNYO,replaceNYO);
   }
   else{
      tempLocation = theLocation + "&nyo=" + yearOffset
   }
   
   if(queryString["t"]){
     var currentSearch="&t=" + queryString["t"];
     var replaceSearch="";  
         tempLocation = tempLocation.replace(currentSearch,replaceSearch);
   }
   location = tempLocation;
}

/*'''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Author: JDelia
Use: Created for Edgar Interactive Charts but can be used
for other functionality going forward
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''*/
/*      CONSTANTS      */
var CCBN_SHOW = "visible";
var CCBN_HIDE = "hidden";
var CCBN_SHOW_DISPLAY = "block";
var CCBN_HIDE_DISPLAY = "none";
var CCBN_TIMER = 500;
var CCBN_GET_X = 0;
var CCBN_GET_Y = 1;
var CCBN_GET_XY = 2;
var CCBN_BIOHOVER = 0;
var CCBN_NEWSHOVER = 1;
var CCBN_EVENTHOVER = 2;
var CCBN_DEFINITIONHOVER = 3;
var CCBN_OVER = 0;
var CCBN_OUT = 1;
var CCBN_IE = "Microsoft Internet Explorer";
/*      CONSTANTS      */

/* GLOBALS */
var ccbn_mozMouseX, ccbn_mozMouseY, ccbn_popover_width, ccbn_fhObj, ccbnTimeout, ccbnHoverReady;

var ccbn_appName=navigator.appName;
var ccbn_appVersion=navigator.appVersion;
var ccbn_offsetX=10;
var ccbn_offsetY=5;
var ccbn_no_doctype=false;
/* GLOBALS */

/* used to add new window events (onmouseover, onresize, etc) without 
   losing any other events that have been set */
function ccbnAddEvent(which, func){
	var oldEvent = which;
	if(typeof oldEvent != 'function') newEvent = func;
	else{
		newEvent = function(){
			if(oldEvent) oldEvent();
			func();
		}
	}
	return newEvent
}

/* used to add new window onload event without 
   losing any other events that have been set */
function ccbnAddLoadEvent(_function){ 
	var _onload = window.onload;
	if ( typeof window.onload != 'function' ){
		if ( window.onload ){
			window.onload = _function;
		}
		else{
			var _addEventListener = window.addEventListener || document.addEventListener;
			var _attachEvent = window.attachEvent || document.attachEvent;
			if ( _addEventListener ){
				_addEventListener('load', _function, true);
				return true;
			}
			else if ( _attachEvent ){
				var _result = _attachEvent('onload', _function);
				return _result;
			}
			else{
				//todo: preloading fix for ie5.2 on mac os
				return false;
			}
		}
	} 
	else{
		window.onload = function(){
			_onload();
			_function();
		}
	}
}

function ccbnCloneToBody(objID){
	var obj = ccbnGetObj(objID);
	if(obj.parentNode!=document.body){
		var tmpNode = obj.cloneNode(true);
		tmpNode.style.left=tmpNode.style.top=0;
		obj.parentNode.removeChild(obj);
		document.body.appendChild(tmpNode);
	}
}

function ccbnCloseObj(id){ if(!ccbnGetObj(id)) return; ccbnShowHide(ccbnGetObj(id),CCBN_HIDE); }

/* moves the object to the specified X and Y coordinates */
function ccbnDoMove(objectID, moveToX, moveToY, moveToPx) {
    if (document.layers && document.layers[objectID] != null) {
        document.layers[objectID].left = moveToX + moveToPx;
        document.layers[objectID].top = moveToY + moveToPx;
    }
    else if (document.all) {
        document.all[objectID].style.posLeft = moveToX;
        document.all[objectID].style.posTop = moveToY;
    }
    else if (document.getElementById){
       document.getElementById(objectID).style.left = moveToX + moveToPx;
       document.getElementById(objectID).style.top = moveToY + moveToPx;
    }
}

function ccbnEObj(){return(ccbn_appName=="Netscape"?'event':'\'\'');}

/* finds the position of the object and returns X and Y coordinates in an array */
function ccbnFindPos(obj){
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft;
		curtop = obj.offsetTop;
		while (obj = obj.offsetParent){
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		}
	}
	return [curleft,curtop];
}

/* splits a string based on the & character
   returns the parameter / value pair as an object */
function ccbnGetArgs(query){
	var args = new Object();
	var pairs = query.split("&");
	for(ccbn_i=0; ccbn_i<pairs.length;ccbn_i++){
		var pos = pairs[ccbn_i].indexOf('=');
		if(pos == -1){ break;}
		var argname = pairs[ccbn_i].substring(0,pos);
		var value = pairs[ccbn_i].substring(pos+1);
		args[argname] = unescape(value);
	}
	return args;
}

/* returns the dimensions of the browser window
   parameter getWhich
   			0 - returns the width of the window
			1 - returns the height of the window
			2 - returns both width and height
 */
function ccbnGetBrowserDimensions(getWhich){
	var tmpX, tmpY, tmpArray;
	if (self.innerHeight) // all except Explorer
	{
		tmpX = self.innerWidth;
		tmpY = self.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientHeight) // Explorer 6 Strict Mode
	{
		tmpX = document.documentElement.clientWidth;
		tmpY = document.documentElement.clientHeight;
	}
	else if (document.body) // other Explorers
	{
		tmpX = document.body.clientWidth;
		tmpY = document.body.clientHeight;
	}
	
	tmpArray = new Array(tmpX, tmpY);
	if(getWhich == CCBN_GET_XY) return tmpArray;
	else return tmpArray[getWhich];
}

/* finds the value of the selector that is passed */
function ccbnGetCSSValue(selector){
       var ccbn_sheetList = document.styleSheets;
       var ccbn_ruleList;
       var ccbn_i, ccbn_j;
	   
       for (ccbn_i=0;ccbn_i<ccbn_sheetList.length;ccbn_i++)
       {
	   	try{
           if(ccbn_sheetList[ccbn_i].rules) ccbn_ruleList = ccbn_sheetList[ccbn_i].rules;
		   else if(ccbn_sheetList[ccbn_i].cssRules) ccbn_ruleList = ccbn_sheetList[ccbn_i].cssRules;
		   else break;

           for (ccbn_j=0; ccbn_j<ccbn_ruleList.length; ccbn_j++)
           {
               if (ccbn_ruleList[ccbn_j].selectorText == selector)
               {
			   	   var ccbn_cssValue = ccbn_ruleList[ccbn_j].style.cssText.toLowerCase();
				   ccbn_cssValue=ccbn_cssValue.replace(/; /g, ';');
               }   
           }
		  }
		  catch(e){}  //try catch for cross domain access issue
       }
	return ccbn_cssValue;	   
}

/* find the current position of the mouse */
function ccbnGetMouseXY(e) {
  if(ccbn_appName!="Netscape") { // grab the x-y pos.s if browser is IE
    if ((!document.compatMode || document.compatMode == 'BackCompat') && document.body && typeof document.body.scrollLeft != 'undefined'){
        ccbn_scrollLeft = document.body.scrollLeft;
        ccbn_scrollTop = document.body.scrollTop;
     }
     else{
        ccbn_scrollLeft = document.documentElement.scrollLeft;
        ccbn_scrollTop = document.documentElement.scrollTop;
    }
    ccbn_tempX = event.clientX + ccbn_scrollLeft;
    ccbn_tempY = event.clientY + ccbn_scrollTop;
  } else {  // grab the x-y pos.s if browser is NS
    ccbn_tempX = e.pageX;
    ccbn_tempY = e.pageY;
  }  

  // catch possible negative values in NS4
  if (ccbn_tempX < 0){ccbn_tempX = 0}
  if (ccbn_tempY < 0){ccbn_tempY = 0}  

  ccbn_mozMouseX = ccbn_tempX;
  ccbn_mozMouseY = ccbn_tempY;
  return true;
}

/* returns the ccbnAjaxObject based on the module name that is passed */
function ccbnGetAjaxObjByModuleName(moduleName){
	for(ccbn_i=0;ccbn_i<ccbnAjaxObject.length;ccbn_i++){
		if(ccbnAjaxObject[ccbn_i].moduleName == moduleName) {
			return ccbnAjaxObject[ccbn_i];
		}
	}
}

/* cross browser method that finds named DOM objects on a page */
function ccbnGetObj(objName){
	if (document.layers && document.layers[objName] != null){ return document.layers[objName]; }
	else if (document.all){ return document.all[objName]; }
	else if (document.getElementById){ return document.getElementById(objName); }
}

/* function called by the mouse over moudles to display hidden divs */
function ccbnHandleHover(theAnchor, theType, theEvent){
	var ccbnTheHref = theAnchor.href.toLowerCase();
	var anchorArgs = ccbnGetArgs(ccbnTheHref);
	
	var theID;
	
	if(!ccbnHoverReady){ ccbnSetupHovers(); return; }
	switch(theType){
			case CCBN_BIOHOVER:			if(theEvent==CCBN_OVER){
											if(!anchorArgs.id) break;
											theID = "bio" + anchorArgs.id;
											ccbnOpenObj(theID);
										}
										else ccbnStartTimer();
										break;
			case CCBN_NEWSHOVER:		if(theEvent==CCBN_OVER){
											if(!anchorArgs.id) break;
											theID = "release" + anchorArgs.id;
											ccbnOpenObj(theID);
										}
										else ccbnStartTimer();
										break;
			case CCBN_EVENTHOVER:		if(theEvent==CCBN_OVER){
											if(anchorArgs.item_id) theID = "eventHeader" + anchorArgs.item_id;
											else if(anchorArgs.eventid) theID = "eventHeader" + anchorArgs.eventid;
											else break;
											ccbnOpenObj(theID);
										}
										else ccbnStartTimer();
										break;
			case CCBN_DEFINITIONHOVER:	if(theEvent==CCBN_OVER){
											anchorArgs = ccbnGetArgs(theAnchor.href);  //have to redo this because of case sensitivity
											var defID = anchorArgs.def_id;
											var refModuleType = anchorArgs.mt;
											var defSource = refModuleType;
											
											/* remove bad characters from definition id */
											defID = defID.replace(/%*/g,"")
											
											/*  need to change value of refMoudleType in certain situations
											    this logic matches the logic found in the Engine */
											if(refModuleType == "TFSnapshot"){
												defSource = "Multex";
												switch(defID){
													case "APR2REV": case "APRCFPS": case "APRICE2BK": case "ATOTD2EQ":
													case "DIVTRENDGR": case "REVTRENDGR": case "NITRENDGR": case "ACURRATIO":
														defSource = "Worldscope";
												}
											}
											
											if(refModuleType == "TFTradingStatistics"){
												defSource = "Multex Market Guide";
												switch(defID){
													case "6": case "7": case "17":
														defSource = "MarketWatch";
												}
											}
											
											if(refModuleType == "TFRatios"){
												switch(defID){
													case "AROIPCT": case "APMGN": case "APMGNPCT": case "316": case "ACURRATIO":
													case "AINVTURN": case "ARECTURN": case "AASTTURN": case "AROAPCT": case "AROEPCT":
													case "391": case "APR2REV": case "APRCFPS": case "ATOTD2EQ": case "APRICE2BK": case "APRICE2BK":
														defSource = "Worldscope";
														break;
													case "308":
														defSource = "Multex";
														break;
												}
											}
											
											if(refModuleType == "WS") defSource = "Worldscope";
											if(refModuleType == "SEC") defSource = "SECFeed";
											if(refModuleType == "HL") defSource = "Highline";
											if(refModuleType == "TR") defSource = "Reuters";
											theID = "definition" + defID + defSource.substring(0,5);
											ccbnOpenObj(theID);
										}
										else ccbnStartTimer();
										break;
	}
}

function ccbnForceHide(){ if(!ccbn_fhObj) return; var ccbn_tmpObjId = ccbn_fhObj.id; ccbnShowHide(ccbn_fhObj,CCBN_HIDE); ccbnDoMove(ccbn_tmpObjId, -1000, -1000, ((ccbn_appName=="Netscape")?'px':''))}

/* prepares an object to be moved */
function ccbnMoveObj(objectID,e,resolved_x,resolved_y,absolute_div,abs_x) {
	var tmpX = (resolved_x)?resolved_x:ccbn_mozMouseX;
	var tmpY = (resolved_y)?resolved_y:ccbn_mozMouseY;
	var ccbn_x = tmpX + ccbn_offsetX;
	var ccbn_y = tmpY + ccbn_offsetY;
	abs_x = abs_x ? abs_x : ccbn_x;
	var ccbn_px=ccbn_appName=="Netscape"?'px':'';
	var ccbn_cssValue;
	
	ccbn_browser_x = ccbnGetBrowserDimensions(CCBN_GET_X);
	
	//if the global variable for the popover width has not yet been set, get the width
	if(ccbn_popover_width == null || isNaN(ccbn_popover_width)){
		var tmpClassNames = ccbnGetObj(objectID).className.split(" ");
		for(ccbn_i=0;ccbn_i<tmpClassNames.length;ccbn_i++){
			ccbn_cssValue = ccbnGetCSSValue("." + tmpClassNames[ccbn_i]);
			if(ccbn_cssValue && ccbn_cssValue.lastIndexOf(";width: ") != -1) ccbn_popover_width = parseInt( ccbn_cssValue.substring(ccbn_cssValue.lastIndexOf(";width: ")+8,ccbn_cssValue.length));
			 if(ccbn_popover_width == null || isNaN(ccbn_popover_width)){ ccbn_popover_width = 300;}
		 }
	}
	
	//if the div is not supposed to be relatively positioned
	//clone the div from its current parent onto the document.body
	if(absolute_div) ccbnCloneToBody(objectID);
	
	//if the div is too wide to fit in the window, put it to the left of the node
	if(abs_x+ccbn_popover_width > ccbn_browser_x) ccbn_x -= ccbn_popover_width;	
	
	//move the object
	ccbnDoMove(objectID, ccbn_x, ccbn_y, ccbn_px);
}

function ccbnOpenObj(id){
	ccbnStopTimer();
	ccbnForceHide();
	if(!ccbnGetObj(id)) return;
	ccbnMoveObj(id,ccbnEObj(),null,null,true);
	ccbnShowHide(ccbnGetObj(id),CCBN_SHOW);
}

function ccbnSetInnerHtml(el,inner){ el.innerHTML = inner; }

function ccbnSetupHovers(){
	if(!ccbnHoverReady){
		// If NS then set up for mouse capture
		if(document.captureEvents){ document.captureEvents(Event.MOUSEMOVE); }
		
		// Set-up to use getMouseXY function onMouseMove
		document.onmousemove = ccbnAddEvent(document.onmousemove, ccbnGetMouseXY);
		
		ccbnHoverReady=true;
	}
}

function ccbnSetupAjax(){
	for(ccbn_i=0;ccbn_i<ccbnAjaxObject.length;ccbn_i++){
		ccbnAjaxObject[ccbn_i].init();
	}
}

function ccbnShowHide(el,which){ el.style.visibility = which; if(which==CCBN_SHOW) ccbn_fhObj=el; else ccbn_fhObj = '';}
function ccbnShowHide_Display(el,which){ el.style.display = which;}

function ccbnStopTimer(){ clearTimeout(ccbnTimeout); }

function ccbnStartTimer(timerOverride){
	//allows end users to set a specific time to wait
	if(timerOverride > -1) CCBN_TIMER = timerOverride;
	ccbnTimeout = setTimeout(ccbnForceHide,CCBN_TIMER);
}


/*'''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Author: JDelia
Use: Animated Anchor Jumps
	This script originally found at Brand Spanking New:
	http://www.brandspankingnew.net/archive/2005/09/animated_anchor.html
	Then modified for IE support by Steve Cochrane (hq at stevecochrane dot com)
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''*/	

/* needs to be on page or in module
// initializes the script
window.onload = ccbnAddEvent(window.onload, ccbnReplaceAnchorLinks);
*/

/* GLOBALS */
var ccbnScrollInterval;
var ccbnScrTime, ccbnScrSt, ccbnScrDist, ccbnScrDur, ccbnScrInt;
/* GLOBALS */

// Found this script at http://blog.firetree.net/2005/07/04/javascript-find-position/
// Just used here to provide offsetTop functionality for IE
function ccbnFindPosY(obj) {
    var curtop = 0;
    if(obj.offsetParent)
        while(1)
        {
          curtop += obj.offsetTop;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.y)
        curtop += obj.y;
    return curtop;
}

function ccbnReplaceAnchorLinks(){
	var anchors, ccbn_i, targ, targarr;

	if (!document.getElementById) return;
	
	// get all anchors
	anchors = document.getElementsByTagName("a");
	
	for (ccbn_i=0;ccbn_i<anchors.length;ccbn_i++)
	{
		// check if href links to an anchor on this page
		if ( anchors[ccbn_i].href.indexOf("#") != -1)
		{
			// get name of target anchor
			targ = anchors[ccbn_i].href.substring( anchors[ccbn_i].href.indexOf("#")+1 );
			
			// find target anchor
			targarr = document.getElementsByName( targ );
			
			if (targarr.length)
			{
				anchors[ccbn_i].className = (targarr[0].offsetTop < anchors[ccbn_i].offsetTop) ? "up" : "down";
				anchors[ccbn_i].id = "__" + targ;	// save target as id with prefix (used in onclick function below)
				anchors[ccbn_i].onclick = function () { ccbnScrollToAnchor( this.id.substring( 2 ) ); return false; };
			}
		}
		
	}
}

function ccbnScrollPage(){
	ccbnScrTime += ccbnScrInt;
	if (ccbnScrTime < ccbnScrDur) {
		window.scrollTo( 0, ccbnEaseInOut(ccbnScrTime,ccbnScrSt,ccbnScrDist,ccbnScrDur) );
	}else{
		window.scrollTo( 0, ccbnScrSt+ccbnScrDist );
		clearInterval(ccbnScrollInterval);
	}
}

function ccbnScrollToAnchor(aname){
	var anchors, ccbn_i, ele, elePosY, heightCorrection;

	if (!document.getElementById)
		return;
	
	// get anchor
	anchors = document.getElementsByTagName("a");
	for (ccbn_i=0;ccbn_i<anchors.length;ccbn_i++) {
		if (anchors[ccbn_i].name == aname) {
			ele = anchors[ccbn_i];
			ccbn_i = anchors.length;
		}
	}
	
	// Find anchor's Y position
	elePosY = ccbnFindPosY(ele);
	
	//	The following is just to give some vertical space above where the anchor lands, 
	//	in case you think it stops too close to the top of the window.  Set to 0 if unnecessary.
	heightCorrection = 30;
	
	// set scroll target
	if (typeof (window.pageYOffset) == 'number') {
		// Non-IE modern browsers
		ccbnScrSt = window.pageYOffset;
		ccbnScrDist = elePosY - heightCorrection - ccbnScrSt;
		ccbnScrDur = 500;
	} else if (document.documentElement) {
		// IE in Standards Compliance mode
		ccbnScrSt = document.documentElement.scrollTop;
		ccbnScrDist = elePosY - ccbnScrSt;
		if (window.XMLHttpRequest) {
			// IE7
			ccbnScrDur = 500;
		} else {
			// IE6
			ccbnScrDur = 1500;
		}
	} else if (document.body && (document.body.scrollLeft || document.body.scrollTop) ) {
		// DOM compliant method, IE Quirks Mode
		ccbnScrSt = document.body.scrollTop;
		ccbnScrDist = elePosY - ccbnScrSt;
		ccbnScrDur = 500;
	}

	ccbnScrTime = 0;
	ccbnScrInt = 10;
	
	// set interval
	clearInterval(ccbnScrollInterval);
	ccbnScrollInterval = setInterval( ccbnScrollPage, ccbnScrInt );
}

/*
EASING FUNCTIONS
*/

function ccbnEaseInOut(t,b,c,d)
{
	return c/2 * (1 - Math.cos(Math.PI*t/d)) + b;
}

/*'''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Author: JDelia
Use: Scroll divs within a container
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''*/
var IdNo=0;
function ccbnScroller(scrollContainer,scrollWidth,scrollHeight,scrollPause,scrollSpeed,scrollTime,scrollDirection){
/* ||||||||||||||||||||||||||||||||||||||||||||||||||||
	ccbnScroller - This is an object that will scroll
	all div's that are contained within the scrollContainer
	arguments
	scrollContainer - an object that contains the divs to be scrolled
	scrollHeight - this is an integer representing the height, in pixels, of the container
	scrollPause - this is an integer representing the amount of time to wait once a div has completed its scroll, before triggering the next div to begin its scroll; the time is in milliseconds
	scrollSpeed - this is an integer representing the number of pixels to move the div each time the move is triggered
	scrollTime - this is an integer representing the amount of time to wait before triggering the movement; the time is in milliseconds (1000 = 1 second)
					Example
					scrollPause = 5000
					scrollSpeed = 1
					scrollTime = 10
					The div will move by 1 pixel every 10 milliseconds.  Once it has finished scrolling, the current div will remain on the page for 5000 milliseconds before the next div will begin to scroll
   |||||||||||||||||||||||||||||||||||||||||||||||||||| */
   
	//Save a reference to myself
	this.id = "myObject" + IdNo++;
	window[this.id] = this;
	
	this.container=scrollContainer;
	this.layers=this.container.getElementsByTagName("div");
	this.layerCount=this.layers.length;
	this.currentLayer=1;
	this.scrollTime=scrollTime;
	this.scrollSpeed=scrollSpeed;
	this.scrollPause=scrollPause;
	this.scrollWidth=scrollWidth;
	this.scrollHeight=scrollHeight;
	/*  
		scrollDirection:
		0 = scrolls from below
		1 = scrolls from above
		2 = scrolls from right to left
		3 = scrolls from left to right
	*/	
	this.scrollDirection=scrollDirection;
	this.currentLayerY;
	this.currentLayerX;	
	this.scrollLayerY=0;
	this.scrollLayerX=0;
	this.ccbn_px=navigator.appName=="Netscape"?'px':'';
	this.runTimeout;
	this.scrollTimeout;
	
	this.stopped;
	
	this.scrollTop;
	this.scrollRight;
	this.scrollBottom;
	this.scrollLeft;
	this.previousLayer;
	this.scrollLayer;

	this.ccbnStartScroll=ccbnStartScroll;
	this.ccbnStopScroll=ccbnStopScroll;
	this.ccbnDoScroll=ccbnDoScroll;	
	this.ccbnRunScroll=ccbnRunScroll;
	this.ccbnRestartScroll=ccbnRestartScroll;
	
	this.ccbnSetScrollLayerBoundaries=ccbnSetScrollLayerBoundaries
	
}

function ccbnStartScroll(){
	ccbnDoMove(this.layers[this.currentLayer].id, 0, (-this.scrollHeight), this.ccbn_px);
	ccbnDoMove(this.layers[0].id, -1000, -1000, this.ccbn_px);  //move the loading... div	
	this.currentLayerY=-this.scrollHeight;
	this.currentLayerX=0;
	this.runTimeout=setTimeout("window."+this.id+".ccbnRunScroll()",this.scrollPause);
}

function ccbnStopScroll(){
	this.stopped=true;
	clearTimeout(this.runTimeout);
}

function ccbnRestartScroll(){
	this.stopped=false;
	this.runTimeout=setTimeout("window."+this.id+".ccbnRunScroll()",this.scrollPause);
}

function ccbnRunScroll(){
	//if the user has hovered over the div, the scroller is stopped
	if(this.stopped) return;
	
	//move the layer that is now hidden to its original position and zindex
	if(this.previousLayer) ccbnSetZIndex(this.layers[this.previousLayer].id,-1);
	
	//set the index of the currently shown layer
	ccbnSetZIndex(this.layers[this.currentLayer].id,0);
	
	//set the scrollLayer by incremening the currentLayer or, if we have reached the count, setting it back to 1
	this.scrollLayer=(this.currentLayer==(this.layerCount-1))?1:this.currentLayer+1;

	this.ccbnSetScrollLayerBoundaries();

	//set the zIndex for the scrollLayer
	ccbnSetZIndex(this.layers[this.scrollLayer].id,1);		
	
	//move the scroll layer into position which is directly under the clipped area
	ccbnDoMove(this.layers[this.scrollLayer].id, (this.scrollLayerX), (this.scrollLayerY), this.ccbn_px);
	
	//begin the scroll process
	this.scrollTimeout=this.ccbnDoScroll();
		
}

function ccbnSetScrollLayerBoundaries(){
	switch(this.scrollDirection){
		case 0:	
				//set the scrollTop for the current layer
				this.scrollTop=this.scrollHeight*-this.scrollLayer;

				//set the scrollScrollLayerY to zero it out
				this.scrollLayerY=this.scrollTop+this.scrollHeight;
				
				break;
		
		case 1:
				//set the scrollTop for the current layer
				this.scrollTop=this.scrollHeight*-this.scrollLayer;
						
				//set the scrollScrollLayerY to zero it out
				this.scrollLayerY=this.scrollTop;
						
				//set the scrollTop for the current layer
				this.scrollLeft=0;
				this.scrollLayerX=this.scrollWidth;
				
				break;
	}
}

function ccbnDoScroll(){
	switch(this.scrollDirection){
		case 0:
	
			if(this.scrollLayerY!=this.scrollTop){
				var ccbn_y=((this.scrollLayerY-this.scrollSpeed)<this.scrollTop)?this.scrollTop:(this.scrollLayerY-this.scrollSpeed);
				ccbnDoMove(this.layers[this.scrollLayer].id, 0, ccbn_y, this.ccbn_px);
				this.scrollLayerY=ccbn_y;
				var ccbn_yCur=this.currentLayerY-this.scrollSpeed;
				ccbnDoMove(this.layers[this.currentLayer].id, 0, ccbn_yCur, this.ccbn_px);
				this.currentLayerY=ccbn_yCur;		
				this.scrollTimeout=setTimeout("window."+this.id+".ccbnDoScroll()",this.scrollTime);
			}
			else{
				//scroll is complete, reset values
				this.previousLayer=this.currentLayer;
				this.currentLayer=this.scrollLayer;
				this.currentLayerY=this.scrollLayerY;
				clearTimeout(this.scrollTimeout);
				clearTimeout(this.runTimeout);
				
				//run the next scroll
				this.runTimeout=setTimeout("window."+this.id+".ccbnRunScroll()",this.scrollPause);	
			}
			
			break;
		
		case 1:
		
			if(this.scrollLayerX!=this.scrollLeft){
				var ccbn_x=((this.scrollLayerX-this.scrollSpeed)<this.scrollLeft)?this.scrollLeft:(this.scrollLayerX-this.scrollSpeed);
				ccbnDoMove(this.layers[this.scrollLayer].id, ccbn_x, this.scrollLayerY, this.ccbn_px);
				this.scrollLayerX=ccbn_x;
				var ccbn_xCur=this.currentLayerX-this.scrollSpeed;
				var jdx = (this.scrollLayerY+(this.scrollHeight*(this.scrollLayer)))
				ccbnDoMove(this.layers[this.currentLayer].id, ccbn_xCur, jdx, this.ccbn_px);
				this.currentLayerX=ccbn_xCur;		
				this.scrollTimeout=setTimeout("window."+this.id+".ccbnDoScroll()",this.scrollTime);
			}
			else{
				//scroll is complete, reset values
				this.previousLayer=this.currentLayer;
				this.currentLayer=this.scrollLayer;
				this.currentLayerX=this.scrollLayerX;
				clearTimeout(this.scrollTimeout);
				clearTimeout(this.runTimeout);
				
				//run the next scroll
				this.runTimeout=setTimeout("window."+this.id+".ccbnRunScroll()",this.scrollPause);	
			}
			
			break;
	
	}
}

function ccbnSetZIndex(objID,index){
    if (document.layers && document.layers[objID] != null) {
        document.layers[objID].zIndex = index;
    }
    else if (document.all) {
        document.all[objID].style.zIndex = index;
    }
    else if (document.getElementById){
       document.getElementById(objID).style.zIndex = index;
    }
}

/*'''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Author: JDelia
Use: Global Ajax functions
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''*/

function ccbnAjax(moduleName, CMID, queryString, moduleContainer, refreshRate, objectArrayID){
	var theURL;

	//properties
	this.moduleName=moduleName;
	this.CMID = CMID;
	this.queryString=queryString;
	this.container=moduleContainer;
	this.refreshRate=refreshRate;
	this.objectArrayID=objectArrayID;
	
	//methods
	//initialize the ajax object
	this.init=function(){
		//set the container and make sure it is an Object
		this.container=(typeof(this.container)!='object')?ccbnGetObj(this.container):this.container;				

		//set the URL we will hit to get the HTML
		this.setURL();
		
		//start running the ajax calls			
		if(this.refreshRate) setTimeout("ccbnAjaxObject["+this.objectArrayID+"].executeXMLReq("+this.objectArrayID+")",this.refreshRate);
	};
			
	//creates and sets the module URL
	this.setURL=function(){		
		theURL = "phoenix.zhtml?c=" + this.CMID + "&m=" + this.moduleName + this.queryString;
		//add on any other parameters that exists other than p, m, c and ym
		var queryString = ccbnGetQS();
		for(var param in queryString){
			if(param!="p" && param!="m" && param!="c" && param!="ym") theURL+="&" + param + "=" + queryString[param];
		}
	};
	
	//code that is to be executed after the Request is complete			
	this.executeAfterReq=function(x,m){
		ccbnSetInnerHtml(ccbnAjaxObject[x].xmlReq[m].responseText,ccbnAjaxObject[x].container);
		if(ccbnAjaxObject[x].refreshRate) setTimeout("ccbnAjaxObject["+x+"].executeXMLReq("+x+")",ccbnAjaxObject[x].refreshRate);
	}
	
	this.xmlReq = new Array();
	//executes the Request back to the server		
	this.executeXMLReq=function(x,q,r){
		if(q){ this.queryString=q; this.setURL(); }
		this.xmlReq[r] = new setXMLReq();
		if(this.xmlReq[r]){
			this.xmlReq[r].onreadystatechange=function(){
				if(ccbnAjaxObject[x].xmlReq[r].readyState == 4 && ccbnAjaxObject[x].xmlReq[r].status == 200){
					ccbnAjaxObject[x].executeAfterReq(x,r);
				}
			};
		}
		
		//if either of this are null we can't create the URL so we bail out
		if(ccbnAjaxObject[x].CMID == null || ccbnAjaxObject[x].moduleName == null)
		    return;
		
		this.xmlReq[r].open("GET", theURL, true);
		this.xmlReq[r].send(null);
	};
	
	//creates the XMLHttpRequest object
	function setXMLReq(){
						if (window.XMLHttpRequest){
							try{ xmlRequest = new XMLHttpRequest(); }
							catch (e){ xmlRequest = false; }
						}
						else if (window.ActiveXObject){
							try{ xmlRequest = new ActiveXObject("Msxml2.XMLHTTP"); }
							catch (e){
								try{ xmlRequest = new ActiveXObject("Microsoft.XMLHTTP"); }
								catch (e){ xmlRequest = false; }
							}
						}
						return xmlRequest
	}	
}

/* IE6 doesn't recognize :hover on TDs or TRs - this is a work around */
var ccbnHiliteSuffix = 'ccbnIE6Over';
function ccbnAddClass(theObj, classToAdd){
	theObj.className = theObj.className + ' ' + classToAdd
}

function ccbnRemoveClass(theObj, classToRemove){
	var cls = theObj.className.split(" ");
	var ar = new Array();
	for (var ccbn_i = cls.length; ccbn_i > 0;) {
		if (cls[--ccbn_i] != classToRemove) {
			ar[ar.length] = cls[ccbn_i];
		}
	}
	
	theObj.className = ar.join(" ");
}

function ccbnIE6TurnHoversOn(){
	//               Only do this for IE6 or if browser is IE and there is no doctype
	if ((document.documentElement && !window.XMLHttpRequest)  ||  (document.all && ccbn_no_doctype)){
		var divs = document.getElementsByTagName('div');
		var tables = document.getElementsByTagName('table');
		//company calendar project
		//only enable IE6 hover for cells with ccbnCalButton or ccbnDay class name
		var hoverEnabled = new Array("ccbnCalButton", "ccbnDay");
		for(ccbn_i=0;ccbn_i < divs.length; ccbn_i++){
			if(divs[ccbn_i].id.indexOf("month") != -1){
				var tds = divs[ccbn_i].getElementsByTagName('td');
				for(ccbn_j=0;ccbn_j < tds.length; ccbn_j++){
					for(ccbn_k=0; ccbn_k < hoverEnabled.length; ccbn_k++){
						if(tds[ccbn_j].className.indexOf(hoverEnabled[ccbn_k]) != -1){
							tds[ccbn_j].onmouseover = function(){ ccbnAddClass(this,ccbnHiliteSuffix); };
							tds[ccbn_j].onmouseout = function(){ ccbnRemoveClass(this,ccbnHiliteSuffix); };
						}
					}
				}
			}
		}
		//row highlighting on tables
		for(ccbn_i=0;ccbn_i < tables.length; ccbn_i++){
			if(tables[ccbn_i].className.indexOf("ccbnRowHoverTbl") != -1){
				var trs = tables[ccbn_i].getElementsByTagName('tr');
				for(ccbn_j=0;ccbn_j < trs.length; ccbn_j++){
					if(trs[ccbn_j].className.indexOf("ccbnBgTblTtl") == -1){  //do not want to highlight the table titles
						trs[ccbn_j].onmouseover = function(){ ccbnAddClass(this,ccbnHiliteSuffix); };
						trs[ccbn_j].onmouseout = function(){ ccbnRemoveClass(this,ccbnHiliteSuffix); };
					}
				}
			}
		}
	}
}

//global ajax object
var ccbnAjaxObject = new Array();

//initialize any ajax objects onload
ccbnAddLoadEvent(ccbnSetupAjax);
