// JavaScript Document

d = document;
		var script = document.createElement('script');
		script.type = 'text/javascript';
		script.src = '/add_ons/reminders/generators/md5.js';
		document.getElementsByTagName('head')[0].appendChild(script); 
		
		var user_id;
		 
		function reminders(id) {
		var xmlHTTP;
		
				//alert (d.getElementById('pop_up_table').firstChild.firstChild.nextSibling);
		tableCell = d.getElementById('pop_up_table').firstChild.firstChild.nextSibling;
		tableCell.style.backgroundColor="#fff";
		tableCell.style.border="1px solid #000";
		tableCell.style.borderBottomWidth="0";
		a = d.createElement('a');
		a.href = 'javascript:closePopUp2()';
		a.innerHTML = '[x] close';
		a.className = 'smallRed';
		tableCell.appendChild(a);
		
		h1 = d.createElement('h1');
		h1.innerHTML = 'Remind Me of This Event';
		tableCell.appendChild(h1);
		if (!user_id) {
		

		var p = d.createElement('p');
		p.id="txt_to_change";
		p.innerHTML = "You must be logged in to use this feature.";
		tableCell.appendChild(p);

		var f = document.createElement("form");
		tableCell.appendChild(f);
		f.id="quick_login";
		var event_id = document.createElement("input");
		event_id.type="hidden";
		event_id.id="event_id";
		event_id.value=id;
		f.appendChild(event_id);
		var user = document.createElement("input");
		var pass = document.createElement("input");
		user.name = "user";
		pass.name ="pass";
		pass.type="password";
		user.id="user";
		pass.id="pass";
		
		var t = document.createElement("table");
		tr = document.createElement("tr");
		td = document.createElement("td");
		td.innerHTML="Email Address:";
		tr.appendChild(td);
		td = document.createElement("td");
		td.appendChild(user);
		tr.appendChild(td);
		t.appendChild(tr);
		tr = document.createElement("tr");
		td = document.createElement("td");
		td.innerHTML="Password:";
		tr.appendChild(td);
		td = document.createElement("td");
		td.appendChild(pass);
		tr.appendChild(td);
		t.appendChild(tr);	
		f.appendChild(t);
		
		var sub = document.createElement("a");
		sub.innerHTML="Login";
		sub.href = 'javascript:submitLoginForm()';
		f.appendChild(sub);
		}
		else {
		var f = document.createElement("form");

		// Add it to the document body
		tableCell.appendChild(f);

		// Add action and method attributes
		//f.action = "javascript:submitReminderForm";
		//f.method = "POST"
		f.name="reminder_form";
		f.id="reminder_form";
		var s = document.createElement("select");
		s.id="days_before";
		var o = document.createElement("option");
		o.value=1;
		o.innerHTML ="1 Day Before";
		s.appendChild(o);
				var o = document.createElement("option");
		o.value=2;
		o.innerHTML="2 Days Before";
		s.appendChild(o);
				var o = document.createElement("option");
		o.value=3;
		o.innerHTML="3 Days Before";
		s.appendChild(o);
				var o = document.createElement("option");
		o.value=4;
		o.innerHTML="4 Days Before";
		s.appendChild(o);
				var o = document.createElement("option");
		o.value=5;
		o.innerHTML="5 Days Before";
		s.appendChild(o);
				var o = document.createElement("option");
		o.value=6;
		o.innerHTML="6 Days Before";
		s.appendChild(o);
				var o = document.createElement("option");
		o.value=7;
		o.innerHTML="7 Days Before";
		s.appendChild(o);
		 
		f.appendChild(s);
		var i = document.createElement("input");
		i.type ="hidden";
		i.value=id;
		i.id="event_id";
		i.name="event_id";
		f.appendChild(i);
		var sub = document.createElement("a");
		sub.innerHTML="Remind Me";
		sub.href = 'javascript:submitReminderForm()';
		f.appendChild(sub);
		}
		}
		
		function closePopUp2() {
			
			div = d.getElementById('pop_up_table').firstChild.firstChild.nextSibling;
			div.borderStyle='none';
			while (y = div.firstChild)
			{
				div.removeChild(y);
			}
		}
		function submitReminderForm()
		{
			var event_id = d.getElementById('event_id').value;
			//var user_id = d.getElementById('user_id').value;
			var days_before = d.getElementById('days_before').value;
			xmlHttp=GetXmlHttpObject()
			if (xmlHttp==null)
			 {
			 alert ("Browser does not support HTTP Request")
			 return
			 } 
			var url = "/add_ons/reminders/generators/reminder_ajax.php";
			url=url+"?event_id="+event_id;
			url=url+"&days_before="+days_before;
			url=url+"&sid="+Math.random()
			xmlHttp.onreadystatechange=reminderStateChanged 
			xmlHttp.open("GET",url,true)
			xmlHttp.send(null)
		
		
		}
		function submitLoginForm()
		{
			var user = d.getElementById('user').value;
			var pass= hex_md5(d.getElementById('pass').value);
			
			
			xmlHttp=GetXmlHttpObject()
			if (xmlHttp==null)
			 {
			 alert ("Browser does not support HTTP Request")
			 return
			 } 
			var url = "/add_ons/reminders/generators/login_ajax.php";
			url=url+"?user="+user;
			url=url+"&pass="+pass;
			url=url+"&sid="+Math.random()
			xmlHttp.onreadystatechange=stateChanged 
			xmlHttp.open("GET",url,true)
			xmlHttp.send(null)
		
		}
		function reminderStateChanged() 
			{ 
			if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
			 { 
					xmlDoc=xmlHttp.responseXML;
					var feedback = xmlDoc.getElementsByTagName("feedback")[0].childNodes[0].nodeValue;
					var f =d.getElementById('reminder_form');
					var c = f.parentNode;
					c.removeChild(f);
					c.innerHTML=feedback;
			 } 
			}
		
			function stateChanged() 
			{ 
			if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
			 { 
					event_id = d.getElementById('event_id').value;
					xmlDoc=xmlHttp.responseXML;
					
					if (xmlDoc.getElementsByTagName("login_result")[0].childNodes[0].nodeValue =='1')
					{
						closePopUp2();
						user_id= xmlDoc.getElementsByTagName("user_id")[0].childNodes[0].nodeValue;
						reminders(event_id);
					}
					else
						d.getElementById('txt_to_change').innerHTML = xmlDoc.getElementsByTagName("login_error")[0].childNodes[0].nodeValue;

			 } 
			}
			
			function GetXmlHttpObject()
			{
			var xmlHttp=null;
			try
			 {
			 // Firefox, Opera 8.0+, Safari
			 xmlHttp=new XMLHttpRequest();
			 }
			catch (e)
			 {
			 // Internet Explorer
			 try
			  {
			  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
			  }
			 catch (e)
			  {
			  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			  }
			 }
			return xmlHttp;
			}
		
		var xmlHTTP;
		var user_id;
		var rating_image;
		

		
		 
		function mouseover()
		{
		 var stardiv = document.getElementById('current_rating'); 
		 stardiv.style.backgroundImage='none';
		}
		function mouseout()
		{
			var stardiv = document.getElementById('current_rating'); 
			stardiv.style.backgroundImage="url("+rating_image+")";
			starout();
		}
		function starover(id)
		{
			var stardiv = document.getElementById('star' + id); 
			
			var k;
			for (k=1; k <= 5; k++)
			{
				var stardiv = document.getElementById('star' +k); 
				stardiv.style.backgroundImage='url(/add_ons/ratings/images/star.jpg)';
				if (k <= id)

					stardiv.className='filledStar';
				else
					stardiv.className='emptyStar';

			}


			
		}
		function starout()
		{
		
			var id;
			for (id =1; id <=5; id++)
			{ 
				var stardiv = document.getElementById('star' +id); 
				stardiv.style.backgroundImage='none';
			}
		}
		
		function display_rating(event_id)
		{
	
		tableCell = d.getElementById('middle_middle');
		var browser=navigator.appName;
		if (browser != "Microsoft Internet Explorer")
		{
		var oLink = document.createElement("link")
		oLink.href = "add_ons/ratings/stars.css";
		oLink.rel = "stylesheet";
		oLink.type = "text/css";
		document.body.appendChild(oLink);
		}
			var bigdiv = d.createElement('div');
			bigdiv.style.clear='both';
			var a=d.createElement('div');
			a.className='nonHover';
			a.innerHTML='Event Rating: ';
			a.style.cssFloat='left';
			a.style.clear='both';
			div = d.createElement('div');
			div.id='current_rating';
			div.style.cssFloat='left';
			div.className='nonHover';
			div.onmouseover=mouseover;
			div.onmouseout=mouseout;
						var ldiv = d.createElement('div');
			ldiv.id='star1';
			ldiv.style.cssFloat='left';
			ldiv.style.width='15px';
			ldiv.style.height='11px';
			ldiv.className='nonHover';
			ldiv.onmouseover= function (e1)
			{ 
				starover('1'); 
			}
			
			ldiv.onclick = function (v1)
			{
				vote(event_id, '1');
			}
			div.appendChild(ldiv);
			
			
						var ldiv = d.createElement('div');
			ldiv.id='star2';
			ldiv.style.cssFloat='left';
			ldiv.style.width='15px';
			ldiv.style.height='11px';
			ldiv.className='nonHover';
			ldiv.onmouseover= function (e2)
			{ 
				starover('2'); 
			}
			
			ldiv.onclick = function (v2)
			{
				vote(event_id, '2');
			}
			div.appendChild(ldiv);
			
			
						var ldiv = d.createElement('div');
			ldiv.id='star3';
			ldiv.style.cssFloat='left';
			ldiv.style.width='15px';
			ldiv.style.height='11px';
			ldiv.className='nonHover';
			ldiv.onmouseover= function (e3)
			{ 
				starover('3'); 
			}
			
			ldiv.onclick = function (v3)
			{
				vote(event_id, '3');
			}
			div.appendChild(ldiv);
			
			
						var ldiv = d.createElement('div');
			ldiv.id='star4';
			ldiv.style.cssFloat='left';
			ldiv.style.width='15px';
			ldiv.style.height='11px';
			ldiv.className='nonHover';
			ldiv.onmouseover= function (e4)
			{ 
				starover('4'); 
			}
			
			ldiv.onclick = function (v4)
			{
				vote(event_id, '4');
			}
			div.appendChild(ldiv);
			
			
						var ldiv = d.createElement('div');
			ldiv.id='star5';
			ldiv.style.cssFloat='left';
			ldiv.style.width='15px';
			ldiv.style.height='11px';
			ldiv.className='nonHover';
			ldiv.onmouseover= function (e5)
			{ 
				starover('5'); 
			}
			
			ldiv.onclick = function (v5)
			{
				vote(event_id, '5');
			}
			div.appendChild(ldiv);
			
			
						
			var result_div = d.createElement('div');
			result_div.style.cssFloat='left';
			result_div.className='nonHover';
			result_div.id="vote_result";
			
			
			bigdiv.appendChild(a);
			bigdiv.appendChild(div);
			bigdiv.appendChild(result_div);
			var br = d.createElement('br');
			tableCell.appendChild(bigdiv);
			tableCell.appendChild(br);
		
			xmlHttp=ratingsGetXmlHttpObject()
			var url = "/add_ons/ratings/generators/ratings_ajax.php";
			url=url+"?event_id="+event_id;
			url=url+"&sid="+Math.random();
			xmlHttp.onreadystatechange=ratingsStateChanged;
			xmlHttp.open("GET",url,true);
			xmlHttp.send(null);			

		}
		
		function vote(event_id, rating) {
		
				//alert (d.getElementById('pop_up_table').firstChild.firstChild.nextSibling);

	
		if (!user_id) {
		var browser=navigator.appName;
		if (browser == "Microsoft Internet Explorer")
		{
			var t = d.getElementById('vote_result');
			t.innerHTML='<a href="/login" >You Must Be Logged in to use this Feature</a>';
		
		}
		else
		{
		
		tableCell = d.getElementById('pop_up_table').firstChild.firstChild.nextSibling;
		tableCell.style.backgroundColor="#fff";
		tableCell.style.border="1px solid #000";
		tableCell.style.borderBottomWidth="0";
		a = d.createElement('a');
		a.href = 'javascript:closeRatingsLoginPopup()';
		a.innerHTML = '[x] close';
		a.className = 'smallRed';
		tableCell.appendChild(a);
		h1 = d.createElement('h1');
		h1.innerHTML = 'Rate Event';
		tableCell.appendChild(h1)
		
		var p = d.createElement('p');
		p.id="txt_to_change";
		p.innerHTML = "You must be logged in to use this feature.";
		tableCell.appendChild(p);

		var f = document.createElement("form");
		tableCell.appendChild(f);
		f.id="quick_login";
		var event_id = document.createElement("input");
		event_id.type="hidden";
		event_id.id="event_id";
		event_id.value=event_id;
		f.appendChild(event_id);
		var user = document.createElement("input");
		var pass = document.createElement("input");
		user.name = "user";
		pass.name ="pass";
		pass.type="password";
		user.id="user";
		pass.id="pass";
		var t = document.createElement("table");
		tr = document.createElement("tr");
		td = document.createElement("td");
		td.innerHTML="Email Address:";
		tr.appendChild(td);
		td = document.createElement("td");
		td.appendChild(user);
		tr.appendChild(td);
		t.appendChild(tr);
		tr = document.createElement("tr");
		td = document.createElement("td");
		td.innerHTML="Password:";
		tr.appendChild(td);
		td = document.createElement("td");
		td.appendChild(pass);
		tr.appendChild(td);
		t.appendChild(tr);	
		f.appendChild(t);
		
		var sub = document.createElement("a");
		sub.innerHTML="Login";
		sub.href = 'javascript:submitRatingsLoginForm()';
		f.appendChild(sub);
		}
		}
		
		else {
		
			xmlHttp=ratingsGetXmlHttpObject()
			var url = "/add_ons/ratings/generators/ratings_ajax.php";
			url=url+"?rating="+rating;
			url = url+"&user_id="+user_id;
			url =url+"&event_id="+event_id;
			url=url+"&sid="+Math.random();
			xmlHttp.onreadystatechange=ratingsStateChanged;
			xmlHttp.open("GET",url,true);
			xmlHttp.send(null);			
		}
		}
		
		
		function closeRatingsLoginPopup() {
			
			div = d.getElementById('pop_up_table').firstChild.firstChild.nextSibling;
			div.borderStyle='none';
			while (y = div.firstChild)
			{
				div.removeChild(y);
			}
		}
		
		
		function submitRatingsLoginForm()
		{
			var user = d.getElementById('user').value;
			var pass= hex_md5(d.getElementById('pass').value);
			
			
			xmlHttp=GetXmlHttpObject()
			if (xmlHttp==null)
			 {
			 alert ("Browser does not support HTTP Request")
			 return
			 } 
			var url = "/add_ons/reminders/generators/login_ajax.php";
			url=url+"?user="+user;
			url=url+"&pass="+pass;
			url=url+"&sid="+Math.random()
			xmlHttp.onreadystatechange=ratingsLoginStateChanged 
			xmlHttp.open("GET",url,true)
			xmlHttp.send(null)
		
		}

		function ratingsStateChanged() 
			{ 
			if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
			 { 
					xmlDoc=xmlHttp.responseXML;
					var rating = xmlDoc.getElementsByTagName("rating")[0].childNodes[0].nodeValue;
					rating_image = xmlDoc.getElementsByTagName("image")[0].childNodes[0].nodeValue;
					
					var txt = xmlDoc.getElementsByTagName("vote_result")[0].childNodes[0].nodeValue;
					var t = d.getElementById('vote_result');
					t.innerHTML=txt;
					var r =d.getElementById('current_rating');
					r.style.backgroundImage="url("+rating_image+")";
					r.style.backgroundRepeat='no-repeat';
					r.style.width='75px';
					r.style.height='11px';
			 } 
			}
		
			function ratingsLoginStateChanged() 
			{ 
			if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
			 { 
					event_id = d.getElementById('event_id').value;
					xmlDoc=xmlHttp.responseXML;
					
					if (xmlDoc.getElementsByTagName("login_result")[0].childNodes[0].nodeValue =='1')
					{
						closePopUp2();
						user_id= xmlDoc.getElementsByTagName("user_id")[0].childNodes[0].nodeValue;
					}
					else
						d.getElementById('txt_to_change').innerHTML = xmlDoc.getElementsByTagName("login_error")[0].childNodes[0].nodeValue;

			 } 
			}
			
			function ratingsGetXmlHttpObject()
			{
			var xmlHttp=null;
			try
			 {
			 // Firefox, Opera 8.0+, Safari
			 xmlHttp=new XMLHttpRequest();
			 }
			catch (e)
			 {
			 // Internet Explorer
			 try
			  {
			  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
			  }
			 catch (e)
			  {
			  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			  }
			 }
			return xmlHttp;
			}
		

function uploadPhoto(feedback, dayValue, monthValue, yearValue) {
		
		
//		backgroundBlack();
		
		popup();
		
		disableDateDropDowns();
		
		tableCell = d.getElementById('middle_middle');
		
		a = d.createElement('a');
		a.href = 'javascript:closePopUp()';
		a.innerHTML = '[x] close';
		a.className = 'smallRed';
		
		tableCell.appendChild(a);
		
		h1 = d.createElement('h1');
		h1.innerHTML = 'Send Us Your Photo';

		tableCell.appendChild(h1);
		
		if (feedback != '') {

			p = d.createElement('p');
			p.innerHTML = feedback;
			p.style.color = 'red';
			p.style.fontWeight = 'bold';
			tableCell.appendChild(p);
			
		}
		
		form = d.createElement('form');
		form.name = 'upload';
		form.action = '/cgi-bin/upload.pl';
		form.method = 'POST';
		form.enctype = 'multipart/form-data';
		form.setAttribute('onSubmit', 'submitUploadPhoto()');
		form.setAttribute('enctype', 'multipart/form-data');
		
		p = d.createElement('p');
		p.innerHTML = 'You can send us any image in jpg, jpeg or gif file formats.  You can send us any size file.  Your image will automatically be resized for our calendar and for possible use on the air. ';
		form.appendChild(p);
		
		p = d.createElement('p');
		p.innerHTML = '<b>Upload your photo:</b> <br />';
		
		input = d.createElement('input');
		input.type = 'file';
		input.name = '1';
		
		p.appendChild(input);
		form.appendChild(p);
		
		p = d.createElement('p');
		p.innerHTML = '<b>Pick a date (mm/dd/yyyy):</b> <i>Optional</i> ';
		
		input = d.createElement('input');
		input.type = 'text';
		input.name = 'month';
		input.size = '2';
		
		p.appendChild(input);
		p.innerHTML += '/';
		
		input = d.createElement('input');
		input.type = 'text';
		input.name = 'day';
		input.size = '2';
		
		p.appendChild(input);
		p.innerHTML += '/';
		
		input = d.createElement('input');
		input.type = 'text';
		input.name = 'year';
		input.size = '4';
		
		p.appendChild(input);
		form.appendChild(p);
		
		p = d.createElement('p');
		p.innerHTML = '<b>Your Name:</b> ';
		
		input = d.createElement('input');
		input.type = 'text';
		input.name = 'name';
//		input.value = '';
		
		p.appendChild(input);
		form.appendChild(p);
		
		p = d.createElement('p');
		p.innerHTML = '<b>Your Email:</b> ';
		
		input = d.createElement('input');
		input.type = 'text';
		input.name = 'email';
		input.id = 'email_id';
		input.setAttribute('onblur', "javascript:validateEmail(this.value, '')"); 
//		input.value = '';
		
		p.appendChild(input);
		form.appendChild(p);
		
		p = d.createElement('p');
		p.innerHTML = '<b>Your Caption:</b> <i>Optional</i> ';
		
		input = d.createElement('input');
		input.type = 'text';
		input.name = 'caption';
		
		p.appendChild(input);
		form.appendChild(p);
		
		p = d.createElement('p');
		p.innerHTML = '<b>Photo Location:</b> <i>Optional</i> ';
		
		input = d.createElement('input');
		input.type = 'text';
		input.name = 'location';
		
		p.appendChild(input);
		form.appendChild(p);
		
/*		p = d.createElement('p');
		
		input = d.createElement('input');
		input.type = 'checkbox';
		input.name = 'remember';
		input.value = 'yes';
		
		label = d.createElement('label');
		label.appendChild(input);
		label.innerHTML += ' Remember My Information';
		
		p.appendChild(label);
		form.appendChild(p);
*/	
		p = d.createElement('p');
		
		input = d.createElement('input');
		input.type = 'submit';
		input.value = 'Submit your photo';
				
		p.appendChild(input);
		
		input = d.createElement('input');
		input.type = 'button';
		input.value = 'Cancel';
		input.setAttribute('onclick',"closePopUp()");
		
		p.appendChild(input);
		form.appendChild(p);
		
		input = d.createElement('input');
		input.type = 'hidden';
		input.name = 'ip';
		input.value = '71.226.62.243';
		form.appendChild(input);
		
		input = d.createElement('input');
		input.type = 'hidden';
		input.name = 'sesID';
		input.value = 'c36dd8b44425b0d9a6c16da05610139a';
		form.appendChild(input);
		
		input = d.createElement('input');
		input.type = 'hidden';
		input.name = 'date';
		input.value = '08-07-02_01-47-25';
		form.appendChild(input);
		
		tableCell.appendChild(form);
		
		d.forms['upload'].elements['day'].value = dayValue;
		d.forms['upload'].elements['month'].value = monthValue;
		d.forms['upload'].elements['year'].value = yearValue;
		
		
		
}

function validateEmail(i, response) {
	if(response!='') {
		//response mode
		if(response == 'false') {
			alert('Please enter a valid email address.'); 	
			d.getElementById('email_id').focus();
		}
	} else { 
		// input mode
		var url = '/xml/validate_email.php?email=' + i;
		loadXMLDoc(url);
	}
}

function thankyou() {
			
//		backgroundBlack();
		
		popup();
		
		tableCell = d.getElementById('middle_middle');
		
		a = d.createElement('a');
		a.href = 'javascript:closePopUp()';
		a.innerHTML = '[x] close';
		a.className = 'smallRed';
		
		tableCell.appendChild(a);
		
		h1 = d.createElement('h1');
		h1.innerHTML = 'Thank You!';

		tableCell.appendChild(h1);

		p = d.createElement('p');
		p.innerHTML = "Thank you for sending us your photo.  We will contact you by email when your image has been reviewed.<br /><br /><a href=\"javascript:closePopUp()\">Click here to close this window</a>";
		tableCell.appendChild(p);
		
		
		
	}

function closePopUp() {

	
	div = d.getElementById('popup');
	div.parentNode.removeChild(div);
	
//	div = d.getElementById('backgroundBlack');
//	div.parentNode.removeChild(div);
	
	if (f = d.forms['monthYear'])
	{
	e = f.elements['month'];
	e.disabled = false;
	
	e = f.elements['year'];
	e.disabled = false;
	
	enableObjects();
	}
	
}



function submitUploadPhoto() {
	
	tableCell = d.getElementById('middle_middle');
	
	f = d.forms['upload'];
//	f.style.display = 'none';
	
//	tableCell.innerHTML += "Sending your photo now...";
	
}

function disableDateDropDowns() {

	if (d.forms['monthYear']) {
		
		f = d.forms['monthYear'];
		
		if (f.elements['month']) {
			e = f.elements['month'];
			e.disabled = true;
		}
		
		if (f.elements['year']) {
			e = f.elements['year'];
			e.disabled = true;
		}
	}
	
}

function createBorderTable() {

	table = d.createElement('table');
	table.id = 'pop_up_table';
	table.cellPadding = '0';
	table.cellSpacing = '0';
	table.width = '640px';
	
	tr = d.createElement('tr');
	
	td = d.createElement('td');
//	td.id = 'top_left';
	tr.appendChild(td);
	
	td = d.createElement('td');
//	td.id = 'top_middle';
	tr.appendChild(td);
	
	td = d.createElement('td');
//	td.id = 'top_right';
	tr.appendChild(td);
	
	table.appendChild(tr);
	
	tr = d.createElement('tr');
	
	td = d.createElement('td');
//	td.id = 'middle_left';
	tr.appendChild(td);
	
	td = d.createElement('td');
	td.id = 'middle_middle';
	tr.appendChild(td);
	
	td = d.createElement('td');
//	td.id = 'middle_right';
	tr.appendChild(td);
	
	table.appendChild(tr);
	
	tr = d.createElement('tr');
	
	td = d.createElement('td');
//	td.id = 'bot_left';
	tr.appendChild(td);
	
	td = d.createElement('td');
//	td.id = 'bot_middle';
	tr.appendChild(td);
	
	td = d.createElement('td');
//	td.id = 'bot_right';
	tr.appendChild(td);
	
	table.appendChild(tr);
	
	return table;
	
}

function disableObjects() {
	
	if (d.getElementById('300by250')) {
		obj = d.getElementById('300by250');
		
		obj.style.display = 'none';
	}
	
	if (d.getElementById('300by100')) {
		obj = d.getElementById('300by100');
		
		obj.style.display = 'none';
	}
	
}

function enableObjects() {
	
	if (d.getElementById('300by250')) {
		obj = d.getElementById('300by250');
		
		obj.style.display = '';
	}
	
	if (d.getElementById('300by100')) {
		obj = d.getElementById('300by100');
		
		obj.style.display = '';
	}
}

function popup() {
	
	disableObjects();
	
	div = d.createElement('div');
	html = d.getElementById('kacl');
	div.id = 'popup';
	table = createBorderTable();
	div.appendChild(table);
	
	var top = 20;
	var left = 0;
	
	div.style.top = top+'px';
	div.style.left = left+'px';
	
	d.body.appendChild(div);
	
}

function backgroundBlack() {
		
		html = d.getElementById('kacl');
				
		div = d.createElement('div');
		
		height = ( html.offsetHeight > d.body.scrollHeight) ?  html.offsetHeight : d.body.scrollHeight + 50;
		//width = ( html.offsetWidth > d.body.scrollWidth ) ? html.offsetWidth : d.body.scrollWidth;
		width = 505;
		
		div.id = 'backgroundBlack';
		
		div.style.height = height+"px";
		div.style.width = width+"px";
		
		
		d.body.appendChild(div);
		
}

function openPosting(i) {

		
//		backgroundBlack();
	
		popup();
		disableDateDropDowns();
		
		tableCell = d.getElementById('middle_middle');
	
		h1 = d.createElement('h1');
		h1.innerHTML = 'View Event';
		h1.id = 'event_popup_header';
		tableCell.appendChild(h1);
		
		
		a = d.createElement('a');
		a.href = 'javascript:closePopUp()';
		a.innerHTML = '[x] close';
		a.className = 'smallRed';
		
		tableCell.appendChild(a);
		var bar = d.createTextNode(" | ");
		tableCell.appendChild(bar);
		
		a.charset="ISO-8859-1";
		a = d.createElement('a');
		a.href = '/printer_friendly/flier.php?d_id='+i+'&type=flier';
		a.innerHTML = ' Printer Friendly flier';
		a.className = 'smallRed';
		a.target = "_blank";

		tableCell.appendChild(a);
		var bar = d.createTextNode(" | ");
		tableCell.appendChild(bar);

		a = d.createElement('a');
		a.href = '/Calendar/event_ics.php?id='+i;
		a.innerHTML = ' Add to Outlook';
		a.className = 'smallRed';
		
		tableCell.appendChild(a);
		var bar = d.createTextNode(" | ");
		tableCell.appendChild(bar);

		a = d.createElement('a');
		a.href = '/user/contact_event_lister.php?id='+i;
		a.innerHTML = ' Contact Event Lister';
		a.className = 'smallRed';
		
		tableCell.appendChild(a);
		var bar = d.createTextNode(" | ");
		tableCell.appendChild(bar);

		a = d.createElement('a');
		a.href = 'javascript:reminders('+i+')';
		a.innerHTML = 'Remind Me';
		a.className = 'smallRed';
		
		tableCell.appendChild(a);

		a = d.createElement('a');
		a.href = '/user/add_to_personal_calendar.php?id='+i;
		a.innerHTML = ' Add to Personal Calendar';
		a.className = 'smallRed';

		var bar = d.createTextNode(" | ");
		tableCell.appendChild(bar);
		tableCell.appendChild(a);

		display_rating(i);
		
		p = d.createElement('p');
		
		img = d.createElement('img');
		img.src = '/images/progress.gif';
		
		p.appendChild(img);
		p.innerHTML += ' Loading...';
		p.style.fontSize = '0%';
		p.id = 'loading';
		
		tableCell.appendChild(p);
		
		getImage(i, img, '');
		}
function adminOpenPosting(i) {
		
//		backgroundBlack();
	
		popup();
		
		disableDateDropDowns();
		
		tableCell = d.getElementById('middle_middle');
		
		a = d.createElement('a');
		a.href = 'javascript:closePopUp()';
		a.innerHTML = '[x] close';
		a.className = 'smallRed';
		
		tableCell.appendChild(a);

		h1 = d.createElement('h1');
		h1.innerHTML = 'View Event';
		h1.id = 'event_popup_header'

		tableCell.appendChild(h1);
		
		p = d.createElement('p');
		
		img = d.createElement('img');
		img.src = '/images/progress.gif';
		
		p.appendChild(img);
		p.innerHTML += ' Loading...';
		p.style.fontSize = '0%';
		p.id = 'loading';
		
		tableCell.appendChild(p);
		
		getImage(i, img, '');

		
}
function getImage(i, img, input) {
	
	if (input != '') {
		
		str = input.split(/\.\|\./);
		
		p = d.getElementById('loading');
		p.parentNode.removeChild(p);
		
		tableCell = d.getElementById('middle_middle');
		
		container = d.createElement('div');
		container.style.width = '100%';
		
		div = d.createElement('div');
		div.style.width = '300px';
		div.style.height = '250px';
		div.style.marginTop = '5px';
		div.style.cssFloat = 'left';
				
		img = d.createElement('img');
		img.src = '/images/get_image.php?id='+i+'&type=featured';
		img.style.cssFloat = 'left';
		
		
		div.appendChild(img);
		container.appendChild(div);
		
		div = d.createElement('div');
		div.style.cssFloat = 'right';
		div.style.marginLeft = '20px';
		div.style.width = '260px';
		
		if (str[2] != ' ') {
			p = d.createElement('p');
			p.innerHTML = '<b>Event Name</b>: '+str[2];
			div.appendChild(p);
		}
		
		p = d.createElement('p');
		p.innerHTML = '<b>' + str[15] + '</b>';
		div.appendChild(p);
		
		p = d.createElement('p');
		p.innerHTML = '<b>Event Price</b>: ' + str[14];
		div.appendChild(p);
		
		if (str[0] != ' ') {
			p = d.createElement('p');
			p.innerHTML = '<b>Event Organization</b>: '+str[0];
			div.appendChild(p);
		}
		
		if (str[1] != ' ') {
			p = d.createElement('p');
			p.innerHTML = '<b>Event Location</b>: '+str[8]+' on '+str[9];
			div.appendChild(p);
		}
		
		if (str[5] != 'http://') {
			p = d.createElement('p');
			p.innerHTML = '<b>URL</b>: <a target=\'_blank\' href=\''+str[5]  + '\' >' +str[5] +'</a>';
			div.appendChild(p);
		}
		
        container.appendChild(div);
        br = d.createElement('br');
        br.style.clear = 'both';
        container.appendChild(br);
		tableCell.appendChild(container);
		
		
				
		
		div = d.createElement('div');
		div.style.cssFloat = 'right';
		div.style.styleFloat = 'right';
		div.style.height = '350px';
		div.style.width = '300px';
		div.style.marginTop = '-1.5em';
		div.style.marginBottom = '60px';
		div.id = 'google_map';
		
		h2 = d.createElement('h2');
		h2.innerHTML = "Map to Event";
		h2.style.textAlign = 'right';
		div.appendChild(h2);
		
		div2 = d.createElement('div');
		div2.style.height = '300px';
		div2.style.width = '100%';
		div2.id = 'map_canvas';
		div.appendChild(div2);
		
		tableCell.appendChild(div);
		
		name = str[8];
		street = str[9];
		city = str[10];
		state = str[11];
		zip = str[12];
		
		setTimeout('initialize(name, street, city, state, zip)', 1000);

		
				
		if (str[3] != ' ') {
            p = d.createElement('p');
            str[3] = str[3].replace(/\\/, '');
			p.innerHTML = '<b>Event Description</b>: '+str[3];
			p.style.clear = 'left';
			tableCell.appendChild(p);
		}

		h1 = d.getElementById('event_popup_header');
		h1.innerHTML += ' on ' + str[4];
		if (str[6] != ' ' && str[7] != ' ')
			h1.innerHTML += '&nbsp;&nbsp;' + str[6] + ' - ' +str[7];
		else
		{
		if (str[6] != ' ') {
			h1.innerHTML += '  Start Time: ' + str[6];
		}
		if (str[7] != ' ') {
			h1.innerHTML +=  '  End Time: ' +str[7];
		}
		}
	}
	else {
		
		url = '/xml/getPhoto.php?d_id='+i;
		loadXMLDoc(url);
		
	}
	
}

function start_slideshow(i, imgs) {

		if(imgs != '') {
			backgroundBlack();
		
			popup();
			
			disableDateDropDowns();
			
			tableCell = d.getElementById('middle_middle');
			
			a = d.createElement('a');
			a.href = 'javascript:closePopUp()';
			a.innerHTML = '[x] close';
			a.className = 'smallRed';
			
			tableCell.appendChild(a);
			
			a = d.createElement('a');
			a.href = 'javascript:window.print()';
			a.innerHTML = ' | print';
			a.className = 'smallRed';
			
			tableCell.appendChild(a);
			
			h1 = d.createElement('h1');
			h1.innerHTML = 'View Photo';
	
			tableCell.appendChild(h1);
			
			p = d.createElement('p');
			p.style.textAlign = 'center';
			
			s = d.createElement('strong');
			s.className = 'slide_links';
			s.innerHTML = '<A HREF="javascript:SLIDES.previous()">&lt;Previous</A>&nbsp;';
			p.appendChild(s);
			
			s = d.createElement('strong');
			s.className = 'slide_links';
			s.innerHTML = '<A HREF="javascript:SLIDES.next()">Next&gt;</A>&nbsp;';
			p.appendChild(s);
			
			s = d.createElement('strong');
			s.className = 'slide_links';
			s.innerHTML = '<A HREF="javascript:SLIDES.play()">Play</A>&nbsp;';
			p.appendChild(s);
			
			s = d.createElement('strong');
			s.className = 'slide_links';
			s.innerHTML = '<A HREF="javascript:SLIDES.pause()">Stop</A>';
			p.appendChild(s);
			
			b = d.createElement('br');
			p.appendChild(b);
			b = d.createElement('br');
			b.style.lineHeight = '3px';
			p.appendChild(b);
			
			img = d.createElement('img');
			img.name = 'SLIDESIMG';
			img.src = '/images/progress.gif';
			img.style.filter = 'progid:DXImageTransform.Microsoft.Fade()';
			p.appendChild(img);
			
			b = d.createElement('br');
			p.appendChild(b);
			
			div = d.createElement('div');
			div.id = 'SLIDESTEXT';
			p.appendChild(div);
			
			tableCell.appendChild(p);
			
			SLIDES = new slideshow("SLIDES");
			SLIDES.timeout = 5000;
			SLIDES.prefetch = 1;
			SLIDES.repeat = true;
			SLIDES.image = document.images.SLIDESIMG;
			
			newStr = imgs.split(/\.\|\./);
			j = 1;
			for(i = 0; i < newStr[0]; i++) {
				s = new slide();
				s.src =  "/images/get_image.php?id="+newStr[j]+"&type=popUp";
				s.text ="";
								s.text += "<div style=\"text-align:left; padding: 3px;\"><b>Name</b>: "+newStr[j+1]+"<br /><b>Location</b>: "+newStr[j+2]+"<br /><b>Caption</b>: "+newStr[j+3]+"<br /><b>Date</b>: "+newStr[j+4]+"</span>";
				
				s.link = "javascript:preview('"+newStr[j]+"', '10', '10');";
				s.target = "";
				s.attr = "";
				s.filter = "";
				SLIDES.add_slide(s);
				j+=5;
				
				if (false) SLIDES.shuffle();
			}
			
			if (document.images) {
				SLIDES.textid = "SLIDESTEXT";
				SLIDES.update();
				SLIDES.play();
			}
			
			// For browsers that cannot change the HTML on the page,
			// display all of the text from the slideshow.
			// I place this within the DIV, so browers won't see it
			// if they can change the DIV.
			
			//nodivtext = SLIDES.get_all_text("<li>", "<p>\n");
			//nodivtext = SLIDES.get_text();
			//if (nodivtext) {
			  //document.write("\n" + nodivtext + "\n");
			//}
		} // end if
		else {
			url = '/xml/getPhotos.php?id='+i;
			loadXMLDoc(url);
		}
		
}

function preview(id, h, w) {
		
		string = "page" + id + " = window.open('/Calendar/photo_preview.php?id=" + id + "', 'mssgDisplay', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width="+h+",height="+w+"');";
		eval(string);
}	

var req;
function loadXMLDoc(url) {	
	// branch for native XMLHttpRequest object
	if (window.XMLHttpRequest) 
	{
		req = new XMLHttpRequest();
		req.onreadystatechange = processReqChange;
		req.open("GET", url, true);
		req.send(null);
	// branch for IE/Window ActiveX version
	} 
	
	else if (window.ActiveXObject)
	 {
		req = new ActiveXObject("Microsoft.XMLHTTP");
		if (req) 
		{
			req.onreadystatechange = processReqChange;
			req.open("GET", url, true);
			req.send();
		}
	}
}
function processReqChange() {
	// only if req shows "complete"
	if (req.readyState == 4) {
		// only if "OK"
		if(req.status == 200) {
			// ...processing statements go here...
			response = req.responseXML.documentElement;
			method = response.getElementsByTagName('method')[0].firstChild.data;
			result = response.getElementsByTagName('result')[0].firstChild.data;
			eval (method + ' result)');
		}
	}
}

