//image pre-loader
function imgLoader(pth,iNames,ext){
	if (document.images) {
		var act=['a','i'];
		for (i=0;i<iNames.length;i++){
			for (j=0;j<2;j++){
				eval(iNames[i]+act[j]+"= new Image();");
				eval(iNames[i]+act[j]+".src = '/images/"+pth+iNames[i]+"_"+act[j]+"."+ext+"';");
			}
		}
	}
}
function loadup(pth,iNames,ext){
	for (i=0;i<iNames.length;i++){
		for (j=0;j<2;j++){
			eval(iNames[i]+"= new Image();");
			eval(iNames[i]+".src = '/images/"+pth+iNames[i]+"."+ext+"';");
		}
	}
}
var navary = ['gogreen_thelife','gogreen_thehomes','gogreen_thetour','gogreen_sayhello'];
imgLoader('nav/nav_',navary,'jpg');

var pop_n = null;

function OpenCenteredWindow(theURL,winName,features, myWidth, myHeight, isCenter) { //v3.0
  features = 'width='+myWidth+',height='+myHeight+','+features;
  if(window.screen)if(isCenter)if(isCenter=="true"){
    var myLeft = (screen.width-myWidth)/2;
    var myTop = (screen.height-myHeight)/2;
    features+=',left='+myLeft+',top='+myTop;
  }
	window.open(theURL,winName,features);
}

function doPopup(theURL,winName,features,myWidth,myHeight,isCenter){
  features = 'width='+myWidth+',height='+myHeight+','+features;
  if(window.screen)if(isCenter)if(isCenter=="true"){
    var myLeft = (screen.width-myWidth)/2;
    var myTop = (screen.height-myHeight)/2;
    features+=',left='+myLeft+',top='+myTop;
  }
  if(pop_n == null || pop_n.closed){
    pop_n = window.open(theURL,winName,features);
  }else{
    pop_n.close();
    pop_n = window.open(theURL,winName,features);
  }
  pop_n.focus();
}

function dropfoot(){
	if (document.documentElement && document.documentElement.clientHeight){
		winH = document.documentElement.clientHeight;
		docH = document.body.clientHeight;
	}
	if (window.innerHeight){
		winH = window.innerHeight;
		docH = document.height;
	}
	diffH = (docH > winH);
	ffs = document.getElementById('footfloat');
	pos = (diffH)?'relative':'absolute';
	document.getElementById('footfloat').style.position = pos;
}

function swap(st,nm){
	eval("document.images['"+nm+"'].src="+nm+st+".src;");
}
lifenav = ['redrock','recreation','education','entertainment','culture','wellness','worship','council'];
homesnav = ['villages','customhomes','grandopenings','currentlyselling','homesearch','builders'];
developernav = ['developer','environment','company','distinctions'];
newsnav = ['pressreleases','events'];
gogreennav = ['nevadapower', 'republic', 'transport', 'water', 'desertlandscaping'];

function smpl_swap(nm,fl){
	eval("document.images['"+nm+"'].src='"+fl+"';");
}

function admin_swap(st,nm){
	eval("document.images['"+nm+"'].src='/admin/images/nav_"+nm+"_"+st+".jpg';");
}

function getposOffset(what,offsettype){
	mainPos=[what.offsetLeft,what.offsetTop,what.offsetWidth,what.offsetHeight]; //load parent pos
	totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
	sum = totaloffset;
	parentEl=what.offsetParent;
	while (parentEl!=null){
		sum += (offsettype=="left")?parentEl.offsetLeft : parentEl.offsetTop;
		parentEl=parentEl.offsetParent;
	}
	return sum;
}

function billboard(dsply,vlg,what,hposition){
    var hposition = (hposition == null) ? 'left' : hposition;

	flt=eval("document.getElementById('float_"+vlg+"')");
	bb= document.getElementById('billboard');
	if(dsply == 'hide'){
		bb.style.visibility='hidden';
	}else{
		bb.innerHTML = flt.innerHTML;
		bbW=flt.offsetWidth;
		pos = getposOffset(what,'left');
		  if(hposition == 'right') {
              bb.style.left=(pos+180)+'px';
		  } else {
		      bb.style.left=(pos-bbW)+'px';
		  }
		tp = getposOffset(what,'top');
		bb.style.top=tp+'px';
		bb.style.visibility='visible';
	}
}

function initBillboard(divID){
	document.write('<div id="'+divID+'" class="village_billboard bodytext" style="visibility:hidden;"></div>');
}

