var hdiv = ""
var ldiv = ""
var cdiv = ""
var adiv = ""
var lcnt = 0
var hcnt = 0
var ccnt = 0
function data(plist, stat, descript, price, lotsize, taxID, pics)
{
this.plist = plist
this.stat = stat
this.descript = valDescript(descript)
this.price = valPrice(price)
this.lotsize = valSize(lotsize)
this.taxID = taxID
this.pics = valPics(pics)
}

function showProp(arg)
{
return showdata(arg)
}
  
function ReadList(arg)
{
var i
var ptype
i = 0
ptype = arg
var str = ""
var tok = ""
var tmp = ""
if(ptype=='homes')
  {
  if(getData.length==0)
    {
    tmp += "<div class='mdiv' id='h0'><br/><br/><center><span class='headtxt'>No Homes Listed at this time.  Contact Ken to list your Property Today!</span></center><a class='expand' id='mh" + i + "' href='javascript:showDiv(document.getElementById(&#34;" + "h0" + "&#34;))'>(more)</a></span><br/>"
    tmp += "<p style='text-align:center'><a href='http://www.bayrealtyalaska.com/AreaHomes.asp' class='blink' target='_blank'>View other area Home Listings at bayrealtyalaska.com</a></p></div>"
    tok = ""
    }
  else
    {
    tok = "h"
    for(i=0;i<getData.length;i++)
      {
      str = getData[i].price
      if(str.length > 40) then
        {
         str = ""
         for(x=0;x<41;x++)
           {
           str += getData[i].price.charAt(x)
           }
        } 
      tmp += "<div class='mdiv' id='h" + i + "'><span style='line-height:17px;'>" + getData[i].plist + " - " + str + "<a class='expand' id='mh" + i + "' href='javascript:showDiv(document.getElementById(&#34;" + "h" + i + "&#34;))'>(more)</a></span><br/>"
      if(getData[i].pics != null)
        {
        tmp += "<img src='http://www.bayrealtyalaska.com/homes/" + getData[i].plist + "/" + getData[i].pics + "' width='265' height='175'><br/>"
        }
      else
        {
        tmp += "<br/><br/><br/><br/><br/>"
        }
      tmp += "<span style='font-family:Arial;font-size:9pt;color:#993300;'>" + getData[i].stat + "</span><br/>" + getData[i].descript + "<br/><br style='line-height:3px;'/><b>Lot Size: </b>" + getData[i].lotsize + "<span class='tax'><b>Tax ID: </b>" + getData[i].taxID + "</span><br/><a href='http://www.bayrealtyalaska.com/?listing=" + getData[i].plist + "' class='blink' target='_blank'>View this listing at bayrealtyalaska.com</a></div>"
      hcnt++
      }
    }
  }

if(ptype == "lots")
  {
  if(getData.length==0)
    {
    tmp += "<div class='mdiv' id='l0'><br/><br/><center><span class='headtxt'>No Lots and Acreage Listed at this time.  Contact Ken to list your Property Today!</span></center><a class='expand' id='ml0' href='javascript:showDiv(document.getElementById(&#34;" + "l0" + "&#34;))'>(more)</a></span>"
    tmp += "<p style='text-align:center'><a href='http://www.bayrealtyalaska.com/acreage.asp' class='blink' target='_blank'>View other Lot and Acreage Listings at bayrealtyalaska.com</a></p></div>"
    tok = ""
    }
  else
    {
    tok = "l"
    for(i=0;i<getData.length;i++)
      {  
      str = getData[i].price
      if(str.length > 36) then
        {
         str = ""
         for(x=0;x<26;x++)
           {
           str += getData[i].price.charAt(x)
           }
        } 
      tmp += "<div class='mdiv' id='l" + i + "'><span style='line-height:17px;'>" + getData[i].plist + " - " + str + "<a class='expand' id='ml" + i + "' href='javascript:showDiv(document.getElementById(&#34;" + "l" + i + "&#34;))'>(more)</a></span><br/>"
      if(getData[i].pics != null)
        {
        tmp += "<img src='http://www.bayrealtyalaska.com/lots/" + getData[i].plist + "/" + getData[i].pics + "' width='265' height='175'><br/>"
        }
      else
        {
        tmp += "<br/><br/><br/><br/><br/>"
        }
      tmp += "<span style='font-family:Arial;font-size:9pt;color:#993300;'>" + getData[i].stat + "</span><br/>" + getData[i].descript + "<br/><br style='line-height:3px;'/><b>Lot Size: </b>" + getData[i].lotsize + "<span class='tax'><b>Tax ID: </b>" + getData[i].taxID + "</span><br/><a href='http://www.bayrealtyalaska.com/?listing=" + getData[i].plist + "' class='blink' target='_blank'>View this listing at bayrealtyalaska.com</a></div>"
      lcnt++
      }
    }
  }

 if(ptype == "commercial")
  {
  if(getData.length==0)
    {
    tmp += "<div class='mdiv' id='c0'><br/><br/><br/><br/><br/><center><span class='headtxt'>No Commercial Lots Listed at this time.  Contact Ken to list your Property Today!</span></center><a class='expand' id='mc" + i + "' href='javascript:showDiv(document.getElementById(&#34;" + "c0" + "&#34;))'>(more)</a></span><br/><br/><br/>"
    tmp += "<p style='text-align:center'><a href='http://www.bayrealtyalaska.com/commercial.asp' class='blink' target='_blank'>View other Commercial Listings at bayrealtyalaska.com</a></p></div>"
    tok = ""
    }
  else
    {
    tok = "c"
    for(i=0;i<getData.length;i++)
      {
      str = getData[i].price
      if(str.length > 40) then
        {
         str = ""
         for(x=0;x<41;x++)
           {
           str += getData[i].price.charAt(x)
           }
        } 
        tmp += "<div class='mdiv' id='c" + i + "'><span style='line-height:17px;'>" + getData[i].plist + " - " + str + "<a class='expand' id='mc" + i + "' href='javascript:showDiv(document.getElementById(&#34;" + "c" + i + "&#34;))'>(more)</a></span><br/>"
      if(getData[i].pics != null)
        {
        tmp += "<img src='http://www.bayrealtyalaska.com/commercial/" + getData[i].plist + "/" + getData[i].pics + "' width='265' height='175'><br/>"
        }
      else
        {
        tmp += "<br/><br/><br/><br/><br/>"
        }
        tmp += "<span style='font-family:Arial;font-size:9pt;color:#993300;'>" + getData[i].stat + "</span><br/>" + getData[i].descript + "<br/><br style='line-height:3px;'/><b>Lot Size: </b>" + getData[i].lotsize + "<span class='tax'><b>Tax ID: </b>" + getData[i].taxID + "</span><br/><a href='http://www.bayrealtyalaska.com/?listing=" + getData[i].plist + "' class='blink' target='_blank'>View this listing at bayrealtyalaska.com</a></div>"
        ccnt++ 
      }
    }
  }
document.write (tmp)
}

function showDiv(d)
{
var cl
var mt
var ol
var dt

if(d.id.charAt(0) == 'h')
  {
  cl = "mh" + d.id.substring(1, d.id.length)
  mt = document.getElementById(cl)
  }

if(d.id.charAt(0) == 'l')
  { 
  cl = "ml" + d.id.substring(1, d.id.length)
  mt = document.getElementById(cl)
  }

if(d.id.charAt(0) == 'c')
  { 
  cl = "mc" + d.id.substring(1, d.id.length)
  mt = document.getElementById(cl)
  }

if((hdiv > "") && (d.id.charAt(0) == 'h'))
  {
  if(d.id.charAt(0) == hdiv.charAt(0))
    {
    ol = "mh" + hdiv.substring(1, hdiv.length)
    dt = document.getElementById(ol)
    if(navigator.appName=='Microsoft Internet Explorer')
       {
       dt.innerText = "(more)"
       }
     else
       {
       dt.textContent = "(more)"
       }
    a = document.getElementById(hdiv)
    a.style.height = "15px"
    }
  }

if((ldiv > "") && (d.id.charAt(0) == 'l'))
  { 
  if(d.id.charAt(0) == ldiv.charAt(0))
    {
    ol = "ml" + ldiv.substring(1, ldiv.length)
    dt = document.getElementById(ol)
    if(navigator.appName=='Microsoft Internet Explorer')
       {
       dt.innerText = "(more)"
       }
     else
       {
       dt.textContent = "(more)"
       }
    a = document.getElementById(ldiv)
    a.style.height = "15px"
    }
  }
if((cdiv > "") && (d.id.charAt(0) == 'c'))
  { 
  if(d.id.charAt(0) == cdiv.charAt(0))
    {
    ol = "mc" + cdiv.substring(1, cdiv.length)
    dt = document.getElementById(ol)
    if(navigator.appName=='Microsoft Internet Explorer')
       {
       dt.innerText = "(more)"
       }
     else
       {
       dt.textContent = "(more)"
       }
    a = document.getElementById(cdiv)
    a.style.height = "15px"
    }
  }
if(d.id.charAt(0) == 'h')
  {
  d.style.height = "370px"
  if(navigator.appName=='Microsoft Internet Explorer')
     {
     mt.innerText = ""
     }
   else
     {
     mt.textContent = ""
     }
  hdiv = d.id
  }

if(d.id.charAt(0) == 'l')
  {
  d.style.height = "370px"
  if(navigator.appName=='Microsoft Internet Explorer')
     {
     mt.innerText = ""
     }
   else
     {
     mt.textContent = ""
     }
  ldiv = d.id
  }

if(d.id.charAt(0) == 'c')
  {
  d.style.height = "370px"
  if(navigator.appName=='Microsoft Internet Explorer')
     {
     mt.innerText = ""
     }
   else
     {
     mt.textContent = ""
     }
  cdiv = d.id
  }

}


function valPrice(p)
  {
  if(p.charAt(0) != '$')
    {
    p = '$' + p
    }
  return p
  }

function valSize(l)
  {
  var x
  x = l.length - 1
  if(isNaN(l.charAt(x))==false)
    {
    l = l + " acres"
    }
  return l
  }

function valPics(p)
  {
  var tmp = ""
  for(g=0;g<p.length;g++)
    {
    if(p.charAt(g) != ";")
      {
      tmp += p.charAt(g)
      }
    else
      {
      return  tmp
      }
    }
  }

function valDescript(d)
  {
  var tmp = ""
  if(d.length > '290')
    {
    for(x=0;x<291;x++)
      {
       tmp += d.charAt(x)
      }
    tmp += "..."  
    }
  else
    {
    tmp = d
    }
  return tmp
  }  
