function bannerDisplay() {
	var opt = Math.round((Math.random() * 1000));
	if (opt > 500) {
		document.write('<table cellpadding="0" cellspacing="0">');
		document.write('	<tr>')
		document.write('		<td class="small_panel_success_stories"></td>');
		document.write('	</tr>');
		document.write('	<tr>');
		document.write('		<td class="small_panel_tile" align="left">');
		document.write('			<div class="small_panel_content">');
		document.write('				<a href="success_story_hospice.htm"><img src="images/hbts_success_image.jpg" width="123" height="109" />');
		document.write('			<div class="small_panel_divider"></div>');
		document.write('				Hospice by the Sea</a>');
		document.write('				<br />');
		document.write('				Boca Raton');
		document.write('			</div>');
		document.write('		</td>');
		document.write('	</tr>');
		document.write('	<tr>');
		document.write('		<td class="small_panel_footer"></td>');
		document.write('	</tr>');
		document.write('</table>');

	} else {
		document.write('<table cellpadding="0" cellspacing="0">');
		document.write('	<tr>')
		document.write('		<td class="small_panel_success_stories"></td>');
		document.write('	</tr>');
		document.write('	<tr>');
		document.write('		<td class="small_panel_tile" align="left">');
		document.write('			<div class="small_panel_content">');
		document.write('				<a href="case_study_dds.htm"><img src="images/DDS_image.jpg" width="123" height="109" />');
		document.write('			<div class="small_panel_divider"></div>');
		document.write('				Discovery Dayschool</a>');
		document.write('				<br />');
		document.write('				West Palm Beach');
		document.write('			</div>');
		document.write('		</td>');
		document.write('	</tr>');
		document.write('	<tr>');
		document.write('		<td class="small_panel_footer"></td>');
		document.write('	</tr>');
		document.write('</table>');		
	}
}


function renderIENavMenu() {
	if (window.navigator.userAgent.indexOf("MSIE") == -1) {
//		document.write('<div style="position: absolute; top: 183px; z-index: 1000">');
		document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="750" height="190" id="slide-nav-top" align="middle">');
		document.write('<param name="allowScriptAccess" value="sameDomain" />');
		document.write('<param name="movie" value="slide-nav-top.swf" />');
		document.write('<param name="quality" value="high" />');
		document.write('<param name="wmode" value="transparent" />');
		document.write('<param name="bgcolor" value="#ffffff" />');
		document.write('<embed src="slide-nav-top.swf" quality="high" wmode="transparent" bgcolor="#ffffff" width="550" height="190" name="slide-nav-top" align="middle" allowscriptaccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
		document.write('</object>');
//		document.write('</div>');
	}
}

function renderNavMenu() {
//	if (window.navigator.userAgent.indexOf("MSIE") != -1) {
//		document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" style="position: absolute; top: 183px; z-index: 1000" width="550" height="190" id="slide-nav-top" align="middle">');
		document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="550" height="190" id="slide-nav-top" align="middle">');
		document.write('<param name="allowScriptAccess" value="sameDomain" />');
		document.write('<param name="movie" value="slide-nav-top.swf" />');
		document.write('<param name="quality" value="high" />');
		document.write('<param name="wmode" value="transparent" />');
		document.write('<param name="bgcolor" value="#ffffff" />');
		document.write('<embed src="slide-nav-top.swf" quality="high" wmode="transparent" bgcolor="#ffffff" width="550" height="190" name="slide-nav-top" align="middle" allowscriptaccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />');
		document.write('</object>');
//	}
}

function renderHomeRotator() {
	document.write('<object style="z-index: 0" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="471" height="311" id="home_rotation" align="middle">');
	document.write('<param name="allowScriptAccess" value="sameDomain" />');
	document.write('<param name="movie" value="home_rotation.swf" />');
	document.write('<param name="loop" value="true" />');
	document.write('<param name="menu" value="false" />');
	document.write('<param name="quality" value="best" />');
	document.write('<param name="wmode" value="transparent" />');
	document.write('<param name="bgcolor" value="#ffffff" />');
	document.write('<embed src="home_rotation.swf" loop="false" menu="false" quality="best" wmode="transparent" ');
	document.write('	bgcolor="#ffffff" width="471" height="311" name="home_rotation" align="middle" ');
	document.write('	allowscriptaccess="sameDomain" type="application/x-shockwave-flash" ');
	document.write('	pluginspage="http://www.macromedia.com/go/getflashplayer" />');
	document.write('</object>');
}

var isIE = (window.navigator.userAgent.indexOf("MSIE") != -1);
var isOpera = (window.navigator.userAgent.indexOf("Opera") != -1);

function attachEventHandler(obj, eventName, method) {
	if (isIE)
		obj.attachEvent("on" + eventName, method);
	else
		obj.addEventListener(eventName, method, false);
}

function loadActiveObjects() {
	if (isIE || isOpera) {
		var objs = document.getElementsByTagName("OBJECT");
		for (i = 0; i < objs.length; i++) {
			var parent = objs[i].parentElement;
			var html = parent.innerHTML;
			parent.innerHTML = "";
			parent.innerHTML = html;
		}
	}
	
	if (isIE) {
		moveFlashMenu();
	}
	
	var small_font = GetCookie("fontsize");
	if (small_font == "true" || small_font == null) {
		if (isOpera);
			largeFont();
		smallFont();
	} else {
		if (isOpera)
			smallFont();
		largeFont();
	}
}

attachEventHandler(window, "load", loadActiveObjects);

if (isIE) {
	attachEventHandler(window, "resize", moveFlashMenu);
}

function moveFlashMenu() {
	var objFlash = document.getElementById("slide-nav-top");
	var nWidth = parseInt(document.body.scrollWidth);
	var nFlashWidth = 800;
	objFlash.style.left = ((nWidth / 2) - (nFlashWidth / 2)) + "px";
}

function SetCookie(name, value, expires, path, domain, secure) {
	// set time, it's in milliseconds
	var today = new Date();
	today.setTime( today.getTime() );
	
	/*
	if the expires variable is set, make the correct 
	expires time, the current script below will set 
	it for x number of days, to make it for hours, 
	delete * 24, for minutes, delete * 60 * 24
	*/
	if (expires)
		expires = expires * 1000 * 60 * 60;
	var expires_date = new Date(today.getTime() + (expires));
	
	document.cookie = name + "=" + escape( value ) +
		((expires) ? ";expires=" + expires_date.toGMTString() : "") + 
		((path) ? ";path=" + path : "") + 
		((domain) ? ";domain=" + domain : "") +
		((secure) ? ";secure" : "");
}

function GetCookie(name) {	
	var start = document.cookie.indexOf( name + "=" );
	var len = start + name.length + 1;
	if ((!start ) && (name != document.cookie.substring(0, name.length )))
		return null;
	
	if (start == -1)
		return null;
		
	var end = document.cookie.indexOf(";", len);
	if (end == -1)
		end = document.cookie.length;
		
	return unescape(document.cookie.substring(len, end));
}

function DeleteCookie(name, path, domain) {
	if (GetCookie(name)) {
		document.cookie = name + "=" +
			((path) ? ";path=" + path : "") +
			((domain) ? ";domain=" + domain : "") +
			";expires=Thu, 01-Jan-1970 00:00:01 GMT";
	}
}

var isSafari = (navigator.userAgent.indexOf("Safari") > 0);

if (isSafari) {
	document.writeln('<link rel="stylesheet" type="text/css" href="small_fonts.css" title="SmallFonts" />')
	document.writeln('<link rel="stylesheet" type="text/css" href="large_fonts.css" title="LargeFonts" />')
}

function SelectStyleSheet(title) {
	var i;
	
	for ( i = 0; i < document.styleSheets.length; i++ ) {
		if ( document.styleSheets[ i ].title == title )
			document.styleSheets[ i ].disabled = false;
		else if ( document.styleSheets[ i ].href.indexOf("styles.css") == -1 ) {
			document.styleSheets[ i ].disabled = true;
		}
	}
}

function smallFont() {
	SetCookie("fontsize", "true");
	SelectStyleSheet("SmallFonts");
	
	var smallFontButton = document.getElementById("smallFontButton");
	if (smallFontButton)
		smallFontButton.src = "images/minus_disabled.jpg";
		//alert(document.styleSheets.length);

	var largeFontButton = document.getElementById("largeFontButton");
	if (largeFontButton)
		largeFontButton.src = "images/plus_enabled.jpg";
}

function largeFont() {
	SetCookie("fontsize", "false");
	SelectStyleSheet("LargeFonts");
	var smallFontButton = document.getElementById("smallFontButton");
	if (smallFontButton)
		smallFontButton.src = "images/minus_enabled.jpg";

	var largeFontButton = document.getElementById("largeFontButton");
	if (largeFontButton)
		largeFontButton.src = "images/plus_disabled.jpg";
}

function writeHeadLines() {
	document.writeln('<table cellpadding="0" cellspacing="0"><tr>' +
			'<td class="small_panel_recent_headlines"></td>' +
			'</tr><tr>' +
			'<td class="small_panel_tile" align="left">' +
				'<div class="small_panel_content">' +
					'<a href="http://www.yourcancertoday.com/Cancers/Bone/Wellness-Holistic/Articles/Whistle-While-You-Recuperate/12/18/9092/searchSort=-3&amp;searchPage=2&amp;searchQ=" target="_blank">' +
					'Whistle While You Recuperate</a><br />' +
					'Forbes Magazine' +
					'<div class="small_panel_divider"></div>' +
					'<a href="http://www.cancer.org/docroot/NWS/content/NWS_2_1x_Music_Soothes_Distress_of_Cancer_Treatment.asp" target="_blank">' +
					'Music Therapy<br>&amp; Cancer Treatment</a><br />' +
					'American Cancer Society' +
					'<div class="small_panel_divider"></div>' +
					'<a href="http://abclocal.go.com/wabc/story?section=local&id=3845726" target="_blank">' +
					'The Healing<br /> Power of Music</a><br />' +
					'ABC Eyewitness News' +
				'</div>' +
			'</td></tr><tr>' +
			'<td class="small_panel_footer"></td>' +
			'</tr></table>');
}

function writeTherapyLinks() {
	document.write('<table cellpadding="0" cellspacing="0">' +
			'<tr><td class="small_panel_mtlinks"></td></tr>' +
			'<tr><td class="small_panel_tile" align="left">' +
			'<div class="small_panel_content">' +
			'<a href="http://steinhardt.nyu.edu/music/page.php?page_id=718" target="_blank">Nordoff-Robbins Center<br /> for Music Therapy</a><br />' +
			'New York City, USA' + 
			'<div class="small_panel_divider"></div>' +
			'<a href="http://www.musicconservatory.org/therapy.htm#about" target="_blank">The Music Conservatory</a><br />' +
			'White Plains, NY' +
			'<div class="small_panel_divider"></div>' +
			'<a href="http://www.musictherapy.ca/" target="_blank">Canadian Association for Music Therapy</a><br />' +
			'Ontario, Canada' +
			'</div></td></tr>' +
			'<tr><td class="small_panel_footer"></td></tr></table>');
}

function writeSuccessStories() {
	document.write('<table cellpadding="0" cellspacing="0">' +
			'<tr><td class="small_panel_success_stories"></td></tr>' +
			'<tr><td class="small_panel_tile" align="left">' +
			'	<div class="small_panel_content">' +
			'		<a href="case_study_dds.htm"><img src="images/DDS_image.jpg" width="123" height="109" />' +
			'			<div class="small_panel_divider"></div>' +
			'			Discovery Dayschool</a><br />' +
			'			West Palm Beach' +
			'	</div>' +
			'	</td></tr>' +
			'	<tr><td class="small_panel_footer"></td></tr>' +
			'</table>');
}
