// calendar popup
function showCalPopup(date, artist, genre, mp3, time, url, special) {
	// change the color depending on
	// the genre
	switch(genre) {
		case 'acoustic rock':
			document.getElementById('calPopupBG').style.background = '#981b1e';
			break;
		case 'blues':
			document.getElementById('calPopupBG').style.background = '#981b1e';
			break;
		case 'crooner':
			document.getElementById('calPopupBG').style.background = '#981b1e';
			break;
		case 'euro lounge':
			document.getElementById('calPopupBG').style.background = '#981b1e';
			break;
		case 'jazz':
			document.getElementById('calPopupBG').style.background = '#981b1e';
			break;
		case 'pop':
			document.getElementById('calPopupBG').style.background = '#981b1e';
			break;
		case 'r&b':
			document.getElementById('calPopupBG').style.background = '#981b1e';
			break;
		case 'soft rock':
			document.getElementById('calPopupBG').style.background = '#981b1e';
			break;
		case 'sultry singer':
			document.getElementById('calPopupBG').style.background = '#981b1e';
			break;
		case 'dance - high nrg':
			document.getElementById('calPopupBG').style.background = '#981b1e';
			break;
		case 'hits - 70s, 80s, 90s':
			document.getElementById('calPopupBG').style.background = '#981b1e';
			break;
		case 'classic rock':
			document.getElementById('calPopupBG').style.background = '#981b1e';
			break;
		default:
			document.getElementById('calPopupBG').style.background = '#981b1e';
			break;
	}
	
	if(mp3 == true) {
		// there's an MP3; indicate instructions in popup
		document.getElementById('popupSample').innerHTML = 'Click to listen';
	}
	document.getElementById('popupDate').innerHTML = date;
	document.getElementById('popupArtist').innerHTML = artist;
	document.getElementById('popupGenre').innerHTML = genre;
	document.getElementById('popupTime').innerHTML = time;
	document.getElementById('popupURL').innerHTML = '<a href="'+url+'" style="color: white;">'+url+'</a>';
	document.getElementById('popupSpecial').innerHTML = special;

	
	document.onmousemove = follow;
	document.getElementById('calPopup').style.display = 'inline';
}
function hideCalPopup() {
	document.getElementById('calPopup').style.display = 'none';
	document.onmousemove = null;
	document.getElementById('calPopup').style.left = -2000;
	document.getElementById('calPopup').style.right = -2000;
	// clear old information
	document.getElementById('popupDate').innerHTML = '';
	document.getElementById('popupArtist').innerHTML = '';
	document.getElementById('popupGenre').innerHTML = '';
	document.getElementById('popupSample').innerHTML = '';
	document.getElementById('popupTime').innerHTML = '';
	document.getElementById('popupURL').innerHTML = '';
	document.getElementById('popupSpecial').innerHTML = '';
}

var followerDiv = 'calPopup';
var offX = 25;          // X offset from mouse position
var offY = -55;          // Y offset from mouse position

function mouseX(evt) {
	if (!evt) evt = window.event;
	if (evt.pageX) return evt.pageX;
	else if (evt.clientX) return evt.clientX + (document.documentElement.scrollLeft ?  document.documentElement.scrollLeft : document.body.scrollLeft);
	else return 0;
}
function mouseY(evt) {
	if (!evt) evt = window.event;
	if (evt.pageY) return evt.pageY;
	else if (evt.clientY) return evt.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);
	else return 0;
}

function follow(evt) {
	if (document.getElementById) {
		var obj = document.getElementById(followerDiv).style; 
		obj.visibility = 'visible';
		obj.left = (parseInt(mouseX(evt))+offX) + 'px';
		obj.top = (parseInt(mouseY(evt))+offY) + 'px';
	}
}


// google map
function loadMap(address,location) {
  if (GBrowserIsCompatible()) {
	var map = new GMap2(document.getElementById("map"));
	var geocoder = new GClientGeocoder();
	
	geocoder.getLatLng(
		address,
		function(point) {
			if (!point) {
				alert(address + " not found");
			} else {
				map.setCenter(point, 13);
				var marker = new GMarker(point);
				map.addOverlay(marker);
				marker.openInfoWindowHtml('<h1>'+location+'</h1><p>'+address+'</p><p><a href="http://maps.google.com/maps?daddr='+address+'&ct=directions-to">Get Directions</a>',{maxWidth:250,maxHeight:50, autoScroll:true});

				GEvent.addListener(marker, "click", function() {
					marker.openInfoWindowHtml('<h1>'+location+'</h1><p>'+address+'</p><p><a href="http://maps.google.com/maps?daddr='+address+'&ct=directions-to">Get Directions</a>',{maxWidth:250,maxHeight:50, autoScroll:true});
				});

				map.addControl(new GSmallZoomControl());
				map.addControl(new GMapTypeControl());
				map.addControl(new GOverviewMapControl());
			}
		}
	);
  }
}

function mp3Popup(URL) {
	window.open(URL, 'music_player', 'toolbar=0,scrollbars=0,directories=0,location=0,statusbar=0,status=0,menubar=0,resizable=0,width=200,innerWidth=200,height=65,innerHeight=65');
}
