//CHECK BROWSER 
var sUserAgent = navigator.userAgent;
var fAppVersion = parseFloat(navigator.appVersion);

var isOpera = sUserAgent.indexOf("Opera") > -1;
var isMinOpera4 = isMinOpera5 = isMinOpera6 = isMinOpera7 = isMinOpera7_5 = false;

if (isOpera) {
    var fOperaVersion;
    if(navigator.appName == "Opera") {
	 fOperaVersion = fAppVersion;
    } else {
	 var reOperaVersion = new RegExp("Opera (\\d+\\.\\d+)");
	 reOperaVersion.test(sUserAgent);
	 fOperaVersion = parseFloat(RegExp["$1"]);
    }

    isMinOpera4 = fOperaVersion >= 4;
    isMinOpera5 = fOperaVersion >= 5;
    isMinOpera6 = fOperaVersion >= 6;
    isMinOpera7 = fOperaVersion >= 7;
    isMinOpera7_5 = fOperaVersion >= 7.5;
}

var isKHTML = sUserAgent.indexOf("KHTML") > -1 
		|| sUserAgent.indexOf("Konqueror") > -1 
		|| sUserAgent.indexOf("AppleWebKit") > -1; 
		
var isMinSafari1 = isMinSafari1_2 = false;
var isMinKonq2_2 = isMinKonq3 = isMinKonq3_1 = isMinKonq3_2 = false;

if (isKHTML) {
    isSafari = sUserAgent.indexOf("AppleWebKit") > -1;
    isKonq = sUserAgent.indexOf("Konqueror") > -1;

    if (isSafari) {
	 var reAppleWebKit = new RegExp("AppleWebKit\\/(\\d+(?:\\.\\d*)?)");
	 reAppleWebKit.test(sUserAgent);
	 var fAppleWebKitVersion = parseFloat(RegExp["$1"]);

	 isMinSafari1 = fAppleWebKitVersion >= 85;
	 isMinSafari1_2 = fAppleWebKitVersion >= 124;
    } else if (isKonq) {

	 var reKonq = new RegExp("Konqueror\\/(\\d+(?:\\.\\d+(?:\\.\\d)?)?)");
	 reKonq.test(sUserAgent);
	 isMinKonq2_2 = compareVersions(RegExp["$1"], "2.2") >= 0;
	 isMinKonq3 = compareVersions(RegExp["$1"], "3.0") >= 0;
	 isMinKonq3_1 = compareVersions(RegExp["$1"], "3.1") >= 0;
	 isMinKonq3_2 = compareVersions(RegExp["$1"], "3.2") >= 0;
    } 
    
}

var isIE = sUserAgent.indexOf("compatible") > -1 
	    && sUserAgent.indexOf("MSIE") > -1
	    && !isOpera;
	    
var isMinIE4 = isMinIE5 = isMinIE5_5 = isMinIE6 = false;

if (isIE) {
    var reIE = new RegExp("MSIE (\\d+\\.\\d+);");
    reIE.test(sUserAgent);
    var fIEVersion = parseFloat(RegExp["$1"]);

    isMinIE4 = fIEVersion >= 4;
    isMinIE5 = fIEVersion >= 5;
    isMinIE5_5 = fIEVersion >= 5.5;
    isMinIE6 = fIEVersion >= 6.0;
}

var isMoz = sUserAgent.indexOf("Gecko") > -1
	     && !isKHTML;

var isMinMoz1 = sMinMoz1_4 = isMinMoz1_5 = false;

if (isMoz) {
    var reMoz = new RegExp("rv:(\\d+\\.\\d+(?:\\.\\d+)?)");
    reMoz.test(sUserAgent);
    isMinMoz1 = compareVersions(RegExp["$1"], "1.0") >= 0;
    isMinMoz1_4 = compareVersions(RegExp["$1"], "1.4") >= 0;
    isMinMoz1_5 = compareVersions(RegExp["$1"], "1.5") >= 0;
}

var isNS4 = !isIE && !isOpera && !isMoz && !isKHTML 
	     && (sUserAgent.indexOf("Mozilla") == 0) 
	     && (navigator.appName == "Netscape") 
	     && (fAppVersion >= 4.0 && fAppVersion < 5.0);

var isMinNS4 = isMinNS4_5 = isMinNS4_7 = isMinNS4_8 = false;

if (isNS4) {
    isMinNS4 = true;
    isMinNS4_5 = fAppVersion >= 4.5;
    isMinNS4_7 = fAppVersion >= 4.7;
    isMinNS4_8 = fAppVersion >= 4.8;
}

var isWin = (navigator.platform == "Win32") || (navigator.platform == "Windows");
var isMac = (navigator.platform == "Mac68K") || (navigator.platform == "MacPPC") 
	     || (navigator.platform == "Macintosh");

var isUnix = (navigator.platform == "X11") && !isWin && !isMac;

var isWin95 = isWin98 = isWinNT4 = isWin2K = isWinME = isWinXP = false;
var isMac68K = isMacPPC = false;
var isSunOS = isMinSunOS4 = isMinSunOS5 = isMinSunOS5_5 = false;

if (isWin) {
    isWin95 = sUserAgent.indexOf("Win95") > -1 
		|| sUserAgent.indexOf("Windows 95") > -1;
    isWin98 = sUserAgent.indexOf("Win98") > -1 
		|| sUserAgent.indexOf("Windows 98") > -1;
    isWinME = sUserAgent.indexOf("Win 9x 4.90") > -1 
		|| sUserAgent.indexOf("Windows ME") > -1;
    isWin2K = sUserAgent.indexOf("Windows NT 5.0") > -1 
		|| sUserAgent.indexOf("Windows 2000") > -1;
    isWinXP = sUserAgent.indexOf("Windows NT 5.1") > -1 

		|| sUserAgent.indexOf("Windows XP") > -1;
    isWinNT4 = sUserAgent.indexOf("WinNT") > -1 
		|| sUserAgent.indexOf("Windows NT") > -1 
		|| sUserAgent.indexOf("WinNT4.0") > -1 
		|| sUserAgent.indexOf("Windows NT 4.0") > -1 
		&& (!isWinME && !isWin2K && !isWinXP);
} 

if (isMac) {
    isMac68K = sUserAgent.indexOf("Mac_68000") > -1 
		 || sUserAgent.indexOf("68K") > -1;
    isMacPPC = sUserAgent.indexOf("Mac_PowerPC") > -1 
		 || sUserAgent.indexOf("PPC") > -1;  
}

if (isUnix) {
    isSunOS = sUserAgent.indexOf("SunOS") > -1;

    if (isSunOS) {
	 var reSunOS = new RegExp("SunOS (\\d+\\.\\d+(?:\\.\\d+)?)");
	 reSunOS.test(sUserAgent);
	 isMinSunOS4 = compareVersions(RegExp["$1"], "4.0") >= 0;
	 isMinSunOS5 = compareVersions(RegExp["$1"], "5.0") >= 0;
	 isMinSunOS5_5 = compareVersions(RegExp["$1"], "5.5") >= 0;
    }
}


/* Add getElementsByClassName Method */
function getElementsByClassName(searchClass,node,tag) {
	var classElements = new Array();
	if ( node == null )
		node = document;
	if ( tag == null )
		tag = '*';
	var els = node.getElementsByTagName(tag);
	var elsLen = els.length;
	var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
	for (i = 0, j = 0; i < elsLen; i++) {
		if ( pattern.test(els[i].className) ) {
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}

/* Add getElementsByClassName Method */
document.getElementsByClassName=function(_Class){
	var DocumentContent=document.all;
	if(!DocumentContent){
		DocumentContent=document.getElementsByTagName("*")
	};
	var returnList=new Array();
	for(var i=0;i<DocumentContent.length;i++){
		if(DocumentContent[i].className==_Class){
			returnList[returnList.length]=DocumentContent[i]
		}
	}
	return returnList
};


/* Used for Search */
function KeyDownHandler(btn, submitvalue, e){
       // process only the Enter key
		 var key

		 if (window.event) {
		 	key = event.keyCode;
		 }
		 else {
		 	key = e.which;
		 }

		 if (key == 13)
       {
           // cancel the default submit
           key.returnValue=false;
           key.cancel = true;
			  
			  if (submitvalue.value=="edisonegg") {
			  		window.open('http://www.edisonegg.com','_new')
			  }
			  
           // submit the form by programmatically clicking the specified button
           btn.click();
       }
}
function searchfocus(status,btn){
		btn.value='';
}



/* Used for doing the toxic's popup in community */
var toxicWin;
function toxicPop()
	{	if (!toxicWin || toxicWin.closed)
			toxicWin = window.open(baseHref+"community/emissions.asp","","width=700,height=450,toolbar=yes,status=yes,scrollbars=yes,menubar=yes,location=yes,resizable=yes");
		else
			toxicWin.focus();
	}
	var sitename = "edison";
	var accountWin;
	function accountPop(id)
	{	if (!accountWin || accountWin.closed)
	{	accountWin = window.open("managing_popup.asp?id=" + id, "", "width=600,height=400,scrollbars=yes");
	}
	else
	{	accountWin.location = "managing_popup.asp?id=" + id;
		accountWin.focus();
	}
}


function togglemenu(_ID, _ID2) {

	//alert("Hi")
	document.getElementById([_ID]).style.visibility = "visible";
	document.getElementById([_ID2]).style.visibility = "hidden";
	/*
	NOZ 06-15-06
	Problem regarding Bad NPDataObject please go to here
	https://bugzilla.mozilla.org/show_bug.cgi?id=309044
	.style.display causing error to be thrown 	
	//	document.getElementById([_ID]).style.display = "block";
	//	document.getElementById([_ID2]).style.display = "none";
	*/
}

/*Functionality Added by Ralph 11-04-05*/
function turnGoButtonMouseOverOn(){
	/* If there is any code that needs to be run at startup then place it here */
	document.getElementsByName('search')[0].onmouseover = function(){
	document.getElementsByName('search')[0].className ="eix_search_submit_on"
	}; 
	document.getElementsByName('search')[0].onmouseout = function(){
	document.getElementsByName('search')[0].className ="eix_search_submit"
	}; 
}

/*Added by Eph on 12/29/05
Simple function that switches an object's class name*/
function switchClass(obj, className) {
	obj.className=className
}

function init_library() {

	//Checking Browser
	if(isOpera){loadStandardNav();	}
	else if(isKHTML){loadStandardNav();}
	else if(isIE){loadStandardNav();}
	else if(isMoz){loadStandardNav();}
	else if(isNS4){loadStandardNav();}
	else{loadStandardNav();}
	//Checking Browser
	turnGoButtonMouseOverOn();
	return true;
}

//Function added by Noz used to detect Browser 11-04-05
function compareVersions(sVersion1, sVersion2) {

    var aVersion1 = sVersion1.split(".");
    var aVersion2 = sVersion2.split(".");
    
    if (aVersion1.length > aVersion2.length) {
        for (var i=0; i < aVersion1.length - aVersion2.length; i++) {
            aVersion2.push("0");
        }
    } else if (aVersion1.length < aVersion2.length) {
        for (var i=0; i < aVersion2.length - aVersion1.length; i++) {
            aVersion1.push("0");
        }    
    }
    
    for (var i=0; i < aVersion1.length; i++) {
 
        if (aVersion1[i] < aVersion2[i]) {
            return -1;
        } else if (aVersion1[i] > aVersion2[i]) {
            return 1;
        }    
    }
    return 0;
}

//FUNCTIONS FOR NAV SWAP *modified 11-02-05 by noz
function loadStandardNav(){
	return;
}

function loadAlternateNav(){

	return true;

	var eix_topnavigation_div = document.getElementById("eix_topnavigation_div");
	var kids = eix_topnavigation_div.childNodes;
	var numberOfKids = kids.length;
	for (var i = numberOfKids - 1; i >= 0; i--){
		var deletedNode = eix_topnavigation_div.removeChild(kids[i]);
	}

	var eix_topnavigation_img = document.createElement("img");
	eix_topnavigation_img.alt = "Edison.com Navigation";
	eix_topnavigation_img.src =  baseHref +"remote/images/topnavhomeon.gif";
	eix_topnavigation_img.id = "eix_topnavigation_img";
	eix_topnavigation_img.useMap = "#Map";
	eix_topnavigation_img.border = "0";
	
	var checkSectionName =  sectionName;
	checkSectionName = checkSectionName.toLowerCase();

	if(checkSectionName == "ourcompany"){
		eix_topnavigation_img.src = baseHref + "remote/images/topnavourcompanyon.gif";
	}
	else if (checkSectionName == "investors"){
		eix_topnavigation_img.src=  baseHref + "remote/images/topnavinvestorson.gif";
	}
	else if (checkSectionName == "pressroom"){
		eix_topnavigation_img.src =  baseHref + "remote/images/topnavpressroomon.gif";
	}
	else if(checkSectionName == "careers"){
		eix_topnavigation_img.src = baseHref +"remote/images/topnavcareerson.gif";
	}
	else if(checkSectionName == "community"){
		eix_topnavigation_img.src =  baseHref + "remote/images/topnavcommunityon.gif";
	}
	else if(checkSectionName == "global"){
		eix_topnavigation_img.src =  baseHref + "remote/images/topnavhomeon.gif";
	}
	else if(checkSectionName == ""){
		eix_topnavigation_img.src =  baseHref + "remote/images/topnavhomeon.gif";
	}
	else {
		eix_topnavigation_img.src =  baseHref + "remote/images/topnavhomeon.gif";
	}
	
	var imageMap = document.createElement("map");
	imageMap.id = "Map";
	imageMap.name = "Map";
	var map1 = document.createElement("area");
	map1.shape = "rect";
	map1.coords = "1,1,74,54";
	map1.href = baseHref + "default.asp";
	var map2 = document.createElement("area");
	map2.shape = "rect";
	map2.coords = "74,1,180,54";
	map2.href = baseHref + "ourcompany/default.asp";
	var map3 = document.createElement("area");
	map3.shape = "rect";
	map3.coords = "180,1,302,54";
	map3.href = baseHref + "investors/default.asp";
	var map4 = document.createElement("area");
	map4.shape = "rect";
	map4.coords = "302,1,395,54";
	map4.href = baseHref + "pressroom/default.asp";	
	var map5 = document.createElement("area");
	map5.shape = "rect";
	map5.coords = "395,1,471,54";
	map5.href = baseHref + "careers/default.asp";	
	var map6 = document.createElement("area");
	map6.shape = "rect";
	map6.coords = "471,1,561,54";
	map6.href = baseHref + "community/default.asp";
	
	imageMap.appendChild(map1);
	imageMap.appendChild(map2);
	imageMap.appendChild(map3);
	imageMap.appendChild(map4);
	imageMap.appendChild(map5);
	imageMap.appendChild(map6);
	
	eix_topnavigation_div.appendChild(eix_topnavigation_img);
	eix_topnavigation_div.appendChild(imageMap);
}

//Function Added by NOZ 01-10-06
//Rate This Page Option that is going to be included on all second and third tier pages - Client Request
function build_footer_rate() {
	var rateThisPage = document.getElementById("rateThisPage");
	
	var rateThisPageScript = document.createElement("script");
	rateThisPageScript.language = "javascript";
	rateThisPageScript.src = "http://www.sce.com/Includes/onlineopinionS3t/oo_engine.js";
	rateThisPageScript.type = "text/javascript";
	rateThisPageScript.charset = "windows-1252";
	rateThisPage.appendChild(rateThisPageScript);
	
	var rateThisPageImg = document.createElement("img");	
	rateThisPageImg.src = "https://www.edison.com/images/cms_images/c453_sm_green_o_9115.gif";
	rateThisPageImg.align = "baseline";
	rateThisPageImg.border = "0";
	rateThisPage.appendChild(rateThisPageImg);
	
	var blankSpace = document.createTextNode(" ");
	rateThisPage.appendChild(blankSpace);
	
	var rateThisPageAHref = document.createElement("a");
	rateThisPageAHref.href = "javascript:O_LC()";
	
	rateThisPageAHref.appendChild(document.createTextNode("Rate this page"));
	rateThisPage.appendChild(rateThisPageAHref);
	build_footer_email(rateThisPage);

	//Tagger Line: Guru Feb 26,2007
//	var tagLine=document.createElement('<table width="372" border="0" align="center" cellpadding="0" cellspacing="0"><tr><td><img src="underconstruction/images/spacer.gif" width="1" height="13" /></td></tr><tr><td bgcolor="#ffd325" td align="center" class="tagLine"><div align="center">LIFE. POWERED BY EDISON</div></td></tr><tr><td><img src="underconstruction/images/spacer.gif" width="1" height="13" /></td></tr></table>');
//	rateThisPage.appendChild(tagLine);
	
}

//Injects the script for link 'Email this Page'
function build_footer_email(objDivId) {
	var emailThisPage = objDivId;
	var url;		
		
	var blankSpace = document.createTextNode("   |   ");	
	emailThisPage.appendChild(blankSpace);
	
	//Adds hidden variable that holds page url and passes to popup window
	//var hdnTextURL = document.createElement("<input type=hidden name=EmailURL id=EmailURL>");
	
	var hdnTextURL = document.createElement('EmailURL');
	hdnTextURL.type = 'hidden';
	hdnTextURL.id = 'EmailURL';
	hdnTextURL.value =  document.URLUnencoded ;
	emailThisPage.appendChild(hdnTextURL);
	
	//Adds hidden variable that holds page title and passes to popup window
	//var hdnTextTitle = document.createElement("<input type=hidden name=EmailTitle id=EmailTitle>");
	var hdnTextTitle = document.createElement('EmailTitle');
	hdnTextTitle.type = 'hidden';
	hdnTextTitle.id = 'EmailTitle';
	
	hdnTextTitle.value = document.title ;
	emailThisPage.appendChild(hdnTextTitle);
	blankSpace = document.createTextNode(" ");
	emailThisPage.appendChild(blankSpace);
	
	//Adds email gif
	var emailThisPageImg = document.createElement("img");	
	emailThisPageImg.src = baseHref + "/remote/images/email.gif";
	emailThisPageImg.align = "baseline";
	emailThisPageImg.border = "0";
	
	//Adds link that will open up email this page window
	var emailThisPageAHref = document.createElement("a");
	url = baseHref + "remote/email_page.asp" //?EmailTitle=" + document.title + "&EmailURL=" + document.URLUnencoded;
	
	emailThisPageAHref.appendChild(emailThisPageImg);
	blankSpace = document.createTextNode(" ");
	emailThisPageAHref.appendChild(blankSpace);
	emailThisPageAHref.href = "javascript:open_win(\"" + url + "\",\"status=no,menubar=no,resizable=no,height=420,width=370,scrollbars=no\")";
	emailThisPageAHref.appendChild(document.createTextNode("E-mail this page"));
	emailThisPage.appendChild(emailThisPageAHref);
	
}

//opens a new window
function open_win(url, windowStyle) 
{
	window.open(url,'xx',windowStyle,true);
	//window.showModalDialog(url,'_Blank',windowStyle);
}
