<!--

/*  North Raleigh Realty Javascript Library
*		Written by Peter Graber, grabers.com
*
*/


function loadSelect(hood) {
	document.location = 'http://www.northraleighrealty.net/neighborhoods.php?n='+hood;
}
			
			
function loadList(type, spec) {
	if(spec == '') {
			return false;
			}
	document.location = 'http://www.northraleighrealty.net/neighborhoods.php?q='+type+'&s='+spec;
}


function show(tab) {
		var theSections = ['specs','activity','history','media', 'forsale'];
		
		for(i=0; i < theSections.length; i++) {
			if(tab == theSections[i]) {
						 button = document.getElementById(theSections[i]);
						 section = document.getElementById(theSections[i]+'Info');
						button.className = "current";
						 section.style.display = "block";
						 }
			else {
					 button = document.getElementById(theSections[i]);
					 section = document.getElementById(theSections[i]+'Info');
					 button.className = "none";
					 section.style.display = "none";
					 }	
		}
		
		return false;
}


function highlight(page) {  //Highlights the associated LI to designate current page
	if(page == null) {	//Hack for links mainpage.
			page = links;
			}
	//alert(page);
	//Step 1 - Clear any associated classNames for LI elements
	var navDiv = document.getElementById('leftNav');
		var allLi = navDiv.getElementsByTagName('Li');
		for(i=0; i < allLi.length; i++) {
				allLi[i].className = '';
				}
				
	//Step 2 - Assign class to associated element (page).
	var li = document.getElementById(page);
	li.className = 'current';
	
	//Hack for the schools/education page header graphic
	if(page=='schools') {
		var headGraphic = '/images/'+page+'Ed.gif'
		var pageGraphic = document.getElementById('page');
		pageGraphic.src = headGraphic;
		}
	  return true;
}


function checkData() {
	 if(this.id == 'contact') {
	 		var fields = ['name','address','city','state','zip','email','email2'];
			}
	
	 else if (this.id == 'relocate') {
	 		 var fields = ['name', 'address', 'city', 'state', 'zip', 'email'];
			}
	
	 else if (this.id == 'analysis') {
	 		 var fields = ['name', 'address', 'city', 'state', 'zip', 'email','subdivision','homestyle','sqfoot','garage'];
			}
			
	 else {
	 		return true;
			}
	 this.fields = fields;
	 for(var i=0; i < this.fields.length; i++) {
	 if(isEmpty(this.fields[i])) {
		var field = this.fields[i];
		field = document.getElementById(field);
		var msg = 'Please complete all required fields.\n';
		msg += 'The '+ this.fields[i]+' field contains an error.';
		alert (msg);
		field.style.backgroundColor = '#ffcc00';
		field.onblur = highlightOff;
		field.focus();
		return false;
		}
		
	}	
}


function isEmpty(field) {
	var widget = document.getElementById(field);
	var value = widget.value;
	if(widget.type == 'text') {
		if(value.length < 1) return true;
		
			for (j=0; j < value.length + 1; j++) {
			var c = value.charAt(j);
			if(c == '\n' || c=='\t'){
			return true;
			}	
			}
		}
		
	else if (widget.type =='select-one') {
			if(widget.selectedIndex < '1') return true 		
			}
}


function highlightOff() {
			this.style.backgroundColor= '#ffffff';
			return true;
}



var fields = new Array();

window.onload = function() {
		form = document.getElementsByTagName('form');
		form[0].onsubmit = checkData;
		}
		
		
function gmapLoad(lat, lon) {
			
      if (GBrowserIsCompatible()) {
				container = document.getElementById("map");
				container.style.width = '210px';
				container.style.height = '200px';
				container.style.visibility = 'visible';
				
        var map = new GMap2(document.getElementById("map"));
				map.addControl(new GSmallMapControl());
				map.setCenter(new GLatLng(lat, lon), 14);
				
				stf = document.getElementById("stfUl");
				stf.className = 'oneCol';
				
				
      }
    }

-->
