// JavaScript Document

//var pageURL = document.URL
//if(pageURL.indexOf('bank')!=-1) {
//var pageInd = 'bank';
//} else if (pageURL.indexOf('financial_svc')!=-1) {
//var pageInd = 'financial_svc';
//} else if (pageURL.indexOf('insurance')!=-1) {
//var pageInd = 'insurance';
//} else {
//var pageInd = '/';
//}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

var brow=(navigator.appName);

function capitalizeMe(obj) {
        val = obj;
        newVal = '';
        val = val.split(' ');
        for(var c=0; c < val.length; c++) {
                newVal += val[c].substring(0,1).toUpperCase() +
val[c].substring(1,val[c].length) + ' ';
        }
        obj = newVal;
		return newVal;
}

function screenCapToggle(label,imagePath) 
{
    URL = window.location.pathname;
    var screenCapLabel = '';
    var screenCap = '';

        f = capitalizeMe(label).replace(' And ',' and ');
        f = f.replace('For','for');
        f = f.replace('Include:','');
        document.getElementById('screenCapLabel').innerHTML = f;
        if(URL.indexOf('/Real_Estate') != -1)
        {
            document.getElementById('screenCapLabel').style.color = '#009933';
        }
        else if((URL.indexOf('/Power')||URL.indexOf('/gas') ||URL.indexOf('/coal') ) != -1)
        {
            document.getElementById('screenCapLabel').style.color = '#E3892B';
        }
        else if(URL.indexOf('/Media_Comm') != -1)
        {
            document.getElementById('screenCapLabel').style.color = '#B01E23';
        }        

        screenCapLabel = document.getElementById('screenCapLabel');
           
        document.getElementById('nlImage').innerHTML='<img src="'+ imagePath + '" />'; 
        
}

function showCover(PID, blurb) {
path = window.location.pathname;
isBasic = path.indexOf('/basic')
isUnltd = path.indexOf('/unlimited')
industry = '';
if(isBasic!=-1){industry = path.slice(1,isBasic);}
if(isUnltd!=-1){industry = path.slice(1,isUnltd);}
alert('show cover called');
blurb = blurb.slice(blurb.indexOf(':')+2,blurb.length);
document.getElementById('nlImage').innerHTML='<img src="/Images/products/'+industry+'/'+PID+'.gif" />';
document.getElementById('nlBlurb').innerHTML=blurb;
}

function popNameDefaultPages() {
window.open('/SNL-Financial/quick_tour/qtv1.html','popup','scrollbars=0,menubar=0,width=718,height=587,left=150,top=120,resizable=1,status=0');
  }
  
function popName() {
window.open('/SNL-Financial/quick_tour/qtv1.html','popup','scrollbars=0,menubar=0,width=718,height=587,left=150,top=120,resizable=1,status=0');
  }

function popName1() {
    window.open('/SNL-Financial/quick_tour/qtv1.html', 'popup', 'scrollbars=0,menubar=0,width=718,height=587,left=150,top=120,resizable=1,status=0');
  }

function pageImage(images,page) {

var ranNum = Math.floor(Math.random()*images+1);
if (page=="bank"){
	document.write('<img src="../../../Images/badges/'+ page + ranNum + '.gif" width="380" height="164" alt="Banking data, banking news, branch data, banking newsletters" />');
}
else if (page=="insurance"){
	document.write('<img src="../../../Images/badges/'+ page + ranNum + '.gif" width="380" height="164" alt="Insurance data, Insurance news, statutory data, insurance newsletters" />');
}
else if (page=="financial_svc"){
	document.write('<img src="../../../Images/badges/'+ page + ranNum + '.gif" width="380" height="164" alt="financial services data, financial services news, mergers & acquisitions, financial technology" />');
}
else if (page=="real_estate"){
	document.write('<img src="../../Images/badges/'+ page + ranNum + '.gif" width="380" height="164" alt="REIT data, REIT news, homebuilder data, real estate newsletter" />');
}


else if (page=="power"){
	document.write('<img src="../../../Images/badges/'+ page + ranNum + '.gif" width="380" height="164" alt="power plant data, power news, regulatory research associates, ERCOT" />');
}

else if (page=="gas"){
	document.write('<img src="../../../Images/badges/'+ page + ranNum + '.gif" width="380" height="164" alt="gas data, natural gas news, regulatory research associates" />');
}

else if (page=="coal"){
	document.write('<img src="../../../Images/badges/'+ page + ranNum + '.gif" width="380" height="164" alt="coal news, coal report, coal mines" />');
}

else if (page=="rra"){
	document.write('<img src="../../../Images/badges/'+ page + ranNum + '.gif" width="380" height="164" alt="Regulatory Research Associates provides independent research and consultation on electric utility securities and regulation, with a 25-year reputation for unmatched expertise in both areas" />');
}

else if (page=="media_comm"){
	document.write('<img src="../../../Images/badges/'+ page + ranNum + '.gif" width="380" height="164" alt="Kagan, Kagan media appraisals, cable data, broadcast data" />');
}

else if (page=="ir"){
	document.write('<img src="../../Images/badges/'+ page + ranNum + '.gif" width="380" height="164" alt="SNL Financial, IR Console, IR Web site management, Conference calls, Webcasts" />');
}

else {
document.write('<img src="Images/badges/'+ page + ranNum + '.gif" width="380" height="164"  alt="Financial information, financial data, business information, financial news" />');
//document.write('<div style="position: absolute; left: 0px; top: 0px; background-color: #FFFFFF; font-weight: bold; color: #000000;">'+ranNum+'</div>')
}
}



function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function MM_CheckFlashVersion(reqVerStr,msg){
  with(navigator){
    var isIE  = (appVersion.indexOf("MSIE") != -1 && userAgent.indexOf("Opera") == -1);
    var isWin = (appVersion.toLowerCase().indexOf("win") != -1);
    if (!isIE || !isWin){  
      var flashVer = -1;
      if (plugins && plugins.length > 0){
        var desc = plugins["Shockwave Flash"] ? plugins["Shockwave Flash"].description : "";
        desc = plugins["Shockwave Flash 2.0"] ? plugins["Shockwave Flash 2.0"].description : desc;
        if (desc == "") flashVer = -1;
        else{
          var descArr = desc.split(" ");
          var tempArrMajor = descArr[2].split(".");
          var verMajor = tempArrMajor[0];
          var tempArrMinor = (descArr[3] != "") ? descArr[3].split("r") : descArr[4].split("r");
          var verMinor = (tempArrMinor[1] > 0) ? tempArrMinor[1] : 0;
          flashVer =  parseFloat(verMajor + "." + verMinor);
        }
      }
      // WebTV has Flash Player 4 or lower -- too low for video
      else if (userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 4.0;

      var verArr = reqVerStr.split(",");
      var reqVer = parseFloat(verArr[0] + "." + verArr[2]);
  
      if (flashVer < reqVer){
        if (confirm(msg))
          window.location = "http://www.macromedia.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash";
      }
    }
  } 
}


function clientSideInclude(id, url) {
  var req = false;
  // For Safari, Firefox, and other non-MS browsers
  if (window.XMLHttpRequest) {
    try {
      req = new XMLHttpRequest();
    } catch (e) {
      req = false;
    }
  } else if (window.ActiveXObject) {
    // For Internet Explorer on Windows
    try {
      req = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
        req = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (e) {
        req = false;
      }
    }
  }
 var element = document.getElementById(id);
 if (!element) {
  alert("Bad id " + id +
   "passed to clientSideInclude." +
   "You need a div or span element " +
   "with this id in your page.");
  return;
 }
  if (req) {
    // Synchronous request, wait till we have it all
    req.open('GET', url, false);
    req.send(null);
    element.innerHTML = req.responseText;
  } else {
    element.innerHTML =
   "Sorry, your browser does not support " +
      "XMLHTTPRequest objects. This page requires " +
      "Internet Explorer 5 or better for Windows, " +
      "or Firefox for any system, or Safari. Other " +
      "compatible browsers may also exist.";
  }
}

function loadXMLDoc(url) 
{
xmlhttp=null
// code for Mozilla, etc.
if (window.XMLHttpRequest)
  {
  xmlhttp=new XMLHttpRequest()
  }
// code for IE
else if (window.ActiveXObject)
  {
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
  }
if (xmlhttp!=null)
  {
  xmlhttp.open("GET",url,true);
  xmlhttp.send(null);
  }
else
  {
  alert("Your browser does not support XMLHTTP.")
  }
}

function checkReadyState(obj)
{
  if(obj.readyState == 4)
  {
    if(obj.status == 200)
    {
      return true;
    }
    else
    {
      alert("Problem retrieving XML data");
    }
  }
}

var xmlhttp=false;
function getXML(URL) {
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
	try {
		xmlhttp = new XMLHttpRequest();
	} catch (e) {
		xmlhttp=false;
	}
}
if (!xmlhttp && window.createRequest) {
	try {
		xmlhttp = window.createRequest();
	} catch (e) {
		xmlhttp=false;
	}
}

 xmlhttp.open("GET", URL ,true);
 xmlhttp.onreadystatechange=function() {
  if (xmlhttp.readyState==4) {
   x=xmlhttp.responseXML;
   alert(x.getElementsByTagName('link').childNodes[0]);
  }
 }
 xmlhttp.send(null)
}

/*
activateActiveX
---------------
Purpose:  Dynamically replace any elements that will be affected by the new security feature in IE6/IE7 that requires a user to click certain types of elements to activate them before use.

Usage:  Include this file in the <head></head> section of your html document using the following...
	<script language="JScript" type="text/jscript" src="activateActiveX_onload.js"></script>


Since this script is in response to a software patent lawsuit, I feel it necessary to state the following...	

License:
activateActiveX is Copyright (C) 2006 Jason Baker (therippa AT gmail.com). It is available as open source code from:
http://therippa.blogspot.com

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details http://www.gnu.org/licenses/gpl.html
*/

//trap onload event
window.onload = function () {
	//Determine browser, we only need this for Internet Explorer
	if (navigator.appName == "Microsoft Internet Explorer") {
		
		//Array of elements to be replaced
		var arrElements = new Array(3);
		arrElements[0] = "object";
		arrElements[1] = "embed";
		arrElements[2] = "applet";
	
		
		//Loop over element types
		for (n = 0; n < arrElements.length; n++) {
		
			//set object for brevity
			replaceObj = document.getElementsByTagName(arrElements[n]);
			
			//loop over element objects returned
			for (i = 0; i < replaceObj.length; i++ ) {
			
				//set parent object for brevity
				parentObj = replaceObj[i].parentNode;
				
				//grab the html inside of the element before removing it from the DOM
				newHTML = parentObj.innerHTML;
				
				//remove element from the DOM
				parentObj.removeChild(replaceObj[i]);
				
				//stick the element right back in, but as a new object
				parentObj.innerHTML = newHTML;
			
				}
			}
		}
	}

//Added new on dated 29th Aug,2008

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


function nlBlurb(pName,PID,industry,blurb) {
document.getElementById('nlHeadline').innerHTML=pName;
if(blurb !='') { document.getElementById('nlSubHead').innerHTML=blurb; }
document.getElementById('nlImage').innerHTML='<img src="../../../../Images/products/'+industry+'/'+PID+'.gif" style="margin-left: 93px; margin-right: 94px;" />';
}

function nlBlurbRestore() {
document.getElementById('nlHeadline').innerHTML='Easy-to-use desk references providing comprehensive listings and rankings';
document.getElementById('nlSubHead').innerHTML='Industry leaders in each of our sectors rely on SNL data publications to put guaranteed accurate data at their fingertips.';
document.getElementById('nlImage').innerHTML='<img src="../../../../Images/data_publications_all.gif" width="482" height="327" />';
}
