function oRoll(img)
{
	var x=(img.prevSrc?0:1);
	img.src=img.src.replace(/_\d/,"_"+x);
	img.prevSrc=x;
}

var current_nav_obj="";
function listingRoll(obj)
{
	if(obj) {
		obj.style.backgroundColor = '#664B21';
		obj.style.border = '1px solid #AB7D38';
		obj.style.color = '#AB7D38';
		current_nav_obj = obj;
	} else {
		current_nav_obj.style.backgroundColor = '';
		current_nav_obj.style.border = '1px solid #725325';
		current_nav_obj.style.color = '#382912';
	}
}

var current_img_num=1;
var previous_underline_num;
function imgSwap(bn,img_path)
{
	// undo underline for current number
	var obj = cross_obj('num_'+current_img_num,1);
	current_underline_num_obj = obj;
	obj.textDecoration = "none";
	// figure the next 'current' number
	if(bn=='back') {
		current_img_num = (current_img_num==1) ? tot_imgs : (current_img_num-1);
	} else if(bn=='next') {
		current_img_num = (current_img_num==tot_imgs) ? 1 : (current_img_num+1);
	}
	// loading...
	var lobj = cross_obj('loading_2');
	lobj.visibility = 'visible';
	//lobj.innerHTML = "<b>LOADING...</b>";
	//return false;

	// swap the image
	if(!img_path) { img_path = "/images/homes/"; }
	document.images['main_img'].src = img_path+home_id+"_"+current_img_num+".jpg";
	// underline the new number
	var obj = cross_obj('num_'+current_img_num,1);
	current_underline_num_obj = obj;
	obj.textDecoration = "underline";
}
function hideLoadingLyr()
{
	var lobj=cross_obj('loading_2');
	lobj.visibility='hidden';
}
function imgNext()
{
	current_img_num = (current_img_num==tot_imgs) ? 1 : (current_img_num+1);
	document.images['main_img'].src = "/images/homes/"+home_id+"_"+current_img_num+".jpg";
}

function go(page)
{
	window.location.href=page;
}

function cross_obj(id,styles,framenum)
{
	var obj, obj_base;
	if(cross_obj.arguments.length==3) {
		obj_base = window.parent.frames[framenum].document;
	}
	else
		obj_base = window.document;
	if(cross_obj.arguments[1]!=0) styles=true;
	//alert(styles);
	if(document.all)
		if(styles) { obj=obj_base.all[id].style; }
		else obj=obj_base.all[id];
	else if(document.layers)
		obj=obj_base.layers[id];
	else if(document.getElementById)
		if(styles) obj=obj_base.getElementById(id).style;
		else obj=obj_base.getElementById(id);
	else return false;
	if(obj) return obj;
	else return false;
}

function openWindow(url, width, height, type, winName) {
	var paramStr="";
	if (type=="console") {
		paramStr="resizable,height="+height+",width="+width;
	} else if (type=="fixed") {
		paramStr="status,height="+height+",width="+width;
	} else if (type=="content") { // fixed size with scrolling
		paramStr="scrollbars,status,height="+height+",width="+width;
	} else if (type=="normal") { // a normal window but with width & height set
		paramStr="status,toolbar,menubar,scrollbars,resizable,location,height="+height+",width="+width;
	} else if(!type || type=="flexible") { // default
		paramStr="scrollbars,resizable,height="+height+",width="+width;
	}
	if(!winName) { // make unique but consistent window name for this page
		winName = 'myWin_'+url.substr(0,url.indexOf("?")).replace(/\W/g,"");
	}
	winObj = window.open(url, winName, paramStr);
	winObj.focus();
	return winObj;
}
