// JavaScript Document

function fadeEngine(x) {
	var total_divs=10;
	var y=x;
	if(x==total_divs) y=1; else y++;
	$("#eventsRotation"+x).css("display","none");
	$("#eventsRotation"+y).fadeIn("slow");
	setTimeout('fadeEngine('+y+')',10000); //modify 3000 to set the time in miliseconds for a div to be shown
}

function scrollToTop() {
	window.scrollTo(0,0);
}

function eventExpand(id,odate) {
	el = 'event_' + id + '_' + odate;
	elCompact = el + '_compacted';
	elExtended = el + '_extended';
	document.getElementById(elCompact).style.display = 'none';
	document.getElementById(elExtended).style.display = 'block';
}

function eventContract(id,odate) {
	el = 'event_' + id + '_' + odate;
	elCompact = el + '_compacted';
	elExtended = el + '_extended';
	document.getElementById(elCompact).style.display = 'block';
	document.getElementById(elExtended).style.display = 'none';
}

function printView(id) { //eventsCalendar
	url = '/residents/Events?a=print&id=' + id;
	name = '_blank';
	window.open(url,name,'width=525,height=700,resizable=0,toolbar=0,status=0,menubar=1,location=0');
}

function printView2(id) { //eventsCalendar2
	url = '../events2.php?a=print&id=' + id;
	name = '_blank';
	window.open(url,name,'width=525,height=700,resizable=0,toolbar=0,status=0,menubar=1,location=0');
}

function printView3(id) { //eventsCalendar3
	url = '../events.php?a=print&id=' + id;
	name = '_blank';
	window.open(url,name,'width=525,height=700,resizable=0,toolbar=0,status=0,menubar=1,location=0');
}

function switchMonth(val) { //eventsCalendar
	value = escape(val);
	window.location.href = '/residents/Events?month='+value;
}

function switchMonth2(val) { //eventsCalendar2
	value = escape(val);
	window.location.href = '/residents/Events?month='+value;
}
function switchMonth3(val) { //eventsCalendar3
	value = escape(val);
	window.location.href = '/events.php?month='+value;
}

function couponView(id) {
	url = '../coupons.php?a=print&id=' + id;
	name = '_blank';
	window.open(url,name,'width=550,height=250,resizable=0,toolbar=0,status=0,menubar=1,location=0');
}

function fbs_click(u) {
	u = (u==null) ? location.href : u;
	t = document.title;
	window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');
	return false;
}

function emailLink(user,domain) {
	document.write("<a href=\"mailto:" + user + "@" + domain + "\">Email Me</a>");
}