//JS for seach form
	
	var searchWhat = null;
	
	function fRadio(whichElement){
		
		if (whichElement == 1){
			document.images.radioUn.src= "/assets/shared/radioOn.gif";
			document.images.radioDeux.src= "/assets/shared/radioOff.gif";
			searchWhat = 1;
		
		}else{
			document.images.radioUn.src= "/assets/shared/radioOff.gif";
			document.images.radioDeux.src= "/assets/shared/radioOn.gif";
			searchWhat = 2;
		}
		
		fSwap();
	
	}
	
	function fSwap() {
		var tmpval = document.ecmsearch.ecmswapfolder.value;
		document.ecmsearch.ecmswapfolder.value = document.ecmsearch.ecmstartingfolder.value;
		document.ecmsearch.ecmstartingfolder.value = tmpval;
	}
	
	
	function fSubmit(){
		document.ecmsearch.submit();
	}
	
	function newImage(src) {
		var anImg = new Image;
		anImg.src = src;
		return anImg;
	}



/*
	Standards Compliant Rollover Script
	Author : Daniel Nolan
	http://www.bleedingego.co.uk/webdev.php
*/

	function initRollovers() {
		if (!document.getElementById) return
		
		var aPreLoad = new Array();
		var sTempSrc;
		var aImages = document.getElementsByTagName('img');
	
		for (var i = 0; i < aImages.length; i++) {		
			if (aImages[i].className == 'imgover') {
				var src = aImages[i].getAttribute('src');
				var ftype = src.substring(src.lastIndexOf('.'), src.length);
				var hsrc = src.replace(ftype, '_o'+ftype);
	
				aImages[i].setAttribute('hsrc', hsrc);
				
				aPreLoad[i] = new Image();
				aPreLoad[i].src = hsrc;
				
				aImages[i].onmouseover = function() {
					sTempSrc = this.getAttribute('src');
					this.setAttribute('src', this.getAttribute('hsrc'));
				}	
				
				aImages[i].onmouseout = function() {
					if (!sTempSrc) sTempSrc = this.getAttribute('src').replace('_o'+ftype, ftype);
					this.setAttribute('src', sTempSrc);
				}
	
				aImages[i].onclick = function() {
					if (!sTempSrc) sTempSrc = this.getAttribute('src').replace('_o'+ftype, ftype);
					this.setAttribute('src', sTempSrc);
				}
	
			}
		}
	}


	
/*
DHTML TOP NAVIGATION
*/
sfTop = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfTop";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfTop\\b"), "");
		}
	}
}

/*
DHTML LEFT TIP NAVIGATION
*/

sfLeft = function() {
	if (document.getElementById("tipNav")){
	
		var sfEls = document.getElementById("tipNav").getElementsByTagName("LI");
		for (var i=0; i<sfEls.length; i++) {
			sfEls[i].onmouseover=function() {
				this.className+=" sfLeft";
			}
			sfEls[i].onmouseout=function() {
				this.className=this.className.replace(new RegExp(" sfLeft\\b"), "");
			}
		}
	}
}

	
//calls functions on page load
	window.onload = function() {
		initRollovers();
	}
	
	if (window.attachEvent){ //IE Mac will not pick this up
		window.attachEvent("onload", dhtmlNav);
	}

function dhtmlNav(){
	sfTop();
	sfLeft();
}


function ecmPopUpWindow (url, hWind, nWidth, nHeight, nScroll, nResize) {
	var cToolBar = 'toolbar=0,location=0,directories=0,status=' + nResize + ',menubar=0,scrollbars=' + nScroll + ',resizable=' + nResize + ',width=' + nWidth + ',height=' + nHeight;
	var popupwin = window.open(url, hWind, cToolBar);
	return popupwin;
}

function popup(url, width, height, winId, scroll) {
  if (winId == null) {
  	time = new Date();
    winId = time.getTime().toString();
  }
  if (!winId.substr(0, 3) == 'rn_')
    winId = 'rn_' + winId;
	var wtop = (screen.height - height) / 2 - 30;
	var wleft = (screen.width - width) / 2;
	var ref = window.open(url,winId,'width='+width+',height='+height+',top='+wtop+',left='+wleft+
              ',resizable=yes,scrollbars=' + (scroll ? 'yes' : 'no') + ',toolbar=no,location=no,directories=no,status=yes,menubar=no,copyhistory=no');
  ref.focus();
}

function refreshParent()
	{
		window.opener.location.reload();
		window.close();
	}


/*
CODE ADDED for April Timberlands Update
*/


function p_link(mylink, closeme){
	if ( (window.focus && window.opener)){
		window.opener.focus();
		window.opener.location.href=mylink;
		}
	if (closeme){
		window.close();
		}
}


function validateLegal(){
		
	if(legal.disclaimer.value == ""){
		alert('After reading the Terms of Use, Privacy Policy and Offer to Buy Agreements, check the checkbox.');
		return false;
	}else{
		p_link("4_properties_for_sale.html", 1)
	}

}



function calcBid(currentBid){
	
	//calculate the bid
		currentBid = formatCurrency(currentBid);
		currentBid = stripCurrency(currentBid);
			
		bidSum = currentBid * bid.acreage.value;
		bidSum = formatCurrency(bidSum);
	
	//reset the inputted bid
		bid.totalBid.value = bidSum; // this is formatted - it's indented for display only
		bid.totalBidCleaned.value = stripCurrency(bidSum); // this is not formatted - it's indented to be used
	
	
	//format the displayed data
		bid.priceAcre.value = formatCurrency(bid.priceAcre.value);
	
}

function formatCurrency(strValue){
	strValue = strValue.toString().replace(/\$|\,/g,'');
	dblValue = parseFloat(strValue);
	
	blnSign = (dblValue == (dblValue = Math.abs(dblValue)));
	dblValue = Math.floor(dblValue*100+0.50000000001);
	intCents = dblValue%100;
	strCents = intCents.toString();
	dblValue = Math.floor(dblValue/100).toString();
	if(intCents<10)
			strCents = "0" + strCents;
	for (var i = 0; i < Math.floor((dblValue.length-(1+i))/3); i++)
			dblValue = dblValue.substring(0,dblValue.length-(4*i+3))+','+
			dblValue.substring(dblValue.length-(4*i+3));
	return (((blnSign)?'':'-') + '$' + dblValue + '.' + strCents);
}


function stripCurrency(dinero){

	dinero = dinero.replace(",","");
	dinero = dinero.replace(" ","");
	dinero = dinero.replace("$","");

	return dinero;
}


function pullNav(href){

	location = "5_search_results.html";
}
//rainforest and population counters
var timerID = null
var timerRunning = false
var timerIDr = null
var timerRunningr = false


function stopclock(){
    // cannot directly test timerID on DEC OSF/1 in beta 4.
    if(timerRunning)
        clearTimeout(timerID)
    timerRunning = false
}

function startclock(){
     // Make sure the clock is stopped
    stopclock()
    showtime()
 showtimer()
}

function showtime(){
    var now = new Date()
 var month = now.getMonth()
 var date = now.getDate()
 var year = now.getYear()

 var minute = now.getMinutes()
 var second = now.getSeconds()

 var x = now.getTimezoneOffset() / 60
 var y = (-6 + (x))
 var hour = now.getHours() + y
 
 var parsecurrent = Date.UTC(year,month,date,hour,minute,second) / 1000

 var parselast = Date.UTC(97,7,7,17,29,15) / 1000
 
 var lastCount = 5859825706
 var deltaSecs = parsecurrent - parselast
 var popSecs = deltaSecs * 2.5
 var popCount = popSecs + lastCount
 var population = Math.round(popCount)
 
 var t = Math.floor(population/1000000000)
 var m = Math.floor(population/1000000) - (t * 1000)
 var h = Math.floor(population/1000) - (Math.floor(population/1000000) * 1000)
 var o = Math.floor(population) - (Math.floor(population/1000) * 1000)
 var f = t + ","

//millions

 if (m >= 100) {
  f += m + ","
  }
  
 if (m < 100 && m >= 10) {
  f += "0" + m + ","
  }
 
 if (m < 10) {
  f += "00" + m + ","
  }
  
//hundreds

 if (h >= 100) {
  f += h + ","
  }
  
 if (h < 100 && h >= 10) {
  f += "0" + h + ","
  }
 
 if (h < 10) {
  f += "00" + h + ","
  }
 
//ones

 if (o >= 100) {
  f += o
  }
  
 if (o < 100 && o >= 10) {
  f += "0" + o
  }
 
 if (o < 10) {
  f += "00" + o
  }
 
 document.clock2.face.value = f
 
    timerID = setTimeout("showtime()",1000)
    timerRunning = true
}

function showtimer(){
    var now = new Date()
 var month = now.getMonth()
 var date = now.getDate()
 var year = now.getYear()

 var minute = now.getMinutes()
 var second = now.getSeconds()

 var x = now.getTimezoneOffset() / 60
 var y = (-6 + (x))
 var hour = now.getHours() + y
 
 var parsecurrent = Date.UTC(year,month,date,hour,minute,second) / 1000

 var parselast = Date.UTC(97,7,7,17,29,15) / 1000
 
 var lastCount = 5683200000
 var deltaSecs = parsecurrent - parselast
 var popSecs = deltaSecs * 1.3
 var popCount = lastCount - popSecs
 var population = Math.round(popCount)
 
 var t = Math.floor(population/1000000000)
 var m = Math.floor(population/1000000) - (t * 1000)
 var h = Math.floor(population/1000) - (Math.floor(population/1000000) * 1000)
 var o = Math.floor(population) - (Math.floor(population/1000) * 1000)
 var f = t + ","

//millions

 if (m >= 100) {
  f += m + ","
  }
  
 if (m < 100 && m >= 10) {
  f += "0" + m + ","
  }
 
 if (m < 10) {
  f += "00" + m + ","
  }
  
//hundreds

 if (h >= 100) {
  f += h + ","
  }
  
 if (h < 100 && h >= 10) {
  f += "0" + h + ","
  }
 
 if (h < 10) {
  f += "00" + h + ","
  }
 
//ones

 if (o >= 100) {
  f += o
  }
  
 if (o < 100 && o >= 10) {
  f += "0" + o
  }
 
 if (o < 10) {
  f += "00" + o
  }
 
 document.clock3.face.value = f
 
    timerIDr = setTimeout("showtimer()",1000)
    timerRunningr = true
}



