NS = (document.layers)?1:0;	
IE4 = (document.all) ? 1 : 0;
ver4 = (IE4 || NS) ? 1 : 0;
arPopups = new Array();
var navigTopOffset;
navigLayerTopOffset = 114;
navigLayerLeftOffset = 16
navigTopOffsetConst = (NS)?17:18;
navTableWidth=173
navTableOffset=133
HomePageLeftOffset = 185
HomePageTopOffset = 7
secNavBgColor = "";
secSubnavLn = "#66676a";
selectBgColor="#eaeaea"; //
var stout;
var tout;
var Ptout;
primNavTopOffset = 96;
timeoutdelay = 1500;


// inkoo added 20060106 to check browser
var detect = navigator.userAgent.toLowerCase();
var OS,browser,version,total,thestring;

if (checkIt('konqueror'))
{
	browser = "Konqueror";
	OS = "Linux";
}
else if (checkIt('safari')) browser = "Safari"
else if (checkIt('omniweb')) browser = "OmniWeb"
else if (checkIt('opera')) browser = "Opera"
else if (checkIt('webtv')) browser = "WebTV";
else if (checkIt('icab')) browser = "iCab"
else if (checkIt('msie')) browser = "Internet Explorer"
else if (!checkIt('compatible'))
{
	browser = "Netscape Navigator"
	version = detect.charAt(8);
}
else browser = "An unknown browser";

if (!version) version = detect.charAt(place + thestring.length);

if (!OS)
{
	if (checkIt('linux')) OS = "Linux";
	else if (checkIt('x11')) OS = "Unix";
	else if (checkIt('mac')) OS = "Mac"
	else if (checkIt('win')) OS = "Windows"
	else OS = "an unknown operating system";
}

// inkoo added 20060106 to check browser
function checkIt(string) {
	place = detect.indexOf(string) + 1;
	thestring = string;
	return place;
}

if (NS) {
	layerRef="document.layers";
	styleSwitch="";
} else {
    if (document.all) { // inkoo added 20060106 for safari compatability
        layerRef="document.all";
        styleSwitch=".style";
    }
}

function getSecondaryNav(){
	secNavHTML="";
	NSsecNavHTML="";
	count=0;
	
	for(label in navmenu){
		navCSS = (navsection == label)?"secnavHighlight":"secnav";
		subNavEls = navmenu[label];
		
		secondaryNavHref = subNavEls;
		secondaryNavHrefMouseover="onmouseOver='getSecondarySubnav(\""+label+"\","+count+")'";
		secondaryNavHrefMouseout="onmouseOut='tout=setTimeout(\"CloseSecSubnav()\",timeoutdelay)'";
        if (secondaryNavHref.toUpperCase().indexOf(".PDF") != -1) {
			secNavHTML += "<tr><td class="+navCSS+"><div id=secondarynavtable"+count+"><a href=\""+secondaryNavHref+"\" "+secondaryNavHrefMouseover+" "+secondaryNavHrefMouseout+" class="+navCSS+" target=\"_blank\">"+label+"</a></div></td></tr>\n";
			NSsecNavHTML += "<tr><td class="+navCSS+"><div id=secondarynavtable"+count+"><a href=\""+secondaryNavHref+"\" "+secondaryNavHrefMouseover+" "+secondaryNavHrefMouseout+" class="+navCSS+" target=\"_blank\">"+label+"</a></div></td></tr>\n";
        } else {
			secNavHTML += "<tr><td class="+navCSS+"><div id=secondarynavtable"+count+"><a href=\""+secondaryNavHref+"\" "+secondaryNavHrefMouseover+" "+secondaryNavHrefMouseout+" class="+navCSS+">"+label+"</a></div></td></tr>\n";
			NSsecNavHTML += "<tr><td class="+navCSS+"><div id=secondarynavtable"+count+"><a href=\""+secondaryNavHref+"\" "+secondaryNavHrefMouseover+" "+secondaryNavHrefMouseout+" class="+navCSS+">"+label+"</a></div></td></tr>\n";
        }
		count++;
    }

    secNavHTMLtable = "<table border=0 cellspacing=0 cellpadding=0 width="+navTableWidth+">\n"+secNavHTML+"</table>";

    writeToDiv("secondarynav",secNavHTMLtable);
    
    if(NS) {
        document.secondarynav.top=navigLayerTopOffset;
        document.secondarynav.left=navigLayerLeftOffset;
        document.NSsecondarynav.top=navigLayerTopOffset;
        
        NSsecNavHTMLtable = "<table border=0 cellspacing=0 cellpadding=0 bgcolor="+selectBgColor+" width="+navTableWidth+">\n"+NSsecNavHTML+"</table>";
        writeToDiv("NSsecondarynav",NSsecNavHTMLtable);
    }else{
        if (document.all) { // inkoo added 20060106 for safari compatability
            document.all.secondarynav.style.top=navigLayerTopOffset;
            document.all.secondarynav.style.left=navigLayerLeftOffset;
        } else {
            document.getElementById('secondarynav').style.top=navigLayerTopOffset;
            document.getElementById('secondarynav').style.left=navigLayerLeftOffset;
        }
    }
    
    showLayer("secondarynav");
}

// inkoo added 20060106 for safari compatability (remove flash hover flicker)
var flashExists = false;
function fixFlashLayer() {
    if (flashExists == true) {
        if (browser == "Safari") {
            // force flicker to re-render html
            hideLayer("secondarysubnav");
            setTimeout('showLayer("secondarysubnav")', 10);
        }
    }
}

function getSecondarySubnav(subNavLabel,offset){
	clearTimeout(tout);
	resetNavTableClass();
	secSubNavHTML="";
	secSubNavHTMLtable = "";

    var tmpCounter = 0;

// inkoo added 20060106 for safari compatability (remove flash hover flicker)
    if (browser == "Safari") {
        for (label in subnavmenu[subNavLabel]){
            if (subnavmenu[subNavLabel][label].toUpperCase().indexOf(".PDF") != -1) {
                secSubNavHTML +="<tr><td width="+navTableWidth+" style=\"padding-left:6px\"><a class=\"secsubnav\" target=\"_blank\" href=\""+subnavmenu[subNavLabel][label]+"\" onmouseover='fixFlashLayer(); clearTimeout(tout);clearTimeout(stout)' onmouseout='fixFlashLayer(); stout=setTimeout(\"CloseSecSubnav()\",timeoutdelay)'>"+label+"</a></td></tr>\n"+"<tr><td bgcolor="+secSubnavLn+"><img src=images/1px.gif width=1 height=1></td></tr>\n";
            } else {
                secSubNavHTML +="<tr><td width="+navTableWidth+" style=\"padding-left:6px\"><a class=\"secsubnav\" href=\""+subnavmenu[subNavLabel][label]+"\" onmouseover='fixFlashLayer(); clearTimeout(tout);clearTimeout(stout)' onmouseout='fixFlashLayer(); stout=setTimeout(\"CloseSecSubnav()\",timeoutdelay)'>"+label+"</a></td></tr>\n"+"<tr><td bgcolor="+secSubnavLn+"><img src=images/1px.gif width=1 height=1></td></tr>\n";
            }
            tmpCounter++;
        }
    } else {
        for (label in subnavmenu[subNavLabel]){
            if (subnavmenu[subNavLabel][label].toUpperCase().indexOf(".PDF") != -1) {
                secSubNavHTML +="<tr><td width="+navTableWidth+" style=\"padding-left:6px\"><a class=\"secsubnav\" target=\"_blank\" href=\""+subnavmenu[subNavLabel][label]+"\" onmouseover='clearTimeout(tout);clearTimeout(stout)' onmouseout='stout=setTimeout(\"CloseSecSubnav()\",timeoutdelay)'>"+label+"</a></td></tr>\n"+"<tr><td bgcolor="+secSubnavLn+"><img src=images/1px.gif width=1 height=1></td></tr>\n";
            } else {
                secSubNavHTML +="<tr><td width="+navTableWidth+" style=\"padding-left:6px\"><a class=\"secsubnav\" href=\""+subnavmenu[subNavLabel][label]+"\" onmouseover='clearTimeout(tout);clearTimeout(stout)' onmouseout='stout=setTimeout(\"CloseSecSubnav()\",timeoutdelay)'>"+label+"</a></td></tr>\n"+"<tr><td bgcolor="+secSubnavLn+"><img src=images/1px.gif width=1 height=1></td></tr>\n";
            }
            tmpCounter++;
        }
    }

    if(document.all){
        document.all["secondarynavtable"+offset].className="secsubnav";
    }

    navigTopOffset = navigLayerTopOffset+(navigTopOffsetConst*offset);

    if(NS){
        document.secondarysubnav.top=navigTopOffset;
        mapOverX(true,offset);
    }else{
        if (document.all) { // inkoo added 20060106 for safari compatability
            document.all["secondarysubnav"].style.top=navigTopOffset;
        } else {
            document.getElementById("secondarysubnav").style.top=navigTopOffset;
        }
    }
    if(subnavmenu[subNavLabel]){
        secSubNavHTMLtable = "<table id='secsubnavid' border=0 cellspacing=0 cellpadding=0 bgcolor="+selectBgColor+" width="+navTableWidth+"><tr><td bgcolor="+secSubnavLn+"><img src=images/1px.gif width=1 height=1></td></tr>"+secSubNavHTML+"</table>";
    }

    writeToDiv("secondarysubnav",secSubNavHTMLtable);

    if(NS) {
        document.secondarysubnav.left=navTableOffset+navigLayerLeftOffset;
    }else{
        if (document.all) { // inkoo added 20060106 for safari compatability
            document.all.secondarysubnav.style.left=navTableOffset+navigLayerLeftOffset;
        } else {
            document.getElementById('secondarysubnav').style.left=navTableOffset+navigLayerLeftOffset;
        }
    }

    showLayer("secondarysubnav");
    //tout = setTimeout("CloseSecSubnav()",timeoutdelay)		
}


function mapOverX(on,offset){
	if (IE4) {
        whichEl = document.all.NSsecondarynav.style 
    } else {
        whichEl = document.NSsecondarynav
    };
	
	if (!on) {whichEl.visibility = "hidden"; return };
		clLeft = 0
		clTop = (offset*navigTopOffsetConst)
		clRight = navTableWidth
		clBot = clTop+navigTopOffsetConst
	
	 if (NS) {
		whichEl.clip.top = clTop;
		whichEl.clip.bottom = clBot;
		whichEl.clip.left = clLeft;
		whichEl.clip.right = clRight;
	 }else{
	   whichEl.clip = "rect(" + clTop + " " + clLeft + " " + clBot + " " + clRight + ")";
	 }
	
	whichEl.visibility = "visible"
}

function showLayer(layerName){
    if (document.all || document.layers) { // inkoo added 20060106 for safari compatability
        eval(layerRef+'["'+layerName+'"]'+styleSwitch+'.visibility="visible"');
    } else {
        document.getElementById(layerName).style.visibility='visible';
    }
}

function hideLayer(layerName){
    if (document.all || document.layers) { // inkoo added 20060106 for safari compatability
        eval(layerRef+'["'+layerName+'"]'+styleSwitch+'.visibility="hidden"');
    } else {
        document.getElementById(layerName).style.visibility='hidden';
    }
}

function moveLayer(layername,left,top) {
	left = (!homePage)?left:left-HomePageLeftOffset;
	top = (!homePage)?top:top-HomePageTopOffset;
    if (document.all || document.layers) { // inkoo added 20060106 for safari compatability
        eval(layerRef+'["'+layername+'"]'+styleSwitch+'.top='+top);
        eval(layerRef+'["'+layername+'"]'+styleSwitch+'.left='+left);
    } else {
        document.getElementById(layername).style.top=top;
        document.getElementById(layername).style.left=left;
    }
}

function resetNavTableClass(){
    for(cn=0;cn<count;cn++) {
        if(document.all) {
            document.all["secondarynavtable"+cn].className="secnav";
        }
    }
}

function CloseSecSubnav(){
    writeToDiv("secondarysubnav","");
}

function writeToDiv(divLayer,HTMLcode){

	if(NS){
		eval("document."+divLayer+".document.open()")
		eval("document."+divLayer+".document.write(HTMLcode)")	
		eval("document."+divLayer+".document.close()")	
	}else{
        if (document.all) { // inkoo added 20060106 for safari compatability
            document.all[divLayer].innerHTML = HTMLcode;
        } else {
            document.getElementById(divLayer).innerHTML = HTMLcode;
        }
	}
		
}

// real top nav

navimg = ['myaccount','customercentral','businesscenter','investor','community','aboutus','news','c_overview','c_news','c_govern','c_contact', 'c_invest_info', 'c_cei']

//create the preload array
for(a=0;a<navimg.length;a++) {
	eval("nav"+navimg[a]+"= new Image();")
	eval("nav"+navimg[a]+".src = '/images/topnav/top_nav_"+navimg[a]+".gif'")

	eval("nav"+navimg[a]+"_lit= new Image();")
	eval("nav"+navimg[a]+"_lit.src = '/images/topnav/top_nav_"+navimg[a]+"_lit.gif'")		

}

function liteNav(wh,bool) {
	layr = (NS)?"subnav.document.":"";

	onoff = (bool)?"_lit":"";

    var tmpImgId = "navimg_" + wh;
    var tmpImgSrc = "nav" + wh + onoff;

    // inkoo added 20060106 for safari compatability 
    document.getElementById(tmpImgId).src = eval(tmpImgSrc + ".src");

	if(bool && homePage){
		Ptout = setTimeout("hideLayer('subnavigation')",timeoutdelay)
	}
	if(!bool && !homePage){
		Ptout = setTimeout("hideLayer('subnavigation')",timeoutdelay)
	}	
}
	

navimg['myaccount'] = [200,
'in english','http://www.coned.com/csol',
'en espa&ntilde;ol','http://www.coned.com/csol_spanish']

navimg['customercentral'] = [266,
//'customer central home','http://www.coned.com/customercentral',
'my bill/ways to pay','http://www.coned.com/customercentral/paymentoption.asp',
'becoming a customer','http://www.coned.com/customercentral/becomingacustomer.asp',
'energy choices','http://www.coned.com/customercentral/energychoices.asp',
'energy savings','http://www.coned.com/customercentral/energysavings.asp',
'safety tips','http://www.coned.com/customercentral/safetytip.asp',
'storm central','http://www.coned.com/sm/',
'publications','http://www.coned.com/customercentral/energynews.asp',
'special services','http://www.coned.com/customercentral/specialservices.asp',
'products and programs','http://www.coned.com/sales',
'power<i>your</i>way','http://www.poweryourway.com',
'claims','http://www.coned.com/lawclaims',
'FAQ','http://www.coned.com/customercentral/faqs.asp',
'kids','http://www.coned.com/kids',
'informaci&oacute;n en espa&ntilde;ol','http://www.coned.com/customercentral/espanol.asp',
//'informaci&oacute;n en espa&ntilde;ol','http://www.coned.com/athome/spanish/spindex.htm',
'contact us','http://www.coned.com/customercentral/contactus.asp']



navimg['businesscenter'] = [359,
//'customer central','http://www.coned.com/customercentral',
'distributed generation','http://www.coned.com/dg',
'energy services','http://www.coned.com/es',
'ESCOs','http://www.coned.com/escos',
'maintenance services','http://www.coned.com/conedmtce/',
'products and programs','http://www.coned.com/sales',
'rates & tariffs','http://www.coned.com/rates',
'steam','http://www.coned.com/steam',
'TeAM','http://www.coned.com/team',
'vendor services','http://www.coned.com/vendorservices']

navimg['investor'] = [447,
'investor relations','http://investor.conedison.com',
'corporate reports','http://investor.conedison.com/ireye/ir_site.zhtml?ticker=ed&script=700&layout=7',
'corporate governance','http://www.conedison.com/governance'];

navimg['community'] = [502,
//'diversity','http://www.coned.com/diversity',
'kids','http://www.coned.com/kids',
'partnerships','http://www.coned.com/partnerships',
'retirees','http://retirees.coned.com']

navimg['news'] = [567,
'newsroom','http://www.coned.com/newsroom',
'public issues','http://www.coned.com/publicissues']

navimg['aboutus'] = [602,
'eh&s','http://www.coned.com/ehs',
'careers','http://www.coned.com/careers',
'diversity','http://www.coned.com/diversity',
'document center','http://www.coned.com/documents',
'history','http://www.coned.com/history',
'shopping','http://www.coned.com/shopping']


function setDelay(bool){
	if(bool){
		clearTimeout(Ptout);
	}else{
        // inkoo added 20060106 for safari compatability (remove flash hover flicker)
        if (browser == "Safari" && flashExists) {
            hideLayer("subnavigation");
            setTimeout('showLayer("subnavigation")', 10);
        }

        Ptout = setTimeout("hideLayer('subnavigation')",timeoutdelay)
	}
}

function showSubnav(which) {
	navbgcolor=(homePage)?"C1D7EE":"ffffff";
	navlinecolor=(homePage)?"ffffff":"66676A";
	navWidth=(homePage)?"1":"3";

	clearTimeout(Ptout);	
	hideLayer('subnavigation');

	subnav_html = "<table cellspacing=0 cellpadding=0 border=0 width=150 bgcolor=#"+navbgcolor+">\n"
	for(sn=1;sn<navimg[which].length;sn++) {
        subnav_html +="<tr><td bgcolor=#"+navlinecolor+"><img src=/images/1px.gif width=1 height=17></td><td width=100%>&nbsp;<a href=\""+navimg[which][sn+1]+"\" class=secnav onmouseover='setDelay(1)' onmouseout='setDelay(0)'>"+navimg[which][sn]+"</a></td><td bgcolor=#"+navlinecolor+"><img src=images/1px.gif width="+navWidth+" height=1></td></tr>\n"
        subnav_html +="<tr><td bgcolor=#"+navlinecolor+"><img src=/images/1px.gif></td><td bgcolor=#"+navlinecolor+"><img src=\"images/1px.gif\" width=1 height=1></td><td bgcolor=#"+navlinecolor+"><img src=images/1px.gif width=1 height=1></td></tr>\n"
        eval("nav"+which+sn+"= new Image();")
        eval("nav"+which+sn+".src = 'images/topnav/nav_"+navimg[which][sn]+".gif'")
    
        eval("nav"+which+sn+"_lit= new Image();")
        eval("nav"+which+sn+"_lit.src = 'images/topnav/nav_"+navimg[which][sn]+"_lit.gif'")			
        sn++;
	}
	
	if(!homePage){
		subnav_html += "<tr><td bgcolor=#"+navlinecolor+"><img src=images/1px.gif width=1 height=3></td><td bgcolor=#66676A><img src=images/1px.gif width=3 height=3></td><td bgcolor=#66676A><img src=images/1px.gif width=3 height=3></td></table>\n"
	}
	
	
	if(NS) {
		document.subnavigation.document.open()
		document.subnavigation.document.write(subnav_html)
		document.subnavigation.document.close()
	} else {
        if (document.all) { // inkoo added 20060106 for safari compatability
            document.all['subnavigation'].innerHTML = subnav_html;
        } else {
            document.getElementById('subnavigation').innerHTML = subnav_html;
        }
	}
	
	moveLayer('subnavigation',navimg[which][0],primNavTopOffset);
	showLayer('subnavigation');

}

function writeAlpha(idx){
    c=65;
    for(str=c;str<c+26;str++){
        a = String.fromCharCode(str)
    
        if(a==idx){
            txt=a;
            iurl="<b>"+txt+"</b>";
            document.write("<a name=\""+txt+"\"></a>");
        }else{
            txt=a;
            iurl="<a href='#"+txt+"'>"+txt+"</a>";
        }

        pipe = (str==c+25)?"":" | ";

        document.write(iurl+pipe);
    }
    
    document.write("&nbsp;&nbsp;&nbsp; 	<a href='#top'>Top</a>");
}

// In Koo added 20060221 for future select box hide capability
function hideSelect(selectOptionId){
	if (!selectOptionId) {
		for (j=0; j<document.forms.length; j++) {
			var theForm = document.forms[j]
			for(i=0; i<theForm.elements.length; i++){
				var alertText = ""
				if(theForm.elements[i].type == "select-one") {
					theForm.elements[i].style.visibility = "hidden";
				}
			}
		}
	} else {
		var selectOptionObj = document.getElementById(selectOptionId);
		if (selectOptionObj) {
			selectOptionObj.visibility = "hidden";
		}
	}
}
function showSelect(selectOptionId){
	if (!selectOptionId) {
		for (j=0; j<document.forms.length; j++) {
			var theForm = document.forms[j]
			for(i=0; i<theForm.elements.length; i++){
				var alertText = ""
				if(theForm.elements[i].type == "select-one") {
					theForm.elements[i].style.visibility = "visible";
				}
			}
		}
	} else {
		var selectOptionObj = document.getElementById(selectOptionId);
		if (selectOptionObj) {
			selectOptionObj.visibility = "visible";
		}
	}
}



