function onform(id){
	if ( (document.getElementById( id ).value == "Username") || (document.getElementById( id ).value == "Password") ){
		document.getElementById( id ).value = "";
	}
}

var lastdropdown = "";
function adminover(id)
{
	
	//document.getElementById(id).style.fontWeight = "bold";
	if (lastdropdown != ""){
		dropdownoff();
		lastdropdown = "";
		
	}
	
	lastdropdown = id;
	
	document.getElementById( id ).style.backgroundImage = "url(images/menubg-normal.gif)";
	document.getElementById(id + "dropdown" ).style.display = "block";

}

function adminoff(id)
{
	document.getElementById(id).style.fontWeight = "normal";

}

function dropdownoff() {
	var m = document.getElementById( lastdropdown );
	if (m != undefined){
		m.style.backgroundImage = "url(images/menubg-hover.gif)";
		document.getElementById(lastdropdown + "dropdown" ).style.display = "none";
	}
}



function changePicture(image) {
  
	document.getElementById("cardlogo").style.backgroundImage = "url(images/" + image + ".png)";
	
	var information = "";
	if (image == "peakhomes"){
		information = '<a href="/index.php?maintitle=Listings&link=search_listings">Search</a>  our site to find the home of your<br> dreams! Let us work for you.';
	}else if (image =="peakoffices"){
		information = "<div style='padding-top:20px;'>We are growing to serve you better.<br> <a href='http://newpeakweb.com/index.php?maintitle=Offices&link=search_offices'>Click here </a>to search for an office near you!</div>";
	}else if(image == "peakagents"){
		information = "Whether you are a real estate agent, or <a href='/index.php?maintitle=Agents&link=search_agents'>looking for one</a>, our dedicated and competent staff will get you what you need, where and when you need it.";
	
	}
	
	document.getElementById("cardinfo").innerHTML = information;
	
}

function load(directory){
    if(document.images){
        names=load.arguments
        pictures=new Array;
        for (z=1;z<names.length;z++){
            pictures[z]=new Image;
            pictures[z].src=directory+names[z];
        }
    }    
}

function changeListingPic(pic){

	document.getElementById('listingpic').innerHTML = '<img src="' + pic +  '" style="height:190px; width:300px; border:1px solid black;">';
}

//var currentclick = "all";
function changesearch(type){
	//document.getElementById("residential").style.display = "none";
	document.getElementById("residentialclick").style.backgroundColor = "#666666";
	document.getElementById("residentialclick").style.color = "#FFFFFF";
	document.getElementById("residentialclick").style.fontWeight = "normal";
	
	document.getElementById("commercial").style.display = "none";
	document.getElementById("commercialclick").style.backgroundColor = "#666666";
	document.getElementById("commercialclick").style.color = "#FFFFFF";
	document.getElementById("commercialclick").style.fontWeight = "normal";
	
	document.getElementById("farms").style.display = "none";
	document.getElementById("farmsclick").style.backgroundColor = "#666666";
	document.getElementById("farmsclick").style.color = "#FFFFFF";
	document.getElementById("farmsclick").style.fontWeight = "normal";
	
	document.getElementById(type).style.display = "block";
	document.getElementById(type + "click").style.backgroundColor = "#FF0000";
	document.getElementById(type + "click").style.color = "#FFFFFF";
	document.getElementById(type + "click").style.fontWeight = "bold";
	//document.getElementById(type).style.display = "block";	
	
	//document.getElementById(currentclick + "click").style.backgroundColor = "#FFFFFF";
	//document.getElementById(currentclick + "click").color = "#FFFFFF";
	//document.getElementById(currentclick + "click").style.fontWeight = "normal";
	//document.getElementById(type + "click").style.backgroundColor = "#FF0000";
	//document.getElementById(type + "click").color = "#FFFFFF";
	//document.getElementById(type + "click").style.fontWeight = "bold";
	//currentclick = type;
	
	//if (type == 'residential'){
	//	document.getElementById('commercial').style.display= "none";
	//	document.getElementById('farms').style.display= "none";
	//	document.getElementById('all').style.display= "none";
	//	document.getElementById("commercialclick").style.color = "#FFFFFF";
	//	document.getElementById("farmsclick").style.color = "FFFFFF";

	//}else if (type == 'commercial'){

	//	document.getElementById('residential').style.display= "none";
	//	document.getElementById('farms').style.display= "none";
		
	//	document.getElementById('all').style.display= "none";
	//	document.getElementById("residentialclick").style.color = "";
	//	document.getElementById("farmsclick").style.color = "";

	//}else if (type == 'farms'){
	//	document.getElementById('residential').style.display= "none";
	//	document.getElementById('commercial').style.display= "none";
		
	//	document.getElementById('all').style.display= "none";
	//		document.getElementById("commercialclick").style.color = "";
	//	document.getElementById("residentialclick").style.color = "";

	//}else if(type == 'all'){
	//	document.getElementById('commercial').style.display= "none";
	//	document.getElementById('farms').style.display= "none";
	//	document.getElementById('residential').style.display= "none";
	//}
}
function createMarker(reallisting, point, headline, price, image, ID) {
		//var icon = new GIcon(baseIcon);
		var icon = new GIcon(G_DEFAULT_ICON, "http://maps.google.com/mapfiles/ms/micons/red-dot.png");
		//icon.image = "realestate.png";
		// C R E A T E   T H E   M A R K E R   A N D   R E G I S T E R   T H E   I N F O   W I N D O W   L I S T E N E R   F U N C T I O N
		var marker = new GMarker(point, icon);
		//GEvent.addListener(marker, "click", function() {
		  //marker.openInfoWindowXslt(headline, "realinfo.xsl"); });
	 //GEvent.addListener(marker, "click", function() {
													GEvent.addListener(marker, "click", function() {
            marker.openInfoWindowHtml(showMarker(headline, price, image, ID));
          });

	
		return marker;
		}

	function showMarker(headline, price, txt, ID){
		var returnString = "";
		//returnString += headline.childNodes[0].nodeValue + "<br/>";
		
		returnString += '<span style="font-face:Arial;font-size:8pt;">' + price.childNodes[0].nodeValue + "</span><br/>";
		
		returnString += '<a href="/index.php?link=listingdetail&listingid=' + ID.childNodes[0].nodeValue + '"><img src="' + txt.childNodes[0].nodeValue + '" style="width:150px; height:95px; border:1px solid #222222;"/></a><br/>';
		returnString += '<a href="/index.php?link=listingdetail&listingid=' + ID.childNodes[0].nodeValue + '" style="font-family:Arial;font-size:8pt;">[more details]<a>';
		return returnString;
	}
	// O P E N   A N D   P R O C E S S   T H E   X M L   D O C
	
	function showMap(phpvars){
	
	
	var request = GXmlHttp.create();
	request.open("GET", "peaklistings.php?" + phpvars, true);
	request.onreadystatechange = function() {
		if (request.readyState == 4) {
		// G E T   T H E   N O D E S		
	      var xmlDoc = GXml.parse(request.responseText);
	      
	     

		var realestates = xmlDoc.documentElement.getElementsByTagName("reallisting");
		var maplocations = xmlDoc.documentElement.getElementsByTagName("location");
		var descriptions = xmlDoc.documentElement.getElementsByTagName("headline");
		var prices = xmlDoc.documentElement.getElementsByTagName("price");

		var images = xmlDoc.documentElement.getElementsByTagName("image");
				var ident = xmlDoc.documentElement.getElementsByTagName("ident");
		// I T E R A T E   T H R O U G H   T H E   N O D E S,  C R E A T I N G   M A R K E R S   F O R   E A C H
		for (var i = 0; i < realestates.length; i++) {
		  var point = new GPoint(parseFloat(maplocations[i].getAttribute("lng")), parseFloat(maplocations[i].getAttribute("lat")));
		  var marker = createMarker(realestates[i], point, descriptions[i], prices[i], images[i], ident[i]);
		  map.addOverlay(marker);
		}
	
	  }
	}
	request.send(null);
	
	}
	
	