﻿var weatherMarkers = new Array();
var weatherExist = false;
var weatherLoaded = false;
var weatherAlertPopupDisplayed = false;
var CountyIDVal;
var CountyNameVal;
var tempmarker;
var returnalertdiv;
var htmlsForecast;
var tempmarkerForecast;
var ForecastCountyIDVal;

var CountyID; 
var filename;
var regioname;

var ForecastCountyID;
var Forecastfilename;
var Forecastregioname;

//Load the XSLs to format Weather alerts / warnings.
var xml;
var xsl;
if (document.implementation && document.implementation.createDocument){ 
  xsl=document.implementation.createDocument("","",null);
  xsl.async=true;
  xsl.load("./xml/nwsforecast.xsl"); 
} 
else if (window.ActiveXObject){ 
  xsl = new ActiveXObject("Microsoft.XMLDOM"); 
  xsl.async=true;
  xsl.load("./xml/nwsforecast.xsl");
} 
  
var xsla;
if (document.implementation && document.implementation.createDocument){ 
  xsla=document.implementation.createDocument("","",null);
  xsla.async=true;
  xsla.load("./xml/nwswarning.xsl"); 
} 
else if (window.ActiveXObject){ 
  xsla = new ActiveXObject("Microsoft.XMLDOM"); 
  xsla.async=true;
  xsla.load("./xml/nwswarning.xsl");
}

var xslc;
if (document.implementation && document.implementation.createDocument){ 
  xslc=document.implementation.createDocument("","",null);
  xslc.async=true;
  xslc.load("./xml/nwcountylist.xsl"); 
} 
else if (window.ActiveXObject){ 
  xslc = new ActiveXObject("Microsoft.XMLDOM"); 
  xslc.async=true;
  xslc.load("./xml/nwcountylist.xsl");
}


function createWeatherPopups(elem, xmlDoc) 
{
  
  var tmpTooltip = "";
      
  if (!weatherLoaded) 
  {

    var markers = xmlDoc.documentElement.getElementsByTagName("Region");
    var j = 0 ;
    
    for (var i = 0; i < markers.length; i++) 
    {
            // obtain the attribues of each marker
            //this is for the "Alerts" icon
            

          var lat = parseFloat(markers[i].getAttribute("lat_Alert"));
          var lng = parseFloat(markers[i].getAttribute("lng_Alert"));
          var regionID = markers[i].getAttribute("RegionID");
          var name = markers[i].getAttribute("RegionName");
          var type = "alert";
          var point = new GLatLng(lat,lng);
          
          var textColor = "#003366";    
              
            //======add Animation Icons for county wide events============
            //add animated icons for county wide event
            //Date Added:1/21/2009
            //Added by: Haiyan Du Haiyan.Du@Telvent.com
            var displayAnimatedIcon=false;
		    var facility=Trim(name);
		    var facilityEndString=Right(facility,6);
		    if(facilityEndString.toLowerCase()==countyWideEventEndWith)
		    {
		        displayAnimatedIcon=true;
		    }
		    else
		    {
		        displayAnimatedIcon=false;
		    }
            //============End of the add====================================
           
           
              if(displayAnimatedIcon)
          {
            icon=alertsIcon_Animated;
          }
          else
          {
            icon = alertsIcon;
          }
        
       //icon = alertsIcon;
             	
    	    tmpTooltip = '<div class="markerTooltip" style="color:'+textColor+';height:100%;">';
    		tmpTooltip =  tmpTooltip +'<div class="markerTooltipHeader" >';
    		tmpTooltip = tmpTooltip +"Weather alert / warning "  +'</div>';
    		tmpTooltip = tmpTooltip + name + '</div>';

         
        		
    		   var marker = new PdMarker(point, icon);
    		   
               marker.tooltip = tmpTooltip;
               weatherMarkers[j] = marker;
               createWeatherMarker(point, marker, '', regionID, type, name);
               googleMap.addOverlay(weatherMarkers[j]);
               j = j + 1;
 
       //this is for the "Weather Icon"
       
          lat = parseFloat(markers[i].getAttribute("lat_Weather"));
          lng = parseFloat(markers[i].getAttribute("lng_Weather"));
          regionID = markers[i].getAttribute("RegionID");
          name = markers[i].getAttribute("RegionName");
          type = "weather";
          point = new GLatLng(lat,lng);
          
          textColor = "#003366";        
        //======add Animation Icons for county wide events============
        //add animated icons for county wide event
        //Date Added:1/21/2009
        //Added by: Haiyan Du Haiyan.Du@Telvent.com
            displayAnimatedIcon=false;
		    facility=Trim(name);
		    facilityEndString=Right(facility,6);
		    if(facilityEndString.toLowerCase()==countyWideEventEndWith)
		    {
		        displayAnimatedIcon=true;
		    }
		    else
		    {
		        displayAnimatedIcon=false;
		    }
        //============End of the add====================================

          if(displayAnimatedIcon)
              {
                icon=weatherIcon_Animated;
              }
              else
              {
                icon=weatherIcon;
              }
           
            
                tmpTooltip = '<div class="markerTooltip" style="color:'+textColor+';height:100%;">';
    		    tmpTooltip =  tmpTooltip +'<div class="markerTooltipHeader"  >';
    		    tmpTooltip = tmpTooltip +"Weather Forecast"  +'</div>';
    		    tmpTooltip = tmpTooltip + name + '</div>';
    
      marker = new PdMarker(point, icon);
      marker.tooltip = tmpTooltip;
      weatherMarkers[j] = marker;
      createWeatherMarker(point, marker, '', regionID, type, name);
      googleMap.addOverlay(weatherMarkers[j]);
      j++;
      
      if (i == markers.length - 1) 
      {
        hidePleaseWaitScreen();
      }
    
      weatherLoaded = true;
 
    } //end of for loop
    
  }//end if !weatherLoaded 
} 

function createWeatherMarker(point, marker, html, regionID, type, name) {
    
   
   GEvent.addListener(marker, "click", function() {
  	
  	 CountyID = new Array();
     filename = new Array();
     regioname = new Array();

     ForecastCountyID = new Array();
     Forecastfilename = new Array();
     Forecastregioname = new Array();
     
  	  //added to save the position of the map before the marker is opened.
      googleMap.savePosition();
      overview.hide(true);
      
       if (type == "weather")
      showPleaseWaitScreen("Please wait while we retreive weather forecast information for " + name);
      
       if (type == "alert")
         showPleaseWaitScreen("Please wait while we retreive weather alert information for " + name);
         
      if (CCTVPopupDisplayed) {
          closeCCTVPopupWindow();
      }
      if (crossingPopupDisplayed) {
          closeCrossingPopupWindow();
      }
      
      if (type == "weather") 
      {
      
       
        var requestWFC = GXmlHttp.create();

        var urlCounties = "./xml/GetRegionCounties.aspx?RegionName=" + name + "&Type=" + type;
        
        requestWFC.open("GET", urlCounties, true);
        
        requestWFC.onreadystatechange = function() 
        {
          if (requestWFC.readyState == 4) 
          {
            if (requestWFC.status == 404) 
            {
              alert("An error occured while retreiving weather forecast data.\nPlease try again later.");
              hidePleaseWaitScreen();
              return;
            }
            
            var xml1 = requestWFC.responseXML;
            
             if (xml1.documentElement.getElementsByTagName("errorDesc").length != 0) 
             {
              //error grabbing weather alert
              alert("An error occured while retreiving weather forecast data.\nPlease try again later.");
              hidePleaseWaitScreen();
              return;
             }
             
            var weathermarker = xml1.documentElement.getElementsByTagName("county");
             
             for (var i = 0; i < weathermarker.length; i++) 
             {
            // obtain the attribues of each marker
            //this is for the "Alerts" icon
            
            ForecastCountyID[i] = Trim(weathermarker[i].getAttribute("countyid"));
            Forecastfilename[i] = Trim(weathermarker[i].getAttribute("filename"));
            Forecastregioname[i] = Trim(weathermarker[i].getAttribute("name"));
            
             }
                
                     
             var infoHtmls;
                 infoHtmls = '<div class="title">';
			     infoHtmls += Forecastregioname[0];
		         infoHtmls += '</div>';
                 infoHtmls += '<div style="font-size:small">';
                 infoHtmls += '<tr>';
                 infoHtmls += '<td>';
                 infoHtmls += '&nbsp;<b>Select a County Name :</b> ';
                 infoHtmls += '<select id="WeatherForecastDDL" onchange = "javascript:SaveForecastDDLValue(this.value);" >';
             for(var i=0; i< Forecastfilename.length; i++)
             {
                 infoHtmls += '<option value="' + Forecastfilename[i] + '">';
                 infoHtmls += Forecastfilename[i];
                 infoHtmls += '</option>';
				 
             }
                 infoHtmls += '</select>';
			     infoHtmls += '</td>';
			     infoHtmls += '</tr>';
			     infoHtmls += '</div>';  
      
      
        var requestWFC1 = GXmlHttp.create();
          
        var url = "./xml/getWeatherForecasts.aspx?xmlFile=" + Forecastfilename[0] + ".xml" ;
        requestWFC1.open("GET", url, true);
        
        requestWFC1.onreadystatechange = function() 
        {
          if (requestWFC1.readyState == 4) {
            if (requestWFC1.status == 404) {
              alert("An error occured while retreiving weather forecast data.\nPlease try again later.");
              hidePleaseWaitScreen();
              return;
            }
            
            var xml2 = requestWFC1.responseXML;
            
            if (xml2.documentElement.getElementsByTagName("errorDesc").length != 0) {
              //error grabbing weather alert
              alert("An error occured while retreiving weather forecast data.\nPlease try again later.");
              hidePleaseWaitScreen();
              googleMap.closeExtInfoWindow();
              return;
            }
            
            var cont = document.createElement('div');
            cont.setAttribute('id','weatherForecastDiv');
            
            var forecastDiv = getTransformedDoc(xml2, xsl);
              
            //globaly replace less than greater than with symbols
            forecastDiv = forecastDiv.replace(/&lt;/g,'<');
            forecastDiv = forecastDiv.replace(/&gt;/g,'>');
            
            cont.innerHTML = infoHtmls + forecastDiv;
            if(cont.innerHTML == "") {
              alert("An error occured while retreiving weather forecast data.\nPlease try again later.");
              hidePleaseWaitScreen();
              googleMap.closeExtInfoWindow();
              return;
            } 
            
            tempmarkerForecast = marker;
              
            //special extended marker  
            marker.openExtInfoWindow(
              googleMap,
              "weatherForecastPopup",
              cont.innerHTML,
              {beakOffset: 2}
            ); 
            
            hidePleaseWaitScreen();
          }// end if (request.readyState == 4)
        }// end request.onreadystatechange = function() {
        requestWFC1.send(null);
        weatherAlertPopupDisplayed = true;
       }
      }

        requestWFC.send(null);
      }// end else {//type == "Weather"
   
      else 
      {//type == "alert"
       var request = GXmlHttp.create();

        var urlCounties = "./xml/GetRegionCounties.aspx?RegionName=" + name + "&Type=" + type;
        request.open("GET", urlCounties, true);
        
        request.onreadystatechange = function() 
        {
          if (request.readyState == 4) 
          {
           try
            {
            
                if (request.status == 404) 
                {
                  alert("An error occured while retreiving weather alert data.\nPlease try again later.");
                  hidePleaseWaitScreen();
                  googleMap.closeExtInfoWindow();
                  return;
                }
                
                var xml3 = request.responseXML;
                

             if (xml3.documentElement.getElementsByTagName("errorDesc").length != 0) 
             {
              //error grabbing weather alert
              alert("An error occured while retreiving weather alert data.\nPlease try again later.");
              hidePleaseWaitScreen();
              googleMap.closeExtInfoWindow();
              return;
             }
             
             var alertmarker = xml3.documentElement.getElementsByTagName("county");
             
             for (var i = 0; i < alertmarker.length; i++) 
             {
            // obtain the attribues of each marker
            //this is for the "Alerts" icon
            
            CountyID[i] = Trim(alertmarker[i].getAttribute("countyid"));
            filename[i] = Trim(alertmarker[i].getAttribute("filename"));
            regioname[i] = Trim(alertmarker[i].getAttribute("name"));
            
            }
             
                     
             var infoHtmls;
                 infoHtmls = '<div class="title">';
			     infoHtmls += regioname[0];
		         infoHtmls += '</div>';
                 infoHtmls += '<div style="font-size:small">';
                 infoHtmls += '<tr>';
                 infoHtmls += '<td>';
                 infoHtmls += '&nbsp;<b>Select a County Name :</b> ';
                 infoHtmls += '<select id="WeatherAlertsDDL" onchange = "javascript:SaveAlertsDDLValue(this.value);" >';
             for(var i=0; i< filename.length; i++)
             {
                 infoHtmls += '<option value="' + CountyID[i] + '">';
                 infoHtmls += filename[i];
                 infoHtmls += '</option>';
				 
             }
                 infoHtmls += '</select>';
			     infoHtmls += '</td>';
			     infoHtmls += '</tr>';
			     infoHtmls += '</div>';  
	     }
	     catch(e){
	     alert("An error occured while retreiving weather alert data.\nPlease try again later.");
         return;
	     }

        //Get the weather alerts for the first county which will be the default view.

         var alertDiv;
         var request1 = GXmlHttp.create();
         var url = "./xml/getWeatherAlerts.aspx?Countyid=" + CountyID[0];
        request1.open("GET", url, true);
        
        request1.onreadystatechange = function() 
        {
          if (request1.readyState == 4) 
          {
           try
           {
            if (request1.status == 404) 
            {
              alert("An error occured while retreiving weather alert data.\nPlease try again later.");
              hidePleaseWaitScreen();
              googleMap.closeExtInfoWindow();
              return;
            }
            
            var xml4 = request1.responseXML;
            
            if (xml4.documentElement.getElementsByTagName("errorDesc").length != 0) {
              //error grabbing weather alert
              alert("An error occured while retreiving weather alert data.\nPlease try again later.");
              hidePleaseWaitScreen();
              googleMap.closeExtInfoWindow();
              return;
            }
            
            //var cont = document.getElementById('weatherAlertDiv');
            alertDiv = getTransformedDoc(xml4, xsla);
              
            //globaly replace less than greater than with symbols
            alertDiv = alertDiv.replace(/&lt;/g,'<');
            alertDiv = alertDiv.replace(/&gt;/g,'>');
            
            returnalertdiv = alertDiv;
            
             var cont = document.createElement('div');
             cont.setAttribute('id','weatherAlertDiv');
               
             cont.innerHTML = infoHtmls + returnalertdiv;
            if(cont.innerHTML == "") {
              alert("An error occured while retreiving weather alert data.\nPlease try again later.");
              hidePleaseWaitScreen();
              googleMap.closeExtInfoWindow();
              return;
            } 
              
            tempmarker = marker;
            
            //special extended marker  
                     
            marker.openExtInfoWindow(
              googleMap,
              "weatherAlertPopup",
              cont.innerHTML,
              {beakOffset: 2}
            ); 
            
            hidePleaseWaitScreen();
          }
	      catch(e)
	      {
	      alert("An error occured while retreiving weather alert data.\nPlease try again later.");
	      hidePleaseWaitScreen();
          googleMap.closeExtInfoWindow();
          return;
	      }
            
         }// end if (request.readyState == 4)
        }// end request.onreadystatechange = function() {
        request1.send(null);
      
      weatherAlertPopupDisplayed = true;
       }
      }

        request.send(null);
      }// end else {//type == "alert"
      
      weatherAlertPopupDisplayed = true;
    });

    GEvent.addListener(marker,"mouseover", function() {
        markerTooltipFlag=true;
        clearPopupTimer();
    	showTooltip(marker);
    });        
    GEvent.addListener(marker,"mouseout", function() {
        markerTooltipFlag=false;
		markerTooltip.style.visibility="hidden"
    });       
    
    GEvent.addListener(googleMap, "extinfowindowclose", function() {
        //return the map to its original position.
        googleMap.returnToSavedPosition();    
        weatherAlertPopupDisplayed = false;
    });
     
}


function SaveAlertsDDLValue(CountyIDVal)
{
     try
     {
      showPleaseWaitScreen("Please wait while we retreive weather alert information");
    
             var infoHtmls;
                 infoHtmls = '<div class="title">';
			     infoHtmls += regioname[0];
		         infoHtmls += '</div>';
                 infoHtmls += '<div style="font-size:small">';
                 infoHtmls += '<tr>';
                 infoHtmls += '<td>';
                 infoHtmls += '&nbsp;<b>Select a County Name :</b> ';
                 infoHtmls += '<select id="WeatherAlertsDDL" onchange = "javascript:SaveAlertsDDLValue(this.value);" >';
             for(var i=0; i< filename.length; i++)
             {
                 if(CountyIDVal == CountyID[i])
                 {
                     infoHtmls += '<option value="' + CountyID[i] + '" selected>';
                     infoHtmls += filename[i];
                     infoHtmls += '</option>';
                  }
                  else
                  {
                     infoHtmls += '<option value="' + CountyID[i] + '">';
                     infoHtmls += filename[i];
                     infoHtmls += '</option>';
                  }
				 
             }
                 infoHtmls += '</select>';
			     infoHtmls += '</td>';
			     infoHtmls += '</tr>';
			     infoHtmls += '</div>';  

         var alertDiv;
         
         var request2 = GXmlHttp.create();
         var url = "./xml/getWeatherAlerts.aspx?Countyid=" + CountyIDVal;
        request2.open("GET", url, true);
        
        request2.onreadystatechange = function() 
        {
          if (request2.readyState == 4) 
          {
            try
            {
             if (request2.status == 404) 
             {
              alert("An error occured while retreiving weather alert data.\nPlease try again later.");
              hidePleaseWaitScreen();
              googleMap.closeExtInfoWindow();
              return;
             }
            
            var xml5 = request2.responseXML;
            
            if (xml5.documentElement.getElementsByTagName("errorDesc").length != 0) {
              //error grabbing weather alert
              alert("An error occured while retreiving weather alert data.\nPlease try again later.");
              hidePleaseWaitScreen();
              googleMap.closeExtInfoWindow();
              return;
            }
            
           
            //var cont = document.getElementById('weatherAlertDiv');
            alertDiv = getTransformedDoc(xml5, xsla);
              
            //globaly replace less than greater than with symbols
            alertDiv = alertDiv.replace(/&lt;/g,'<');
            alertDiv = alertDiv.replace(/&gt;/g,'>');
            
            returnalertdiv = alertDiv;
            
             var cont = document.createElement('div');
             cont.setAttribute('id','weatherAlertDiv');
               
             cont.innerHTML = infoHtmls + returnalertdiv;
            if(cont.innerHTML == "") {
              alert("An error occured while retreiving weather alert data.\nPlease try again later.");
              hidePleaseWaitScreen();
              googleMap.closeExtInfoWindow();
              return;
            } 
              
            //special extended marker  
            request2 = null;
                     
            tempmarker.openExtInfoWindow(
              googleMap,
              "weatherAlertPopup",
              cont.innerHTML,
              {beakOffset: 2}
            ); 
            
            hidePleaseWaitScreen();
           }
           catch(e)
           {
              alert("An error occured while retreiving weather alert data.\nPlease try again later.");
              hidePleaseWaitScreen();
              googleMap.closeExtInfoWindow();
              return;
           }
            
          }// end if (request.readyState == 4)
        }// end request.onreadystatechange = function() {
        request2.send(null);
        
      
      weatherAlertPopupDisplayed = true;
      }
      catch(e){
      alert("An error occured while retreiving weather alert data.\nPlease try again later.");
            hidePleaseWaitScreen();
            googleMap.closeExtInfoWindow();
              return;
      }


//    GEvent.addListener(tempmarker,"mouseover", function() 
//    {
//        markerTooltipFlag=true;
//        clearPopupTimer();
//    	showTooltip(tempmarker);
//    });        
//    GEvent.addListener(tempmarker,"mouseout", function() 
//    {
//        markerTooltipFlag=false;
//		markerTooltip.style.visibility="hidden"
//    });       
    
    GEvent.addListener(googleMap, "extinfowindowclose", function() 
    {
        //return the map to its original position.
        googleMap.returnToSavedPosition();    
        weatherAlertPopupDisplayed = false;
    });
     
}


function SaveForecastDDLValue(ForecastCountyIDVal)
{
     try
     {
      showPleaseWaitScreen("Please wait while we retreive weather forecast information");
    
             var infoHtmls;
                 infoHtmls = '<div class="title">';
			     infoHtmls += Forecastregioname[0];
		         infoHtmls += '</div>';
                 infoHtmls += '<div style="font-size:small">';
                 infoHtmls += '<tr>';
                 infoHtmls += '<td>';
                 infoHtmls += '&nbsp;<b>Select a County Name :<b> ';
                 infoHtmls += '<select id="WeatherForecastDDL" onchange = "javascript:SaveForecastDDLValue(this.value);" >';
             for(var i=0; i< Forecastfilename.length; i++)
             {
                 if(ForecastCountyIDVal == Forecastfilename[i])
                 {
                     infoHtmls += '<option value="' + Forecastfilename[i] + '" selected>';
                     infoHtmls += Forecastfilename[i];
                     infoHtmls += '</option>';
                  }
                  else
                  {
                     infoHtmls += '<option value="' + Forecastfilename[i] + '">';
                     infoHtmls += Forecastfilename[i];
                     infoHtmls += '</option>';
                  }
				 
             }
                 infoHtmls += '</select>';
			     infoHtmls += '</td>';
			     infoHtmls += '</tr>';
			     infoHtmls += '</div>';  

         var alertDiv;
         
         var Forecastrequest2 = GXmlHttp.create();
         var url = "./xml/getWeatherForecasts.aspx?xmlFile=" + ForecastCountyIDVal + ".xml";
        Forecastrequest2.open("GET", url, true);
        
        Forecastrequest2.onreadystatechange = function() 
        {
          if (Forecastrequest2.readyState == 4) 
          {
            try
            {
                if (Forecastrequest2.status == 404) 
                {
                  alert("An error occured while retreiving weather forecast data.\nPlease try again later.");
                  hidePleaseWaitScreen();
                  return;
                }
            
                var xml6 = Forecastrequest2.responseXML;
                
                if (xml6.documentElement.getElementsByTagName("errorDesc").length != 0) {
                  //error grabbing weather alert
                  alert("An error occured while retreiving weather forecast data.\nPlease try again later.");
                  hidePleaseWaitScreen();
                  googleMap.closeExtInfoWindow();
                  return;
                }
                
               
                //var cont = document.getElementById('weatherAlertDiv');
                alertDiv = getTransformedDoc(xml6, xsl);
                  
                //globaly replace less than greater than with symbols
                alertDiv = alertDiv.replace(/&lt;/g,'<');
                alertDiv = alertDiv.replace(/&gt;/g,'>');
                
              
                
                 var cont = document.createElement('div');
                 cont.setAttribute('id','weatherAlertDiv');
                   
                 cont.innerHTML = infoHtmls + alertDiv;
                 
                if(cont.innerHTML == "") {
                  alert("An error occured while retreiving weather forecast data.\nPlease try again later.");
                  hidePleaseWaitScreen();
                  googleMap.closeExtInfoWindow();
                  return;
                } 
                  
                //special extended marker  
                         
                tempmarkerForecast.openExtInfoWindow(
                  googleMap,
                  "weatherForecastPopup",
                  cont.innerHTML,
                  {beakOffset: 2}
                ); 
                
                hidePleaseWaitScreen();
            }
            catch(e)
            {
              alert("An error occured while retreiving weather alert data.\nPlease try again later.");
              hidePleaseWaitScreen();
              googleMap.closeExtInfoWindow();
              return;
            }
            
          }// end if (request.readyState == 4)
        }// end request.onreadystatechange = function() {
        Forecastrequest2.send(null);
      
      weatherAlertPopupDisplayed = true;
     }
     catch(e){
     alert("An error occured while retreiving weather forecast data.\nPlease try again later.");
             
              return;
     }

//    GEvent.addListener(tempmarkerForecast,"mouseover", function() 
//    {
//        markerTooltipFlag=true;
//        clearPopupTimer();
//    	showTooltip(tempmarkerForecast);
//    });        
//    GEvent.addListener(tempmarkerForecast,"mouseout", function() 
//    {
//        markerTooltipFlag=false;
//		markerTooltip.style.visibility="hidden"
//    });       
    
    GEvent.addListener(googleMap, "extinfowindowclose", function() 
    {
        //return the map to its original position.
        googleMap.returnToSavedPosition();    
        weatherAlertPopupDisplayed = false;
    });
     
}

//method called from createWeatherMarker()
function getTransformedDoc(xmlD, xslD) {
  if (document.implementation && document.implementation.createDocument){ 
    xsltProcessor = new XSLTProcessor();
    xsltProcessor.importStylesheet(xslD);    
    var output = xsltProcessor.transformToDocument(xmlD); 
    var serial = new XMLSerializer();
    resultDoc = serial.serializeToString(output);
  }
  else if (window.ActiveXObject){ 
    resultDoc = xmlD.transformNode(xslD);
  }  
  return resultDoc;
} 

