﻿function XBrowserAddHandler(target,eventName,handlerName) { 
  if ( target.addEventListener ) { 
    target.addEventListener(eventName, function(e){target[handlerName](e);}, false);
  } else if ( target.attachEvent ) { 
    target.attachEvent("on" + eventName, function(e){target[handlerName](e);});
  } else { 
    var originalHandler = target["on" + eventName]; 
    if ( originalHandler ) { 
      target["on" + eventName] = function(e){originalHandler(e);target[handlerName](e);}; 
    } else { 
      target["on" + eventName] = target[handlerName]; 
    } 
  } 
}

var printContent = ""
var defaultWinAttr = "width=640,height=550,toolbar=0,resizable=0,scrollbars=1";
var PreLoadImage = new Array();
var ActiveTab = 0;

function OpenWindow(location, name, attributes){window.open(location,name,attributes);}

function PrintPage(ContentID, PrintPageUrl){
    printContent = document.getElementById(ContentID).innerHTML;
    OpenWindow(PrintPageUrl, "printPage", defaultWinAttr)
}

function changeFontSize(what){
	document.body.style.fontSize=what+"em";
}

function toggleLinks(Index){
	var OnLink, OffLink, OnSet, OffSet;	
	if(Index == 0){
		OnLink = "ResLink";
		OffLink = "BizLink";
		OnSet = "ResLinks";
		OffSet = "BizLinks";
	}
	else{
		OnLink = "BizLink";
		OffLink = "ResLink";
		OnSet = "BizLinks";
		OffSet = "ResLinks";
	}
	document.getElementById(OnLink).className = "on";
	document.getElementById(OffLink).className = "";
	document.getElementById(OnSet).style.display = "block";
	document.getElementById(OffSet).style.display = "none";
}

function UpdateTab(index){
    var Buttons = document.getElementById("news_btns");
    var Content = document.getElementById("news_content");
    var NewsArchived=document.getElementById("news_bottom");
    for(i=0;i<3;i++){
        if(i==index){
            if(Buttons.childNodes[i].src.indexOf("_active") == -1)
                Buttons.childNodes[i].src = Buttons.childNodes[i].src.replace(".jpg", "_active.jpg");
            Content.childNodes[i].style.display = "block";
            ActiveTab = i;
        }
        else{
            if(Buttons.childNodes[i].src.indexOf("_active") != -1)
                Buttons.childNodes[i].src = Buttons.childNodes[i].src.replace("_active.jpg", ".jpg");
            Content.childNodes[i].style.display = "none";
        }        
    }
    if (index==1)
    { 
    	NewsArchived.childNodes[0].style.display = "none";
    } 
    else
    {
    NewsArchived.childNodes[0].style.display = "block";
    }
}

function GetArchive(mode){
    var Location = document.location.href;
    if(mode == 0){
        if(Location.indexOf("?") == -1)
            Location += "?";
        else 
            Location += "&";
        Location += "archive=true";
    }
    else if(Location.indexOf("archive=true") > -1){
        Location = Location.replace("archive=true", "");
    }
    document.location.href = Location;
}

function Search()
{
    document.location.href = "SearchResult.aspx?search=" + document.getElementById('Search').value;          
 }
 
 function GetUtility()
 {
    var PreviousUrl;
    if(window.location.search != '')
    {
     PreviousUrl=window.location.pathname + window.location.search;
    }
    else
    {    
    PreviousUrl=window.location.pathname;
    }
    document.location.href ="LocalUtility.aspx?Zipcode=" + document.getElementById('Zipcode').value;   
    //document.location.href ="LocalUtility.aspx?Zipcode=" + document.getElementById('Zipcode').value+'&BaseUrl=' + PreviousUrl;   
 }
