/*
*
*  Power Properties 
*  240 Sycamore Drive, Athens, GA 30606
*  Javascript Functions
*  
*/
function writeEmail(){document.write('<a  class="normalU" href=\"mailto:' + user + '@' + site + '\">'+user + '@' + site + '</a>');}
function writeDate(){
	var mydate=new Date();
	var year=mydate.getYear();
	if (year < 1000){year+=1900;}
	var day=mydate.getDay();
	var month=mydate.getMonth();
	var daym=mydate.getDate();
	if (daym<10){daym="0"+daym;}
	var day_array=new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
	var month_array=new Array("January","February","March","April","May","June","July","August","September","October","November","December");
	document.write(day_array[day]+ " " +month_array[month]+ " " +daym+ ", " +year);
}
function handler(e) {
    if (document.all) { e = window.event; }
    // Unicode Value
    var key = e.keyCode;
    // String Value
    var chr = String.fromCharCode(key);
    document.write('Character= ' + chr);
}
function hide(id){
	document.getElementById(id).display = "none";
}
function include(filename){ 
	var xml_type = "text";
	var id = "theBody";
	var xmlhttp = getXmlHttpObject(xml_type);
	if (xmlhttp==null){	alert ("Your browser does not support AJAX!");} 
	xmlhttp.open("GET",filename,false);
	xmlhttp.send(null);
    document.getElementById(id).innerHTML=xmlhttp.responseText;
}
function createPricesTable(properties,xml,show_column_one){
	/*
	 *
	 * There are 3 possible uses for this Routine to display the prices table.
	 * 
	 * 1. Show only a specified property with or without the first column
	 * 2. Show all the properties with or without first column
	 * 3. Show several properties with or without 1st column based on the properties array.
	 *
	 * Arguments: 
	 *
	 * var properties = Array of properties to show.  Show all properties if only value is set to "all"
	 * var xml = reference to an xml file to parse the search results
	 * var show_column_one = boolean value indicating whether or not to show first column
	 *
	 * example:
	 * 		var properties = Array("dearing_garden", "stonecrest", "riverfront")
	 *		createPricesTable(properties, "xml_location.xml", true);
	 *
	 *///createPricesTable(properties,xml,show_column_one){
	var j,t,x,y,z,xmlDoc;
	var table;

	xmlDoc=loadXMLDoc(xml);
	row=xmlDoc.getElementsByTagName("tr");
	table  ='<table class="prices" cellpadding="0" cellspacing="0">';
	table +='<tr class="apartment_headings">';
	if(show_column_one){ table += '<th>Complex</th>'; }
	table += '<th>#&nbsp;Beds/<br/>#&nbsp;Baths</th><th>Sq. Foot</th><th>Price</th><th>Deposit</th><th>Util. Incl.</th><th>Pet</th><th>W/D</th><th>Alarm System</th></tr>';
	for(h=0;h<properties.length;h++){
		for(i=0;i < row.length;i++){
		  if((row[i].nodeType==1) && (row[i].attributes[0].value == properties[h]) || properties[0] == ""){
			  t = row[i].attributes[0].value.split("_");
			  table += '<tr class="' +row[i].getAttribute('class')+ '">';
			  column = row[i].childNodes;
			  if(show_column_one == false){j=0;}else{j=0;}
				while(j<column.length){
					if (column[j].nodeType==1){
						if(!column[j].getAttribute('rowspan')=="" && show_column_one){ table += '<td rowspan="' +column[j].getAttribute('rowspan')+ '">'; } else { table += '<td>'; }
						column_tag=column[j].childNodes;
						table += column[j].firstChild.data;
						if(show_column_one){
							for(k=0;k<column_tag.length;k++){
								if(column_tag[k].nodeType==1){
									switch(column_tag[k].tagName){
										case "location":
											table += '<a href="' +column_tag[k].childNodes[0].data+ '"><img src="';
											break;
										case "link":
											table += column_tag[k].childNodes[0].data+ '" /><br/>';
											break;
										case "span":
											table += column_tag[k].childNodes[0].data+ "</a>";
											break;
										default:
											break;
									}
								}
							}
						}table += "</td>";
					}
					j++;
				}table += '</tr>';
		  }
		}
	}
	table += '</table>';
	return table;
}
function echo(val){	document.write(val);}
function loadXMLDoc(dname){
var xmlDoc;
// code for IE
if (window.ActiveXObject){
	xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
} else if (document.implementation && document.implementation.createDocument){
	xmlDoc=document.implementation.createDocument("","",null);
} else {
	alert('Your browser cannot handle this script');
}
xmlDoc.async=false;
xmlDoc.load(dname);
return(xmlDoc);
}
function getURL(name){
  name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
  var regexS = "[\\?&]"+name+"=([^&#]*)";
  var regex = new RegExp( regexS );
  var results = regex.exec( window.location.href );
  if( results == null )
    return "";
  else
    return results[1];
}
function getFiles(filenames, id){
	var xml_type = "text";
	var xmlhttp = getXmlHttpObject(xml_type);
	var text;
	if (xmlhttp==null){
		alert ("Your browser does not support Javascript!");
	}
	for($i=0;$i < filenames.length;$i++){
		xmlhttp.open("GET",filenames[$i],false);
		xmlhttp.send(null);
		document.write(xmlhttp.responseText);
	}
}
function getFile(filename, id){ 
	var xml_type = "text";
	var xmlhttp = getXmlHttpObject(xml_type);
	if (xmlhttp==null){
		alert ("Your browser does not support Javascript!");
	} 
	xmlhttp.open("GET",filename,false);
	xmlhttp.send(null);
    document.getElementById(id).innerHTML=xmlhttp.responseText;
}
function getXmlHttpObject(xml_type){
	// New stuff
	var xmlHttp=null;
	try{
	  // Firefox, Opera 8.0+, Safari
	  	xmlHttp=new XMLHttpRequest();
	  	// If just returning text and not posting anything, set type to text.
	  	if(xml_type == "text"){
	  		xmlHttp.overrideMimeType("text/xml");
  		}
	} catch (e){
	  // Internet Explorer
		try{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e){
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlHttp;
}
//Toggle popup link setting: popupsetting[0 or 1, "pop up window attributes" (if 1)]
var popupsetting=[1, "width=500px, height=400px, scrollbars, resizable"]
function popuplinkfunc(imgsrc){
	var popwin=open(imgsrc, "popwin", popupsetting[1])
	popwin.focus()
	return false
}