var pageLoaded = false;

function onLoadComplete() {
	pageLoaded = true;
}

function isPageLoaded() {
	return pageLoaded;
}


function imageFadeIn(img) 
{
  if ( document.all) 
  {

    //img.opacity = 0;
    //setOpacity(img.name, 20, 10);
	img.opacity = 60;
    img.style.filter = 'alpha(opacity = ' + img.opacity + ')'; 	
  }
  else if (document.getElementById)
  {
	img.opacity = 60;
    img.style.filter = 'alpha(opacity = ' + img.opacity + ')'; 	//For IE
    img.style.MozOpacity = img.opacity/10;  // For older Mozilla 
	img.style.opacity = img.opacity/10;  // For recent Mozilla & non-IE 
  }
}
function setOpacity (imgName, step, delay) 
{
  var img = document.images[imgName];
  img.opacity += step;
  if (document.all) img.style.filter = 'alpha(opacity = ' + img.opacity + ')';
  if (step > 0 && img.opacity < 60 || step < 0 && img.opacity > 0)
    setTimeout('setOpacity("' + img.name + '",' + step + ', ' + delay + ')', delay);
} 

  function gotoCountyPage(areaId)
    {
      var qs = new Querystring();
      var edid = paddedEdition(qs.get('edid',0));
      var salerent = qs.get('salerent',0);
      window.location.href = 'listcounties.aspx?edid=' + edid + '&salerent=' + salerent + '&countyid=' + areaId;
    }

  function gotoRegionPage(areaId)
    {
      var qs = new Querystring();
      var edid = paddedEdition(qs.get('edid',0));
      var salerent = qs.get('salerent',0);
      window.location.href = 'listregions.aspx?edid=' + edid + '&salerent=' + salerent  + '&regionid=' + areaId;
    }

  function gotoGLRegionPage(areaId)
    {
      var qs = new Querystring();
      var edid = paddedEdition(qs.get('edid',0));
      var salerent = qs.get('salerent',0);
      window.location.href = 'listregions.aspx?edid=' + edid + '&salerent=' + salerent  + '&regionid=' + areaId + '&gl=1';
    }

  function gotoAreaPage(areaId)
    {
      var qs = new Querystring();
      var edid = paddedEdition(qs.get('edid',0));
      var salerent = qs.get('salerent',0);
      window.location.href = 'areadetails.aspx?edid=' + edid + '&salerent=' + salerent  + '&areaid=' + paddedArea(areaId);
    }

  function gotoSearchResultsPage(areaId)
    {
      var qs = new Querystring();
      var edid = paddedEdition(qs.get('edid',0));
      var salerent = qs.get('salerent',1);
      window.location.href = 'searchresults.aspx?edid=' + edid + '&salerent=' + salerent  + '&areaid=' + paddedArea(areaId);
    }

    function gotoURL(url) {
        window.location.href = url;
    }

    function paddedEdition(editionId)
    {
        var tp="0"+editionId;
        return tp.substring(tp.length-2,tp.length);
    }

    // pad area with 0s for areaIds shorter than 4 digits
    // 4 and 5 digit areaIds pass through this unmolested
    function paddedArea(ar)
    {
	    var tp="0000"+ar;
	    if(ar.length<4)
	    {
		    return tp.substring(tp.length-4,tp.length);		
	    } else {
		    return ar;
	    }
    }

