/* assumes prototype.js already included somewhere */

var gReq = null;

var omCanReplace = canReplaceNight();


function replaceNight(nightid, id)
{
  var url =  window.location.protocol + "//" + window.location.hostname + '/listings/show1.php';
  var parms = 'nightid=' + nightid;
  var theimg = $('plus' + nightid);

  var upd = new Ajax.Updater( id, url, 
			      { method: 'get', parameters: parms, 
                    onLoading:  function() {
		      theimg.src = '/images/refresh.png';
                    }
                  }
			    );

  return(false);
}

function canReplaceNight()
{
  var x = Ajax.getTransport();

  if (x)
  {
    x = null;
    return(true);
  }

  return(false);
}

function expandoLink(nightid, divid, desc)
{
  if (omCanReplace)
  {
    var link = "/listings/" + nightid;
    var jslink = "return(replaceNight(" + nightid + ',"' + divid + '"));';

    document.writeln("<a href='" + link + "' onclick='" + jslink + "' title=\"see details for " + desc + "\">" +
	"<img class='explink' src='/images/add.png' alt='(+)' id='plus" + nightid  +  "'  />" +
	"</a>" );
  }
}
