// specify background textures here
// var bgimg = "moment.jpg";
var bgimg = "listing2_bkg.jpg";
var hosturl = "http://www.generalrubric.com/family/catalog/precog";
var hostpath = "images";

var maxBgs = 10;

function setMainBg() {
	// select a random background
	var x = Math.round(Math.random() * (maxBgs - 1)) + 1;

	if (Math.random() < .75) {
		x = ((new Date()).getDate() % maxBgs) + 1;
	}

	// alert("bg: " + x);
	return x;
}

if (typeof(useMainBg) != "undefined") {
	bgimg = setMainBg() + ".jpg";
	hosturl = "http://www.generalrubric.com";
	hostpath = "backgrounds";
}

var w, h = 0;
function setImage() {
		w = getWindowContentWidth(self);
		h = getWindowContentHeight(self);

		// alert("W:" + w + " H:" + h + " --> NW:" + (w - 18) + " NH:" + (h - 2));
}

setImage();

document.writeln('<div id="bgwrapper">');
// document.writeln('<img name="bg" src="' + hosturl + '/' + hostpath + '/' + bgimg + '" width="' + w + '" height="' + h + '">');
if ((w > 800) || (h > 600)) {
	document.writeln('<img name="bg" src="' + hosturl + '/' + hostpath + '/' + bgimg + '" width="100%" height="100%">');
}
else {
	document.writeln('<img name="bg" src="' + hosturl + '/' + hostpath + '/' + bgimg + '" width="800" height="600">');
}
document.writeln('</div>');
