// JavaScript Function Library
if 	(document.getElementById)	var DOMS = 3	// Supports Web Standard (getElementById)
else if	(document.all)		var DOMS = 2	// Supports MS document.all
else if	(document.layers)		var DOMS = 1	// Supports NS layers
else				var DOMS = 0;	// No DOM gateway support

function getObj(oid) {
  switch(DOMS) {					// Check for various browsers
    case 1: return(document[oid]);			// Supports Layers (NS4)
    case 2: return(document.all[oid]);			// Supports document.all (ie4)
    case 3: return( ((document.getElementById(oid))?document.getElementById(oid):'') );	// Supports getElementById
  }
}

LISTING = new Object();
LAND = new Object();

function genList() {
  var OUTP = '';
  for ( var i in LISTING ) {
    switch(LISTING[i].type) {
      case 'H': {
        OUTP += '<table align="center" border="1" cellpadding="0" cellspacing="0" width="100%"><tr><td width="100%">' +
                '<table border="0" cellpadding="0" cellspacing="0" width="100%" bgcolor="#FFFFFF">' +
                '<tr><th width= "3%" bgcolor="#000080" rowspan="5" valign="top" style="padding:6px;">' +
                '<table border="0" cellspacing="0" cellpadding="0" width="200"><tr valign="top"><th background="images/listings/' + i + '.gif" width="200" height="156">' +
                '<font face="Arial Black,sans-serif" color="#ff0000" size="5">' + LISTING[i].status + '</font></th></tr></table>' +
                '<font color="#FFFFFF" face="Arial Black,sans-serif" size="3">' + LISTING[i].caption + '</font></th>' +
                '<td width="13%" style="padding-left:10px"><b><font face="Verdana" size="2" color="#000080">Price:</font></b></td>' +
                '<th width="31%" style="padding-right:8px;"><font face="Verdana" size="2" color="#ff0000">' + LISTING[i].price + '</font></th>' +
                '<th width="53%" bgcolor="#000080" rowspan="5" align="left" valign="middle" style="padding:6px 20px;"><font face="Verdana" color="#FFFFFF"><font face="Verdana" size="2">' + LISTING[i].desc + '</font></th></tr>' +
                '<tr><td width="13%" style="padding-left:10px"><b><font face="Verdana" size="2" color="#000080">Bdrms:</font></b></td>' +
                '<th width="31%" style="padding-right: 8"><b><font face="Verdana" color="#FF0000">' + LISTING[i].bdrms + '</font></th></tr>' +
                '<tr><td width="13%" style="padding-left:10px"><b><font face="Verdana" size="2" color="#000080">Baths:</font></b></td>' +
                '<th width="31%" style="padding-right: 8"><font face="Verdana" color="#FF0000">' + LISTING[i].baths + '</font></th></tr>' +
                '<tr><td width="13%" style="padding-left:10px"><b><font face="Verdana" size="2" color="#000080">Sq Ft:</font></b></td>' +
                '<th width="31%" style="padding-right: 8" ><font face="Verdana" color="#FF0000" size="2">' + LISTING[i].sqft + '</th></tr>' +
                '<tr><td width="13%" style="padding-left:10px"><font face="Verdana" size="2" color="#02106F"><b>Location</b></font><b><font face="Verdana" size="2" color="#000080">:</font></b></p></td>' +
                '<th width="31%" style="padding-right: 8"><b><font color="#FF0000" size="2" face="Verdana">' + LISTING[i].location + '</font></th></tr>' +
                '</table></td></tr></table><br><br>\n'
        break;
      }

      case 'L': {
        OUTP += '<table align="center" border="1" cellpadding="0" cellspacing="0" width="100%"><tr><td width="100%">' +
                '<table border="0" cellpadding="0" cellspacing="0" width="100%" bgcolor="#FFFFFF">' +
                '<tr><th width= "3%" bgcolor="#000080" rowspan="5" valign="top" style="padding:6px;">' +
                '<table border="0" cellspacing="0" cellpadding="0" width="200"><tr valign="top"><th background="images/listings/' + i + '.gif" width="200" height="156">' +
                '<font face="Arial Black,sans-serif" color="#ff0000" size="5">' + LISTING[i].status + '</font></th></tr></table>' +
                '<font color="#FFFFFF" face="Arial Black,sans-serif" size="3">' + LISTING[i].caption + '</font></th>' +
                '<td width="13%" style="padding-left:10px"><b><font face="Verdana" size="2" color="#000080">Price:</font></b></td>' +
                '<th width="31%" style="padding-right:8px;"><font face="Verdana" size="2" color="#ff0000">' + LISTING[i].price + '</font></th>' +
                '<th width="53%" bgcolor="#000080" rowspan="5" align="left" valign="middle" style="padding:6px 20px;"><font face="Verdana" color="#FFFFFF"><font face="Verdana" size="2">' + LISTING[i].desc + '</font></th></tr>' +
                '<tr><td width="13%" style="padding-left:10px"><b><font face="Verdana" size="2" color="#000080">Sq Ft:</font></b></td>' +
                '<th width="31%" style="padding-right: 8" ><font face="Verdana" color="#FF0000" size="2">' + LISTING[i].sqft + '</th></tr>' +
                '<tr><td width="13%" style="padding-left:10px"><b><font face="Verdana" size="2" color="#000080">Acres:</font></b></td>' +
                '<th width="31%" style="padding-right: 8" ><font face="Verdana" color="#FF0000" size="2">' + LISTING[i].acres + '</th></tr>' +
                '<tr><td width="13%" style="padding-left:10px"><font face="Verdana" size="2" color="#02106F"><b>Location</b></font><b><font face="Verdana" size="2" color="#000080">:</font></b></p></td>' +
                '<th width="31%" style="padding-right: 8"><b><font color="#FF0000" size="2" face="Verdana">' + LISTING[i].location + '</font></th></tr>' +
                '</table></td></tr></table><br><br>\n'
        break;
      }
    }
  }
  document.write(OUTP);
}


function genListing() { var OUTP = '';
  for ( var i in LISTING ) {
    OUTP += '<table align="center" border="1" cellpadding="0" cellspacing="0" width="100%"><tr><td width="100%">' +
            '<table border="0" cellpadding="0" cellspacing="0" width="100%" bgcolor="#FFFFFF">' +
            '<tr><th width= "3%" bgcolor="#000080" rowspan="5" valign="top" style="padding:6px;">' +
            '<table border="0" cellspacing="0" cellpadding="0" width="200"><tr valign="top"><th background="images/listings/' + i + '.gif" width="200" height="156">' +
            '<font face="Arial Black,sans-serif" color="#ff0000" size="5">' + LISTING[i].status + '</font></th></tr></table>' +
            '<font color="#FFFFFF" face="Arial Black,sans-serif" size="3">' + LISTING[i].caption + '</font></th>' +
            '<td width="13%" style="padding-left:10px"><b><font face="Verdana" size="2" color="#000080">Price:</font></b></td>' +
            '<th width="31%" style="padding-right:8px;"><font face="Verdana" size="2" color="#ff0000">' + LISTING[i].price + '</font></th>' +
            '<th width="53%" bgcolor="#000080" rowspan="5" align="left" valign="middle" style="padding:6px 20px;"><font face="Verdana" color="#FFFFFF"><font face="Verdana" size="2">' + LISTING[i].desc + '</font></th></tr>' +
            '<tr><td width="13%" style="padding-left:10px"><b><font face="Verdana" size="2" color="#000080">Bdrms:</font></b></td>' +
            '<th width="31%" style="padding-right: 8"><b><font face="Verdana" color="#FF0000">' + LISTING[i].bdrms + '</font></th></tr>' +
            '<tr><td width="13%" style="padding-left:10px"><b><font face="Verdana" size="2" color="#000080">Baths:</font></b></td>' +
            '<th width="31%" style="padding-right: 8"><font face="Verdana" color="#FF0000">' + LISTING[i].baths + '</font></th></tr>' +
            '<tr><td width="13%" style="padding-left:10px"><b><font face="Verdana" size="2" color="#000080">Sq Ft:</font></b></td>' +
            '<th width="31%" style="padding-right: 8" ><font face="Verdana" color="#FF0000" size="2">' + LISTING[i].sqft + '</th></tr>' +
            '<tr><td width="13%" style="padding-left:10px"><font face="Verdana" size="2" color="#02106F"><b>Location</b></font><b><font face="Verdana" size="2" color="#000080">:</font></b></p></td>' +
            '<th width="31%" style="padding-right: 8"><b><font color="#FF0000" size="2" face="Verdana">' + LISTING[i].location + '</font></th></tr>' +
            '</table></td></tr></table><br><br>\n'
  }
  document.write(OUTP);
}

function genLand() { var OUTP = '';
  for ( var i in LAND ) {
    OUTP += '<table align="center" border="1" cellpadding="0" cellspacing="0" width="100%"><tr><td width="100%">' +
            '<table border="0" cellpadding="0" cellspacing="0" width="100%" bgcolor="#FFFFFF">' +
            '<tr><th width= "3%" bgcolor="#000080" rowspan="5" valign="top" style="padding:6px;">' +
            '<table border="0" cellspacing="0" cellpadding="0" width="200"><tr valign="top"><th background="images/listings/' + i + '.gif" width="200" height="156">' +
            '<font face="Arial Black,sans-serif" color="#ff0000" size="5">' + LAND[i].status + '</font></th></tr></table>' +
            '<font color="#FFFFFF" face="Arial Black,sans-serif" size="3">' + LAND[i].caption + '</font></th>' +
            '<td width="13%" style="padding-left:10px"><b><font face="Verdana" size="2" color="#000080">Price:</font></b></td>' +
            '<th width="31%" style="padding-right:8px;"><font face="Verdana" size="2" color="#ff0000">' + LAND[i].price + '</font></th>' +
            '<th width="53%" bgcolor="#000080" rowspan="5" align="left" valign="middle" style="padding:6px 20px;"><font face="Verdana" color="#FFFFFF"><font face="Verdana" size="2">' + LAND[i].desc + '</font></th></tr>' +
            '<tr><td width="13%" style="padding-left:10px"><b><font face="Verdana" size="2" color="#000080">Sq Ft:</font></b></td>' +
            '<th width="31%" style="padding-right: 8" ><font face="Verdana" color="#FF0000" size="2">' + LAND[i].sqft + '</th></tr>' +
            '<tr><td width="13%" style="padding-left:10px"><b><font face="Verdana" size="2" color="#000080">Acres:</font></b></td>' +
            '<th width="31%" style="padding-right: 8" ><font face="Verdana" color="#FF0000" size="2">' + LAND[i].acres + '</th></tr>' +
            '<tr><td width="13%" style="padding-left:10px"><font face="Verdana" size="2" color="#02106F"><b>Location</b></font><b><font face="Verdana" size="2" color="#000080">:</font></b></p></td>' +
            '<th width="31%" style="padding-right: 8"><b><font color="#FF0000" size="2" face="Verdana">' + LAND[i].location + '</font></th></tr>' +
            '</table></td></tr></table><br><br>\n'
  }
  document.write(OUTP);
}

function verifyDelete(s) { return(confirm("Are you sure you want to delete " + s + "?")); }

function defListing(s1,s2,s3,s4,s5,s6,s7,s8) { this.type="H"; this.status=s1; this.price=s2; this.bdrms=s3; this.baths=s4; this.sqft=s5; this.location=s6; this.caption=s7; this.desc=s8 }
function defLand(s1,s2,s5,s6,s7,s8,s9)	     { this.type="L"; this.status=s1; this.price=s2; this.sqft=s5; this.acres=s6; this.location=s7; this.caption=s8; this.desc=s9 }

function editAlbum(pid,picid) {
  window.open('admin_album_edit.php?pid='+pid+'&picid='+picid,'album','height=550,width=540,scrollbars,resizable');
  return false;
}

function editListing(pid) {
  window.open('admin_listings_edit.php?pid='+pid,'mls','height=520,width=600,scrollbars,resizable');
  return false;
}

function showPic(s,purl,caption) {
  document.images[s].src = purl;
  var dobj = getObj(s);
  return false;
}
