var active = null;
var browser=navigator.appName;
var currentTime;

var agent = navigator.userAgent.toLowerCase(); 
var isMac = (agent.indexOf("mac") != -1) ? true : false;
var isMSIE = (navigator.appVersion.indexOf("MSIE")!=-1) ? true : false;

var browserName = "";

var tourType = "";

var discography = new Object;

var videos = new Object;

var photoAlbums = new Object;

var ua = navigator.userAgent.toLowerCase();

if ( ua.indexOf( "opera" ) != -1 )
{
	browserName = "opera";
} else if ( ua.indexOf( "msie" ) != -1 )
{
	browserName = "msie";
} else if ( ua.indexOf( "safari" ) != -1 )
{
	browserName = "safari";
} else if ( ua.indexOf( "mozilla" ) != -1 )
{
	if ( ua.indexOf( "firefox" ) != -1 )
	{
		browserName = "firefox";
	} else {
		browserName = "mozilla";
	}
}


var paneDifference = 0;
var backBodyDif = 0;
var baseScroll = 390;
var pageScroll = 0;
var thisY = 0;

if (navigator.appVersion.indexOf("Mac")!=-1) OSName="MacOS";

//document.onmousemove = getClientY;

function getClientY(event) {

	e = event || window.event;
	
	topBuffer = 290;
	thisY = topBuffer;
	switch(browserName)
	{
		case "firefox":
		case "mozilla":
		case "safari":
			//thisY = e.layerY + topBuffer;
			pageScroll = window.pageYOffset;
			break;

		default:
			e.cancelBubble = true;
			//thisY = document.documentElement.scrollTop + topBuffer;
			pageScroll = document.documentElement.scrollTop;
			break;
	}
	
	if(pageScroll > baseScroll)
	{
		thisY = topBuffer + (pageScroll - baseScroll);
	} else {
		thisY = topBuffer;
	}
}

var screenWidth = 0;
var screenHeight = 0;

var loadingImage = 'images/loading.gif';

function getPageScroll(){

	var yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
	}

	arrayPageScroll = new Array('',yScroll) 
	return arrayPageScroll;
}



//
// getPageSize()
// Returns array with page width, height and window width, height
// Core code from - quirksmode.org
// Edit for Firefox by pHaez
//
function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}


	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

function initOverlay()
{

	var objBody = document.getElementsByTagName("body").item(0);
	
	// create overlay div and hardcode some functional styles (aesthetic styles are in CSS file)
	var objOverlay = document.createElement("div");
	objOverlay.setAttribute('id','overlay');
	objOverlay.onclick = function () {return false;}
	objOverlay.style.display = 'none';
	objOverlay.style.position = 'absolute';
	objOverlay.style.top = '0';
	objOverlay.style.left = '0';
	objOverlay.style.background ="transparent url(overlay.gif)";
	//objOverlay.style.filter = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src="overlay.png", sizingMethod="scale")';
	objOverlay.style.zIndex = '90';
 	objOverlay.style.width = '100%';
	objBody.insertBefore(objOverlay, objBody.firstChild);
	
	var objLoadingImage = document.createElement("img");
	objLoadingImage.src = loadingImage;
	objLoadingImage.setAttribute('id','loadingImage');
	objLoadingImage.style.position = 'absolute';
	objLoadingImage.style.zIndex = '150';
	objOverlay.appendChild(objLoadingImage);
		
	var arrayPageSize = getPageSize();
	var arrayPageScroll = getPageScroll();

	// preload and create loader image
	var imgPreloader = new Image();
	/*
	// if loader image found, create link to hide lightbox and create loadingimage
	imgPreloader.onload=function(){

		var objLoadingImageLink = document.createElement("a");
		objLoadingImageLink.setAttribute('href','#');
		objLoadingImageLink.onclick = function () {hideLightbox(); return false;}
		objOverlay.appendChild(objLoadingImageLink);
		
		var objLoadingImage = document.createElement("img");
		objLoadingImage.src = loadingImage;
		objLoadingImage.setAttribute('id','loadingImage');
		objLoadingImage.style.position = 'absolute';
		objLoadingImage.style.zIndex = '150';
		objLoadingImageLink.appendChild(objLoadingImage);

		objLoadingImage.style.top = (arrayPageScroll[1] + ((arrayPageSize[3] - 35 - objLoadingImage.height) / 2) + 'px');
		objLoadingImage.style.left = (((arrayPageSize[0] - 20 - objLoadingImage.width) / 2) + 'px');
		
		imgPreloader.onload=function(){};	//	clear onLoad, as IE will flip out w/animated gifs

		return false;
	}
	
	*/
	imgPreloader.src = loadingImage;
}

function showOverlay()
{

		var objOverlay = document.getElementById('overlay');
		var objLightbox = document.getElementById('lightbox');
		var objCaption = document.getElementById('lightboxCaption');
		var objImage = document.getElementById('lightboxImage');
		var objLoadingImage = document.getElementById('loadingImage');
		var objLightboxDetails = document.getElementById('lightboxDetails');


		var arrayPageSize = getPageSize();
		var arrayPageScroll = getPageScroll();

		// center loadingImage if it exists
		if (objLoadingImage) {
			objLoadingImage.style.top = (arrayPageScroll[1] + ((arrayPageSize[3] - 35 - objLoadingImage.height) / 2) + 'px');
			objLoadingImage.style.left = (((arrayPageSize[0] - 20 - objLoadingImage.width) / 2) + 'px');
			objLoadingImage.style.display = 'block';
		}

		// set height of Overlay to take up whole page and show
		objOverlay.style.height = (arrayPageSize[1] + 'px');
		objOverlay.style.display = 'block';
		
}

function hideOverlay()
{
	// get objects
	objOverlay = document.getElementById('overlay');
	objLoadingImage = document.getElementById('loadingImage');

	// hide lightbox and overlay
	objOverlay.style.display = 'none';
	objLoadingImage.style.display = 'none';

}

function getScreenSize()
{
	if( typeof( window.innerWidth ) == 'number' ) {
	//Non-IE
		screenWidth = window.innerWidth;
		screenHeight = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
	//IE 6+ in 'standards compliant mode'
		screenWidth = document.documentElement.clientWidth;
		screenHeight = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
	//IE 4 compatible
		screenWidth = document.body.clientWidth;
		screenHeight = document.body.clientHeight;
	}
}

function scrollToTop()
{
	scroll(0);
}
switch(browserName)
{
	case "firefox":
	case "mozilla":
		if (OSName == "MacOS") paneDifference = 0;
		break;

	case "safari":
		paneDifference = 2;
		break;
	
	case "msie":
		paneDifference = 2;
		backBodyDif = 35;
		backBodyLeft = 35;
		break;
}

function changeVal(id) {
	s1 = ""
	document.getElementById(id).value = s1
} 

function buildPlayer()
{

	var jukeboxCode = "";
	switch(browserName)
	{

		case "netscape" :
		case "mozilla" :
		case "firefox" :
		case "safari" :
			jukeboxCode = "<embed src=\"jukeboxEMBED_brandi.swf\" wmode=\"transparent\" quality=\"high\" bgcolor=\"#000000\" width=\"205\" height=\"24\"  id=\"jukebox\" name=\"jukebox\" align=\"middle\" allowScriptAccess=\"always\" allowFullScreen=\"false\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" />";
			break;

		default :

			jukeboxCode = "<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0\" width=\"205\" height=\"24\" id=\"jukebox\" align=\"middle\">";
			jukeboxCode += "<param name=\"allowScriptAccess\" value=\"always\" />";
			jukeboxCode += "<param name=\"allowFullScreen\" value=\"false\" />";
			jukeboxCode += "<param name=\"wmode\" value=\"transparent\" />";
			jukeboxCode += "<param name=\"movie\" value=\"jukeboxEMBED_brandi.swf\" />";
			jukeboxCode += "<param name=\"quality\" value=\"high\" />";
			jukeboxCode += "<param name=\"bgcolor\" value=\"#000000\" />";
			jukeboxCode += "<embed src=\"jukeboxEMBED_brandi.swf\" wmode=\"transparent\" quality=\"high\" bgcolor=\"#000000\" width=\"205\" height=\"24\" id=\"jukebox\" name=\"jukebox\" align=\"middle\" allowScriptAccess=\"always\" allowFullScreen=\"false\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" />";
			jukeboxCode += "</object>";
			break;

	}

	document.getElementById('jukeboxDiv').innerHTML = jukeboxCode;
		
}

function stopjukebox()
{

	objectPlaying = getElement('jukebox');
	objectPlaying.stopjukebox();
}

function buildJumbotron()
{

	var jumbotronCode = "";
	switch(browserName)
	{

		case "netscape" :
		case "mozilla" :
		case "firefox" :
		case "safari" :
			jumbotronCode = "<embed src=\"flash/jumbotron.swf\" wmode=\"transparent\" quality=\"high\" bgcolor=\"#000000\" width=\"805\" height=\"200\"  id=\"jumbotron\" name=\"jumbotron\" align=\"middle\" allowScriptAccess=\"always\" allowFullScreen=\"false\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" />";
			break;

		default :

			jumbotronCode = "<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0\" width=\"805\" height=\"200\" id=\"jumbotron\" align=\"middle\">";
			jumbotronCode += "<param name=\"allowScriptAccess\" value=\"always\" />";
			jumbotronCode += "<param name=\"allowFullScreen\" value=\"false\" />";
			jumbotronCode += "<param name=\"wmode\" value=\"transparent\" />";
			jumbotronCode += "<param name=\"movie\" value=\"flash/jumbotron.swf\" />";
			jumbotronCode += "<param name=\"quality\" value=\"high\" />";
			jumbotronCode += "<param name=\"bgcolor\" value=\"#000000\" />";
			jumbotronCode += "<embed src=\"flash/jumbotron.swf\" wmode=\"transparent\" quality=\"high\" bgcolor=\"#000000\" width=\"805\" height=\"200\" id=\"jumbotron\" name=\"jumbotron\" align=\"middle\" allowScriptAccess=\"always\" allowFullScreen=\"false\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" />";
			jumbotronCode += "</object>";
			break;

	}

	document.getElementById('jumbotronDiv').innerHTML = jumbotronCode;
		
}

function toCamelCase(s) {
	for (var exp = /-([a-z])/; exp.test(s); s=s.replace(exp, RegExp.$1.toUpperCase())) {
	}
	return s;
}

function GetXMLHttpObject()
{
      var oXMLHttp = null;

      try
      {
            oXMLHttp = new ActiveXObject("MSXML2.XMLHTTP");
      }
      catch (E)
      {
            try
            {
                  oXMLHttp = new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch (E)
            {
              oXMLHttp = null;
            }
    }

      if ((oXMLHttp == null) && (typeof(XMLHttpRequest) != 'undefined'))
      {
            oXMLHttp = new XMLHttpRequest();
      }

      return oXMLHttp;
}

var ajaxBusy = false;

function loadSection(thisSection, param1, param2)
{
	if(ajaxBusy == true)
	{
		oXMLHttp.onreadystatechange = function () {};
		oXMLHttp.abort();
	}

	switch(thisSection)
	{
		case "store":
			break;
			
		default:
			document.images[oldSection].src = items[oldSection].off.src;
			
			section = oldSection = thisSection;
			document.images[section].src = items[section].on.src;
			break;
	}

	var oXMLHttp = GetXMLHttpObject();
	
	var url="";
	
	switch(section)
	{
	
		case "home":
			showOverlay();
			url="php/home.php";
			break;
			
		case "news":
			showOverlay();
			url="php/news.php";
			if(param1 != null)
			{	
				url += "?start=" + param1;
			}
			break;
			
		case "tours":
			showOverlay();
			url="php/tours.php";
			
			document.getElementById('tertiaryDiv').innerHTML = "";
			
			if(param1 != null)
			{	
				url += "?archiveYear="+param1;
			}
			break;

		case "brandi":
			showOverlay();
			
			url="php/journal.php";
			
			if(param1 != null)
			{	
				url += "?start=" + param1;
			}
			var body = "<div id=\"newsBody\"><p align=\"justify\">Brandi Carlile\'s third album, <i>Give Up The Ghost</i>, unveils her talents in their truest form.  After two albums and non-stop touring, she has let her guard down and offers her most candid recording to date.  If the phrase \"give up the ghost\" most often refers to death or dying, it can also be used to describe the passing of stages in life, of transformation.<br><br> \"To give up the ghost is not just to die since we do it a handful of times throughout our lives.  It\'s a sort of leaving yourself behind,\" she explains.  \"Or what you knew yourself to be so that you can grow and transcend love or youth.  Sometimes both.\"<br><br>The recording of <i>Give Up The Ghost</i> offered new experiences including working with the likes of Elton John, Tom Petty and the Heartbreakers multi-instrumentalist Benmont Tench, drummer Chad Smith and Amy Ray of The Indigo Girls, all of whom contribute to the album.<br><br>For Carlile, the album is one of extremes: \"The songs that are stripped down, raw and bare are that way so it makes the listener feel a little uncomfortable,\" she says. \"And the ones that are huge are really big, with big harmonies, piano, layering electric guitar solos and a string arrangement like at the end of \'Pride and Joy.\'\"<br><br>After debuting with her self-titled album in 2005, the Washington State-bred Carlile saw her fanbase mushroom with her sophomore disc, <i>The Story</i>, in 2007. Among the growing legion of Carlile fans is Elton John. \"Brandi has an amazing voice,\" he says. \"She’s a great songwriter and has a tremendous career ahead of her.\" Proudly, Carlile says that John - who duets with her on the song, \"Caroline\" - played a key a role in her evolution as an artist: \"I\'ve been listening to country and western music my whole life and I was totally immersed in Grand Ole Opry culture, wherein the entertainers are usually not the ones who wrote the music. But when I was 11 and discovered Elton John, I realized that performers do write and perform their own songs, and I immediately went out and got a keyboard and started writing.\"  When they recorded together, \"I was just overwhelmed by the years, and by the influence that somebody can have on another person\'s life without even knowing it.\"<br><br> \"Caroline,\" a playful song inspired by her niece, is one of several songs riddled with confidence and proudly wearing the influence of Carlile\'s recent studio and stage success. Elsewhere, the sparse \"If There Was No You,\" and the passionate, open-hearted \"Looking Out\" are simple, spirited love letters.  On \"That Year,\" Carlile remembers a friend who committed suicide while they were both teenagers. She had a dream about that friend, which led to the song: \"Something like that never really leaves you. At that age, you might not have the coping skills to really understand.\"<br><br><i>Give Up The Ghost</i> was recorded at Sunset Sound in Hollywood, birthplace of legendary recordings by The Doors and Led Zeppelin. The first single, \"Dreams,\" was written with her longtime bandmates, twin brothers Tim and Phil Hanseroth (on guitar and bass, respectively - Carlile\'s band also features cellist Josh Neumann). \"The twins and I sat together in a circle and wrote \'Dreams\' acoustically, with three-part harmonies. We put all of our energy into and it, and played it on the road for a year. But when it came time to record it with a drummer, we couldn\'t get it right. It wasn\'t sounding as energetic as it was supposed to. So we decided to just record it as the three of us. But, unbeknownst to us, in the other room, drums were being recorded as we were playing. It worked - we didn\'t end up changing the way we play it.\"<br><br> If she took root in performing songs by the likes of Patsy Cline as a child, Carlile\'s journey to places like Sunset Sound gained traction during her teen years when she first started playing in bands. Eventually, she and the Hanseroth twins recorded a collection of songs, for which they had modest hopes. To their surprise, those songs became <i>Brandi Carlile</i>, which sold more than 120,000 copies and spawned the popular single \"What Can I Say.\"<br><br>Her second album, <i>The Story</i>, upped the ante considerably, selling 313,000 copies and rising to No. 41 on the Billboard albums chart, and boasting songs like the title track and \"Turpentine.\" Several of Carlile\'s songs have appeared in commercials and on televisions shows such as <i>Grey\'s Anatomy</i>. Along the way, she has toured with the likes of Ray LaMontagne, and Sheryl Crow, who raved about Carlile\'s support performances online: \"She has the most amazing voice I may have ever heard. Soulful. Country. Perfect in every way-and propelled by taste.\"<br><br>With all that encouragement and experience under her belt, when Carlile set out to make <i>Give Up The Ghost</i>, she did so with ample ambition: \"When we recorded <i>The Story</i>, we set up our instruments with one drummer, like a stage, and we treated the record like a show, and we recorded that performance. This is this is the first time we treated something like a record. We really dug in and created an environment specifically for each song. We didn\'t go halfway on anything.\"<br></p></div>";
			document.getElementById('tertiaryDiv').innerHTML = body;
			
			var charity ="<table width=\"770\" height=\"140\" cellspacing=\"0\">";
			charity +="<tr valign=\"top\"><td width=\"350\" height=\"140\" style=\"padding: 20px 20px 0px 0px\">";
			charity +="<table width=\"350\" height=\"110\" cellspacing=\"0\" cellpadding=\"0\"><tr><td height=\"110\" /></tr><tr valign=\"top\"><td width=\"350\" height=\"34\"><div id=\"newsBody\"><p align=\"justify\">Established in 2008, The Looking Out Foundation [501(c)(3)] was created by Brandi Carlile as a way for her to financially support causes and organizations she believes in.</p></div></td></tr></table>";
			charity +="</td>";
			charity +="<td style=\"padding: 20px 0px 0px 0px\"><div id=\"newsBody\"><p align=\"justify\">Although the focus will be mainly on the environment, the foundation will offer grants to a variety of organizations and causes. All donations must be sent to:<br/><br/>The US Charitable Gift Trust<br/>FBO The Looking Out Foundation - Acct 4606<br/>2710 Centerville Road, Suite 101 <br/>Wilmington, DE 19808<br/><br/>To make a donation checks must be made out to \"AST Capital Trust Company of Delaware\" with \"Looking Out Foundation Act No 4606\" in the check memo.  You can also make a donation via Paypal (credit card donations are accepted) to the email address <a href=\"mailto:lookingoutfoundation@cpahelpme.com\">lookingoutfoundation@cpahelpme.com</a>.  Brandi donates $1 from every concert ticket sold to the Looking Out Foundation.  Grant requests can be emailed to <a href=\"mailto:mark@awaremusic.com\">mark@awaremusic.com</a></p></div></td></tr>";
			charity +="<tr valign=\"top\" colspan=\"2\"><td height=\"15\" colspan=\"2\"><div id=\"newsBody\"><p align=\"justify\">The Looking Out Foundation has offered grants to the following organizations -- Fight The Fear Campaign, The If Project, Maple Valley Food Bank, Honor The Earth, Reverb, MOFGA, United Nations World Food Programme, Yele, Global Health, Common Ground Church, American Diabetes Association, Covenant Nursery School and Captain Planet Foundation. For more information contact Mark Cunningham at: A-Squared Management  - <a href=\"mailto:mark@awaremusic.com\">mark@awaremusic.com</a></p></div></td></tr></table>";
			
			document.getElementById('secondaryDiv').innerHTML = charity;
			break;	

		case "contact":	
			showOverlay();
			url="php/contact.php";
			break;
			
		case "photos":
			showOverlay();
			if (param1 == null)
			{
				param1 = 0;
			}
			
			var url="php/photos.php?galleryId="+param1;
			
			if (param2 != null)
			{
				url +="&imageId="+param2;
			}
			
			break;
			
		case "video":
			url="php/video.php";
			break;
			
		case "music":
			showOverlay();
			url="php/albums.php";
			break;
	}

	oXMLHttp.open("GET", url, true);

	oXMLHttp.onreadystatechange = function()
	    {
		  if (oXMLHttp.readyState == 4)
		  {
		  	hideOverlay();
		  	ajaxBusy = false;
		  	var contentDiv = document.getElementById('content');
		  	var secondaryDiv = document.getElementById('secondaryDiv');
		  	var tertiaryDiv = document.getElementById('tertiaryDiv');
		  	var holderDiv = document.getElementById('contentHolder');
		  	var footerDiv = document.getElementById('footer');
		  	var jumbotronDiv = document.getElementById('jumbotronDiv');
			
			switch(section)
			{
				case "news":
				case "contact":
					contentDiv.innerHTML = oXMLHttp.responseText;
					holderDiv.style.height = (contentDiv.offsetHeight + 335)+"px";
					setContentBackground(section, contentDiv, contentDiv.offsetHeight);
					break;

				case "brandi":
					contentDiv.innerHTML = oXMLHttp.responseText;
					holderDiv.style.height = (contentDiv.offsetHeight + 335)+"px";
					setContentBackground(section, contentDiv, contentDiv.offsetHeight);
					break;
					
				case "home":
				
					var JSONObject = new Object;
					var response = oXMLHttp.responseText;
					
					JSONObject = JSON.parse(response);
					
					contentDiv.innerHTML = JSONObject.newsAndTours;
					holderDiv.style.height = (contentDiv.offsetHeight + 335)+"px";
					setContentBackground(section, contentDiv, contentDiv.offsetHeight);
					break;
					
				case "tours":
				
					var JSONObject = new Object;
					var response = oXMLHttp.responseText;
					
					JSONObject = JSON.parse(response);
					
					contentDiv.innerHTML = JSONObject.tourdates;
					holderDiv.style.height = (contentDiv.offsetHeight + 335)+"px";
					var archiveNav = "";
					archiveNav += "<div id=\"tourCurrent\" style=\"height: 40px;\">";
					archiveNav += "<A HREF=\"javascript:void(0);\" onclick=\"loadSection('tours', null);return false;\"><IMG NAME=\"upcoming\" SRC=\"images/tour.upcoming.off.gif\" WIDTH=\"83\" HEIGHT=\"18\" BORDER=\"0\"/></A>";
					archiveNav += "</div>";
					archiveNav += "<div id=\"tourArchives\" style=\"height: 40px; width: 250px\">";
					archiveNav += "<A HREF=\"javascript:void(0);\" onclick=\"loadSection('tours', '2010');return false;\"><IMG NAME=\"2009\" SRC=\"images/tour.2010.off.gif\" WIDTH=\"45\" HEIGHT=\"18\" BORDER=\"0\"/></A>";
					archiveNav += "<A HREF=\"javascript:void(0);\" onclick=\"loadSection('tours', '2009');return false;\"><IMG NAME=\"2009\" SRC=\"images/tour.2009.off.gif\" WIDTH=\"45\" HEIGHT=\"18\" BORDER=\"0\"/></A>";
					archiveNav += "<A HREF=\"javascript:void(0);\" onclick=\"loadSection('tours', '2008');return false;\"><IMG NAME=\"2008\" SRC=\"images/tour.2008.off.gif\" WIDTH=\"45\" HEIGHT=\"18\" BORDER=\"0\"/></A>";
					archiveNav += "<A HREF=\"javascript:void(0);\" onclick=\"loadSection('tours', '2007');return false;\"><IMG NAME=\"2007\" SRC=\"images/tour.2007.off.gif\" WIDTH=\"45\" HEIGHT=\"18\" BORDER=\"0\"/></A>";
					archiveNav += "<A HREF=\"javascript:void(0);\" onclick=\"loadSection('tours', '2006');return false;\"><IMG NAME=\"2006\" SRC=\"images/tour.2006.off.gif\" WIDTH=\"45\" HEIGHT=\"18\" BORDER=\"0\"/></A>";
					archiveNav += "<A HREF=\"javascript:void(0);\" onclick=\"loadSection('tours', '2005');return false;\"><IMG NAME=\"2005\" SRC=\"images/tour.2005.off.gif\" WIDTH=\"45\" HEIGHT=\"18\" BORDER=\"0\"/></A>";
					archiveNav += "</div>";

					document.getElementById('secondaryDiv').innerHTML = archiveNav;
					setContentBackground(section, contentDiv, contentDiv.offsetHeight);

					switch(JSONObject.tourType)
					{
						case "upcoming":
							contentDiv.style.width = "750px";
							tertiaryDiv.style.height = "0px";
							break;
							
						case "past":
							contentDiv.style.width = "560px";
							tertiaryDiv.style.height = "500px";
							break;
					}
					
					break;
					
				case "photos":
					var JSONObject = new Object;
					
					var response = oXMLHttp.responseText;

					photoAlbums = JSON.parse(response);

					contentDiv.innerHTML = photoAlbums.thumbnails;
					loadGalleryListing(photoAlbums.albums, photoAlbums.id, photoAlbums.desc);
					loadPhoto(photoAlbums.albums.album[photoAlbums.id].photos.photo[photoAlbums.imageId].img['@attributes']['src'], photoAlbums.imageId, photoAlbums.id);
					holderDiv.style.height = (contentDiv.offsetHeight + 335)+"px";
					
					setContentBackground(section, contentDiv, (contentDiv.offsetHeight + 360));
					break;
					
				case "video":
					var JSONObject = new Object;
					
					var response = oXMLHttp.responseText;

					videos = JSON.parse(response);

					secondaryDiv.innerHTML = videos.videoData;
					loadVideo(videos.videos.video[0].video_id, 'myPlay' ,'0');
					
					holderDiv.style.height = (contentDiv.offsetHeight + 335)+"px";
					
					setContentBackground(section, contentDiv, (contentDiv.offsetHeight + 360));
					break;

				case "music":
					var JSONObject = new Object;
					
					var response = oXMLHttp.responseText;
					
					JSONObject = JSON.parse(response);

					discography = JSONObject.discography;
					
					contentDiv.innerHTML = JSONObject.thumbnails;
					loadAlbums();
					holderDiv.style.height = (contentDiv.offsetHeight + 335)+"px";
					
					break;
			}
			
			$(document).pngFix();
		  }
	    }

	oXMLHttp.send(null);
	ajaxBusy = true;
}



function loadTourInfo(eventId)
{

	document.getElementById('tertiaryDiv').innerHTML = "<table width=\"200\" cellspacing=\"10\" cellpadding=\"0\"><tr><td><img src=\"images/tours.info.header.gif\" width=\"30\" height=\"17\" /></td></tr><tr><td><span id=\"tourTitle\">Loading Info...</span></td></tr></table>";
	document.getElementById('tertiaryDiv').style.top = thisY+"px";
	
	var oXMLHttp = GetXMLHttpObject();

	var url="php/tourInfo.php?eventId="+eventId;
	
	oXMLHttp.open("GET", url, true);

	oXMLHttp.onreadystatechange = function()
	    {
		  if (oXMLHttp.readyState == 4)
		  {
		  	document.getElementById('tertiaryDiv').innerHTML = oXMLHttp.responseText;
		  	//scrollToTop();
		  }
	    }

	oXMLHttp.send(null);
}

function loadAlbums() {

	function track(name, url)
	{
		this.name = name;
		this.url = url;
	}
	
	function releaseDate(terrirtory, date)
	{
		this.territory = territory;
		this.date = date;
	}

	function newBuyLink(type, link)
	{
		this.buyType = type;
		this.href = link;
	}
	
	var albumListing = "";
	
	albumListings = "<table width=\"730\" cellspacing=\"0\" cellpadding=\"0\">";
	albumListings += "<tr valign=\"top\" align=\"left\">";
	albumListings += "<td><img src=\"images/studioalbums.gif\" width=\"122\" height=\"28\" /></td></tr>";
	albumListings += "<tr valign=\"top\" align=\"left\">";
	albumListings += "<td><table width=\"730\" cellspacing=\"0\" cellpadding=\"0\">";
	albumListings += "<tr valign=\"top\" align=\"left\">";
	
	var counter = 0;
	
	for(x= 0; x < discography.albums.album.length; x++)
	{
		if(discography.albums.album[x]['@attributes']['type'] == "fullLength")
		{
			var mini = discography.albums.album[x].img['@attributes']['src'];
			var title = discography.albums.album[x].titles.official;
			var alternateTitle = discography.albums.album[x].titles.alternate;
			var info = discography.albums.album[x].titles.description;
			if (typeof discography.albums.album[x].releaseDates.releaseDate.length == 'undefined')
			{
				var localDate = discography.albums.album[x].releaseDates.releaseDate.date;
			} else {
				var localDate = discography.albums.album[x].releaseDates.releaseDate[0].date;
			}

			albumListings += "<td width=\"115\" height=\"215\" style=\"padding:0px 7px 5px 0px;\">";
			albumListings += "<table cellspacing=\"0\" cellpadding=\"0\">";
			albumListings += "<tr><td style=\"border-style: solid; border-color: #362719; border-width:1px;\"><table cellspacing=\"2\" cellpadding=\"0\">";
			albumListings += "<tr valign=\"top\"><td><a href=\"#\" onclick=\"loadAlbum('"+ x +"');\"><img src=\""+ mini+"\" width=\"115\" height=\"115\" border=\"0\" /></a></td></tr>";
			albumListings += "<tr valign=\"top\"><td height=\"55\"><span id=\"musicTitle\">"+ title +"</span><br /><span id=\"musicNotes\">"+ localDate+"</span></td></tr>";
			
			var buyLinks = new Array();
			
			if (typeof discography.albums.album[x].buyLinks.buyLink != 'undefined')
			{
				if (typeof discography.albums.album[x].buyLinks.buyLink.length == 'undefined')
				{
					var buyType = discography.albums.album[x].buyLinks.buyLink.type;
					var buyHref = discography.albums.album[x].buyLinks.buyLink.href;
					var thisBuyLink = new newBuyLink(buyType, buyHref);
					buyLinks.push(thisBuyLink);
				} else {
					for(z = 0; z < discography.albums.album[x].buyLinks.buyLink.length; z++)
					{
						var buyType = discography.albums.album[x].buyLinks.buyLink[z].type;
						var buyHref = discography.albums.album[x].buyLinks.buyLink[z].href;
						var thisBuyLink = new newBuyLink(buyType, buyHref);
						buyLinks.push(thisBuyLink);
					}
				}			
			}		

			albumListings += "<tr align=\"center\"><td height=\"20\"><table cellspacing=\"0\" cellpadding=\"0\"><tr>";			
			
			if (typeof buyLinks.length != 'undefined')
			{
				for(y = 0; y < buyLinks.length; y++)
				{
					switch(buyLinks[y].buyType)
					{
						case "vinyl":
							buyImage = "images/vinyl.gif";
							buyWidth = 50;
							buyUrl = buyLinks[y].href;
							break;
							
						case "cd":
							buyImage = "images/cd.gif";
							buyWidth = 50;
							buyUrl = buyLinks[y].href;
							break;

						case "digital":
							buyImage = "images/itunes.gif";
							buyWidth = 44;
							buyUrl = buyLinks[y].href;
							break;

					}
					albumListings += "<td style=\"padding: 0px 2px 0px 2px\"><a href=\""+buyUrl+"\" target=\"_blank\"><img src=\""+ buyImage +"\" width=\""+ buyWidth +"\" height=\"16\" border=\"0\" /></a></td>";
				}
			}
			
			
			albumListings += "</tr></table></td></tr>";
			
			albumListings += "</table></td></tr></table>";
			albumListings += "</td>";
			counter++;
			if (counter % 6 == 0 && x != 0)
			{
				albumListings += "</tr><tr valign=\"top\" align=\"left\">";
			}
		}
	}
	
	if (counter < 6)
	{
		for(y = 0; y < (6 - counter); y++)
		{
			albumListings += "<td width=\"115\" style=\"padding:0px 7px 5px 0px\">";
		}
	} else {
		for(y = 0; y < (counter % 6); y++)
		{
			albumListings += "<td width=\"115\" style=\"padding:0px 7px 5px 0px\">";
		}
	}

	albumListings += "</tr>";
	albumListings += "</table>";
	albumListings += "</td></tr>";
	albumListings += "<tr><td height=\"20\" /></tr>";	
	albumListings += "<tr valign=\"top\" align=\"left\">";
	albumListings += "<td><img src=\"images/epsandsingles.gif\" width=\"133\" height=\"28\" /></td></tr>";
	albumListings += "<tr valign=\"top\" align=\"left\">";
	albumListings += "<td><table width=\"730\" cellspacing=\"0\" cellpadding=\"0\">";
	albumListings += "<tr valign=\"top\" align=\"left\">";
	
	counter = 0;

	for(x= 0; x < discography.albums.album.length; x++)
	{
		if(discography.albums.album[x]['@attributes']['type'] == "epSingle")
		{
			var mini = discography.albums.album[x].img['@attributes']['src'];
			var title = discography.albums.album[x].titles.official;
			var alternateTitle = discography.albums.album[x].titles.alternate;
			var info = discography.albums.album[x].titles.description;
			if (typeof discography.albums.album[x].releaseDates.releaseDate.length == 'undefined')
			{
				var localDate = discography.albums.album[x].releaseDates.releaseDate.date;
			} else {
				var localDate = discography.albums.album[x].releaseDates.releaseDate[0].date;
			}

			albumListings += "<td width=\"115\" height=\"215\" style=\"padding:0px 7px 5px 0px;\">";
			albumListings += "<table cellspacing=\"0\" cellpadding=\"0\">";
			albumListings += "<tr><td style=\"border-style: solid; border-color: #362719; border-width:1px;\"><table cellspacing=\"2\" cellpadding=\"0\">";
			albumListings += "<tr valign=\"top\"><td><a href=\"#\" onclick=\"loadAlbum('"+ x +"');\"><img src=\""+ mini+"\" width=\"115\" height=\"115\" border=\"0\" /></a></td></tr>";
			albumListings += "<tr valign=\"top\"><td height=\"55\"><span id=\"musicTitle\">"+ title +"</span><br /><span id=\"musicNotes\">"+ localDate+"</span></td></tr>";
			
			var buyLinks = new Array();
			
			if (typeof discography.albums.album[x].buyLinks.buyLink != 'undefined')
			{
				if (typeof discography.albums.album[x].buyLinks.buyLink.length == 'undefined')
				{
					var buyType = discography.albums.album[x].buyLinks.buyLink.type;
					var buyHref = discography.albums.album[x].buyLinks.buyLink.href;
					var thisBuyLink = new newBuyLink(buyType, buyHref);
					buyLinks.push(thisBuyLink);
				} else {
					for(z = 0; z < discography.albums.album[x].buyLinks.buyLink.length; z++)
					{
						var buyType = discography.albums.album[x].buyLinks.buyLink[z].type;
						var buyHref = discography.albums.album[x].buyLinks.buyLink[z].href;
						var thisBuyLink = new newBuyLink(buyType, buyHref);
						buyLinks.push(thisBuyLink);
					}
				}			
			}
			
			albumListings += "<tr align=\"center\"><td height=\"20\"><table cellspacing=\"2\" cellpadding=\"0\"><tr>";			
			
			if (typeof buyLinks.length != 'undefined')
			{
				for(y = 0; y < buyLinks.length; y++)
				{
					switch(buyLinks[y].buyType)
					{
						case "vinyl":
							buyImage = "images/vinyl.gif";
							buyWidth = 50;
							buyUrl = buyLinks[y].href;
							break;
							
						case "cd":
							buyImage = "images/cd.gif";
							buyWidth = 50;
							buyUrl = buyLinks[y].href;
							break;

						case "digital":
							buyImage = "images/itunes.gif";
							buyWidth = 44;
							buyUrl = buyLinks[y].href;
							break;

					}
					albumListings += "<td style=\"padding: 0px 2px 0px 2px\"><a href=\""+buyUrl+"\" target=\"_blank\"><img src=\""+ buyImage +"\" width=\""+ buyWidth +"\" height=\"16\" border=\"0\" /></a></td>";
				}
			}
			
			
			albumListings += "</tr></table></td></tr>";
			
			albumListings += "</table></td></tr></table>";
			albumListings += "</td>";

			counter++;
			if (counter % 6 == 0 && x != 0)
			{
				albumListings += "</tr><tr valign=\"top\" align=\"left\">";
			}
		}
	}
	
	if (counter < 6)
	{
		for(y = 0; y < (6 - counter); y++)
		{
			albumListings += "<td width=\"115\" style=\"padding:0px 7px 5px 0px\">";
		}
	} else {
		for(y = 0; y < (counter % 6); y++)
		{
			albumListings += "<td width=\"115\" style=\"padding:0px 7px 5px 0px\">";
		}
	}	

	albumListings += "</tr>";
	albumListings += "</table>";
	albumListings += "</td></tr>";
	
	document.getElementById('content').innerHTML = albumListings;
	
	loadAlbum(0);
}

function loadAlbum(albumId)
{

	function track(name, url)
	{
		this.name = name;
		this.url = url;
	}
	
	function releaseDate(date, territory)
	{
		this.territory = territory;
		this.date = date;
	}
	
	var x = albumId;
	var mini = discography.albums.album[x].img['@attributes']['src'];
	var titleImage = discography.albums.album[x].titleImg['@attributes']['src'];
	var title = discography.albums.album[x].titles.official;
	var alternateTitle = discography.albums.album[x].titles.alternate;
	var info = discography.albums.album[x].description;

	var releaseDates = new Array();
	
	
	if (typeof discography.albums.album[x].releaseDates.releaseDate.length == 'undefined')
	{
		var thisDate = discography.albums.album[x].releaseDates.releaseDate.date;
		var thisTerritory = discography.albums.album[x].releaseDates.releaseDate.territory;
		var thisReleaseDate = new releaseDate(thisDate, thisTerritory);

		releaseDates.push(thisReleaseDate);
	} else {
		for(z = 0; z < discography.albums.album[x].releaseDates.releaseDate.length; z++)
		{
			var thisDate = discography.albums.album[x].releaseDates.releaseDate[z].date;
			var thisTerritory = discography.albums.album[x].releaseDates.releaseDate[z].territory;
			var thisReleaseDate = new releaseDate(thisDate, thisTerritory);

			releaseDates.push(thisReleaseDate);
		}
	}


	var tracks = new Array();

	if (typeof discography.albums.album[x].tracks.track.length == 'undefined')
	{
		var trackTitle = discography.albums.album[x].tracks.track.title;
		var buyUrl = discography.albums.album[x].tracks.track.buy;

		var thisTrack = new track(trackTitle, buyUrl);
		tracks.push(thisTrack);
	} else {
		for(z= 0; z < discography.albums.album[x].tracks.track.length; z++)
		{
			var trackTitle = discography.albums.album[x].tracks.track[z].title;
			var previewUrl = discography.albums.album[x].tracks.track[z].preview;

			var thisTrack = new track(trackTitle, previewUrl);
			tracks.push(thisTrack);
		}
	}
	
	var albumListing = "";
	albumListing += "<table width=\"730\" cellspacing=\"0\" cellpadding=\"0\">";
	albumListing += "<tr valign=\"bottom\">";
	albumListing += "<td align=\"left\" style=\"padding: 0px 17px 0px 0px\"><img src=\""+titleImage+"\" /></td><td style=\"padding: 0px 17px 0px 0px\"><table width=\"300\" cellspacing=\"0\" cellpadding=\"0\"><tr align=\"left\"><td width=\"76\"><img src=\"images/tracks_header.png\" width=\"76\" height=\"32\" /></td><td width=\"220\" align=\"right\"></td></tr></table></td><td><img src=\"images/release_header.png\" width=\"137\" height=\"31\" /></td>";
	albumListing += "</tr>";
	albumListing += "<tr valign=\"top\">";
	albumListing += "<td align=\"left\" style=\"padding: 0px 17px 0px 5px\"><img src=\""+mini+"\" width=\"235\" height=\"235\" style=\"border-style: solid; border-color: #362719; border-width:1px;\"/></td>";
	albumListing += "<td align=\"left\" style=\"padding: 0px 17px 0px 0px\"><table width=\"300\" cellspacing=\"0\" cellpadding=\"0\">";
	
	for(trackCount = 0; trackCount < tracks.length; trackCount++)
	{
		if(trackCount % 2 == 0)
		{
			bgcolor="#26211a";
		} else {
			bgcolor="transparent";
		}
		
		albumListing += "<tr valign=\"top\"><td width=\"260\" align=\"left\" style=\"padding: 2px 0px 2px 0px; background-color: "+ bgcolor + "\"><span id=\"musicNotes\">"+tracks[trackCount].name+"</span></td><td width=\"40\" align=\"center\" style=\"background-color: "+ bgcolor + "\">";
		
		if(typeof tracks[trackCount].url == 'string')
		{
			var playerTitle = "audioPlayer"+ trackCount;
			albumListing += "<div id=\""+playerTitle+"\" style=\"padding: 3px 0px 0px 0px\"> "+placePreview(playerTitle, tracks[trackCount].url, trackCount); +"</div>";
		}
		albumListing += "</td>";
	}
	
	
	albumListing += "</table></td>";
	albumListing += "<td><table width=\"200\" cellspacing=\"0\" cellpadding=\"0\">";
	
	for(dateCount = 0; dateCount < releaseDates.length; dateCount++)
	{
		albumListing += "<tr valign=\"top\"><td height=\"10\"><span id=\"musicDateBold\">"+releaseDates[dateCount].territory+"</span><span id=\"musicDate\">: "+releaseDates[dateCount].date+"</span></td></tr>";
	}
	
	albumListing += "</table></td>";
	albumListing += "</tr></table>";
	
	document.getElementById('secondaryDiv').innerHTML = albumListing;
	
	$(document).pngFix();
	
	var contentDiv = document.getElementById('content');
	var secondaryDiv = document.getElementById('secondaryDiv');
	setContentBackground(section, contentDiv, (contentDiv.offsetHeight + 350));
}

var totalPhotos;

function loadGalleryListing(albums, galleryId, description)
{
	totalPhotos = albums.album[galleryId].photos.photo.length - 1;
	var albumlisting = "";
	var albumInfo = "";
	
	var galleryListing = "";
	
	galleryListing += "<table width=\"200\" cellspacing=\"0\" cellpadding=\"0\">";
	galleryListing += "<tr valign=\"top\">";
	galleryListing += "<td height=\"17\"><img src=\""+albums.album[galleryId].header['@attributes']['src']+"\" /></td></tr>";
	galleryListing += "</tr>";
	galleryListing += "<tr valign=\"top\">";
	galleryListing += "<td><span id=\"galleryInfo\">"+ albums.album[galleryId].photos.photo.length +" photos</span></td>";
	galleryListing += "</tr>";
	
	if (description != null)
	{
		galleryListing += "<tr valign=\"top\">";
		galleryListing += "<td height=\"150\"><span id=\"galleryInfo\">"+ description +"</span></td>";
		galleryListing += "</tr>";
	}
	galleryListing += "<tr valign=\"top\"><td><hr size=\"1\" color=\"#eae1d8\"></td></tr>";
	
	for(x= 0; x < albums.album.length; x++)
	{	
		galleryListing += "<tr valign=\"top\">";
		galleryListing += "<td height=\"40\"><a href=\"#\" onclick=\"loadSection('photos', '"+ x +"'); return false;\"><img src=\""+albums.album[x].header['@attributes']['src']+"\" border=\"0\" /></a></td></tr>";
		galleryListing += "</tr>";

	}
	galleryListing += "</table>";
	
	document.getElementById('tertiaryDiv').innerHTML = galleryListing;
	
	
}

function loadPhoto(url, imageId, galleryId)
{
	imageId = parseInt(imageId);
	imageText = "<table width=\"530\" height=\"430\" cellspacing=\"0\" cellpadding=\"0\"><tr valign=\"middle\" align=\"left\"><td height=\"430\"><img src=\""+url+"\" /></td></tr>";
	imageText += "<tr><td><table width=\"530\" height=\"20\" cellspacing=\"0\" cellpadding=\"0\"><tr align=\"center\" valign=\"top\"><td width=\"86\" height=\"20\">";
	
	if(imageId > 0) 
	{
		thisImageId = imageId - 1;
		imageUrl = photoAlbums.albums.album[galleryId].photos.photo[thisImageId].img['@attributes']['src'];
		imageText += "<a href=\"#\" onclick=\"loadPhoto('" + imageUrl +"', '"+ thisImageId +"', '" + galleryId +"'); return false;\"><img src=\"images/photoBackButton.gif\" width=\"86\" height=\"20\" border=\"0\"></a>";
	}


	if(photoAlbums.albums.album[galleryId].photos.photo[imageId].caption != undefined) 
	{
		caption = photoAlbums.albums.album[galleryId].photos.photo[imageId].caption;
		imageText += "</td><td width=\"358\" style=\"padding: 3px 0px 0px 0px\"><span id=\"galleryInfo\">" + caption +"<td width=\"86\" height=\"20\">";
		
	} else {
		imageText += "</td><td width=\"358\"><td width=\"86\" height=\"20\">";
	}

	
	//imageText += "</td><td width=\"358\"><td width=\"86\" height=\"20\">";

	if(imageId < totalPhotos) 
	{
		nextImageId = imageId + 1;
		imageUrl = photoAlbums.albums.album[galleryId].photos.photo[nextImageId].img['@attributes']['src'];
		imageText += "<a href=\"#\" onclick=\"loadPhoto('" + imageUrl +"', '"+ nextImageId +"', '" + galleryId +"'); return false;\"><img src=\"images/photoNextButton.gif\" width=\"86\" height=\"20\" border=\"0\"></a>";
	}
	
	imageText += "</tr></table></td></tr>";
	imageText += "</table>";
	
	document.getElementById('secondaryDiv').innerHTML = imageText;
}

function loadVideo(videoId, videoType, videoCount)
{
	stopjukebox();
	var videoPlayerCode ="<table width=\"544\" height=\"360\" cellspacing=\"0\" cellpadding=\"0\">";
	videoPlayerCode += "<tr valign=\"top\" align=\"left\"><td><div id=\"videoDiv\">";
	videoPlayerCode += "</div></td></tr></table>";
	document.getElementById('content').innerHTML = videoPlayerCode;
	switch(videoType)
	{
		case "myPlay":
			var config = new Array();
			config["videoId"] = videoId;
			config["lineupId"] = null;
			config["playerTag"] = "";
			config["autoplay"] = true;
			config["automatedPlay"] = false;
			config["preloadBackColor"] = "#ffffff";
			config["externalAds"] = true;
			config["playerId"] = 1138430364;
			config["width"] = 544;
			config["height"] = 422;
			createExperience(config, 8, 'videoDiv');
			document.getElementById('secondaryDiv').style.top = "545px";
			break;
			
		case "youTube":
			youTubecode = "<object width=\"544\" height=\"440\"><param name=\"movie\" value=\""+ videoId +"\"></param><param name=\"wmode\" value=\"transparent\"></param><param name=\"allowFullScreen\" value=\"true\"></param><param name=\"allowscriptaccess\" value=\"always\"></param><embed src=\""+ videoId +"\" type=\"application/x-shockwave-flash\" wmode=\"transparent\" allowscriptaccess=\"always\" allowfullscreen=\"true\" width=\"544\" height=\"440\"></embed></object>";
			document.getElementById('videoDiv').innerHTML = youTubecode ;
			document.getElementById('secondaryDiv').style.top = "566px";
			break;
	}
	
	var videoInfo ="<table width=\"220\" height=\"425\" cellspacing=\"0\" cellpadding=\"0\">";
	videoInfo+= "<tr valign=\"top\" align=\"left\"><td width=\"220\"><img src=\"images/tours.info.header.gif\" width=\"30\" height=\"17\" /><br/>";
	videoInfo += "<span id=\"tourTitle\">"+ videos.videos.video[videoCount].video_title+"</span><br/><br/>";
	videoInfo += "<span id=\"tourNotes\">"+ videos.videos.video[videoCount].description+"</span></td></tr>";
	videoInfo += "</table>";
	document.getElementById('tertiaryDiv').innerHTML = videoInfo;
}

function submitEmail()
{

	var thisEmail = document.getElementById('email').value;

	var url = "signup.php?email="+thisEmail;

	var options = "menubar=0,toolbar=0,location=0,directories=0,status=0,scrollbars=0,resizable=0";
	
	launch(url, "download", 480, 500, options);

}

function setContentBackground(section, divId, divHeight)
{
	var offset = 105;
	var container = document.getElementById('container');
	var bgHeader = document.getElementById('bgHeader');
	var bgBody = document.getElementById('bgBody');
	var bgFooter = document.getElementById('bgFooter');
	var footerDiv = document.getElementById('footer');
	var jumbotronDiv = document.getElementById('jumbotronDiv');
	switch(section)
	{
	
		case "home":
			
			jumbotronDiv.style.height = "200px";
			bgHeader.style.left = "-10px";
			bgHeader.style.width = "883px";
			bgHeader.style.height = "273px";
			bgHeader.style.background ="transparent url(images/home_header.jpg) no-repeat center top";
			
			bgBody.style.background = "transparent url(images/body_background.png) repeat-y right top";
			bgBody.style.left = "-10px";
			bgBody.style.width = "883px";
			if (divHeight >= 550)
			{
				bgBody.style.height = (divHeight + 30) +"px";
				footerDiv.style.top = "140px";
			} else {
				bgBody.style.height = "545px";
				footerDiv.style.top = "110px";
			}
			
			
			bgFooter.style.left = "-10px";
			bgFooter.style.width = "883px";
			bgFooter.style.height = "197px";
			
			bgFooter.style.background =" transparent url(images/body_footer_standard.png) no-repeat right top";
			
			$(document).pngFix();
			break;
			
		case "news":
			jumbotronDiv.style.height = "200px";
			bgHeader.style.left = "-10px";
			bgHeader.style.width = "883px";
			bgHeader.style.height = "273px";
			bgHeader.style.background ="transparent url(images/news_header.jpg) no-repeat center top";
			
			bgBody.style.background = "transparent url(images/body_background.png) repeat-y right top";
			bgBody.style.left = "-10px";
			bgBody.style.width = "883px";
			
			if (divHeight >= 550)
			{
				bgBody.style.height = (divHeight + 30) +"px";
			} else {
				bgBody.style.height = "550px";
			}
			
			
			
			
			bgFooter.style.left = "-10px";
			bgFooter.style.width = "883px";
			bgFooter.style.height = "197px";
			
			bgFooter.style.background =" transparent url(images/body_footer_standard.png) no-repeat right top";
			
			var footerDiv = document.getElementById('footer');
			footerDiv.style.top = "140px";
			
			$(document).pngFix();
			break;
			
		case "tours":
			
			jumbotronDiv.style.height = "200px";
			bgHeader.style.left = "-10px";
			bgHeader.style.width = "883px";
			bgHeader.style.height = "280px";
			bgHeader.style.background ="transparent url(images/tours_header.jpg) no-repeat center top";
			
			bgBody.style.left = "-10px";
			bgBody.style.width = "883px";
			
			var footerDiv = document.getElementById('footer');
			
			bgBody.style.height = (divHeight + 30) +"px";
			footerDiv.style.top = "357px";
			/*
			if (divHeight >= 350)
			{
				bgBody.style.height = (divHeight + 30) +"px";
				footerDiv.style.top = "357px";
			} else {
				bgBody.style.height = "350px";
				footerDiv.style.top = (350 + 105) +"px";
				
			}
			*/
			
			bgBody.style.background = "transparent url(images/body_background.png) repeat-y right top";
			
			bgFooter.style.left = "-15px";
			bgFooter.style.width = "883px";
			bgFooter.style.height = "407px";
			
			bgFooter.style.background =" transparent url(images/body_footer_tour.png) no-repeat right top";
		
			$(document).pngFix();
			break;
			
		case "contact":

			bgHeader.style.left = "-10px";
			bgHeader.style.width = "883px";
			bgHeader.style.height = "240px";
			bgHeader.style.background ="transparent url(images/"+ section +"_header.jpg) no-repeat center top";
			
			bgBody.style.left = "-10px";
			bgBody.style.width = "883px";
			
			var footerDiv = document.getElementById('footer');
			
			if (divHeight >= 550)
			{
				bgBody.style.height = (divHeight - 171) +"px";
			} else {
				bgBody.style.height = (350 - 171) +"px";
			}
			
			
			bgBody.style.background = "transparent url(images/body_background.png) repeat-y right top";
			
			bgFooter.style.left = "-10px";
			bgFooter.style.width = "883px";
			bgFooter.style.height = "197px";
			footerDiv.style.top = "-95px";
			
			bgFooter.style.background =" transparent url(images/body_footer_standard.png) no-repeat right top";
		
			jumbotronDiv.style.height = "0px";
			$(document).pngFix();
			break;
			
		case "brandi":

			jumbotronDiv.style.height = "0px";
			bgHeader.style.left = "-10px";
			bgHeader.style.width = "883px";
			bgHeader.style.height = "335px";
			bgHeader.style.background ="transparent url(images/"+ section +"_header.jpg) no-repeat center top";
			
			bgBody.style.left = "-10px";
			bgBody.style.width = "883px";
			if (divHeight >= 550)
			{
				bgBody.style.height = (divHeight + 30) +"px";
			} else {
				bgBody.style.height = "550px";
			}
			
			
			bgBody.style.background = "transparent url(images/body_background.png) repeat-y right top";
			
			bgFooter.style.left = "-10px";
			bgFooter.style.width = "883px";
			bgFooter.style.height = "197px";
			
			bgFooter.style.background =" transparent url(images/body_footer_standard.png) no-repeat right top";
			
			var footerDiv = document.getElementById('footer');
			footerDiv.style.top = "200px";
			
			$(document).pngFix();
			break;
			
		case "photos":

			bgHeader.style.left = "-10px";
			bgHeader.style.width = "883px";
			bgHeader.style.height = "240px";
			bgHeader.style.background ="transparent url(images/"+ section +"_header.jpg) no-repeat center top";
			
			bgBody.style.left = "-10px";
			bgBody.style.width = "883px";
			var footerDiv = document.getElementById('footer');
			if (divHeight >= 550)
			{
				bgBody.style.height = (divHeight - 146) +"px";
				footerDiv.style.top = "290px";
			} else {
				bgBody.style.height = (550 - 209) +"px";
				footerDiv.style.top = "346px";
			}
			
			
			bgBody.style.background = "transparent url(images/body_background.png) repeat-y right top";
			
			bgFooter.style.left = "-10px";
			bgFooter.style.width = "883px";
			bgFooter.style.height = "197px";
			
			bgFooter.style.background =" transparent url(images/body_footer_standard.png) no-repeat right top";
			
			jumbotronDiv.style.height = "0px";
			
			$(document).pngFix();
			break;
			
		case "video":

			bgHeader.style.left = "-10px";
			bgHeader.style.width = "883px";
			bgHeader.style.height = "240px";
			bgHeader.style.background ="transparent url(images/"+ section +"_header.jpg) no-repeat center top";
			
			bgBody.style.left = "-10px";
			bgBody.style.width = "883px";
			
			var footerDiv = document.getElementById('footer');
			
			if (divHeight >= 550)
			{
				bgBody.style.height = (divHeight - 171) +"px";
			} else {
				bgBody.style.height = (550 - 171) +"px";
			}
			
			
			bgBody.style.background = "transparent url(images/body_background.png) repeat-y right top";
			
			bgFooter.style.left = "-10px";
			bgFooter.style.width = "883px";
			bgFooter.style.height = "197px";
			footerDiv.style.top = "266px";
			
			bgFooter.style.background =" transparent url(images/body_footer_standard.png) no-repeat right top";
		
			
			$(document).pngFix();
			break;
			
		case "music":

			jumbotronDiv.style.height = "200px";			
			bgHeader.style.left = "-10px";
			bgHeader.style.width = "883px";
			bgHeader.style.height = "280px";
			bgHeader.style.background ="transparent url(images/"+ section +"_header.jpg) no-repeat center top";
			
			bgBody.style.left = "-10px";
			bgBody.style.width = "883px";
			var footerDiv = document.getElementById('footer');
			if (divHeight >= 550)
			{
				bgBody.style.height = (divHeight - 146) +"px";
				footerDiv.style.top = "320px";
			} else {
				bgBody.style.height = (550 - 156) +"px";
				footerDiv.style.top = "418px";
			}
			
			
			bgBody.style.background = "transparent url(images/body_background.png) repeat-y right top";
			
			bgFooter.style.left = "-10px";
			bgFooter.style.width = "883px";
			bgFooter.style.height = "197px";
			
			bgFooter.style.background =" transparent url(images/body_footer_standard.png) no-repeat right top";
			

			
			$(document).pngFix();
			break;
	}
	
	container.style.height = (offset + bgHeader.offsetHeight + bgBody.offsetHeight + bgFooter.offsetHeight) + "px";
	
	document.getElementById('footer').display = "block";

}

function setBodyStyle(thisSection, param1, param2)
{
	
	dumpDivs(thisSection);
	
	var contentDiv = document.getElementById('content');
	var jumbotronDiv = document.getElementById('jumbotronDiv');
	
	switch(thisSection)
	{
	
		case "home":	
		
			jumbotronDiv.style.top = "60px";
			jumbotronDiv.style.left = "50px";
			contentDiv.style.top="333px";
			contentDiv.style.left="70px";
			contentDiv.style.width = "770px";
			
			document.getElementById('secondaryDiv').style.top = "710px";
			document.getElementById('secondaryDiv').style.left = "74px";
			document.getElementById('secondaryDiv').style.width = "200px";
			
			document.getElementById('tertiaryDiv').style.top = "0px";
			document.getElementById('tertiaryDiv').style.left = "0px";
			document.getElementById('tertiaryDiv').style.width = "0px";
			document.getElementById('tertiaryDiv').style.height = "0px";
			
			setContentBackground(thisSection, contentDiv, 500);
			
			break;
		
		case "news":
		
			//document.body.style.background="#0a0806 url(images/background_news.jpg) no-repeat center 44px";
			jumbotronDiv.style.top = "60px";
			jumbotronDiv.style.left = "50px";
			var contentDiv = document.getElementById('content');
			contentDiv.style.top = "335px";
			contentDiv.style.left = "70px";
			contentDiv.style.width = "900px";
			
			setContentBackground(thisSection, contentDiv, 500);
			
			//document.getElementById('footer').style.top = "px";
	;

			break;
		
		case "tours":

			jumbotronDiv.style.top = "60px";
			jumbotronDiv.style.left = "50px";			
			contentDiv.style.top = "345px";
			contentDiv.style.left = "70px";
			contentDiv.style.width = "560px";
			contentDiv.onmousedown = getClientY;
			document.getElementById('secondaryDiv').style.top = "280px";
			document.getElementById('secondaryDiv').style.left = "70px";
			document.getElementById('secondaryDiv').style.width = "300px";
			//document.getElementById('secondaryDiv').style.height = "20px";
		
			
			document.getElementById('tertiaryDiv').style.top = "330px";
			document.getElementById('tertiaryDiv').style.left = "635px";
			document.getElementById('tertiaryDiv').style.width = "200px";
			document.getElementById('tertiaryDiv').style.height = "500px";
			
			setContentBackground(thisSection, contentDiv, 500);
		
		
			break;
		
		case "photos":	
		
			
			contentDiv.style.top="575px";
			contentDiv.style.left="70px";
			contentDiv.style.width = "544px";
			
			document.getElementById('secondaryDiv').style.top = "123px";
			document.getElementById('secondaryDiv').style.left = "74px";
			document.getElementById('secondaryDiv').style.width = "544px";
			//document.getElementById('secondaryDiv').style.height = "350px";
			
			document.getElementById('tertiaryDiv').style.top = "123px";
			document.getElementById('tertiaryDiv').style.left = "620px";
			document.getElementById('tertiaryDiv').style.width = "200px";
			document.getElementById('tertiaryDiv').style.height = "500px";
			
			setContentBackground(thisSection, contentDiv, 500);
			
			break;
		
		case "video":	

			contentDiv.style.top="123px";
			contentDiv.style.left="75px";
			contentDiv.style.width = "544px";
			
			document.getElementById('secondaryDiv').style.top = "450px";
			document.getElementById('secondaryDiv').style.left = "66px";
			document.getElementById('secondaryDiv').style.width = "440px";
			//document.getElementById('secondaryDiv').style.height = "360px";
			
			document.getElementById('tertiaryDiv').style.top = "123px";
			document.getElementById('tertiaryDiv').style.left = "636px";
			document.getElementById('tertiaryDiv').style.width = "220px";
			document.getElementById('tertiaryDiv').style.height = "425px";
			
			setContentBackground(thisSection, contentDiv, 500);
		
			
			break;
			
		case "brandi":	

			//document.body.style.background="#0a0806 url(images/background_brandi.jpg) no-repeat center 44px";
			document.getElementById('content').style.top = "382px";
			document.getElementById('content').style.left = "74px";
			document.getElementById('content').style.width = "425px";
			
			
			document.getElementById('secondaryDiv').style.top = "40px";
			document.getElementById('secondaryDiv').style.left = "70px";
			document.getElementById('secondaryDiv').style.width = "770px";
			//document.getElementById('secondaryDiv').style.height = "180px";
			
			document.getElementById('tertiaryDiv').style.top = "375px";
			document.getElementById('tertiaryDiv').style.left = "525px";
			document.getElementById('tertiaryDiv').style.width = "305px";
			document.getElementById('tertiaryDiv').style.height = "1350px";
			
			setContentBackground(thisSection, contentDiv, 500);
			
			
			break;

		case "contact":	

			document.getElementById('content').style.top="120px";
			document.getElementById('content').style.left="72px";
			document.getElementById('content').style.width = "900px";

			
			document.getElementById('secondaryDiv').display = "none";
			document.getElementById('tertiaryDiv').display = "none";
			
			document.getElementById('tertiaryDiv').style.top = "338px";
			document.getElementById('tertiaryDiv').style.left = "525px";
			document.getElementById('tertiaryDiv').style.width = "305px";
			document.getElementById('tertiaryDiv').style.height = "0px";
			
			setContentBackground(thisSection, contentDiv, 500);
			
			break;
			
		case "join":	

			//document.body.style.background="#0a0806 url(images/background_join.jpg) no-repeat center 44px";
			document.getElementById('content').style.top="379px";
			document.getElementById('content').style.left="415px";
			document.getElementById('content').style.width = "544px";
			document.getElementById('footer').style.top = "805px";
		
			break;
			
		case "music":	
		
			jumbotronDiv.style.top = "60px";
			jumbotronDiv.style.left = "50px";
			contentDiv.style.top="590px";
			contentDiv.style.left="74px";
			contentDiv.style.width = "800px";
			
			document.getElementById('secondaryDiv').style.top = "290px";
			document.getElementById('secondaryDiv').style.left = "74px";
			document.getElementById('secondaryDiv').style.width = "750px";
			//document.getElementById('secondaryDiv').style.height = "350px";
			
			document.getElementById('tertiaryDiv').style.top = "0px";
			document.getElementById('tertiaryDiv').style.left = "0px";
			document.getElementById('tertiaryDiv').style.width = "0px";
			document.getElementById('tertiaryDiv').style.height = "0px";
			
			setContentBackground(thisSection, contentDiv, 500);
			
			break;
		break;
	}

	loadSection(thisSection, param1, param2);
}

function dumpDivs(thisSection)
{
	document.getElementById('content').display = "block";
	document.getElementById('secondaryDiv').display = "block";
	document.getElementById('tertiaryDiv').display = "block";
	document.getElementById('content').innerHTML = "";
	if (thisSection != "tours" || thisSection != "video")
	{
		document.getElementById('secondaryDiv').innerHTML = "";
	}
	if (thisSection != "photos")
	{
		document.getElementById('tertiaryDiv').innerHTML = "";
	}

}
//
function getStyle(el, style) {
	if (!document.getElementById) {
		return;
	}
	var value = el.style[toCamelCase(style)];
	if (!value) {
		if (document.defaultView) {
			value = document.defaultView.getComputedStyle(el, "").getPropertyValue(style);
		} else if (el.currentStyle) {
			value = el.currentStyle[toCamelCase(style)];
		}
	}
	return value;
}

function getElement(id){	
	if (!document.getElementById){
	 return;
	}
	//
	if (document.getElementById){
		// this is the way the standards work
		var el = document.getElementById(id);
	}else if (document.all){
		// this is the way old msie versions work
		var  el = document.all[id];
	}else if (document.layers){
		// this is the way nn4 works
		var el = document.layers[id];
	}
	return el;
}

toggleDisplay=function(el){
	el.style.display = el.style.display ? "" : "block";
}

replaceAnchors=function(){
	if (document.getElementById) {
		var atags = document.getElementsByTagName("A");
		for (var i = 0; i<atags.length; i++) {
			var ca = atags[i];
			var index=ca.href.indexOf("#");
			var hash=ca.href.substring(index+1);
			if (index>-1 &&	hash.length>0) {
				ca.link=hash;
				ca.onclick = function() {	
					var b = getElement('content');
					b.scrollTop = getElement(this.link).offsetTop;
					return false;
				};
			}
		}
	}
}

/*
function placePreview(sDivId, previewUrl, iteration)
{

      var oXMLHttp = GetXMLHttpObject();
	  var url="php/placePreviewPlayer.php";
	  url=url+"?previewUrl="+escape(previewUrl);
	  url=url+"&iteration="+iteration;
	  url=url+"&browser="+browser;

      oXMLHttp.open("GET", url, true);

      oXMLHttp.onreadystatechange = function()
            {
                  if (oXMLHttp.readyState == 4)
                  {
                        document.getElementById(sDivId).innerHTML = oXMLHttp.responseText;
                  }
            }

      oXMLHttp.send(null);
}
*/


function placePreview(sDivId, previewUrl, iteration)
{
	flashVars = escape(previewUrl +"|"+ iteration);
	var previewText = "";
	switch(browserName)
	{

		case "msie" :

				previewText = "<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0\" width=\"11\" height=\"11\" id=\"audio"+ iteration +"\" align=\"middle\">";
				previewText += "<param name=\"allowScriptAccess\" value=\"always\" />";
				previewText += "<param name=\"allowFullScreen\" value=\"false\" />";
				previewText += "<param name=\"wmode\" value=\"transparent\" />";
				previewText += "<param name=\"movie\" value=\"flash/previewPlayer.swf\" />";
				previewText += "<param name=\"quality\" value=\"high\" />";
				previewText += "<param name=\"flashvars\" value=\"variables="+flashVars+"\" />";
				previewText += "<param name=\"bgcolor\" value=\"#ffffff\" />";
				previewText += "<embed src=\"flash/previewPlayer.swf\" wmode=\"transparent\" quality=\"high\" bgcolor=\"#ffffff\" width=\"11\" height=\"11\" flashvars=\"variables="+flashVars+"\"  id=\"audio"+ iteration +"\" name=\"audio"+ iteration +"\" align=\"middle\" allowScriptAccess=\"always\" allowFullScreen=\"false\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" />";
				previewText += "</object>";
				break;
				
		default :
				previewText = "<embed src=\"flash/previewPlayer.swf\" wmode=\"transparent\" quality=\"high\" bgcolor=\"#ffffff\" width=\"11\" height=\"11\" flashvars=\"variables="+flashVars+"\"  id=\"audio"+ iteration +"\" name=\"audio"+ iteration +"\" align=\"middle\" allowScriptAccess=\"always\" allowFullScreen=\"false\" type=\"application/x-shockwave-flash\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" />";
				break;

	}

      return previewText;

}

function setPlaying(id){
	stopjukebox();
	objectPlaying = getElement(id);
	
}

function stopAudio(id)
{

	if(objectPlaying != getElement(id))
	{
		objectPlaying.stopAudio();
	}
}

function getEmail()
{
	var email = document.getElementById('email').value;

	alert(email);

	var url = "signup.php?email="+email;

	var options = "menubar=0,toolbar=0,location=0,directories=0,status=0,scrollbars=0,resizable=0";

	launch(url, "download", 480, 425, options);
}

switchContent=function(id){	

	//turn off last active
	if(active){
		document.images[oldSection].src = items[oldSection].off.src;
		toggleDisplay(active);
	}
	
	switch(id)
	{
		case "news":
			
			id = "news"+territory;	
			active=getElement(id);
			toggleDisplay(active);
			section = oldSection = "news";
			document.images[section].src = items[section].on.src;
			break;

		case "contest":

			id = "contest"+territory;	
			active=getElement(id);
			toggleDisplay(active);
			section = oldSection = "contest";
			document.images[section].src = items[section].on.src;
			break;

		default:

			active=getElement(id);
			toggleDisplay(active);
			section = oldSection = id;
			document.images[section].src = items[section].on.src;
			break
	}
	
	//var img=(getElement('headerimg'))
	//img.src="images/header-"+id+"+jpg"

	//trackEvent(window.location.host, "/"+id+"+ajaxPage", id, '');
	
	var contentDiv = getElement('content');
	contentDiv.scrollTop = 0;
}

//
function getQueryVariable(variable) {
	var query = window.location.search.substring(1);
	var vars = query.split("&");
	for (var i = 0; i<vars.length; i++) {
		var pair = vars[i].split("=");
		if (pair[0] == variable) {
			return pair[1];
		}
	}
}

function launch(url, name, width, height, options)
	{
	if (!name)
		{
		name = "window_" + Math.floor(1000 * Math.random());
		}
	
	if (!width)
		{
		width = 800;
		}
		
	if (!height)
		{
		height = 600;
		}
	
	if (!options)
		{
		options = "menubar=1,toolbar=1,location=1,directories=1,status=1,scrollbars=1,resizable=1";
		}
	
	width	= Math.min(width, screen.availWidth);
	height	= Math.min(height, screen.availHeight);
	var x	= Math.max(0, 0.5 * (screen.availWidth - width));
	var y	= Math.max(0, 0.5 * (screen.availHeight - height));

	var config = "";
	config += "left=" + x + ",top=" + y + ",";
	config += "screenX=" + x + ",screenY=" + y + ",";
	config += "width=" + width + ",height=" + height;
	config += "," + options;

	var win = window.open(url, name, config);
	if (win && window.focus)
		{
		win.focus();
		}
	}
	
// scrolling Div

function xAddEventListener(e,eT,eL,cap)
{
  if(!(e=xGetElementById(e)))return;
  eT=eT.toLowerCase();
  if(e.addEventListener)e.addEventListener(eT,eL,cap||false);
  else if(e.attachEvent)e.attachEvent('on'+eT,eL);
  else {
    var o=e['on'+eT];
    e['on'+eT]=typeof o=='function' ? function(v){o(v);eL(v);} : eL;
  }
}


function xSlideTo(e, x, y, uTime)
{
  if (!(e=xGetElementById(e))) return;
  if (!e.timeout) e.timeout = 25;
  e.xTarget = x; e.yTarget = y; e.slideTime = uTime; e.stop = false;
  e.yA = e.yTarget - xTop(e); e.xA = e.xTarget - xLeft(e); // A = distance
  if (e.slideLinear) e.B = 1/e.slideTime;
  else e.B = Math.PI / (2 * e.slideTime); // B = period
  e.yD = xTop(e); e.xD = xLeft(e); // D = initial position
  var d = new Date(); e.C = d.getTime();
  if (!e.moving) _xSlideTo(e);
}
function _xSlideTo(e)
{
  if (!(e=xGetElementById(e))) return;
  var now, s, t, newY, newX;
  now = new Date();
  t = now.getTime() - e.C;
  if (e.stop) { e.moving = false; }
  else if (t < e.slideTime) {
    setTimeout("_xSlideTo('"+e.id+"')", e.timeout);

    s = e.B * t;
    if (!e.slideLinear) s = Math.sin(s);
//    if (e.slideLinear) s = e.B * t;
//    else s = Math.sin(e.B * t);

    newX = Math.round(e.xA * s + e.xD);
    newY = Math.round(e.yA * s + e.yD);
    xMoveTo(e, newX, newY);
    e.moving = true;
  }  
  else {
    xMoveTo(e, e.xTarget, e.yTarget);
    e.moving = false;
    if (e.onslideend) e.onslideend();
  }  
}

var slideTime = 700, fId = 'floater';
var topLimit, topOffset, bottomLimit;


function winOnResize()
{
  var p = .33; // keep floater in middle 1/3rd of the page 
  var h = xHeight('leftColumn');
  topLimit = Math.floor(p * h);
  bottomLimit = Math.floor((1 - p) * h);
  xMoveTo(fId, xPageX('leftColumn')+xWidth('leftColumn')+20, topLimit);
  xGetElementById(fId).style.visibility = 'visible';
  winOnScroll(); // initial slide
}

function winOnScroll()
{
  var ft = xTop(fId);
  var fh = xHeight(fId);
  var st = xScrollTop();
  var ch = xClientHeight();
  var y = st + (ch - fh) / 2; // destination (vertical center of window)
  // keep floater within limits
  if (y < topLimit) y = topLimit;
  else if (y + fh > bottomLimit) y = bottomLimit - fh;
  // don't slide unless floater scrolls off-screen
  if (ft < st || ft + fh > st + ch) {
    xSlideTo(fId, xLeft(fId), y, slideTime);
  }
}

function setSlideTime(st)
{
  st = parseInt(st);
  if (!isNaN(st)) slideTime = st;
  var e = xGetElementById('st');
  e.value = st;
  return false;
}
