var popupPlaying=0;

function playPause(){
	img=document.getElementById('playerControl');
	if (popupPlaying){
		img.src='images/play.jpg';
		musicWindow.wimpy_pause()
		popupPlaying=0;
		}
	else{
		img.src='images/pause.jpg';
		musicWindow.wimpy_play()
		popupPlaying=1;
		}
	}

function musicCheck(){
	// only run this if we're on the home page
	if (homePage == 0){
		return;
		}
	
	// Cookies: 1 = play, -1 = don't play, 0 = no cookie found
	var playMusic=getCookie('playMusic');

	if (playMusic == 0){ // no cookie, ask
		//choice = confirm("Would you like to listen to my favorite First Dance songs while you browse around?");

		Modalbox.show('<div><p>Looks like this is your first visit, thanks for dropping by!</p><p>I\'ve licensed some of my favorite wedding songs, like <i>Stealing Cinderella</i>, <i>When You Say Nothing at All</i>, <i>From This Moment On</i>, and (my personal favorite) <i>Bless the Broken Road</i>, to play on my website.</p><p>Would you like to listen while you browse the site?  You\'ll be able to stop the music at any time if you don\'t like it!</p><p align=center><input type=button onClick="musicChoice(1)" value="Sure!"> <input type=button onClick="musicChoice(0)" value="No thanks"></div>',{title: 'Welcome!  Want some tunes?', width: 800, overlayOpacity: 0.8, overlayDuration: 1.0});


		// set the default so if they just close the dialog we won't play
		//document.cookie="playMusic=-1; path=/; expires=Fri, 31 Dec 2100 10:00:00 GMT'; domain=cliffaddy.com";
		}

		if (playMusic == 1){
			// they previously started the player, so let's go!
			musicWindow=window.open('/musicPlayerPopup.html','cliffaddyMusic','toolbar=no,location=no,directories=no,resizable=no,status=no,scrollbars=no');
			popupPlaying=1;
			}
	}

function musicChoice(play){
	if (play){
		//document.cookie="playMusic=1; path=/; expires=Fri, 31 Dec 2100 10:00:00 GMT'; domain=cliffaddy.com";
		musicWindow=window.open('musicPlayerPopup.html','cliffaddyMusic','toolbar=no,location=no,directories=no,resizable=no,status=no,scrollbars=no');
		popupPlaying=1;
		Modalbox.show('<div><p>OK, I\'m starting the player now, you may need to "allow" pop-ups if you\'re running a blocker.  You can control it using the little buttons at the top-right side of the page.</p><p align=center><input type=button onClick="Modalbox.hide()" value="OK"></div>',{title: 'Starting the player', width: 400, overlayOpacity: 0.8, overlayDuration: 1.0});
		}
	else{
		//document.cookie="playMusic=-1; path=/; expires=Fri, 31 Dec 2100 10:00:00 GMT'; domain=cliffaddy.com";
		Modalbox.show('<div><p>OK, I\'m staying quiet.  If you change your mind, you can start the music using the little buttons at the top-right side of the page.</p><p align=center><input type=button onClick="Modalbox.hide()" value="OK"></div>',{title: 'Running silent', width: 400, overlayOpacity: 0.8, overlayDuration: 1.0});
		}
	}

function reFocus(){
	window.focus();
	}

function getCookie ( cookie_name ) {
	var results = document.cookie.match ( '(^|;) ?' + cookie_name + '=([^;]*)(;|$)' );

	if ( results ){
		return (unescape(results[2]));
		}
	else{
		return 0;
		}
	}

