function drawDigital(){
	var dayNames = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
	var monthNames = new Array("January","February","March","April","May","June","July","August","September","October","November","December");
	var now = new Date(); var Hours, Mins, Time, Seconds;
	Hours = now.getHours();
	if (Hours >= 12) { Time = " PM"; } else { Time = " AM"; }
	if (Hours > 12) { Hours -= 12; }
	if (Hours == 0) { Hours = 12; }
	Mins = now.getMinutes();
	Seconds = now.getSeconds();
	if(Seconds < 10){ Seconds = "0" + Seconds; }
	if (Mins < 10) { Mins = "0" + Mins; }
	document.getElementById('w_time').innerHTML = (Hours + ':' + Mins + '<span class="liltime"> ' + Seconds + ' - ' + Time + '</span>');
	document.getElementById('w_basetime').innerHTML = (dayNames[now.getDay()] + ', ' + monthNames[now.getMonth()] + ' ' + now.getDate() + ', ' + now.getFullYear());
	setTimeout('drawDigital()', 1000);
}

function drawCalendar(settings){
	var dayNames = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
	var monthNames = new Array("January","February","March","April","May","June","July","August","September","October","November","December");
	var startDays = new Array("2","5","6","2","4","7","2","5","1","3","6","1"); /* monday 1, tue 2 etc sun 7 */
	var monthDays = new Array("31","29","31","30","31","30","31","31","30","31","30","31");
	var now = new Date(); var day = now.getDate(); var month = now.getMonth(); var year = now.getFullYear(); day = parseInt(day, 10);

	var newContent22 = '<div id="calendartop"><img src="../shared/uic/calendar.gif" alt="Calendar">' + monthNames[month] +' '+ year +'</div>';
	newContent22 += '<table cellspacing="0" cellpadding="0" id="calendar">';
  	newContent22 += '<tr class="calbri"><td>Sun</td><td>Mon</td><td>Tue</td><td>Wed</td><td>Thu</td><td>Fri</td><td>Sat</td></tr>';
  	var currentdays = monthDays[month]; var dayone = parseInt(startDays[month], 10);
	var ccounter = 0; var fd = 0; var gong = 0;

  	for(var j=0; j<6; j++){ /* rows */
  		newContent22 += '<tr>';
  		for(var h=0; h<7; h++){ /* columns */
  			for(var k=0; k < settings.length;k++){
  				if(settings[k] == fd){ /* if an event */
  					newContent22 += '<td class="eday"><a onclick="document.getElementById(\'calbase\').innerHTML = \''+ settings[k+1] +'\'">'+ fd +'</a></td>'; fd++; gong = 1;
  				}
  			}
  			if(gong === 0){ /* if not an event */
				if(ccounter === dayone){ 
					fd = 1; 
					if(fd === day){
						newContent22 += '<td class="hday">'+ fd +'</td>'; fd++;
					}
					else {
						newContent22 += '<td>'+ fd +'</td>'; fd++;
					} 
				}
  				else {
  					if(ccounter > dayone && fd <= currentdays){ 
					  	if(fd === day){
							newContent22 += '<td class="hday">'+ fd +'</td>'; fd++;
						}
						else{
							newContent22 += '<td>'+ fd +'</td>'; fd++;
						} 
					}
  					else { newContent22 += '<td>&nbsp;</td>'; }
  				}
  			}
		ccounter++; gong = 0;
		}
		newContent22 += '</tr>';
	}

  	newContent22 += '<tr><td colspan="7" id="calbase">&nbsp;</td></tr>';
	newContent22 += '</table>';
	return newContent22;
}

/* Draw the widgets ***************************************************** */

if(c_widgets != ""){
	var thewidgets = []; var thesettings = [];
	var temparrays = c_widgets.split("[");
	for(var i=0;i<temparrays.length;i++){
		var temp = temparrays[i].split("^");
		thewidgets[i] = temp[0];
		thesettings[i] = temp[1];
	}
	for(i=0;i<thewidgets.length;i++){
		/*
		if(thewidgets[i] === "Google Adwords"){
			write stuff
		}
		*/
		if(thewidgets[i] === "Tall Banner"){
			temp = thesettings[i].split(",");
			document.write('<a href="'+ temp[0] +'"><img src="'+ temp[1] +'" width="180" height="865" style="margin:5px 0px 0px 5px" /></a>');
		}
		if(thewidgets[i] === "Announcement"){
			tempa = thesettings[i].split(",");
			document.write('<img src="../shared/uic/tack.gif" style="margin:10px auto 0px auto"><div style="width:160px;margin:0px auto;text-align:center;padding:2px 7px 0px 7px;background:#ff9;color:black;"><div style="width:150px;padding:5px;margin-bottom:5px;background:white;font-weight:bold;color:black;">'+ tempa[0] +'</div>'+ tempa[1] +'</div><img src="../shared/uic/tack2.gif" style="margin:0px auto 10px auto">');
		}
		if(thewidgets[i] === "Analog/Digital Clock"){
			if(thesettings[i] === "digital"){
				document.write('<div id="w_time"></div>');
				document.write('<div id="w_basetime"></div>');
				if(c_themecolor === "Nightime"){ document.getElementById('w_time').style.background= "#453c2f"; document.getElementById('w_basetime').style.background= "#0a0a0a"; }
				drawDigital();
			}
			else {
				document.write('<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="170" height="170" id="analogclock" align="middle">');
				document.write('<param name="allowScriptAccess" value="sameDomain" /><param name="allowFullScreen" value="false" />');
				document.write('<param name="movie" value="../shared/uic/analogclock.swf" /><param name="menu" value="false" /><param name="quality" value="high" /><param name="wmode" value="transparent" />');
				if(c_themecolor === "Nightime"){ document.write('<param name="bgcolor" value="#16120c" />'); } else { document.write('<param name="bgcolor" value="#f3f1f1" />'); }
				if(c_themecolor === "Nightime"){ document.write('<embed src="../shared/uic/analogclock.swf" menu="false" quality="high" wmode="transparent" bgcolor="#16120c" width="170" height="170" name="analogclock" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />'); }
				else { document.write('<embed src="../shared/uic/analogclock.swf" menu="false" quality="high" wmode="transparent" bgcolor="#f3f1f1" width="170" height="170" name="analogclock" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />'); }
				document.write('</object>');
			}
		}
		if(thewidgets[i] === "Countdown Timer"){
			var temhj = thesettings[i].split(",");
			document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="170" height="230" id="countdown" align="middle">');
			document.write('<param name="allowScriptAccess" value="sameDomain" /><param name="allowFullScreen" value="false" />');
			document.write('<param name="movie" value="../shared/uic/countdown.swf?'+ temhj[1]+ ','+ temhj[2]+ ','+ temhj[3]+ ','+ temhj[4]+ ','+ temhj[5]+'" /><param name="menu" value="false" /><param name="quality" value="high" /><param name="wmode" value="transparent" />');
			if(c_themecolor === "Nightime"){ document.write('<param name="bgcolor" value="#16120c" />'); } else { document.write('<param name="bgcolor" value="#f3f1f1" />'); }
			if(c_themecolor === "Nightime"){ document.write('<embed src="../shared/uic/countdown.swf?'+ temhj[1]+ ','+ temhj[2]+ ','+ temhj[3]+ ','+ temhj[4]+ ','+ temhj[5]+'" menu="false" quality="high" wmode="transparent" bgcolor="#16120c" width="170" height="230" name="countdown" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />'); }
			else { document.write('<embed src="../shared/uic/countdown.swf?'+ temhj[1]+ ','+ temhj[2]+ ','+ temhj[3]+ ','+ temhj[4]+ ','+ temhj[5]+'" menu="false" quality="high" wmode="transparent" bgcolor="#f3f1f1" width="170" height="230" name="countdown" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />'); }
			document.write('</object>');
			document.write('<div id="cd_message">' + temhj[0] + '</div>');
		}
		if(thewidgets[i] === "Keyword Search"){
			var tembj = thesettings[i].split(",");
			if(usersearch === "yes"){
				document.write('<div style="height:10px;font-size:8px">&nbsp;</div>');
				document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="180" height="250" id="searchbox" align="middle">');
				document.write('<param name="allowScriptAccess" value="sameDomain" /><param name="allowFullScreen" value="false" />');
				document.write('<param name="movie" value="../shared/uic/search.swf?welcome='+ tembj[0]+ '&path='+ tembj[1] + '&admin=no"/><param name="menu" value="false" /><param name="quality" value="high" /><param name="wmode" value="transparent" />');
				if(c_themecolor === "Nightime"){ document.write('<param name="bgcolor" value="#16120c" />'); } else { document.write('<param name="bgcolor" value="#f3f1f1" />'); }
				if(c_themecolor === "Nightime"){ document.write('<embed src="../shared/uic/search.swf?welcome='+ tembj[0]+ '&path='+ tembj[1] + '&admin=no" menu="false" quality="high" wmode="transparent" bgcolor="#16120c" width="180" height="250" name="searchbox" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />'); }
				else { document.write('<embed src="../shared/uic/search.swf?welcome='+ tembj[0]+ '&path='+ tembj[1] + '&admin=no" menu="false" quality="high" wmode="transparent" bgcolor="#f3f1f1" width="180" height="250" name="searchbox" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />'); }
				document.write('</object>');
			}
			else {
				document.write('<div style="height:10px;font-size:8px">&nbsp;</div>');
				document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="180" height="250" id="searchbox" align="middle">');
				document.write('<param name="allowScriptAccess" value="sameDomain" /><param name="allowFullScreen" value="false" />');
				document.write('<param name="movie" value="../shared/uic/search.swf?welcome='+ tembj[0]+ '&path='+ tembj[1] + '&admin=yes"/><param name="menu" value="false" /><param name="quality" value="high" /><param name="wmode" value="transparent" />');
				if(c_themecolor === "Nightime"){ document.write('<param name="bgcolor" value="#16120c" />'); } else { document.write('<param name="bgcolor" value="#f3f1f1" />'); }
				if(c_themecolor === "Nightime"){ document.write('<embed src="../shared/uic/search.swf?welcome='+ tembj[0]+ '&path='+ tembj[1] + '&admin=yes" menu="false" quality="high" wmode="transparent" bgcolor="#16120c" width="180" height="250" name="searchbox" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />'); }
				else { document.write('<embed src="../shared/uic/search.swf?welcome='+ tembj[0]+ '&path='+ tembj[1] + '&admin=yes" menu="false" quality="high" wmode="transparent" bgcolor="#f3f1f1" width="180" height="250" name="searchbox" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />'); }
				document.write('</object>');	
			}
		}
		if(thewidgets[i] === "Fundraiser Board"){
			var temhjj = thesettings[i].split(",");
			document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="170" height="220" id="thermometer" align="middle">');
			document.write('<param name="allowScriptAccess" value="sameDomain" /><param name="allowFullScreen" value="false" />');
			document.write('<param name="movie" value="../shared/uic/thermometer.swf?'+ temhjj[0]+ ','+ temhjj[1]+'" /><param name="menu" value="false" /><param name="quality" value="high" /><param name="wmode" value="transparent" />');
			if(c_themecolor === "Nightime"){ document.write('<param name="bgcolor" value="#16120c" />'); } else { document.write('<param name="bgcolor" value="#f3f1f1" />'); }
			if(c_themecolor === "Nightime"){ document.write('<embed src="../shared/uic/thermometer.swf?'+ temhjj[0]+ ','+ temhjj[1]+'" menu="false" quality="high" wmode="transparent" bgcolor="#16120c" width="170" height="220" name="thermometer" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />'); }
			else { document.write('<embed src="../shared/uic/thermometer.swf?'+ temhjj[0]+ ','+ temhjj[1]+'" menu="false" quality="high" wmode="transparent" bgcolor="#f3f1f1" width="170" height="220" name="thermometer" align="middle" allowScriptAccess="sameDomain" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />'); }
			document.write('</object>');
			document.write('<div id="cd_message">Fundraising Progress<br /><em>' + temhjj[2] + '</em></div>');
		}
		if(thewidgets[i] === "Events Calendar"){
			if(thesettings[i]){ var temhh = thesettings[i].split(","); } else { var temhh = ""; }
			document.write(drawCalendar(temhh));
		}
	}
}