function setContentHeight() {
	if(document.getElementById('content').offsetHeight<400) {
		document.getElementById('content').style.height = "400px";
	}
}

function showThis(element) {
	if(document.getElementById(element).style.display=="block") {
			document.getElementById(element).style.display = "none";
		} else {
			document.getElementById(element).style.display = "block";
		}
}

function showCredits(element) {
	if(document.getElementById(element).style.display=="none") {
		document.getElementById(element).style.display = "inline";
	} 
}

function hideThis(element) {
	if(document.getElementById(element).style.display=="inline") {
		document.getElementById(element).style.display = "none";
	}
}

function showImage(filename) {
	window.open('image.php?filename='+filename, "imageDetail", "status=no, toolbar=no, location=no, width=500, height=500, resizable=yes");	
}

function popup(url) {
	window.open(url, "imageDetail", "status=no, toolbar=no, location=no, width=500, height=500, resizable=yes");	
}

/* function showThisButNotThose(what,which,count) {
	for(var i=1;i<=count;i++) {
		if(i!=which) {
			document.getElementById(what+i).style.display = "none";
			document.getElementById('list'+i).style.background = "none";
			document.getElementById('check'+i).checked = false;
		} else if(document.getElementById('check'+i).checked==true) {
			document.getElementById(what+i).style.display = "block";
			document.getElementById('list'+i).style.backgroundColor = "#fff";
		} else {
			document.getElementById(what+i).style.display = "none";
			document.getElementById('list'+i).style.background = "none";
		}
	}
} */

function showThisButNotThose(what,which,count) {
	for(var i=1;i<=count;i++) {
		if(i!=which) {
			document.getElementById(what+i).style.display = "none";
			document.getElementById('list'+i).style.background = "none";
			document.getElementById('check'+i).checked = false;
		} else {
			document.getElementById('check'+i).checked = true;
			document.getElementById(what+i).style.display = "block";
			document.getElementById('list'+i).style.backgroundColor = "#fff";
		}/*   else {
			document.getElementById(what+i).style.display = "none";
			document.getElementById('list'+i).style.background = "none";
		}*/
	}
}

function verifyAlbumDelete(accountId,albumId) {
	var result = confirm("Are you sure you would like to delete this album?");
	if(result==1) {
		document.location = "deleteAlbum.php?accountId="+accountId+"&albumId="+albumId;
	} 
}

function verifyImageDelete(accountId,imageNumber) {
	var result = confirm("Are you sure you would like to delete this image?");
	if(result==1) {
		document.location = "deleteImage.php?accountId="+accountId+"&imageId="+imageNumber;
	} 
}

function verifySongDelete(accountId,albumId,songId) {
	var result = confirm("Are you sure you would like to delete this song?");
	if(result==1) {
		document.location = "deleteSong.php?accountId="+accountId+"&albumId="+albumId+"&songId="+songId;
	} 
}

function verifySingleDelete(accountId,singleId) {
	var result = confirm("Are you sure you would like to delete this single?");
	if(result==1) {
		document.location = "deleteSingle.php?accountId="+accountId+"&singleId="+singleId;
	} 
}

function showCommentUpdate(id,accountId) {
	window.open('updateComment.php?id='+id+'&accountId='+accountId,'_blank','height=300,width=580');
}

function validateCommentUpdate(id,accountId) {
	var comment = document.updateComment.comment.value;
	var value = null;
	for(i=0;i<document.updateComment.value.length;i++) {
		if(document.updateComment.value[i].checked==true) {
			value = document.updateComment.value[i].value;
		}
	}
	window.opener.location = "validateComment.php?id="+id+"&accountId="+accountId+"&value="+value+"&comment="+comment+"&edit=true";
	window.close();
}

function getMediaPlayer(artist,songFile,songTitle) {
songFile = songFile.replace("\'","\\'");
	 document.write('<object type="application/x-shockwave-flash" data="flash/mediaPlayer.swf?artistName='+artist+'&songFile='+songFile+'&songTitle='+songTitle+'" width="267" height="150">\n');
   document.write('<param name="movie" value="flash/mediaPlayer.swf?artistName='+artist+'&songFile='+songFile+'&songTitle='+songTitle+'" />');
   document.write('<param name="bgcolor" value="#dedede"/>');
   document.write('</object>\n');
}

function getVideo(url) {
	 document.write('<object type="application/x-shockwave-flash" data="'+url+'" width="280" height="216">\n');
   document.write('<param name="movie" value="'+url+'" />');
   document.write('<param name="bgcolor" value="#dedede"/>');
   document.write('</object>\n');
}

function getFeatureMediaPlayer(artist,songFile,songTitle) {
   songFile = songFile.replace("\'","\\'");
   document.write('<object type="application/x-shockwave-flash" id="player" data="flash/featureMediaPlayer.swf?artistName='+artist+'&songFile='+songFile+'&songTitle='+songTitle+'" width="267" height="150">\n');
   document.write('<param name="movie" value="flash/featureMediaPlayer.swf?artistName='+artist+'&songFile='+songFile+'&songTitle='+songTitle+'" />');
   document.write('<param name="bgcolor" value="#dedede"/>');
   document.write('</object>\n');
}

function getMediaPlayerBackend(artist,songFile,songTitle) {
   songFile = songFile.replace("\'","\\'");
   document.write('<object type="application/x-shockwave-flash" data="../flash/mediaPlayer.swf?artistName='+artist+'&songFile='+songFile+'&songTitle='+songTitle+'" width="267" height="150">\n');
   document.write('<param name="movie" value="../flash/mediaPlayer.swf?artistName='+artist+'&songFile='+songFile+'&songTitle='+songTitle+'" />');
   document.write('<param name="bgcolor" value="#dedede"/>');
   document.write('</object>\n');
}

function showLoading(which) {
		document.getElementById('loading'+which).style.display = "block";
		document.getElementById('container').style.display = "none";
}

function uncheckSongs(albumId,arr) {
	for(var i=0;i<arr.length;i++) {
		var name = "songId_"+albumId+"_"+arr[i];
		if(document.getElementById(name).checked==true) {
			document.getElementById(name).checked=false;
		} 
	}
}

function uncheckAlbum(albumId) {
	var name = "albumId_"+albumId;
	if(document.getElementById(name).checked==true) {
		document.getElementById(name).checked=false;
	} 
}

function goHere(url) {
		document.location = url;
}

function startPlay(artist,song,songfile,songId) {
	stopPlay();
	rewind();
	var flashMovie=document.getElementById('player');
	flashMovie.SetVariable("artist.text","Artist: "+artist);
	flashMovie.SetVariable("title.text","Title: "+song);
	flashMovie.SetVariable("songFile",songfile);
	var currentFrame=flashMovie.TGetProperty("/", 4);
	var nextFrame=parseInt(currentFrame);
	flashMovie.GotoFrame(nextFrame);
	updateStreams(songId);		
}
function stopPlay() {
	var flashMovie=document.getElementById('player');
	var currentFrame=flashMovie.TGetProperty("/", 4);
	if(currentFrame==2) {
		var nextFrame=parseInt(currentFrame);
		flashMovie.GotoFrame(nextFrame);		
	} else {
		rewind();
	}
}
function rewind() {
	var flashMovie=document.getElementById('player');
	flashMovie.Rewind();
}

function updateStreams(songId) {
	var client = new HttpClient();
	client.isAsync = true;
	
	client.callback = function(result) {
		
	}
	
	client.makeRequest('updateSongStreams.php?id='+songId,false);
}
