/*'''''''''''''''''''''''''''''''''''''''''''''''''''''''''
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 i, qString = theLocation.search.substr(1);
  var queryString = new Object();
  if (qString.length > 0) {
    var params = qString.replace(/\+/g, " ").split("&");
	for (i in params) {
	  params[i] = unescape(params[i]).split("=");
	  queryString[params[i][0]] = params[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
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''*/
var ccbn_fhObj, ccbnTimeout;

/*      CONSTANTS      */
var CCBN_SHOW = "visible";
var CCBN_HIDE = "hidden";
var CCBN_TIMER = 500;
var CCBN_GET_X = 0;
var CCBN_GET_Y = 1;
var CCBN_GET_XY = 2;

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 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 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 == 2) return tmpArray;
	else return tmpArray[getWhich];
}

function ccbnShowHide(el,which){ el.style.visibility = which; if(which==CCBN_SHOW) ccbn_fhObj=el; else ccbn_fhObj = '';}

function ccbnStopTimer(){ clearTimeout(ccbnTimeout); }
function ccbnStartTimer(timerOverride){
	//allows end users to set a specific time to wait to
	if(timerOverride > -1) CCBN_TIMER = timerOverride;
	ccbnTimeout = setTimeout(ccbnForceHide,CCBN_TIMER);
}

function ccbnForceHide(){ if(!ccbn_fhObj) return; var ccbn_tmpObjId = ccbn_fhObj.id; ccbnShowHide(ccbn_fhObj,CCBN_HIDE); ccbnDoMove(ccbn_tmpObjId, 0, 0, ((ccbn_appName=="Netscape")?'px':''))}