
	$(document).ready(function(){
        document.body.onunload = "GUnload()";
        $("#side_bar li").each(function(){
          this.style.display="block";
          this.removeAttribute("style");
        });

		// Enable this to remove temporarily the map from the page
		//$("#main_content table").css("display","none");
		//$("#main_content p").css("display","none");
		//$("#main_content h1").after('<p style="color: red;">The outage map is currently unavailable. To find out about outages in your area, please call our Customer Service Center at 1-800-743-5000. <br />To report an outage, call 1-800-743-5002.</p>');
    });

	function popuptip(){
		var popup = window.open('/mybusiness/customerservice/energystatus/outagemap/popup/tips.shtml','Map', 'width=600,height=600');
	}

	function search(t){
		var key = t.value.toString().toLowerCase();
		var x = 0;
		var empty = true;
		$("#side_bar li").each(function(){
		  var nodeText = this.childNodes[0].childNodes[0].nodeValue.toString().toLowerCase();
		  nodeText = nodeText.substr(0,key.length);
		  if (nodeText==key){
        this.style.display="block";
        this.removeAttribute("style");
        empty = false;
		  } else {  
			  this.style.display = "none"; 
			}
		});
		if(empty){
      $("#side_bar p").remove();
      var noOutageMsg = "No outage reported for this location.";
      var msgEle = document.createElement("p");
      msgEle.appendChild(document.createTextNode(noOutageMsg));
      document.getElementById("side_bar").appendChild(msgEle);
		}
		else {
      $("#side_bar p").remove();
		}
	}
	
	
	function causeCode(id){
    switch (id){
      case "Awaiting Investigation":
        return "Awaiting investigation";
      case "EQUIPM+T FAIL":
        return "Caused by damaged equipment";
      case "TREES":
        return "Trees falling on the power line";
      case "BRKN POLE":
        return "Broken power pole";
      case "CAR POLE ACC":
        return "Car knocking down a power pole";
      case "FIRE":
        return "Caused by a fire";
      case "WIRE DOWN":
        return "Fallen wires";
      case "TRFMR FAIL":
        return "Caused by a damaged transformer";
      case "PATROLLING":
        return "Unknown";
      case "PLNND SHUTDOWN":
        return "Your area is undergoing scheduled maintenance";
      case "CB/LR LOCKOUT":
        return "Unknown";
      case "BLOWN FUSE":
        return "Unknown";
      case "EXPLOSION":
        return "Unknown";
      case "SUBSTN EQUIP":
        return "Unknown";
      case "STORM":
        return "Result of current storm or emergency conditions";
      case "ROTATING BLOCK":
        return "Interrupted due to high electric demand";
      case "DEBRIS":
        return "Damage on the power line";
      case "NOT OUTAGE":
        return "Electrical emergency - No outage";
      default:
        return "Unknown";
    }
  }
  
  function statusCode(id){
    switch (id){
      case "Awaiting T-Man":
        return "Awaiting assessment";
      case "T-Man Enroute":
        return "Crew en route";
      case "T-Man On Site":
        return "Assessment in progress";
      case "Awaiting repair crew":
        return "Awaiting repair crew";
      case "Crew Enroute":
        return "Awaiting repair crew";
      case "Crew On Site":
        return "Repair crew onsite";
      case "No Access":
        return "Unable to access equipment";
      default:
        return "Awaiting assessment";
    }
  }
  
  /*************************
    Descriptions:
    Receives numeric parameter 'c' and returns the range info in string format.
  *************************/
  function getRange(c){
    if (c>=1 && c<50) return "<strong>1</strong> to <strong>49</strong>";
    else if (c>=50 && c<500)  return "<strong>50</strong> to <strong>499</strong>";
    else if (c>=500 && c<5000)  return "<strong>500</strong> to <strong>4999</strong>";
    else if (c>=5000) return "<strong>5000+</strong>";
    else return "<strong>unknown</strong>";
  }
  
//determine the icon to be shown, based on the number of affected customers 
	function calcIcon(custNum) {
			if (custNum < 50) {	
				return 'green';
			} else if (custNum < 500) {
				return 'yellow';
			} else if (custNum < 5000) {
				return 'orange';
			} else return 'red';			
			
	}
	
	function moveto(loc){
   	var cloc = window.location.toString();
	var newloc = "/myhome/customerservice/energystatus/outagemap/";
	if (cloc.indexOf("myhome")>=0){
		newloc = "/myhome/customerservice/energystatus/outagemap/";
	}
	else if (cloc.indexOf("mybusiness")>=0){
		newloc = "/mybusiness/customerservice/energystatus/outagemap/";
	}
	else if (cloc.indexOf("about")>=0){
		newloc = "/about/news/outagestatus/outagemap/";
	}

    if (loc.toLowerCase() == "city")
    { newloc = newloc+"index.shtml"; }
    else if (loc.toLowerCase() == "county")
    { newloc = newloc+"om_county.shtml"; }
    else if (loc.toLowerCase() == "zip")
    { newloc = newloc+"zip.shtml"; }
    window.location = newloc;
   }
   
   