// player.js
// Ken Ficara 
// Copyright (C) 2008 Harmonica, LLC
// 
// Javascript to control jwplayer
// $Id: player.js,v 1.11 2009-02-18 15:13:16-05 ficara Exp $
//-------------------------------------------------------------------


baseURL='http://smoke.harmoni.ca/minisite/';

// This will be used in the playsong() function for the random images.

song_images = Array (
						'KmizedCharlotte.jpg', 
						'KmizedDay45small.jpg', 
						'KmizedEdBob.jpg', 
						'KmizedPeterClose.jpg', 
						'KmizedPeterHead.jpg', 
						'KmizedStage.jpg', 
						'KmizedStage2.jpg', 
						'KmizedVidShoot.jpg', 
						'KmizedVideoStillLarge.jpg', 
						'KmizedWeston.jpg',
						'KmizedBagList.jpg',
						'KmizedDemonstrates.jpg',
						'KmizedLastPromo.jpg',
						'KmizedWVa.jpg'
					);

// Standard randomizing functions since stupid JS doesn't have one

rnd.today=new Date();
rnd.seed=rnd.today.getTime();

function rnd()
{
	rnd.seed = (rnd.seed*9301+49297) % 233280;
	return rnd.seed/(233280.0);
}

function rand(number)
{
	return Math.ceil(rnd()*number);
}

function playerReady(thePlayer) 
{ 
//	alert ("Player ready");
	player = window.document[thePlayer.id]; 
}

function createVideoPlayer()  
{

	var flashvars = {
			file:baseURL + "media/dayihadsomefunsmall.mp4", 
			autostart:"false",
			backcolor: '#000000',
			frontcolor: '#DDDDDD',
//			stretching: 'exactfit',

// 			Need this to play the whole playlist through
//			repeat:"always",
			image: baseURL+"media/images/KmizedVideoStillLarge.jpg"
	}
	var params = {
			allowfullscreen:"true", 
			allowscriptaccess:"always"
	}
	var attributes = {
			id:"player1",  
			name:"player1"
	}
	
	swfobject.embedSWF("mediaplayer/player.swf", "player", "336", "246", "9.0.115", false, flashvars, params, attributes);
	

}

function playSong(song)
{
	// Picks an image out of the random images array, assigns it
	// and loads song. 
	
	pick = rand(song_images.length) - 1;
	song.image= baseURL + 'media/images/' + song_images[pick];
	player.sendEvent('LOAD',song);
	player.sendEvent('PLAY');

}

function showCovers()
{	

	 cvr01 = {type:"sound",file:baseURL+"media/covers/opener.mp3",title:"Opener",text:'',buylink:''};
	 cvr02 = {type:"sound",file:baseURL+"media/covers/AllIWantIsYou.mp3",title:"All I Want Is You",text:'Roxy Music -- <cite>Country Life</cite> (1974)',buylink:'http://www.amazon.com/gp/product/B000SXL3B4?ie=UTF8&tag=smomusarc-20&linkCode=as2&camp=1789&creative=390957&creativeASIN=B000SXL3B4'};
	 cvr03 = {type:"sound",file:baseURL+"media/covers/BoredToDeath.mp3",title:"Bored To Death",text:'Government Issue',buylink:'http://www.amazon.com/gp/product/B001EDZ3OA?ie=UTF8&tag=smomusarc-20&linkCode=as2&camp=1789&creative=390957&creativeASIN=B001EDZ3OA',kbuylink:'http://www.amazon.com/gp/product/B000VE1496?ie=UTF8&tag=smomusarc-20&linkCode=as2&camp=1789&creative=390957&creativeASIN=B000VE1496'};
	 cvr04 = {type:"sound",file:baseURL+"media/covers/DeadSouls.mp3",title:"Dead Souls",text:'Joy Division -- <cite>Unknown Pleasures</cite> (1977)',buylink:'http://www.amazon.com/gp/product/B0015T2DBY?ie=UTF8&tag=smomusarc-20&linkCode=as2&camp=1789&creative=390957&creativeASIN=B0015T2DBY'};
	 cvr04a = {type:"sound",file:baseURL+"media/covers/BetterOffDead.mp3",title:"Better Off Dead",text:'La Peste',buylink:'http://www.amazon.com/gp/product/B00000DBUV?ie=UTF8&tag=smomusarc-20&linkCode=as2&camp=1789&creative=390957&creativeASIN=B00000DBUV'};
	 
	 cvr05 = {type:"sound",file:baseURL+"media/covers/HarlemNocturne.mp3",title:"Harlem Nocturne",text:'Version by Esquivel, Written by Earle Hagen (1939)',buylink:'http://www.amazon.com/gp/product/B001BHHR5W?ie=UTF8&tag=smomusarc-20&linkCode=as2&camp=1789&creative=390957&creativeASIN=B001BHHR5W', kbuylink:'http://www.amazon.com/gp/product/B000VE14G4?ie=UTF8&tag=smomusarc-20&linkCode=as2&camp=1789&creative=390957&creativeASIN=B000VE14G4'};
	 cvr06 = {type:"sound",file:baseURL+"media/covers/NeutronBomb.mp3",title:"Neutron Bomb",text:'The Weirdos (7" single 1977)',buylink:'http://www.amazon.com/gp/product/B0010B6RLO?ie=UTF8&tag=smomusarc-20&linkCode=as2&camp=1789&creative=390957&creativeASIN=B0010B6RLO'};
	 cvr07 = {type:"sound",file:baseURL+"media/covers/QuestionOfDegree.mp3",title:"Question Of Degree",text:'Wire (1977)',buylink:'http://www.amazon.com/gp/product/B001I59IDG?ie=UTF8&tag=smomusarc-20&linkCode=as2&camp=1789&creative=390957&creativeASIN=B001I59IDG'};
	 cvr08 = {type:"sound",file:baseURL+"media/covers/Stranded.mp3",title:"Stranded",text:'The Saints -- <cite>(I\'m) Stranded</cite> (1977)',buylink:'http://www.amazon.com/gp/product/B000RY029S?ie=UTF8&tag=smomusarc-20&linkCode=as2&camp=1789&creative=390957&creativeASIN=B000RY029S'};
	 cvr09 = {type:"sound",file:baseURL+"media/covers/SurgeonsGirl.mp3",title:"Surgeons Girl",text:'Wire -- Pink Flag (1977)',buylink:'http://www.amazon.com/gp/product/B0013Z2FS6?ie=UTF8&tag=smomusarc-20&linkCode=as2&camp=1789&creative=390957&creativeASIN=B0013Z2FS6'};
	 cvr10 = {type:"sound",file:baseURL+"media/covers/yacky.mp3",title:"Yacky Do",text:'The Fireballs -- <CITE>Here Are the Fireballs</CITE> (1961)',buylink:'http://www.amazon.com/gp/product/B000QO63WE?ie=UTF8&tag=smomusarc-20&linkCode=as2&camp=1789&creative=390957&creativeASIN=B000QO63WE',kbuylink:'http://www.amazon.com/gp/product/B000VDW72K?ie=UTF8&tag=smomusarc-20&linkCode=as2&camp=1789&creative=390957&creativeASIN=B000VDW72K'};
	 cvr11 = {type:"sound",file:baseURL+"media/covers/finish.mp3",title:"Finish",text:'',buylink:''};
	 
	 covers_list = Array(cvr01,cvr02,cvr03,cvr04, cvr04a, cvr05,cvr06,cvr07,cvr08,cvr09,cvr10,cvr11);

	var textblock = '';

	for (var song = 0; song<covers_list.length;song++)
	{
	
		textblock += '<A class="songname" HREF="javascript:playSong(covers_list[';
		textblock += song;
 		textblock += '])">';
		textblock +=  covers_list[song].title+'</A><BR>';

		if (covers_list[song].text != '')
		{	
			textblock += '<p>' +covers_list[song].text;
		}

		if (covers_list[song].buylink != '')
		{
			textblock += '<BR>(<A class="buylink" HREF="';
			textblock += covers_list[song].buylink;
			textblock += '">Buy</A>)';
		}

		if (!(typeof(covers_list[song].kbuylink) == 'undefined'))
		{
			textblock += '&nbsp;(<A class="buylink" HREF="';
			textblock += covers_list[song].kbuylink;
			textblock += '">Buy Kustomized Version</A>)</p>';
		}

		textblock+='</p>';

// 		textblock += '<A HREF="javascript:player.sendEvent';
// 		textblock += "('LOAD', covers_list["
// 		textblock += song;
// 		textblock += '])">';
// 		textblock +=  covers_list[song].title+'</A><BR>';

	}
// 
// 	document.getElementById("covers").innerHTML=textblock;
// 
// 	showpage('covers')

	return (textblock);
}	

function showSampler()
{
	samp01={type:"sound",file:baseURL+"media/best-of/ItLives.mp3",title:"It Lives!",subhed:'From <cite>The Mystery of Kustomized</cite>'};
	samp02={type:"sound",file:baseURL+"media/best-of/Nothing.NotNoOne..mp3",title:"Nothing. Not No One."};
	samp03={type:"sound",file:baseURL+"media/best-of/OvernightNamedrop.mp3",title:"Overnight Namedrop"};
	samp04={type:"sound",file:baseURL+"media/best-of/BigTrick.mp3",title:"Big Trick"};
	
	samp05={type:"sound",file:baseURL+"media/best-of/TheDayIHadSomeFun.mp3",title:"The Day I Had Some Fun",subhed:'From <cite>The Battle for Space</cite>', buylink:"http://www.amazon.com/gp/product/B000VE10P4?ie=UTF8&tag=smomusarc-20&linkCode=as2&camp=1789&creative=390957&creativeASIN=B000VE10P4"};
	samp06={type:"sound",file:baseURL+"media/best-of/The5th.mp3",title:"The 5th", buylink:"http://www.amazon.com/gp/product/B000VE10RC?ie=UTF8&tag=smomusarc-20&linkCode=as2&camp=1789&creative=390957&creativeASIN=B000VE10RC"};
	samp07={type:"sound",file:baseURL+"media/best-of/Gorgeous.mp3",title:"Gorgeous", buylink:"http://www.amazon.com/gp/product/B000VDTT0S?ie=UTF8&tag=smomusarc-20&linkCode=as2&camp=1789&creative=390957&creativeASIN=B000VDTT0S"};
	samp08={type:"sound",file:baseURL+"media/best-of/ThePlaceWherePeopleMeet.mp3",title:"The Place Where People Meet", buylink:"http://www.amazon.com/gp/product/B000VE10TU?ie=UTF8&tag=smomusarc-20&linkCode=as2&camp=1789&creative=390957&creativeASIN=B000VE10TU"};
	samp09={type:"sound",file:baseURL+"media/best-of/Handcuffs.mp3",title:"Handcuffs",subhed:'From <cite>At the Vanishing Point</cite>', buylink:"http://www.amazon.com/gp/product/B000VE2YYK?ie=UTF8&tag=smomusarc-20&linkCode=as2&camp=1789&creative=390957&creativeASIN=B000VE2YYK"};
	samp10={type:"sound",file:baseURL+"media/best-of/Fingertips.mp3",title:"Fingertips", buylink:"http://www.amazon.com/gp/product/B000VDW6WQ?ie=UTF8&tag=smomusarc-20&linkCode=as2&camp=1789&creative=390957&creativeASIN=B000VDW6WQ"};
	samp11={type:"sound",file:baseURL+"media/best-of/TheOneThatGotAway.mp3",title:"The One That Got Away", buylink:"http://www.amazon.com/gp/product/B000VDW702?ie=UTF8&tag=smomusarc-20&linkCode=as2&camp=1789&creative=390957&creativeASIN=B000VDW702"};
	samp12={type:"sound",file:baseURL+"media/best-of/Permission.mp3",title:"Permission", buylink:"http://www.amazon.com/gp/product/B000VDW6YE?ie=UTF8&tag=smomusarc-20&linkCode=as2&camp=1789&creative=390957&creativeASIN=B000VDW6YE"};
	samp13={type:"sound",file:baseURL+"media/best-of/Film.mp3",title:"Film", buylink:"http://www.amazon.com/gp/product/B000VDTWDW?ie=UTF8&tag=smomusarc-20&linkCode=as2&camp=1789&creative=390957&creativeASIN=B000VDTWDW"};

	sampler_list = Array (samp01,samp02,samp03,samp04,samp05,samp06,samp07,samp08,samp09,samp10,samp11,samp12,samp13);

	var textblock = '';

	for (var song = 0; song<sampler_list.length;song++)
	{
		if (!(typeof(sampler_list[song].subhed) == 'undefined'))
		{
			textblock += '<h2>'+sampler_list[song].subhed+'</h2>';
		}
		textblock += '<A class="songname" HREF="javascript:playSong(sampler_list[';
		textblock += song;
 		textblock += '])">';
		textblock +=  sampler_list[song].title+'</A>';
		
		if (!(typeof(sampler_list[song].buylink) == 'undefined'))
		{
			textblock += '(<A class="buylink" HREF="';
			textblock += sampler_list[song].buylink;
			textblock += '">Buy</A>)</p>';
		}
		
		textblock+='<BR>';

		
// 		textblock += '<A HREF="javascript:player.sendEvent';
// 		textblock += "('LOAD', covers_list["
// 		textblock += song;
// 		textblock += '])">';
// 		textblock +=  covers_list[song].title+'</A><BR>';

	}

// 	document.getElementById("sampler").innerHTML=textblock;	

//	showpage('sampler')

	return(textblock);

}	






