// JavaScript Document


// HOME BUTTON
homeon = new Image ();
homeon.src = "images/btn_home.jpg";
homeoff = new Image ();
homeoff.src = "images/btn_home_r.jpg";

// about BUTTON
abouton = new Image ();
abouton.src = "images/btn_about.jpg";
aboutoff = new Image ();
aboutoff.src = "images/btn_about_r.jpg";

// featured BUTTON
featuredon = new Image ();
featuredon.src = "images/btn_featured.jpg";
featuredoff = new Image ();
featuredoff.src = "images/btn_featured_r.jpg";

// testimonials BUTTON
testimonialson = new Image ();
testimonialson.src = "images/btn_testimonials.jpg";
testimonialsoff = new Image ();
testimonialsoff.src = "images/btn_testimonials_r.jpg";

// tips BUTTON
tipson = new Image ();
tipson.src = "images/btn_tips.jpg";
tipsoff = new Image ();
tipsoff.src = "images/btn_tips_r.jpg";

// didyouknow BUTTON
didyouknowon = new Image ();
didyouknowon.src = "images/btn_didyouknow.jpg";
didyouknowoff = new Image ();
didyouknowoff.src = "images/btn_didyouknow_r.jpg";

// calculator BUTTON
calculatoron = new Image ();
calculatoron.src = "images/btn_calculator.jpg";
calculatoroff = new Image ();
calculatoroff.src = "images/btn_calculator_r.jpg";

// contact BUTTON
contacton = new Image ();
contacton.src = "images/btn_contact.jpg";
contactoff = new Image ();
contactoff.src = "images/btn_contact_r.jpg";





function insertDate () {
	// DATE FUNCTION
	monthArray = new Array();
	monthArray[0] = "January";
	monthArray[1] = "February";
	monthArray[2] = "March";
	monthArray[3] = "April";
	monthArray[4] = "May";
	monthArray[5] = "June";
	monthArray[6] = "July";
	monthArray[7] = "August";
	monthArray[8] = "September";
	monthArray[9] = "October";
	monthArray[10] = "November";
	monthArray[11] = "December";
	
	daysArray = new Array();
	daysArray[0] = "Sunday";
	daysArray[1] = "Monday";
	daysArray[2] = "Tuesday";
	daysArray[3] = "Wednesday";
	daysArray[4] = "Thursday";
	daysArray[5] = "Friday";
	daysArray[6] = "Saturday";
	
	var theDate = new Date();
	var aMonth = theDate.getMonth() + 1;
	var aDate = theDate.getDate();
	var aYear = theDate.getFullYear();
	var aDay = theDate.getDay();
	var aHours = theDate.getHours();
	var aMinutes = theDate.getMinutes();
	var aAmpm = "am";
	if (aHours > 12) {
		aHours -= 12;
		aAmpm = "pm";
	}
	
	if (aHours == 24 || aHours == 12) {
		aHours = 0;	
	}
	if (aMinutes < 10) {
		aMinutes = "0" + aMinutes;	
	}


	document.propertyinfo.aMonth.value = aMonth;
	document.propertyinfo.aDate.value = aDate;
	document.propertyinfo.aYear.value = aYear;
	document.propertyinfo.aHours.value = aHours;
	document.propertyinfo.aMinutes.value = aMinutes;
	document.propertyinfo.aAmpm.value = aAmpm;
	
}
// -->




// ROLLOVER / ROLLOUT
function roll (vName, TF) { 
	if (document.images) {
		if (TF == true) {
			img = eval (vName + "off.src");
		} else {
			img = eval (vName + "on.src");
		}
		document[vName].src = img;
	}		
}


function showClock () {
	
	document.write ('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="136px" height="72px" id="clock" align="middle">\n');
	document.write ('<param name="allowScriptAccess" value="sameDomain" />\n');
	document.write ('<param name="movie" value="flash/clock.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#FFFFFF" />\n');	
	document.write ('<embed src="flash/clock.swf" quality="high" bgcolor="#FFFFFF" width="136px" height="72px" name="clock" align="middle" allowscriptaccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />\n');	
	document.write ('</object>\n');
}

function showWeather () {
	
	document.write ('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="274px" height="73px" id="weather" align="middle">\n');
	document.write ('<param name="allowScriptAccess" value="sameDomain" />\n');
	document.write ('<param name="movie" value="flash/weather.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#FFFFFF" />\n');	
	document.write ('<embed src="flash/weather.swf" quality="high" bgcolor="#FFFFFF" width="274px" height="73px" name="weather" align="middle" allowscriptaccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />\n');	
	document.write ('</object>\n');
}

function showForecast () {
	
	document.write ('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="484px" height="250px" id="forecast" align="middle">\n');
	document.write ('<param name="allowScriptAccess" value="sameDomain" />\n');
	document.write ('<PARAM NAME=wmode VALUE=transparent>');
	document.write ('<param name="movie" value="flash/forecast.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#FFFFFF" />\n');	
	document.write ('<embed src="flash/forecast.swf" quality="high" bgcolor="#FFFFFF" width="484px" height="250px" name="forecast" align="middle" allowscriptaccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />\n');	
	document.write ('</object>\n');
}

function showFeature (vImg, vSold, vTotal, vID) {
	
	document.write ('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="484" height="200" id="feature" align="middle">\n');
	document.write ('<param name="allowScriptAccess" value="sameDomain" />\n');
	document.write ('<param name="wmode" value="transparent">\n');
	document.write ('<param name="FlashVars" value="ft_img=' + vImg + '&sold=' + vSold +'&total=' + vTotal +'&list_id=' + vID +'" />\n');	
	document.write ('<param name="movie" value="flash/featured.swf?i=7" /><param name="quality" value="high" /><param name="bgcolor" value="#FFFFFF" />\n');	
	document.write ('<embed src="flash/featured.swf?i=7" wmode="transparent" FlashVars="ft_img=' + vImg + '&sold=' + vSold +'&total=' + vTotal +'&list_id=' + vID +'" quality="high" bgcolor="#FFFFFF" width="484" height="200" name="feature" align="middle" allowscriptaccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />\n');	
	document.write ('</object>\n');	
}

function showMyHouse (vImg, vSold) {
	
	document.write ('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="444" height="200" id="myhouse" align="middle">\n');
	document.write ('<param name="allowScriptAccess" value="sameDomain" />\n');
	document.write ('<param name="FlashVars" value="ft_img=' + vImg + '&sold=' + vSold +'" />\n');	
	document.write ('<param name="movie" value="flash/myhouse.swf" /><param name="quality" value="high" /><param name="bgcolor" value="#FFFFFF" />\n');	
	document.write ('<embed src="flash/myhouse.swf" FlashVars="ft_img=' + vImg + '&sold=' + vSold +'" quality="high" bgcolor="#FFFFFF" width="444" height="200" name="myhouse" align="middle" allowscriptaccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />\n');	
	document.write ('</object>\n');	
}

function showListing (vImg, vSold, vTotal, vID) {
	
	document.write ('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="200" height="149" id="listing" align="middle">\n');
	document.write ('<param name="allowScriptAccess" value="sameDomain" />\n');
	document.write ('<param name="FlashVars" value="ft_img=' + vImg + '&sold=' + vSold +'&total=' + vTotal +'&list_id=' + vID +'" />\n');	
	document.write ('<param name="movie" value="flash/listing.swf?i=2" /><param name="quality" value="high" /><param name="bgcolor" value="#FFFFFF" />\n');	
	document.write ('<embed src="flash/listing.swf?i=2" FlashVars="ft_img=' + vImg + '&sold=' + vSold +'&total=' + vTotal +'&list_id=' + vID +'" quality="high" bgcolor="#FFFFFF" width="200" height="149" name="listing" align="middle" allowscriptaccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />\n');	
	document.write ('</object>\n');	
}


function CalcKeyCode(aChar) {
	var character = aChar.substring(0,1);
	var code = aChar.charCodeAt(0);
	return code;
}
	
function checkNumber(val) {
	
	var strPass = val.value;
	var strLength = strPass.length;
	var lchar = val.value.charAt((strLength) - 1);
	var cCode = CalcKeyCode(lchar);
	
	if (cCode < 48 || cCode > 57 ) {
		if (cCode != 46) {
			var myNumber = val.value.substring(0, (strLength) - 1);
			val.value = myNumber;
		}
	}
	return false;
}


// POPUP WINDOW
function show_gallery (GID) {
	
	var myName = "Gallery";
	var h = "700";
	var w = "825";
	var scroll = "yes";
	var winl = ((screen.width - w) / 2);
	var wint = ((screen.height - h) / 2);
	var myPage = "gallery.php?id=" + GID;
	winprops = 'height=' + h +',width=' + w + ',top=' + wint + ',left=' + winl + ',scrollbars=' + scroll + ',resizable=no';
	win = window.open (myPage, myName, winprops)
}

// GALLERY CHANGE IMAGE
function change_image (vImage) {
	var vTarget = "gallery_img";
	
	if (document.images){
		document[vTarget].src = vImage + "?";
	}
	
	
}

function next_img (vTotal) {
	
	var current = document.gallery_img.src;
	
	// strip src code
	var current_array = current.split("homes/");
	
	var current_img = current_array[1].split(".jpg");
	
	var img_num = current_img[0].split("_");
	
	var new_img = current_array[0] + "homes/" + img_num[0];
	
	
	var num_n = 0;
	// we are on the first image
	if (img_num[1] == undefined) {
		num_n = 1;
		
	// we are NOT on the forst image
	} else {
		var num_c = Number(img_num[1]);
		num_n = Number(num_c + 1);
		
	}
	
	
	
	
		
	// testing to see if we are too high
	if (num_n != vTotal) {
		new_img += "_";
		new_img += num_n;
	}
	
	
	new_img += ".jpg";
	change_image (new_img);
}

function previous_img (vTotal) {
	
	var current = document.gallery_img.src;
	
	// strip src code
	var current_array = current.split("homes/");
	
	var current_img = current_array[1].split(".jpg");
	
	var img_num = current_img[0].split("_");
	
	var new_img = current_array[0] + "homes/" + img_num[0];
	
	
	var num_n = 0;
	// we are on the first image
	if (img_num[1] == undefined) {
		num_n = (vTotal-1);
		
	// we are NOT on the first image
	} else {
		var num_c = Number(img_num[1]);
		num_n = Number(num_c - 1);	
		
	}
	
	// testing to see if we are too hig
	if (num_n != 0) {
		new_img += "_";
		new_img += num_n;
	}
	
	
	new_img += ".jpg";
	change_image (new_img);
	
}






