﻿<!-- hide script from old browsers
// follow mouse only when hover div is showing
var followCursor = false;

// Detect if the browser is IE or not.
// If it is not IE, we assume that the browser is NS.
var IE = document.all?true:false

// Temporary variables to hold mouse x-y pos.s
//var mouseX = 0
//var mouseY = 0

// If NS -- that is, !IE -- then set up for mouse capture
if (!IE) document.captureEvents(Event.MOUSEMOVE)

// Set-up to use getMouseXY function onMouseMove
document.onmousemove = getMouseXY;
var DefaultUnitType;

function GetDefaultUnitType()
{
    if(DefaultUnitType == undefined)
    {
        DefaultUnitType = '2br';
    }
    return DefaultUnitType;
}

/////////////////////////////////////////////////////////////////////////////////////////////
// called on page load
function initThematicMap()
{
  // parse the query string and set params[]
  BuildQuerystringPost();
  //alert(this.params['level']);
  document.getElementById('NationalTab').className = '';
  document.getElementById('RegionalTab').className = '';
  document.getElementById('DivisionTab').className = '';
  document.getElementById('StateTab').className = '';
  document.getElementById('CountyTab').className = '';
  
    
  if ( this.params['level'] == 'regional' || this.params['level'] == 'regionalstart' )
    document.getElementById('RegionalTab').className = 'selected';
  else if ( this.params['level'] == 'division' || this.params['level'] == 'divisionstart')
    document.getElementById('DivisionTab').className = 'selected';
  else if ( this.params['level'] == 'state' ){
    if(this.params['state']){
        $('StateName').html(this.params['state']);
    }
    document.getElementById('StateTab').className = 'selected';
  }
  else if ( this.params['level'] == 'county' )
    
    document.getElementById('CountyTab').className = 'selected';
  else if (this.params['level'] == 'national')
    document.getElementById('NationalTab').className = 'selected'; 
  else
  {//Default Selection is national map
       this.params['level'] = 'national';
       document.getElementById('NationalTab').className = 'selected'; 
  }
  UpdateIndicesTableBedsChanged(showBeds);
  DropDownUnitType();
    
}

/////////////////////////////////////////////////////////////////////////////////////////////
// Tied to onmousemove, if the Hover div is showing then move it with the mouse
function getMouseXY(e) {
  if (!followCursor)
  {
    return true;
  }

  //create objects to store Mouse Coordinates
  var objMouseCoords = new MouseCoords();
  captureMouseCoords(e, objMouseCoords);
  var mouseX = objMouseCoords.X;
  var mouseY = objMouseCoords.Y;
  SetHoverLocation(mouseX, mouseY);
  return true;
}

function SetHoverLocation(mouseX, mouseY)
{

  var d = document;
  
  // get divs that move
  var hoverDiv=d.getElementById?d.getElementById('HoverDiv'):d.all?d.all['HoverDiv']:d.layers['HoverDiv'];
  var IndexTrendGraph_HiddenValue=d.getElementById?d.getElementById('IndexTrendGraph_HiddenValue'):d.all?d.all['IndexTrendGraph_HiddenValue']:d.layers['IndexTrendGraph_HiddenValue'];
         
  if (hoverDiv)
  {
    if ((mouseX + hoverDiv.clientWidth + 25) < document.body.clientWidth)
    {
        hoverDiv.style.left = mouseX + 15 + "px";
    }
    else 
    {
        hoverDiv.style.left = mouseX - (hoverDiv.clientWidth + 15) + "px";
    }
    
    if (mouseY + hoverDiv.clientHeight + 25 < document.documentElement.clientHeight)
    {
        hoverDiv.style.top = mouseY + 15 + "px";
    }
    else 
    {
        hoverDiv.style.top = mouseY - (hoverDiv.clientHeight + 15) + "px";
    }
    
  }
  else 
  { 
    //alert("no div");
  }
  
  
  if (IndexTrendGraph_HiddenValue)
  {
    IndexTrendGraph_HiddenValue.style.left = mouseX + 10 + "px";
    IndexTrendGraph_HiddenValue.style.top = mouseY + 5 + "px";
    //alert(IndexTrendGraph_HiddenValue.style.left + "," + IndexTrendGraph_HiddenValue.style.top);
  }
  else 
  { 
    //alert("no div");
  }
  
    
  return true
}

/////////////////////////////////////////////////////////////////////////////////////////////
// called when user clicks a feature and is logged in
// In the aspx page so we can generate the client id for the modal server control
var doDeHover = true;
function ItemClickLoggedIn(key)
{
  this.params['pkey'] = this.params['key'];
  this.params['key'] = key;
  navigate();
  doDeHover = false;
}

/////////////////////////////////////////////////////////////////////////////////////////////
// called when user clicks a feature and is not logged in, will try to show the modal dialog
// In the aspx page so we can generate the client id for the modal server control
function ItemClickNotLoggedIn(key)
{
    ItemClickLoggedIn(key);
   /*try{ 
      var moddialog = $find("pnlSubscribeBox");
      moddialog.show();
   }
   catch(ex){var i;}*/
}

var hoverCount = 0;
/////////////////////////////////////////////////////////////////////////////////////////////
// hover event tied to an image map.  When mouse enters an image map this is called
function ItemHover(key)
{
    hoverCount = hoverCount + 1;

    var objMouseCoords = new MouseCoords();
    captureMouseCoords(event, objMouseCoords);
    setTimeout('doHover(' + key + ',' + hoverCount + ', ' + objMouseCoords.X + ','+ objMouseCoords.Y + ')',200); 
}

function doHover(key, count, mouseX, mouseY)
{
    if(hoverCount == count)
    {
    // begin tracking
       followCursor = true;
       
       var imgMain;
       var imgAlaska;
       var imgHawaii;

       // map_and_hover_image is the overlay for showing the highlighted feature
       if(this.params != null)
       {
         var level = this.params['level'];
         if(level == null)
         {
         }
       }
       else
       {
         return;
       }
       
       var pkey = this.params['key'];
       if(pkey == null)
       {
       }
       // if key is 1000107, then select the upper left (alaska) div for the highlight
       // if the key is, 1000117 likewise for bottemleft div
       if(key==1000107 || key==1000117)
       {
         // The following cases need to highlight a specific state, including Hawaii and Alaska
         if(level=='national' || level=='regional' || level=='division')
         {
           if(key==1000107)
           {
             imgAlaska=document.getElementById('map_and_hover_imageTL');
           }
           else if(key==1000117)
           {
             imgHawaii=document.getElementById('map_and_hover_imageBL');
           }
         }
       }
       // if key is 1000003 or 1000008, need to check on region and division level
       else 
         // in the following, the region/division, including hawaii and alaska needs to be highlighted
         if((level=='regionalstart' && key==1000003) ||
            (level=='divisionstart' && key==1000008))
         {
           imgMain=document.getElementById('map_and_hover_image');
           imgAlaska=document.getElementById('map_and_hover_imageTL');
           imgHawaii=document.getElementById('map_and_hover_imageBL');
         }
       
       // all others, the highlight will be shown in the main map
       else
       { 
         imgMain = document.getElementById('map_and_hover_image');
       }
       
       // if the main map has an image, show it
       if (imgMain!=null)
       {
          // use key passed from image map to set the appropriate highlight image                
          imgMain.src= 'ShowHighlightImage.aspx?key=' + key + '&pkey=' + pkey + '&level=' + level + '&map=main';   
       }   
       
       if(imgAlaska!=null)
       {
          // use key passed from image map to set the appropriate highlight image                
          imgAlaska.src= 'ShowHighlightImage.aspx?key=' + key + '&pkey=' + pkey + '&level=' + level + '&map=alaska';
       }
       
       if(imgHawaii!=null)
       {
          // use key passed from image map to set the appropriate highlight image                
          imgHawaii.src= 'ShowHighlightImage.aspx?key=' + key + '&pkey=' + pkey + '&level=' + level + '&map=hawaii';
       }
       
       // Show the div and populate it with the appropriate indices
       // Since the hover can block the mouse from the map, show the div off screen initially
       // so the next mouse movement can set the div position right next to the cursor
       var hoverDiv = document.getElementById('HoverDiv');
       hoverDiv.style.left = -200 + "px";
       hoverDiv.style.top = -200 + "px";
       hoverDiv.style.visibility = "visible";
       HoverDivText(key, this.params['level'], this.params['statistic'], this.params['unit_type']);   
       
       
  SetHoverLocation(mouseX, mouseY);  
   }
}

/////////////////////////////////////////////////////////////////////////////////////////////
// de-hover event
function ItemDeHover(key)
{
     setTimeout('doTheDeHover(' + key + ')',200); 
}

function doTheDeHover(key)
{
// no need to track
    followCursor = false;
        
    if (doDeHover == false)
    {
       return;
    }
    
    
    
   var imgMain;
   var imgAlaska;
   var imgHawaii;

   // map_and_hover_image is the overlay for showing the highlighted feature
   if(this.params != null)
   {
     var level = this.params['level'];
     if(level == null)
     {
     }
   }
   

   // if key is 1000107, then select the upper left (alaska) div for the highlight
   // if the key is, 1000117 likewise for bottemleft div
   var img;
   if(key==1000107)
   {
     if(level=='national' || level=='regional' || level=='division')
     {
       img=document.getElementById('map_and_hover_imageTL');
       img.src='img/transparent250x150.png';
     }
   }
   else if(key==1000117)
   {
     if(level=='national' || level=='regional' || level=='division')
     {
       img=document.getElementById('map_and_hover_imageBL');
       img.src='img/transparent250x150.png';
     }  
   }
   // if we were looking at regionstart, and the west region, make sure to clear all 3 maps (main
   // alaska and hawaii)
   else if(key==1000003 && level == 'regionalstart')
   {
     img = document.getElementById('map_and_hover_image');
     img.src='img/transparent.png';
     img=document.getElementById('map_and_hover_imageTL');
     img.src='img/transparent250x150.png';
     img=document.getElementById('map_and_hover_imageBL');
     img.src='img/transparent250x150.png';
   }
   // if we were looking at divisionstart, and the pacific division, make sure to clear all 3 maps (main
   // alaska and hawaii)

   else if(key==1000008 && level == 'divisionstart')
   {
     img = document.getElementById('map_and_hover_image');
     img.src='img/transparent.png';
     img=document.getElementById('map_and_hover_imageTL');
     img.src='img/transparent250x150.png';
     img=document.getElementById('map_and_hover_imageBL');
     img.src='img/transparent250x150.png';
   }
   else
   {
     img = document.getElementById('map_and_hover_image');
     img.src='img/transparent.png';
   }
   
   if (img!=null)
   {
        HideElement('HoverDiv');
   }
}

/////////////////////////////////////////////////////////////////////////////////////////////
// Call the hover web service
function HoverDivText(state, level, statistic, unit_type)
{
    if ( level == null || level == "undefined" || statistic == null || statistic == "undefined" || unit_type == null || unit_type == "undefined" ) 
    {
       return;
    }

    try
    {
        // JTF 8/7/08, set text to 'please wait' 
        var hoverDivContent =$('#HoverDivContent');
        hoverDivContent.show();
        hoverDivContent.html('Please Wait..');
        //HoverService.GetStateInformation(state, getCallback, null);
        HoverService.GetStateInformation(state, level, statistic, unit_type, ThematicHoverDivCallBack, ThematicHoverDivCallBack_Failure);
    }
    catch(err)
    {
        return false;
    }
}
//Need this because if the image is clicked before the hover
//has loaded you will get an error.
function ThematicHoverDivCallBack_Failure(errors, userContext, methodName) {

}

/////////////////////////////////////////////////////////////////////////////////////////////
// handle match results
function ThematicHoverDivCallBack(respStr)
{

    var hoverDivContent = document.getElementById('HoverDivContent');
    hoverDivContent.innerHTML = respStr;
}
        
/////////////////////////////////////////////////////////////////////////////////////////////
// use the pathname and attach a new query string based on current params and the key
// from the feature clicked on.  Navigate to the new URL-querystring
function relocate() 
{ 
  // level is navigation level.  Valid values are national, regionalstart, divisionstart, 
  // regional, division, state, county and selectstart
  var level = this.params['level'];
  if(level == null)
  {
     // default to national
     level='national';
  }
  
  // statistic can have values of propertycount, unitcount, averagerent, vacancy, 
  // and rentsqft (rent/sqft average)
  var statistic = this.params['statistic'];
  if(statistic == null)
  {
     // default to unit count
     statistic='averagerent';
  }
  
  // unit_type is the number of bedrooms.  Valid values are all, studio, bdrm1, bdrm2, bdrm3, and bdrm4plus.
  var unit_type = this.params['unit_type'];
  if(unit_type == null)
  {
     unit_type = GetDefaultUnitType();
  }
  
  // key is integer for primary key at current level
  var key = this.params['key'];
  if(key == null)
  {
     key = 0;
  }
  
  // pkey, or parent key is integer for primary key of parent level
  var pkey = this.params['pkey'];
  if(pkey == null)
  {
     pkey = 0;
  }
      
  // build the query string and post
  location.href = location.pathname + '?key='+key+'&pkey='+pkey+'&level='+level+'&unit_type='+unit_type+'&statistic='+statistic; 
}

/////////////////////////////////////////////////////////////////////////////////////////////
// build a query string for retrieving and image, and update the provided img
function UpdateImage(imagename) 
{ 
  var level = this.params['level'];
  if(level == null)
  {
     // TODO error proc
  }
  
  var statistic = this.params['statistic'];
  if(statistic == null)
  {
     // TODO error proc
  }
  
  var unit_type = this.params['unit_type'];
  if(unit_type == null)
  {
     // TODO error proc
  }
  
  var key = this.params['key'];
  if(key == null)
  {
     // TODO error proc
  }

  var pkey = this.params['pkey'];
  if(pkey == null)
  {
     // TODO error proc
  }
        
  // build the query string
  var qstring = '?key='+key+'&pkey='+pkey+'&level='+level+'&unit_type='+unit_type+'&statistic='+statistic; 
  var img = document.getElementById(imagename);
   
  if (img!=null)
  {
      img.src= 'ShowImage.aspx' + qstring;
  }
}

function ThematicMenu(dest){ 
    if ( dest == 'state') 
        dest = 'national';
    if ( dest == 'county') 
        dest = 'national';
    
    var statistic = this.params['statistic'];
      if(statistic == null)
      {
         // default to unit count
         statistic='averagerent';
      }
      
      // unit_type is the number of bedrooms.  Valid values are all, studio, bdrm1, bdrm2, bdrm3, and bdrm4plus.
      var unit_type = this.params['unit_type'];
      if(unit_type == null)
      {
         unit_type = GetDefaultUnitType();
      }
      // build the query string and post
  location.href = location.pathname + '?key=0&pkey=0&level='+dest+'&unit_type='+unit_type+'&statistic='+statistic; 
  
}
/////////////////////////////////////////////////////////////////////////////////////////////
// use the pathname and attach a new search based on current params and the key
// from the feature clicked on.
function navigate() 
{ 
  // level is navigation level.  Valid values are national, regionalstart, divisionstart, 
  // regional, division, state,and county.  This function will pass the next level down,
  // for example if the level is state, this function will pass county.
  var level = this.params['level'];
  if(level == null)
  {
     // this should not happen
     return;
  }
  
    // statistic can have values of propertycount, unitcount, averagerent, vacancy, 
  // and rentsqft (rent/sqft average)
  var statistic = this.params['statistic'];
  if(statistic == null)
  {
     // default to unit count
     statistic='averagerent';
  }
  
  // unit_type is the number of bedrooms.  Valid values are all, studio, bdrm1, bdrm2, bdrm3, and bdrm4plus.
  var unit_type = this.params['unit_type'];
  if(unit_type == null)
  {
     unit_type = GetDefaultUnitType();
  }
  
  // key is integer, primary key
  var key = this.params['key'];
  if(key == null)
  {
     key = 0;
  }
  
  // pkey is integer, primary key of parent
  var pkey = this.params['pkey'];
  if(pkey == null)
  {
     pkey = 0;
  }  
  
  switch(level)
  {
     case 'national':
        level = 'state';
        break;
     case 'regionalstart':
        level = 'regional';
        break;
     case 'divisionstart':
        level = 'division';
        break;
     case 'regional':
        level = 'state';
        break;
     case 'division':
        level = 'state';
        break;
     case 'state':
        level = 'county';
        break;
     case 'county':
        // set key and level back to default values n case the property search page cannot be navigated to
        this.params['key'] = null;
        this.params['level'] = 'national';
        level = 'zip';
        break;
  }
  
  // build the query string and post
  location.href = location.pathname + '?key='+key+'&pkey='+pkey+'&level='+level+'&unit_type='+unit_type+'&statistic='+statistic; 
  
}

/////////////////////////////////////////////////////////////////////////////////////////////
// called when dropdown for level changes.  Get new level and 
// post
function DropDownLevel(ob)
{
  var number = ob.selectedIndex;
  
  if (ob.options[number].value == 'selectstart')
  {
      return;
  }
  
  this.params['level']=ob.options[number].value;
  relocate();  
}

/////////////////////////////////////////////////////////////////////////////////////////////
// called when the dropdown for statistic changes.  Gets the new value for
// statistic and posts
function DropDownStatistic(ob)
{
  var number = ob.selectedIndex;
  /*switch(number) {
     case 0:
        //TrendClickChange('1000000');
        break;
     case 1:
        //TrendClickChange('1000001');
        break;
     case 2:
        //TrendClickChange('1000002');
        break;
     case 3:
        //TrendClickChange('1000003');
        break;
     default:
        //TrendClickChange('1000000');
        break;
  }*/
  this.params['statistic']=ob.options[number].value;
  UpdateImage('mapMDNS');
  UpdateThemeLegend();
}

function InitThematicMap2()
{
//    this.params['statistic'] = 'averagerent';
//    this.params['unit_type']= showBeds;
//    UpdateImage('mapMDNS');
//    UpdateThemeLegend();
//    DropDownUnitType()


}


GlobalLookup.addListener("CurrentBedSelection", DropDownUnitType);

/////////////////////////////////////////////////////////////////////////////////////////////
// called when the dropdown for unit type changes.  Gets the new value for
// statistic and posts
function DropDownUnitType(newValue)
{
var currentBeds;
    if (newValue == 0) {
        currentBeds = 'studio'
    } else if (newValue == 1) {
        currentBeds = '1br'
    } else if (newValue == 2) {
        currentBeds = '2br'
    } else if (newValue == 3) {
        currentBeds = '3br'
    } else if (newValue == 4) {
        currentBeds = '4br'
    }
  //var number = ob.selectedIndex;
  this.params['unit_type']= currentBeds;
  UpdateImage('mapMDNS');
  
    //Find unit type element
    var input = document.getElementsByTagName("input"); 
    for (var i = 0; i < input.length; i++) 
    {
        if (input[i].id.indexOf('unit_type') > -1)
        {
            //Update UnitType for ThematicIndicesControl
            switch (currentBeds)
            {
                case "studio":
                    input[i].value = "value_studio";
                    break;
                case "1br":
                    input[i].value = "value_1br";
                    break;
                case "2br":
                    input[i].value = "value_2br";
                    break;
                case "3br":
                    input[i].value = "value_3br";
                    break;
                case "4br":
                    input[i].value = "value_4br";
                    break;
                default:
                    input[i].value = "value_all";
                    break;
            }
        }
    }
    
    //Update ThematicIndices Table
    //OnLoadThematic();
  UpdateThemeLegend();
}

/////////////////////////////////////////////////////////////////////////////////////////////
// this is called when statistic or unit_type changes.  display legend for new selection
// and make sure everything wlse is turned off.
//
function UpdateThemeLegend()
{
  // get the theme legend div so we can find the appropriate rows.
  var tlegend = document.getElementById("ThemeLegendDiv");  
  var numkids = tlegend.childNodes.length;
  
  // get current values for statistic and unit_type 
  var stats = this.params['statistic'];
  var unittype = this.params['unit_type'];
  
    switch (unittype)
    {
        case "studio":
            unittype = "studio";
            break;
        case "1br":
            unittype = "bdrm1";
            break;
        case "2br":
            unittype = "bdrm2";
            break;
        case "3br":
            unittype = "bdrm3";
            break;
        case "4br":
            unittype = "bdrm4plus";
            break;
        default:
            unittype = "all";
            break;
    }
            
  // traverse all the legend rows, turning on the one that is currently selected
  // and turning off all others
  for(var i = 0; i < numkids; i++)
  {
    var themerow = tlegend.childNodes[i];
    // div names are of the form statistic_unittype
    var strSplit = themerow.id.split('_');
    if((stats == strSplit[0]) && (unittype == strSplit[1]))
    {
       themerow.style.display='block';
    }
    else
    {
      themerow.style.display='none';
    }
  }
}


/////////////////////////////////////////////////////////////////////////////////////////////
// Called on page init, parse the query string and save it in the params.
// Set the value in the dropdowns based on the querystring
// TODO move to head, then to file
//
function BuildQuerystringPostBase() 
{
    this.params = new Object()
	this.get=Querystring_get
	
    qs=location.search.substring(1,location.search.length)
	if (qs.length == 0) 
	{
	   // no query string, so set defaults
	   this.params['level'] = 'national';
	   this.params['statistic'] = 'averagerent';
	   this.params['unit_type'] = GetDefaultUnitType();
	}

    // Turn <plus> back to <space>
    // See: http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.13.4.1
	qs = qs.replace(/\+/g, ' ')
	var args = qs.split('&') // parse out name/value pairs separated via &
	
    // split out each name=value pair
	for (var i=0;i<args.length;i++) {
		var value;
		var pair = args[i].split('=')
		var name = unescape(pair[0])

	    if (pair.length == 2)
	 		value = unescape(pair[1])
	    else
			value = name
		
	    this.params[name] = value
	}
}

function BuildQuerystringPost() 
{ 
	this.params = new Object()
	this.get=Querystring_get
	
    qs=location.search.substring(1,location.search.length)
	if (qs.length == 0) 
	{
	   // no query string, so set defaults
	   this.params['level'] = 'national';
	   this.params['statistic'] = 'averagerent';
	   this.params['unit_type'] = GetDefaultUnitType();
	}

    // Turn <plus> back to <space>
    // See: http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.13.4.1
	qs = qs.replace(/\+/g, ' ')
	var args = qs.split('&') // parse out name/value pairs separated via &
	
    // split out each name=value pair
	for (var i=0;i<args.length;i++) {
		var value;
		var pair = args[i].split('=')
		var name = unescape(pair[0])

	    if (pair.length == 2)
	 		value = unescape(pair[1])
	    else
			value = name
		
	    this.params[name] = value
	}
	
	// set level dropdown to current level if a starting level, default to prompt to select starting
	// if not a starting level
	var ddl = document.getElementById('LevelDDL');
	var myLevel = this.params['level'];
	if(myLevel!='national' && myLevel!='divisionstart' && myLevel!='regionalstart')
	{
	  myLevel='selectstart';
	}
	
	// find the index in the drop down that matches the current level, and make this the DDL value
	for(index = 0; index < ddl.length; index++)
	{
	    if(ddl[index].value == myLevel)
	    {
	       ddl.selectedIndex=index;
	       break;
	    }
	}
	
    // set statistic dropdown
    //var sddl = form1.StatisticDDL;
	var sddl = document.getElementById('StatisticDDL');

	for(index = 0; index < sddl.length; index++)
	{
	    if(sddl[index].value == this.params['statistic'])
	    {
	       sddl.selectedIndex=index;
	       break;
	    }
	}    

    // set unit type dropdown
    //var utddl = form1.UnitTypeDDL;
	var utddl = document.getElementById('UnitTypeDDL');
	for(index = 0; index < utddl.length; index++)
	{
	    if(utddl[index].value == this.params['unit_type'])
	    {
	       showBeds = this.params['unit_type'];
	       utddl.selectedIndex=index;
	       break;
	    }
	}  
}

/////////////////////////////////////////////////////////////////////////////////////////////
// Support for BuildQueryString
function Querystring_get(key, default_) {
	// This silly looking line changes UNDEFINED to NULL
	if (default_ == null) default_ = null;
	
	var value=this.params[key]
	if (value==null) value=default_;
	
	return value
}

/////////////////////////////////////////////////////////////////////////////////////////////
// TODO function description
function OnLoadThematic()
{
 var found =false;
    var input = document.getElementsByTagName("input"); 
    for (var x = 0; x < input.length; x++) 
    {
        if (input[x].id.indexOf('compare_type') > -1)
        {
            UpdateIndicesTable(showBeds, input[x].value);
            hideShowLinks(input[x].value)
  
            found=true;
        }
    }
}

/////////////////////////////////////////////////////////////////////////////////////////////
// TODO function description
function addEvent(obj, evType, fn)
{
    if (obj.addEventListener)
    {
        obj.addEventListener(evType, fn, false);
        return true;
    }
    else if (obj.attachEvent)
    {
        var r = obj.attachEvent("on"+evType, fn);
        return r;
    }
    else
    {
        return false;
    }
}

function noselect()
{
  return false;
}

-->
