if (document.images && document.getElementById) {
	home_on = new Image();
	home_on.src = 'images/nav/btn1_1.gif';
	home_off = new Image();
	home_off.src = 'images/nav/btn1_0.gif';
	realestate_on = new Image();
	realestate_on.src = 'images/nav/btn2_1.gif';
	realestate_off = new Image();
	realestate_off.src = 'images/nav/btn2_0.gif';
	about_on = new Image();
	about_on.src = 'images/nav/btn3_1.gif';
	about_off = new Image();
	about_off.src = 'images/nav/btn3_0.gif';
	community_on = new Image();
	community_on.src = 'images/nav/btn4_1.gif';
	community_off = new Image();
	community_off.src = 'images/nav/btn4_0.gif';
	faqs_on = new Image();
	faqs_on.src = 'images/nav/btn5_1.gif';
	faqs_off = new Image();
	faqs_off.src = 'images/nav/btn5_0.gif';
	contact_on = new Image();
	contact_on.src = 'images/nav/btn6_1.gif';
	contact_off = new Image();
	contact_off.src = 'images/nav/btn6_0.gif';
	m_kitsap = new Image();
	m_kitsap.src = 'images/map/map_kitsap.gif';
	m_modern = new Image();
	m_modern.src = 'images/map/map_contemporary.gif';
	m_eside = new Image();
	m_eside.src = 'images/map/map_eastside.gif';
	m_kirkland = new Image();
	m_kirkland.src = 'images/map/map_kirkland.gif';
	m_mercerisl = new Image();
	m_mercerisl.src = 'images/map/map_mercer.gif';
	m_northsea = new Image();
	m_northsea.src = 'images/map/map_northseattle.gif';
	m_sanjuan = new Image();
	m_sanjuan.src = 'images/map/map_sanjuan.gif';
	m_seattle = new Image();
	m_seattle.src = 'images/map/map_seattle.gif';
	m_snoho = new Image();
	m_snoho.src = 'images/map/map_westernsnohomish.gif';
	m_southsea = new Image();
	m_southsea.src = 'images/map/map_southseattle.gif';
	m_condos = new Image();
	m_condos.src = 'images/map/map_urbancondos.gif';
	m_westsea = new Image();
	m_westsea.src = 'images/map/map_westseattle.gif';
	m_renton = new Image();
	m_renton.src = 'images/map/map_renton.gif';
	m_gigharbor = new Image();
	m_gigharbor.src = 'images/map/map_tacoma.gif';
	m_default = new Image();
	m_default.src = 'images/map/map_default.gif';
	m_skagit = new Image();
	m_skagit.src = 'images/map/map_skagit.gif';
}

function swap(obj, bool) {
	if (bool) {
//		obj.setAttribute('class', 'active');
		obj.className = 'active';
	}
	else {
//		obj.removeAttribute('class');
		obj.className = '';
	}
}

function blank(uri) {
	blankwindow = window.open(uri);
	return false;
}

function moreinfo(aid) {
	if (document.getElementById('agentinfo'+aid).style.display == 'block') {
		this.innerHTML = 'More info &raquo;';
		document.getElementById('agentinfo'+aid).style.display == 'none';
	}
	else if (document.getElementById('agentinfo'+aid).style.display == 'none') {
		this.innerHTML = 'Less info &laquo;';
		document.getElementById('agentinfo'+aid).style.display = 'block';
	}
}

function loadPicture(obj) {
	img = obj.href;
	document.getElementById('previewimg').innerHTML = '<a href="'+img+'" onclick="return zoomIn(this.href);"><img src="'+img+'" height="264" /></a>';
	objArr = obj.parentNode.childNodes;
	for(i=0;i<objArr.length;i++) {
		if (objArr[i] == obj && objArr[i].className != 'undefined') {
			objArr[i].className = 'active';
			objArr[i].blur();
		}
		else if (objArr[i].className && objArr[i].className != 'clearhack') {
			objArr[i].className = '';
		}
	}
	return false;
}

function zoomIn(obj) {
	zoomwindow = window.open('http://www.360modern.com/home/zoom.php?x='+obj, 'zoomwindow', 'width=640, height=480, resizable=yes, status=no, left=100, top=50, menubar=no, location=no, scrollbars=no');
	return false;
	}

function showFaq(obj) {
	objRef = obj.href.split('aid=');
	faqId = 'faq'+objRef[(objRef.length -1)];	
	faqState = document.getElementById(faqId).style.display;
	if (faqState == 'none') {
		document.getElementById(faqId).style.display = 'block';
		obj.className = 'faqlinkactive';
	}
	else {
		document.getElementById(faqId).style.display = 'none';
		obj.className = 'faqlink';
	}
	obj.blur();
	return false;
}

function showNews(obj) {
	objRef = obj.href.split('aid=');
	faqId = 'news'+objRef[(objRef.length -1)];	
	faqState = document.getElementById(faqId).style.display;
	if (faqState == 'none') {
		document.getElementById(faqId).style.display = 'block';
		obj.className = 'newslinkactive';
	}
	else {
		document.getElementById(faqId).style.display = 'none';
		obj.className = 'newslink';
	}
	obj.blur();
	return false;
}

function mapOvr(area) {
	document.getElementById('remap').src = eval('m_'+area+'.src');
}

// FORM VALIDATION
function validateForm(formObj) { // Hello, I'll be your form validating script today.
var formElements = formObj.elements;

// Now I'll set a bunch of boolean variables that will help us validate your form.
var canSubmit = true; // This will ultimately decide if the form gets submitted or not, and is dependant on the other vars to do so.
var emailValid = true; // This checks if the user's email address is valid (string@string.string).
var fieldsComplete = true; // This checks that all the required text fields are not blank.
var anyChecked = true; // This makes sure all required checkbox/radio box arrays are valid.

// These arrays are used to validate the check/radio boxes.
var rcBoxes = new Array();
rcBoxes[0] = new Array();
rcBoxes[1] = new Array();
var rcArrays = new Array();
rcArrays[0] = new Array;
rcArrays[1] = new Array;

// Getting down to business now, we'll loop through all the elements of your form
for (i=0;i<formElements.length;i++) {
// We'll start with the text fields - making sure all the required ones are not blank.
	if (formElements[i].type == 'text' ||  formElements[i].type == 'textarea') {
		if (formElements[i].name.substring((formElements[i].name.length -4),(formElements[i].name.length)) == '_req' && (formElements[i].value == '' || formElements[i].value == 'undefined')) {
		formElements[i].className += ' highlight'; // Highlights a required field left blank.
		fieldsComplete = false;
			}
// Now we'll check if the user has provided you with a valid email address...
		if (formElements[i].name == 'email_req') {
			if (formElements[i].value.search('.+@.+\\.[a-z]+') < 0) {
				formElements[i].className += ' highlight'; // Highlights the email field if blank or invalid.
				emailValid = false;
				}
			else { // Removes the highlight if email is valid.
				formElements[i].className = formElements[i].className.replace(' highlight','');
				}
			}
		else if (formElements[i].name.substring((formElements[i].name.length -4),(formElements[i].name.length)) == '_req' && formElements[i].value != '') {
			// Removes the highlight if fields are properly filled.
			formElements[i].className = formElements[i].className.replace(' highlight','');
			}
		}

// Finally, we go through the checkboxes and radio boxes, making sure each array of required check/radio boxes has at least one element checked.
	else if (formElements[i].type == 'radio' || formElements[i].type == 'checkbox') {
		if (formElements[i].name.substring((formElements[i].name.length -4),(formElements[i].name.length)) == '_req') {
			// Adds all checkboxes to an array which we'll be looping through later.
			rcBoxes[0].push(formElements[i].name);
			rcBoxes[1].push(formElements[i].checked);
			}
		}
	}

// After loading all the check/radio boxes into a separate array, we go through them again.
if (rcBoxes[0].length > 0) {
	for (i=0;i<rcBoxes[0].length;i++) {
		// The first thing we'll do is separate them into little arrays where they have a common name attribute.
		targetCheck = formObj[rcBoxes[0][i]];
		i += targetCheck.length;
		// Then we'll loop through that array.
		for (j=0;j<targetCheck.length;j++) {
			if (targetCheck[j].checked) {
				// If we find a checked box within a required array, add the element's name to rcArrays[0] and add true to rcArrays[1].
				rcArrays[1].push(true);
				rcArrays[0].push(targetCheck[j].name);
				// That's all we need, so we can break out of the loop.
				break;
				}
			else if (j == (targetCheck.length -1)) {
				// If nothing is checked, we only add the name of the element to rcArrays[0].
				rcArrays[0].push(targetCheck[j].name);
				}
			}
		}
	// So, with all the info we gathered up there, we'll check the length of rcArrays[0] against rcArrays[1].
	// If all the required check/radio arrays have at least one box checked, they're valid and the lengths should match.
	if (rcArrays[0].length != rcArrays[1].length) {
		// If the lengths of rcArrays[0] and rcArrays[1] don't match, it means something that should've been checked was left unchecked.
		anyChecked = false;
		}
	}

// Remember our boolean vars? This is where we check them and give the user an appropriate response.
if (!fieldsComplete || !anyChecked) {
	// This message will display if a required textfield was left blank or a checkbox was left un-checked.
	alert('Please fill out all required fields before submitting this form!');
	canSubmit = false; // Don't let the form submit.
	}
else if (!emailValid) {
	// This message will display if the user didn't enter a valid email address.
	alert('Please enter a valid email address in the highlighted field!');
	canSubmit = false; // Don't let the form submit.
	}
if (fieldsComplete && emailValid && anyChecked) {
	// If everything has been properly filled and a valid email address has been entered, the form can submit!
	canSubmit = true;
	}
return canSubmit;
}

function resourceDrop(obj) {
	if (obj.value != 'null') {
		self.location.href = '?s=resources&aid='+ obj.value;
		return true;
	}
	else {
		return false;
	}
}

function featureDrop(obj) {
	if (obj.value != 'null') {
		self.location.href = '?s=features&aid='+ obj.value;
		return true;
	}
	else {
		return false;
	}
}

function agentDrop(obj) {
	if (obj.value != 'null') {
		self.location.href = obj.value;
		return true;
	}
	else {
		return false;
	}
}

function articleDrop(obj) {
	if (obj.value != 'null') {
		self.location.href = '?s=articles&aid='+ obj.value;
		return true;
	}
	else {
		return false;
	}
}

function mlsDrop(obj) {
	if (obj.value != 'null') {
		self.location.href = obj.value;
		return true;
	}
	else {
		return false;
	}
}

function articleImg(obj) {
	ai = 'zoom.php?x='+ obj.href;
	articleImgWindow = window.open(ai, 'zoomwindow', 'width=640, height=480, resizable=yes, status=no, left=100, top=50, menubar=no, location=no, scrollbars=no');
	return false;
}

if(window.attachEvent) {
	window.attachEvent("onload",setListeners);
}

function setListeners(){
	inputList = document.getElementsByTagName("INPUT");
	for(i=0;i<inputList.length;i++){
		inputList[i].attachEvent("onpropertychange",restoreStyles);
		inputList[i].style.backgroundColor = "";
	}
	selectList = document.getElementsByTagName("SELECT");
	for(i=0;i<selectList.length;i++){
		selectList[i].attachEvent("onpropertychange",restoreStyles);
		selectList[i].style.backgroundColor = "";
	}
}

function noSpam(me) {
	me = me.href;
	me = me.replace('[at]','@');
	me = me.replace('[dot]','.');
	self.location.href = me;
	return false;
	}

function restoreStyles(){
	if(event.srcElement.style.backgroundColor != "")
	event.srcElement.style.backgroundColor = "";
}

function openArchitect(obj) {
	architectWindow = window.open(obj.href, 'archwindow', 'width=640, height=400, resizable=no, status=no, left=100, top=100, menubar=no, location=no, scrollbars=no');
	return false;
}

function openArticleImgs(obj) {
	articleWindow = window.open(obj.href, 'artwindow', 'width=640, height=400, resizable=no, status=no, left=100, top=100, menubar=no, location=no, scrollbars=no');
	return false;
}

function getAlt(obj) {
	objNodes = document.getElementById(obj).childNodes;
	for (i=0;i<objNodes.length;i++) {
		if (objNodes[i].src) {
			return objNodes[i].getAttribute('alt');
			break;
		}
	}
	return false;
}

function positionCredits() {
	if (document.getElementById('focus')) {
		topLeftCredits = '<em>Top left:</em> '+getAlt('focus') +'<br />';
	}
	else {
		topLeftCredits = '';
	}
	if (document.getElementById('top')) {
		topRightCredits = '<em>Top right:</em> '+getAlt('top');
	}
	else {
		topRightCredits = '';
	}
	if (topLeftCredits != '' || topRightCredits != '') {
		document.getElementById('imgcredits').innerHTML = '<b>Photo credits</b><br />'+ topLeftCredits + topRightCredits;	
		document.getElementById('imgcredits').style.display = 'block';	
		ch = document.getElementById('imgcredits').offsetHeight;
		document.getElementById('imgcredits').style.marginTop = ch * (-1) +'px';
	}
}

function signUp(uri) {
	signupform = window.open(uri, 'expressmail', 'width=555, height=495, resizable=yes, status=yes, left=100, top=100, menubar=no, location=no, scrollbars=yes');
	return false;
}

function openCard() {
	var d = new Date();
	month = d.getMonth();
	if (month == 11) {
		if (document.all) {
			wh = document.body.clientHeight;
			ww = document.body.clientWidth;
		}
		else {
			wh = window.innerHeight;
			ww = window.innerWidth;
		}
	
		wx = Math.round((ww/2) - (355/2));
		wy = Math.round((wh/2) - (467/2));
		db = document.getElementsByTagName('body')[0];
		db.innerHTML += '<div id="cardback" onclick="closeCard();"></div><div id="card"></div>';
		document.getElementById('card').style.left = wx +'px';
		document.getElementById('card').style.top = wy + 'px';
		so = new SWFObject('images/holi_card3.swf', '360card', '355', '467', '8', '#ffffff');
		so.write('card');
		document.getElementById('card').style.display = 'block';
		document.getElementById('cardback').style.display = 'block';
	}
}

function closeCard() {
	document.getElementById('card').style.display = 'none';
	document.getElementById('cardback').style.display = 'none';
}

	canSlide = true;
	autoTimer = '';
	var asw = null;
	var acm = null;
	var acd = null;
	
	function gimmeValues() {
		document.getElementById('monitor').innerHTML = '<b>canSlide</b> = '+canSlide.toString()+'<br /><b>autoTimer</b> = '+autoTimer+'<br /><b>asw</b> = '+asw+'<br /><b>acm</b> = '+acm+'<br /><b>acd</b> = '+acd;
	}
	
	function next(divId) {
//		alert('b');
		window.clearTimeout(autoTimer);
		autoTimer = null;
		if (canSlide) {
			asw = document.getElementById(divId).offsetWidth;
			if (!document.getElementById(divId).style.marginLeft) {
				acm = 0;
				acd = -252;
			}
			else {
				acm = parseInt(document.getElementById(divId).style.marginLeft);
				acd = acm -252;
			}
			
			if (acd > ((asw *(-1))+252) && canSlide) {
				mt = new Tween(document.getElementById(divId).style,'marginLeft',Tween.strongEaseOut,acm,acd,1,'px');
				mt.start();
				mt.onMotionFinished = function() {
					canSlide = true;
					acm = acd;
					acd = acm -252;
					}
				canSlide = false;
			}
		}
	}
	
	function prev(divId) {
//		alert('c');
		window.clearTimeout(autoTimer);
		autoTimer = null;
		if (canSlide) {
			asw = document.getElementById(divId).offsetWidth;
			if (!document.getElementById(divId).style.marginLeft) {
				acm = 0;
				acd = 252;
			}
			else {
				acm = parseInt(document.getElementById(divId).style.marginLeft);
				acd = acm +252;
			}
			
			if (acm < 0 && canSlide) {
				mt = new Tween(document.getElementById(divId).style,'marginLeft',Tween.strongEaseOut,acm,acd,1,'px');
				mt.start();
				mt.onMotionFinished = function() {
					canSlide = true;
					acm = acd;
					acd = acm +252;
					}
				canSlide = false;
			}
			else {
				return false;
			}
		}
	}
	
	var going = true;
	
	function automagic() {
//		alert('foo');
		if (asw==null && acm==null && acd==null) {
		asw = parseInt(document.getElementById('featurereel').style.width);
//		alert(asw);
		acm = 0;
		acd = -252;
		}
		if (asw > 504) {
			if (acd > ((asw *(-1))+252) && canSlide && going) {
				next('featurereel');
				autoTimer = window.setTimeout("automagic()",6000);
			}
			else if (canSlide && !going) {
				going = false;
				prev('featurereel');
				autoTimer = window.setTimeout("automagic();",6000);
			}
			
			if (parseInt(document.getElementById('featurereel').style.marginLeft) == 0) {
				going = true;
			}
		}
	}
	
	function setAlpha(obj,val) {
		if (document.all) {
				document.getElementById(obj).filters.alpha.opacity = val;
		}
		else {
				document.getElementById(obj).style.opacity = (val / 100);
		}
	}

window.onload = function() { 
	positionCredits();
	if (document.getElementById('featurereel')) {
		autoTimer = window.setTimeout("automagic()",6000);
		if (document.getElementById('feature_bck')) {
			document.getElementById('feature_bck').onmouseover = function() {
				if (parseInt(document.getElementById('featurereel').style.width) > 504) {
					setAlpha('feature_bck', 70);
					setAlpha('feature_fwd',40);
				}
			}
			document.getElementById('feature_bck').onmouseout = function() {
				if (parseInt(document.getElementById('featurereel').style.width) > 504) {
					setAlpha('feature_bck', 0);
					setAlpha('feature_fwd',0);
				}
			}
			document.getElementById('feature_bck').onclick = function() {
				if (parseInt(document.getElementById('featurereel').style.width) > 504) {
					window.clearTimeout(autoTimer);
					prev('featurereel');
				}
			}
		}
		if (document.getElementById('feature_fwd')) {
			document.getElementById('feature_fwd').onmouseover = function() {
				if (parseInt(document.getElementById('featurereel').style.width) > 504) {
					setAlpha('feature_fwd', 70);
					setAlpha('feature_bck',40);
				}
			}
			document.getElementById('feature_fwd').onmouseout = function() {
				if (parseInt(document.getElementById('featurereel').style.width) > 504) {
					setAlpha('feature_fwd', 0);
					setAlpha('feature_bck',0);
				}
			}
			document.getElementById('feature_fwd').onclick = function() {
				if (parseInt(document.getElementById('featurereel').style.width) > 504) {
					window.clearTimeout(autoTimer);
					next('featurereel');
				}
			}
		}
		document.getElementById('featurereel').onmouseover = function() {
			if (parseInt(document.getElementById('featurereel').style.width) > 504) {
				setAlpha('feature_bck',40);
				setAlpha('feature_fwd',40);
				window.clearTimeout(autoTimer);
			}
		}
		document.getElementById('featurereel').onmouseout = function() {
			if (parseInt(document.getElementById('featurereel').style.width) > 504) {
				setAlpha('feature_bck',0);
				setAlpha('feature_fwd',0);
			}
		}
	}
	
	d = new Date();
	m = d.getMonth();
	
	if (m == 11 && isHome) {
		if (document.all) {
			ww = document.body.clientWidth;
			wh = document.body.clientHeight;
		}
		else {
			ww = window.innerWidth;
			wh = window.innerHeight;
		}
		wwm = Math.round((ww / 2) - (355 / 2)) - 50;
		whm = Math.round((wh / 2) - (467 / 2));
		mkd = document.createElement('div');
		mkd.setAttribute('id', 'card');
		mkb = document.createElement('div');
		mkb.setAttribute('id','cardback');
		mkb.innerHTML = '&nbsp;';
		if (document.all) {
			mkb.setAttribute('filter','Alpha (Opacity=0)');
			mkd.setAttribute('filter','Alpha (Opacity=0)');
		}
		else {
			mkb.setAttribute('opacity','0');
			mkd.setAttribute('opacity','0');
		}
		db = document.getElementsByTagName('body')[0];
		mkd.innerHTML = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="355" height="467" id="holicard" align=""><param name=movie value="images/holi_card3.swf"><param name=quality value=high> <param name=bgcolor value=#FFFFFF><embed src="images/holi_card3.swf" quality=high bgcolor=#FFFFFF width="355" height="467" name="niftyPlayer1" align="" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed></object>';
		db.appendChild(mkb);
		db.appendChild(mkd);
		document.getElementById('card').style.left = wwm+'px';
		document.getElementById('card').style.top = whm+'px';
		var mkbt = new OpacityTween(document.getElementById('cardback'),Tween.strongEaseOut,70,1);
		var mkdt = new OpacityTween(document.getElementById('card'),Tween.strongEaseIn,100,1);
	}
//	window.setInterval('gimmeValues()',1);
}
	
window.onresize = function() {
	if (document.getElementById('card')) {
		if (document.all) {
			wh = document.body.clientHeight;
			ww = document.body.clientWidth;
		}
		else {
			wh = window.innerHeight;
			ww = window.innerWidth;
		}
		
		wx = Math.round((ww/2) - (355/2));
		wy = Math.round((wh/2) - (467/2));
		document.getElementById('card').style.left = wx +'px';
		document.getElementById('card').style.top = wy + 'px';
	}
}