

/*
	durgle.multimedia.js
	version 1.9.4
	first created: 10/27/03
	last revised: 01/01/07
	http://www.durgle.com
	talk@durgle.com
*/


// -------- BEGIN REMOTE CONTROL FUNCTIONS ----------


// Turn a DIV into a widget
function durglize(strDivID, strDivIDCloser) {
	$d(strDivID).setAttribute("class", "drag"); 
	document.getElementById("remote").onclick = function() { closeDurgle("remote"); };
}


// Fade out a durgle
function closeDurgle(strDivOD) {
	//changeOpacity("remote", 1);
}


//durglize("remote", "remoteCloser");


var MyReels = new Array(3);
MyReels[1] = "Como Sempre / Sony F900";
MyReels[2] = "Diamonds bullets and fate / Panasonic Varicam";
MyReels[3] = "LA FABBRICA DELLA NUVOLE / Panasonic DVX-100";


var MyMovies = new Array(3);
MyMovies[1] = "COMESEMP_ref.mov";
MyMovies[2] = "DBF1_ref.mov";
MyMovies[3] = "Enrico_ref.mov";


function nextReel() {
	var currentReel = window.myCurrentMovie;
	var MyReelsLength = MyReels.length -1;
	if (currentReel < MyReelsLength) {
		$d("holder").innerHTML = '<embed src="' + MyMovies[currentReel + 1] + '" width="363" height="272" autoplay="true" controller="false">'
		window.myCurrentMovie = window.myCurrentMovie + 1; 
	}
	if (currentReel >= MyReelsLength) {
		$d("holder").innerHTML = '<embed src="' + MyMovies[1] + '" width="363" height="272" autoplay="true" controller="false">'
		window.myCurrentMovie = 1;
	}
	sub = '<span id="current">' + window.myCurrentMovie + '</span>/<span id="totals">' + MyReelsLength + '</span> &nbsp; | &nbsp; "' + MyReels[window.myCurrentMovie] + '"</p>';
	$d("subtitleP").innerHTML = sub;
	//alert(window.myCurrentMovie);
}


function previousReel() {
	var currentReel = window.myCurrentMovie;
	var MyReelsLength = MyReels.length -1;
	if (currentReel < MyReelsLength) {
		$d("holder").innerHTML = '<embed src="' + MyMovies[currentReel + 1] + '" width="363" height="272" autoplay="true" controller="false">'
		window.myCurrentMovie = window.myCurrentMovie + 1; 
	}
	if (currentReel >= MyReelsLength) {
		$d("holder").innerHTML = '<embed src="' + MyMovies[1] + '" width="363" height="272" autoplay="true" controller="false">'
		window.myCurrentMovie = 1;
	}
	sub = '<span id="current">' + window.myCurrentMovie + '</span>/<span id="totals">' + MyReelsLength + '</span> &nbsp; | &nbsp; "' + MyReels[window.myCurrentMovie] + '"</p>';
	$d("subtitleP").innerHTML = sub;
	//alert(window.myCurrentMovie);
}


function pauseReel() {
	alert("Pause Reel!");
}


var obj = {
	a : Object,
	b : Array,
	c : false,
	d : null,
	init : function() {
		// set local object vars here
		this.run();
	},
	run : function() {
		// run bulk of behavior here
		alert("Test!");
	},
	preloader: function() {
		// Preload Website Images
	},
	websiteSetup: function() {
		// Setup website layout
	}
}


function initializer() {
	obj.init();
	// other init() methods go here
}


function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	}
	else {
		window.onload = function() {
			oldonload();
			func();
		}
	}
}


function closeMovie() {
	opacity('movieContainer', 100, 0, 600);
	$d("movieContainer").style.display = "none";
	opacity('theX', 100, 0, 600);
	$d("theX").style.display = "none";
}
	
function playMovie(intMovie) {
	window.myCurrentMovie = intMovie;
	var MyReelsLength = MyReels.length -1;
	//opacity('body', 100, 1, 600);
	changeOpacity("movieContainer", 1);
	$d("movieContainer").style.display = "block";
	opacity('movieContainer', 1, 100, 600);
	changeOpacity("theX", 1);
	$d("theX").style.display = "block";
	opacity('theX', 1, 100, 600);
	$d("holder").innerHTML = '<embed src="' + MyMovies[intMovie] + '" width="363" height="272" autoplay="true" controller="false">'
	sub = '<span id="current">' + window.myCurrentMovie + '</span>/<span id="totals">' + MyReelsLength + '</span> &nbsp; | &nbsp; "' + MyReels[window.myCurrentMovie] + '"</p>';
	$d("subtitleP").innerHTML = sub;
}



// -------- END REMOTE CONTROL FUNCTIONS ----------




// -------- BEGIN MP3 PLAYER ----------


// Music Player state
var isPlaying;
isPlaying = "NO"


// Current Music Player song which is playing, 1 is default
var currentSong;
currentSong = 1;


var MySounds = Array();
MySounds[0] = "psycho.m4a";


// Div for sound
var divExists;
divExists = 0;


// The div to hold the music embed
var myL;


// Play a sound
function PlaySound(intSound) {
	document.getElementById("sng").src = "song.php?ID=" + MySounds[intSound];
	isPlaying == "YES";
	currentSong = intSound;
	$d("pPlay").innerHTML = '<a href="javascript:void(0);" onclick="stopPlayer();"><img src="images/stop.png"></a></p>';
	//alert(window.isPlaying);
	divExists = 1;
}


// Play a sound
function playSoundOLD(intSound) {
	//stopPlayer();
	//myL.innerHTML = "";
	myL = document.createElement("DIV"); 
	document.body.appendChild(myL); 
	var embedSound = '<embed id="snd" src="' + MySounds[intSound] + '" autostart="true" loop="false" width="1" height="1" controller="false"></embed>';
	myL.innerHTML = embedSound;
	isPlaying == "YES";
	currentSong = intSound;
	divExists = 1;
}


function stopPlayer() {
	if(divExists == 1) {
		//document.getElementById("sng").src = "song.php";
		document.getElementById("sng").src = "song.php";
	}
	$d("pPlay").innerHTML = '<a href="javascript:void(0);" onclick="playSound(1);"><img src="images/play.png"></a>';
}


// Create a div
function createDiv(myL, x, y, w, h, bg) {
	divExists = 1;
	myL = document.createElement("DIV"); 
	document.body.appendChild(myL); 
	myL.style.position = 'absolute';
	myL.style.background = bg;
	myL.style.top = y;
	myL.style.left = x;
	myL.style.width = w;
	myL.style.height = h;
	myL.style.innerHTML = "&nbsp;";
	myL.style.border = "1px solid red";
}


function previous() {
	songsCount = MySounds.length - 1;
	if(currentSong < songsCount) {
		stopPlayer();
		prevSong = currentSong - 1; 
		playSound(prevSong);
	}
}


function next() {
	songsCount = MySounds.length - 1;
	if(songsCount > currentSong) {
		stopPlayer();
		nextSong = currentSong + 1; 
		playSound(nextSong);
	}
}


function buildPlayer() {
}


function mp3Player(strPlayButton, strPauseButton, str) {
}


// Preload Images


// Preloader indicator
var indicator = "images/indicator.gif"


// Images to preload
MyImages = Array();
MyImages[1] = "images/logo.png";


// Preload Images
function preloadImages() {
	pic1= new Image(100,25); 
	pic1.src = MyImages[1];
}


// EOF