// Browser detect

var ie4 = (document.all && !document.getElementById) ? true:false;
var ns4 = (document.layers) ? true:false;
var dom2 = (document.getElementById) ? true:false;


// Random number generator: 0 to (max - 1)

function pickRandom(max) {
	return Math.floor(Math.random() * max);
}


// Pop up functions

function popwin(loc,winname,w,h,scroll,resize) {
	eval('var newwin = window.open("' + loc + '","' + winname + '","width=' + w + ',height=' + h + ',top=0,left=0,location=no,scrollbars=' + scroll + ',menubar=no,toolbar=no,resizable=' + resize + '")');
}

function openinmain(whichpage) {
	window.opener.location = whichpage;
}


// Rollover functions

var offstate = new Array();
var onstate = new Array();

offstate['aboutus'] = new Image();
offstate['aboutus'].src = linkbase + 'images/nav/aboutus_off.gif';
offstate['housedesigns'] = new Image();
offstate['housedesigns'].src = linkbase + 'images/nav/housedesigns_off.gif';
offstate['whytrustway'] = new Image();
offstate['whytrustway'].src = linkbase + 'images/nav/whytrustway_off.gif';
offstate['customreserve'] = new Image();
offstate['customreserve'].src = linkbase + 'images/nav/customreserve_off.gif';
offstate['openhouses'] = new Image();
offstate['openhouses'].src = linkbase + 'images/nav/openhouses_off.gif';
offstate['forsale'] = new Image();
offstate['forsale'].src = linkbase + 'images/nav/forsale_off.gif';
offstate['designcenter'] = new Image();
offstate['designcenter'].src = linkbase + 'images/nav/designcenter_off.gif';
offstate['testimonials'] = new Image();
offstate['testimonials'].src = linkbase + 'images/nav/testimonials_off.gif';
offstate['customerlogin'] = new Image();
offstate['customerlogin'].src = linkbase + 'images/nav/customerlogin_off.gif';
onstate['aboutus'] = new Image();
onstate['aboutus'].src = linkbase + 'images/nav/aboutus_on.gif';
onstate['housedesigns'] = new Image();
onstate['housedesigns'].src = linkbase + 'images/nav/housedesigns_on.gif';
onstate['whytrustway'] = new Image();
onstate['whytrustway'].src = linkbase + 'images/nav/whytrustway_on.gif';
onstate['customreserve'] = new Image();
onstate['customreserve'].src = linkbase + 'images/nav/customreserve_on.gif';
onstate['openhouses'] = new Image();
onstate['openhouses'].src = linkbase + 'images/nav/openhouses_on.gif';
onstate['forsale'] = new Image();
onstate['forsale'].src = linkbase + 'images/nav/forsale_on.gif';
onstate['designcenter'] = new Image();
onstate['designcenter'].src = linkbase + 'images/nav/designcenter_on.gif';
onstate['testimonials'] = new Image();
onstate['testimonials'].src = linkbase + 'images/nav/testimonials_on.gif';
onstate['customerlogin'] = new Image();
onstate['customerlogin'].src = linkbase + 'images/nav/customerlogin_on.gif';


function rollon(whichimg) {
	document.images[whichimg].src = onstate[whichimg].src;
}

function rolloff(whichimg) {
	document.images[whichimg].src = offstate[whichimg].src;
}



// House background

function buildhousebg(whichimg) {
	if (!ns4) {
		document.write('<style type="text/css"> .housebg { background-image: url(' + whichimg + '); background-position: left top; background-repeat: no-repeat; } </style>\n');
	}
}