/* AJAX FUNCTIONALITY - ESSENTIAL */

	var xmlHttp
	function GetXmlHttpObject() { 
		var objXMLHttp=null
		if (window.XMLHttpRequest)
		{
			objXMLHttp=new XMLHttpRequest()
		}
		else if (window.ActiveXObject)
		{
			objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
		}
		return objXMLHttp
	}

/* MINI-CALENDAR FUNCTIONS */

// Display Mini-Calendar
	function showMiniCal() { document.getElementById('minical').style.display = ''; }
// Hide Mini-Calendar
	function hideMiniCal() { document.getElementById('minical').style.display = 'none'; }
	
	
// Change Month
	function changeMonth(str) { 
		xmlHttp=GetXmlHttpObject()
		if (xmlHttp==null) {
			alert ("Browser does not support HTTP Request")
			return
		} 
		var url = 'minical.inc.php?monthOffset=' + str;
		xmlHttp.onreadystatechange=changeMonthDisplay;
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
	}
// Display Function for Change Month
	function changeMonthDisplay()  { 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") { 
			document.getElementById('minical').innerHTML=xmlHttp.responseText; 
		} 
	} 
// CLICKING ON THE MINI CALENDAR
	function selectDate(month, date, year) {
		var monthNames = new Array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
		var str = monthNames[month - 1] + ' ' + date + ', ' + year;
		var shadow = document.getElementById('minical_parent_shadow');
		shadow.innerHTML = str;
		str = year + '-';
		if (month < 10) { str += '0'; }
		str += month + '-';
		if (date < 10) { str += '0'; }
		str += date;
		var parent = document.getElementById('minical_parent');
		parent.value = str;
		hideMiniCal();
	}
// Updating the form with the proper event time
	function update_cal_time(theForm) {
		var parent = document.getElementById('minical_parent');
		theForm.event_time=parent.value+' '+theForm.event_hour;
		return true;
	}

/* MINIMIZE ELEMENTS -- UNDER DEVELOPMENT */
	function toggleElement(element) { 
		xmlHttp=GetXmlHttpObject()
		if (xmlHttp==null)
		{
			alert ("Browser does not support HTTP Request")
			return
		} 
		var url = 'toggle.inc.php?element=' + element;
		if(element=="notepad") { toggle = "toggleNotepad"; }
		if(element=="todolist") { toggle = "toggleTodolist"; }
		if(element=="calendar") { toggle = "toggleCalendar"; }	
		xmlHttp.onreadystatechange=toggle;
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
	}
	function toggleChanged() {
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {   
		 	new Effect.Highlight('nu_link_container', {startcolor:'#ffffff', endcolor:'#8733A3', duration:0.4})
		 	document.getElementById('nu_link_container').innerHTML=xmlHttp.responseText;
		} 
	} 
	function toggleNotepad() {	
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
	 		new Effect.toggle('notepad', 'blind', {duration: 0.6}) 
		} 
	}
	function toggleTodolist() { 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
			new Effect.toggle('todolist_mini', 'blind', {duration: 0.6}) 
		}
	}
	function toggleCalendar() { 
		new Effect.toggle('nu_link_container', 'blind', {duration: 0.6}) 
	}
	function stateChanged() { 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
		{   
		 	new Effect.Highlight('nu_link_container', {startcolor:'#ffffff', endcolor:'#8733A3', duration:0.4})
		 	document.getElementById('nu_link_container').innerHTML=xmlHttp.responseText;
		} 
	} 



/* CLEAR DEFAULT TEXT IN INPUT BOXES */
	function clickclear(thisfield, defaulttext) {
		if (thisfield.value == defaulttext) {
		thisfield.value = "";
		}
	}
	
	function clickrecall(thisfield, defaulttext) {
		if (thisfield.value == "") {
		thisfield.value = defaulttext;
		}
	}	
	
	
/* PNG LINKS */
	function linkTitleOn(input) {
		if(input == "webmail") { document.getElementById('linkTitle').innerHTML = "Webmail"; }
		if(input == "blackboard") { document.getElementById('linkTitle').innerHTML = "Blackboard"; }
		if(input == "u") { document.getElementById('linkTitle').innerHTML = "U.Northwestern"; }
		if(input == "post") { document.getElementById('linkTitle').innerHTML = "Post an Event"; }
	}

	function linkTitleOff() {
		document.getElementById('linkTitle').innerHTML = "&nbsp;"; 
	}
	
	/* PERSONAL LINKS */

// New Personal Link
	function newPersonalLink() { 
		xmlHttp=GetXmlHttpObject()
		if (xmlHttp==null) {
			alert ("Browser does not support HTTP Request")
			return
		} 
		xmlHttp.onreadystatechange=updatePersonalLinksFrame;
		xmlHttp.open("POST","personal_links_edit.inc.php",true);		
		xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		xmlHttp.send('personal_new=yes');
	}
// Edit Personal Links
	function editPersonalLink(input,id) { 
		xmlHttp=GetXmlHttpObject()
		if (xmlHttp==null) {
			alert ("Browser does not support HTTP Request")
			return
		} 
		if(input=="title") { var name = "personal_links_title[" + id + "]"; }
		if(input=="url") { var name = "personal_links_url[" + id + "]"; }
		var variables = "id=" + id + "&input=" + input + "&value=" + document.getElementById(name).value;
		
		xmlHttp.onreadystatechange=updatePersonalLinks;
		xmlHttp.open("POST","personal_links.inc.php",true);		
		xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		xmlHttp.send(variables);
	}
// Delete a Personal Link
	function deletePersonalLink(id) { 
		xmlHttp=GetXmlHttpObject()
		if (xmlHttp==null) {
			alert ("Browser does not support HTTP Request")
			return
		} 
		var variables = "personal_delete=yes&id=" + id;
		xmlHttp.onreadystatechange=updatePersonalLinksFrame;
		xmlHttp.open("POST","personal_links_edit.inc.php",true);		
		xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		xmlHttp.send(variables);
	}
// Display Function for Personal Links
	function updatePersonalLinksFrame() { 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
		 	document.getElementById('personal_links_frame').innerHTML=xmlHttp.responseText;
		} else { 
			document.getElementById('personal_links_close').innerHTML="<img src='images/loading.gif'>"; 
		}
			
	}
// Display Function for Personal Links (Links Only)
	function updatePersonalLinks() { 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
		 	document.getElementById('personal_links').innerHTML=xmlHttp.responseText;
		}
	}



/* CALENDAR FUNCTIONS: MAIN CALENDAR */

// Change Calendar Day
	function changeDay(str) { 
		xmlHttp=GetXmlHttpObject()
		if (xmlHttp==null) {
			alert ("Browser does not support HTTP Request")
			return
		} 
		var url = 'calendar.inc.php?day=' + str;
		xmlHttp.onreadystatechange=changeDayDisplay;
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
	}
// Display Function for Change Calendar Day 
	function changeDayDisplay() { 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {   
		 	new Effect.Highlight('nu_link_container', {startcolor:'#ffffff', endcolor:'#8733A3', duration:0.4})
		 	document.getElementById('nu_link_container').innerHTML=xmlHttp.responseText;
		} 
	} 




// Set Text-Message Reminder
	function setReminder(num,str) { 
		xmlHttp=GetXmlHttpObject()
		if (xmlHttp==null)
		{
			alert ("Browser does not support HTTP Request")
			return
		} 	
		var url="eventreminder.inc.php"
		url=url+"?id="+str+"&on="+num;
		url=url+"&sid="+Math.random()
		xmlHttp.onreadystatechange=setReminderDisplay
		xmlHttp.open("GET",url,true)
		xmlHttp.send(null)
	}
// Display Function for Text-Message Reminder
	function setReminderDisplay() { 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
	 	 	new Effect.Highlight('set_reminder', {startcolor:'#ffffff', endcolor:'#8733A3', duration:0.4});
		 	document.getElementById('set_reminder').innerHTML=xmlHttp.responseText;
		 	document.getElementById('waiting').innerHTML="<a href=\"javascript:Effect.toggle('event_detail', 'blind', {duration: 0.6})\"><img src='images/close.gif' border=0></a>";
		} else { 
			document.getElementById('waiting').innerHTML="<img src='indicator.white.gif'>"; 
		}
	} 


/* CALENDAR FUNCTIONS: SUBSCRIPTIONS */

// Show the Subscriptions Window
	function showSubscriptions() {
		xmlHttp=GetXmlHttpObject()
		if (xmlHttp==null) {
			alert ("Browser does not support HTTP Request")
			return
		} 
		xmlHttp.onreadystatechange=showSubscriptionsDisplay;
		xmlHttp.open("POST","subscribe.inc.php",true);		
		xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		xmlHttp.send(null);
	}
// Display Function for Showing the Subscriptions Window
	function showSubscriptionsDisplay() { 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
		 	if (document.getElementById('subscriptions').style.display=="none") { new Effect.BlindDown('subscriptions', {duration:0.6}) }
		 	else { new Effect.Highlight('subscriptions', {startcolor:'#ffffff', endcolor:'#8733A3', duration:0.4}) }
		 	document.getElementById('subscriptions_content').innerHTML=xmlHttp.responseText;
		 	document.getElementById('waiting2').innerHTML="<a href=\"javascript:Effect.toggle('subscriptions', 'blind', {duration: 0.6})\"><img src='images/close.gif' border=0></a>";
			showSubscriptionCategory(0, 0);
		} else { 
			document.getElementById('waiting2').innerHTML="<img src='indicator.white.gif'>"; 
		}
	} 
// Change the category being displayed
	function showSubscriptionCategory(n, total) {
		for (var i = 0; i < total; i++) {
			document.getElementById(String('subscription' + i)).style.display = 'none';
		}
		document.getElementById(String('subscription' + n)).style.display = 'inline';
	}
// Change the Subscriptions
	function changeSubscription(chkbox_obj) {
		xmlHttp=GetXmlHttpObject()
		if (xmlHttp==null) {
			alert ("Browser does not support HTTP Request")
			return
		}
		xmlHttp.onreadystatechange=changeSubscriptionDisplay;
		xmlHttp.open("POST","subscribe.inc.php",true);		
		xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		xmlHttp.send('id=' + chkbox_obj.value + '&action=toggle');
	}
// Display Function for Changing Subscriptions
	function changeSubscriptionDisplay() { 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
		 	document.getElementById('waiting2').innerHTML="<a href=\"javascript:Effect.toggle('subscriptions', 'blind', {duration: 0.6})\"><img src='images/close.gif' border=0></a>";
		 	changeDay(0);
		} else { 
			document.getElementById('waiting2').innerHTML="<img src='indicator.white.gif'>"; 
		}
	}


/* CALENDAR FUNCTIONS: HIGHLIGHTING */

// Select a Group to Highlight
	function showHighlight(str) {
		xmlHttp=GetXmlHttpObject()
		if (xmlHttp==null) {
			alert ("Browser does not support HTTP Request")
			return
		} 
		xmlHttp.onreadystatechange=showHighlightDisplay;
		xmlHttp.open("POST","highlight.inc.php",true);		
		xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		if (arguments.length > 0) {
			xmlHttp.send('action=show&group=' + str);
		} else {
			xmlHttp.send(null);
		}
	}
// Display Function for Selection of Group
	function showHighlightDisplay() { 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {   
		 	if (document.getElementById('highlight').style.display=="none") { new Effect.BlindDown('highlight', {duration:0.6}) }
		 	else { new Effect.Highlight('highlight', {startcolor:'#ffffff', endcolor:'#8733A3', duration:0.4}) }
		 	document.getElementById('highlight_content').innerHTML=xmlHttp.responseText;
		 	document.getElementById('waiting3').innerHTML="<a href=\"javascript:Effect.toggle('highlight', 'blind', {duration: 0.6})\"><img src='images/close.gif' border=0></a>";
		} 
		else { document.getElementById('waiting3').innerHTML="<img src='indicator.white.gif'>"; }
	} 
// Update DB with Highlight Color for Group
	function highlightText(str,col) {
		xmlHttp=GetXmlHttpObject()
		if (xmlHttp==null) {
			alert ("Browser does not support HTTP Request")
			return
		} 
		xmlHttp.onreadystatechange=highlightTextDisplay;
		xmlHttp.open("POST","highlight.inc.php",true);		
		xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		xmlHttp.send('action=submit&group=' + str + '&color=' + col);
	}
// Display Function for Update of DB
	function highlightTextDisplay() { 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {   
		 	if (document.getElementById('highlight').style.display=="none") { new Effect.BlindDown('highlight', {duration:0.6}) }
		 	else { new Effect.Highlight('highlight', {startcolor:'#ffffff', endcolor:'#8733A3', duration:0.4}) }
		 	document.getElementById('highlight_content').innerHTML=xmlHttp.responseText;
		 	document.getElementById('waiting3').innerHTML="<a href=\"javascript:Effect.toggle('highlight', 'blind', {duration: 0.6})\"><img src='images/close.gif' border=0></a>";
		 	changeDay(0);
		} else { 
			document.getElementById('waiting3').innerHTML="<img src='indicator.white.gif'>"; 
		}
	} 



/* TABBED LINKS */

// HereAndNow Links
	last_link = 'links_1';
	last_linkl = 'links_left_1';
	last_linkr = 'links_right_1';
	
	function showlinks(layerName) {
		document.getElementById(layerName).style.display = '';
	}
	
	function hidelinks(layerName) {
		document.getElementById(layerName).style.display = 'none';
	}
	
	function links_next(tab_num) {
		tab_name = 'links_' + tab_num;
		document.getElementById(last_link).className = 'rss_tab';
		var currlink = document.getElementById(tab_name);
		currlink.className='rss_tab_hover';
		hidelinks(last_link+'_data');
		showlinks(tab_name+'_data');
		last_link=tab_name;
		
		tab_namel = 'links_left_' + tab_num;
		document.getElementById(last_linkl).className = 'rss_tab_left';
		var currlinkl = document.getElementById(tab_namel);
		currlinkl.className='rss_tab_left_on';
		last_linkl=tab_namel;
		
		tab_namer = 'links_right_' + tab_num;
		document.getElementById(last_linkr).className = 'rss_tab_right';
		var currlinkr = document.getElementById(tab_namer);
		currlinkr.className='rss_tab_right_on';
		last_linkr=tab_namer;
	}

// RSS Links
	last_tab = 'rss_1';
	last_tabl = 'tab_left_1';
	last_tabr = 'tab_right_1';
	
	function show(layerName) {
		document.getElementById(layerName).style.display = '';
	}
	
	function hide(layerName) {
		document.getElementById(layerName).style.display = 'none';
	}
	
	function show_next(tab_num) {
		tab_name = 'rss_' + tab_num;
		document.getElementById(last_tab).className = 'rss_tab';
		var curr = document.getElementById(tab_name);
		curr.className='rss_tab_hover';
		hide(last_tab+'_data');
		show(tab_name+'_data');
		last_tab=tab_name;
		
		tab_namel = 'tab_left_' + tab_num;
		document.getElementById(last_tabl).className = 'rss_tab_left';
		var currl = document.getElementById(tab_namel);
		currl.className='rss_tab_left_on';
		last_tabl=tab_namel;
		
		tab_namer = 'tab_right_' + tab_num;
		document.getElementById(last_tabr).className = 'rss_tab_right';
		var currr = document.getElementById(tab_namer);
		currr.className='rss_tab_right_on';
		last_tabr=tab_namer;
	}


	function updateRSS() { 
		xmlHttp=GetXmlHttpObject()
		xmlHttp.onreadystatechange=rssContentUpdate;
		xmlHttp.open("POST","rss_content.inc.php",true);
		xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		xmlHttp.send("var=asdf");	
	}
	
	function rssContentUpdate() {
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {   
		 	document.getElementById('rssfeedcontent').innerHTML=xmlHttp.responseText;
		}
	}


/* NOTEPAD FUNCTIONS */

// Update the Notepad
	function updateNotepad(str) { 
		xmlHttp=GetXmlHttpObject()
		if (xmlHttp==null) {
			alert ("Browser does not support HTTP Request")
			return
		} 
		var new_content = "";
		var content = document.getElementById(str);
		for (var i=0;i<content.length-1;i++) { var new_content = new_content + content.elements[i].name + '=' + escape(content.elements[i].value) + '&'; }
		var new_content = new_content + 'a=1';
		xmlHttp.onreadystatechange=updateNotepadDisplay;
		xmlHttp.open("POST","notepad.inc.php",true);		
		xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		xmlHttp.send(new_content);
	}

// Display Function for Updating Notepad
	function updateNotepadDisplay() { 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {     
	 	 	new Effect.Highlight('notepad_saved', {startcolor:'#ffffff', endcolor:'#8733A3', duration:0.4});
		 	document.getElementById('notepad_saved').innerHTML=xmlHttp.responseText;
		} 
	} 



/* MINI TO-DO LIST FUNCTIONS */

// Add New Item
	function addToDoMini(str) { 
		xmlHttp=GetXmlHttpObject()
		if (xmlHttp==null) {
			alert ("Browser does not support HTTP Request")
			return
		} 
		var new_content = "";
		var content = document.getElementById(str);
		for (var i=0;i<content.length-1;i++) { var new_content = new_content + content.elements[i].name + '=' + escape(content.elements[i].value) + '&'; }
		var new_content = new_content + 'a=1';
	
		xmlHttp.onreadystatechange=todolistminiUpdated;
		xmlHttp.open("POST","todolist_mini.inc.php",true);		
		xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		xmlHttp.send(new_content);
	}
// Complete an Item
	function finishToDoMini(str) { 
		xmlHttp=GetXmlHttpObject()
		if (xmlHttp==null) {
			alert ("Browser does not support HTTP Request")
			return
		} 
		var new_content = 'finish=' + str;
	
		xmlHttp.onreadystatechange=todolistminiUpdated;
		xmlHttp.open("POST","todolist_mini.inc.php",true);		
		xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		xmlHttp.send(new_content);
	}
// Display Function for Mini To-Do List
	function todolistminiUpdated() { 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {
		 	document.getElementById('todo_mini_div').innerHTML=xmlHttp.responseText;
		 	document.getElementById('todo_input').focus();
		}
	}


// RSS FEED LOADING


	function addPoll(str) { 
		xmlHttp=GetXmlHttpObject()
		if (xmlHttp==null){alert("Browser does not support HTTP Request");return} 
		var new_content = "";
		var content = document.getElementById(str);
		for (var i=0;i<content.length-1;i++) { var new_content = new_content + content.elements[i].name + '=' + escape(content.elements[i].value) + '&'; }
		var new_content = new_content + 'a=1';
		xmlHttp.onreadystatechange=addPollDisplay;
		xmlHttp.open("POST","committee/addpoll.inc.php",true);		
		xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		xmlHttp.send(new_content);
	}
	function addPollDisplay() { 
		if (xmlHttp.readyState==4 && xmlHttp.status==200) {   
		 	document.getElementById('areaPoll').innerHTML=xmlHttp.responseText;
		} 
	} 

	function addPoll2(str) { 
		xmlHttp=GetXmlHttpObject()
		if (xmlHttp==null){alert("Browser does not support HTTP Request");return} 
		var new_content = "";
		var content = document.getElementById(str);
		for (var i=0;i<content.length-1;i++) { var new_content = new_content + content.elements[i].name + '=' + escape(content.elements[i].value) + '&'; }
		var new_content = new_content + 'a=1';
		xmlHttp.onreadystatechange=addPollDisplay2;
		xmlHttp.open("POST","committee/addpoll2.inc.php",true);		
		xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		xmlHttp.send(new_content);
	}
	function addPollDisplay2() { 
		if (xmlHttp.readyState==4 && xmlHttp.status==200) {   
		 	document.getElementById('areaPoll2').innerHTML=xmlHttp.responseText;
		} 
	} 



		/****************************************/
/* JUSTIN'S FUNCTIONS (TOUCH AND DIE!)  */
/****************************************/

// SHOW WHATEVER EVENT.INC.PHP OUTPUTS
function eventInfoDisplay() {
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {   
	 	if (document.getElementById('event_detail').style.display=="none") { new Effect.BlindDown('event_detail', {duration:0.6}) }
	 	else { new Effect.Highlight('event_detail', {startcolor:'#ffffff', endcolor:'#8733A3', duration:0.4}) }
	 	document.getElementById('event_detail_content').innerHTML=xmlHttp.responseText;
		if (xmlHttp.responseText == '<b>Your calendar has been updated.</b>') {
			changeDay(0);
		}
	 	document.getElementById('waiting').innerHTML="<a href=\"javascript:Effect.toggle('event_detail', 'blind', {duration: 0.6})\"><img src='images/close.gif' border=0></a>";
	}
	else { document.getElementById('waiting').innerHTML="<img src='indicator.white.gif'>"; }
}

// SHOW ADD PUBLIC EVENT FORM
function showAddPublicEvent() {
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	}
	xmlHttp.onreadystatechange=eventInfoDisplay;
	xmlHttp.open("POST","event.inc.php",true);
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttp.send("action=public");
}

// SHOW ADD PRIVATE EVENT FORM
function showAddPrivateEvent() {
	xmlHttp=GetXmlHttpObject();
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	} 
	xmlHttp.onreadystatechange=eventInfoDisplay;
	xmlHttp.open("POST","event.inc.php",true);
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttp.send("action=private");
}

// SHOW EDIT EVENT FORM
function showEditEvent(str) {
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	}
	xmlHttp.onreadystatechange=eventInfoDisplay;
	xmlHttp.open("POST","event.inc.php",true);
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttp.send("action=edit&id=" + str);
}

// SHOW EVENT INFO
function eventInfo(str) {
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	}
	xmlHttp.onreadystatechange=eventInfoDisplay;
	xmlHttp.open("POST","event.inc.php",true);
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttp.send("action=view&id=" + str);
}

// DELETE EVENTS
function eventDelete(str) { 
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	}
	xmlHttp.onreadystatechange=eventInfoDisplay;
	xmlHttp.open("POST","event.inc.php",true);
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttp.send("action=delete&id=" + str);
}



// ADD A NEW PERSONAL LABEL AND RELOAD THE PAGE
function toggleNewLabel(hide) {
	var element = document.getElementById('newLabelTextbox');
	if (hide == 1) {
		element.style.display = 'inline';
	} else {
		element.style.display = 'none';
	}
}

// SHOW COSPONSORS DROPDOWN
function toggleCosponsors() {
	var cosponsors = document.getElementById('cosponsors_dropdown')
	if (cosponsors.style.display == 'none') {
		cosponsors.style.display = 'inline';
	} else {
		cosponsors.style.display = 'none';
	}
}

// AJAXIFIED EVENT FORM HANDLER
function processEventForm(str) {
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	}
	var new_content = "";
	var content = document.getElementById(str);
	for (var i=0;i<content.length-1;i++)
	{
		var new_content = new_content + content.elements[i].name + '=' + escape(content.elements[i].value) + '&';
	}
	xmlHttp.onreadystatechange=eventInfoDisplay;
	xmlHttp.open("POST","event.inc.php",true);		
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttp.send(new_content);
}

/****************************************/
/* END JUSTIN'S FUNCTIONS               */
/****************************************/

// New Label
function addLabel() { 
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null) {
		alert ("Browser does not support HTTP Request")
		return
	} 
	var label = document.getElementById('select_label_input').options[document.getElementById('select_label_input').selectedIndex].value;
	if(label=="new_label") {
		xmlHttp.onreadystatechange=addLabelDisplay;
		xmlHttp.open("POST","label.inc.php",true);		
		xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		xmlHttp.send('label=new_label');
	}	
}

function addLabelDisplay() { 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {     
 		document.getElementById('select_label').innerHTML=xmlHttp.responseText;
	}
} 
/* CALENDAR FUNCTIONS: MAIN CALENDAR */

// Change Calendar Day
	function changeDayNULL(str) { 
		xmlHttp=GetXmlHttpObject()
		if (xmlHttp==null) {
			alert ("Browser does not support HTTP Request")
			return
		} 
		var url = 'calendar.null.inc.php?day=' + str;
		xmlHttp.onreadystatechange=changeDayDisplay;
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
	}



	function displayEventsNULL(str) {
		xmlHttp=GetXmlHttpObject()
		if (xmlHttp==null) {
			alert ("Browser does not support HTTP Request")
			return
		} 
		var url = 'calendar.null.inc.php?showpop=' + str;
		if(str=="yes") { xmlHttp.onreadystatechange=changePopDisplayYes; }
		else { xmlHttp.onreadystatechange=changePopDisplayNo; }
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
	}		

	function changePopDisplayYes() { 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {   
		 	new Effect.Highlight('nu_link_container', {startcolor:'#ffffff', endcolor:'#8733A3', duration:0.4})
		 	document.getElementById('nu_link_container').innerHTML=xmlHttp.responseText;
		 	document.getElementById('displayPopEventsYes').style.color="#000000";
		 	document.getElementById('displayPopEventsNo').style.color="#707070";
		} 
	} 
	
	function changePopDisplayNo() { 
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {   
		 	new Effect.Highlight('nu_link_container', {startcolor:'#ffffff', endcolor:'#8733A3', duration:0.4})
		 	document.getElementById('nu_link_container').innerHTML=xmlHttp.responseText;
		 	document.getElementById('displayPopEventsYes').style.color="#707070";
		 	document.getElementById('displayPopEventsNo').style.color="#000000";
		} 
	} 



// SHOW EVENT INFO
function eventInfoNULL(str) {
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request")
		return
	}
	xmlHttp.onreadystatechange=eventInfoDisplayNULL;
	xmlHttp.open("POST","event.null.inc.php",true);
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttp.send("action=view&id=" + str);
}

function eventInfoDisplayNULL() {
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {   
	 	if (document.getElementById('event_detail').style.display=="none") { new Effect.BlindDown('event_detail', {duration:0.6}) }
	 	else { new Effect.Highlight('event_detail', {startcolor:'#ffffff', endcolor:'#8733A3', duration:0.4}) }
	 	document.getElementById('event_detail_content').innerHTML=xmlHttp.responseText;
	 	document.getElementById('waiting').innerHTML="<a href=\"javascript:Effect.toggle('event_detail', 'blind', {duration: 0.6})\"><img src='images/close.gif' border=0></a>";
	}
	else { document.getElementById('waiting').innerHTML="<img src='indicator.white.gif'>"; }
}



var string="stupid"

var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "Firefox"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "Explorer",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "Mozilla",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
BrowserDetect.init();	function updateRSS() { 
		xmlHttp=GetXmlHttpObject()
		xmlHttp.onreadystatechange=rssContentUpdate;
		xmlHttp.open("POST","rss_content.inc.php",true);
		xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		xmlHttp.send("var=now");	
	}
	
	function rssContentUpdate() {
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") {   
		 	document.getElementById('rssfeedcontent').innerHTML=xmlHttp.responseText;
		}
	}
	
	function loadtime(time,browser,ip) { 
		xmlHttp=GetXmlHttpObject()
		xmlHttp.open("POST","loadtime.inc.php",true);
		xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		xmlHttp.send("time=" + time + "&browser=" + browser + "&ip=" + ip);	
	}

	var browser=navigator.appName
	var version=parseFloat(navigator.appVersion)
	var browsername = BrowserDetect.browser;
	var ipaddress = '38.103.63.18';
	
	if(BrowserDetect.browser == "Opera") {
		if(BrowserDetect.version < 9.1) {
			alert("Warning: NU Link currently only supports Opera version 9.1 or higher. You may encounter some display issues.")
		}
	}
	
	
	function goToURL() { //v3.0
  		var i, args=goToURL.arguments; document.returnValue = false;
  		for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
	}
