function linkEmail(user) {
	document.location = 'mailto:' + user + '@trementwest.org';
}

function sdmSetColor (td, colour) {
        if (document.getElementById) {
                var cell = document.getElementById(td);
                link = cell.getElementsByTagName('a')[0];
                link.style.color = colour;
        }
}

function sdmStickMenu(id) {
/*
        if (document.getElementById) {
                if (id) {
                	var item = document.getElementById("primary"+id);
                	item.style.background = "url(/pix/layout/background-primarynotch.gif)";
			item.style.backgroundRepeat = "no-repeat";
			item.style.backgroundPosition = "center";
			setTimeout ('item.style.background = "transparent"', 5000);
		}
	}
*/
}


function homeMainImage() {
	var item = document.getElementById("main");
	item.style.background = "url(/pix/layout/background-homemain.jpg)";
	item.style.backgroundRepeat = "no-repeat";
	item.style.backgroundPosition = "bottom left";
//	background:url(/pix/layout/background-homemain.jpg) no-repeat;
//	background-position:bottom left;
}

function switchType (type,date) {
        if (document.getElementById) {
                var item = document.getElementById('calendarvisitor');
		item.style.display = "none";

                item = document.getElementById('calendarresident');
		item.style.display = "none";

                item = document.getElementById('calendar'+type);
		item.style.display = "block";
		
                var item = document.getElementById('selectvisitor');
		item.style.background = "#FFFFFF";
		item.style.color = "#757575";

                item = document.getElementById('selectresident');
		item.style.background = "#FFFFFF";
		item.style.color = "#757575";

		item = document.getElementById('select'+type);
		item.style.background = "#757575";
		item.style.color = "#FFFFFF";

		showEvents(type,date);
        }
}


//FUNCTIONS TO SWAP IN EXTERNAL CONTENT INTO DIV
function getHTTPObject() { 
	var xmlhttp; 
	/*@cc_on 
	@if (@_jscript_version >= 5) 
		try { 
			xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); 
		} catch (e) { 
			try { 
				xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); 
			} catch (E) { 
				xmlhttp = false; } 
		} @else xmlhttp = false; 
	@end @*/ 
	
	if (!xmlhttp && typeof XMLHttpRequest != 'undefined') { 
		try { 
			xmlhttp = new XMLHttpRequest(); 
		} catch (e) { 
			xmlhttp = false; 
		} 
	} 
	return xmlhttp;
}

function showEvents(type,date) {
        if (document.getElementById) {
		for (i=1; i<=12; i++) {
			var item = document.getElementById(type+"month"+i);
			if (item) {
				item.style.background = "#EFEFEF";
				item.style.color = "#000000";
			}
		}
		var item = document.getElementById(type+"month"+date);
		item.style.background = "#658E81";
		item.style.color = "#FFFFFF";
	}

	var http = getHTTPObject();
	http.open("GET", "/index/webapp-events-action?homedate="+date+"&type="+type, true);
	http.onreadystatechange = function() { 
		if (http.readyState == 4) { 
			document.getElementById("homeevents").innerHTML = http.responseText;
		}
	} 
	http.send(null);

}