// JavaScript Document

/////////// START WINDOW ADD EVENT
window.addEvent('domready', function() {

/////////////////////////////////////////////////////////////////////////////////////////////////// PRELOAD IMAGES
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
MM_preloadImages('images/logoOver.gif');
MM_preloadImages('images/mastheadTagBkgnd.gif');
MM_preloadImages('flash/featuredArtist_video.swf');
MM_preloadImages('flash/featuredArtist_audio.swf');

/////////////////////////////////////////////////////////////////////////////////////////////////// FLASH INSERT FUNCTIONS
function insertFlashFeaturedVideo(receiveVideoData){
var so = new SWFObject("flash/featuredArtist_video.swf", "featuredArtist_video", "273", "193", "8");
   			so.addParam("allowScriptAccess", "sameDomain");
   			so.addParam("menu", "false");
   			so.addParam("wmode", "transparent");
   			so.addParam("quality", "high");
				so.addVariable("videoINIT", receiveVideoData);
   			so.write("boxFeaturedArtistMedia");
}

function insertFlashFeaturedAudio(receiveAudioDataUrl, receiveAudioDataArtist, receiveAudioDataTrack){
var so = new SWFObject("flash/featuredArtist_audio.swf", "featuredArtist_audio", "273", "44", "8");
   			so.addParam("allowScriptAccess", "sameDomain");
   			so.addParam("menu", "false");
   			so.addParam("wmode", "transparent");
   			so.addParam("quality", "high");
				so.addVariable("audioINITurl", receiveAudioDataUrl);
				so.addVariable("audioINITartist", receiveAudioDataArtist);
				so.addVariable("audioINITtrack", receiveAudioDataTrack);
   			so.write("boxFeaturedArtistMedia");
}

/////////////////////////////////////////////////////////////////////////////////////////////////// FORMS

$('frontJoinList').addEvent('submit', function(e) {
	   new Event(e).stop();
		showdiv('frontJoinListError');
		var log = $('frontJoinListError').empty().addClass('ajax-loading');
			this.send({
					  update: log,
					  onComplete: function() {
						  log.removeClass('ajax-loading');
						  $('frontJoinList').reset();
	                  }
	        });
});

$('frontCellAlerts').addEvent('submit', function(e) {
	   new Event(e).stop();
		showdiv('frontCellAlertsError');
		var log = $('frontCellAlertsError').empty().addClass('ajax-loading');
			this.send({
					  update: log,
					  onComplete: function() {
						  log.removeClass('ajax-loading');
						  $('frontCellAlerts').reset();
	                  }
	        });
});

/////////////////////////////////////////////////////////////////////////////////////////////////// TOOL TIPS

var toolTips = new Tips($$('.Tips'), {
	initialize:function(){
		this.fx = new Fx.Style(this.toolTip, 'opacity', {duration: 100, wait: false}).set(0);
	},
	onShow: function(toolTip) {
		this.fx.start(1);
	},
	onHide: function(toolTip) {
		this.fx.start(0);
	}

});

var toolTips = new Tips($$('.extraLinkTip'), {
	className: 'extraLinkTip',
	//fixed: true,
	initialize:function(){
		this.fx = new Fx.Style(this.toolTip, 'opacity', {duration: 100, wait: false}).set(0);
	},
	onShow: function(toolTip) {
		this.fx.start(1);
	},
	onHide: function(toolTip) {
		this.fx.start(0);
	}

});

/////////////////////////////////////////////////////////////////////////////////////////////////// FEATURED ARTIST SETUP
$$("#containerFeaturedArtist").each(function(container){

//////////////////////////////////////// DATA
var receiveVideoData = document.getElementById('ffVideo').getAttribute('videoDATA');

var receiveAudioDataUrl = document.getElementById('ffAudio').getAttribute('audioDATAurl');
var receiveAudioDataArtist = document.getElementById('ffAudio').getAttribute('audioDATAartist');
var receiveAudioDataTrack = document.getElementById('ffAudio').getAttribute('audioDATAtrack');

//////////////////////////////////////// TRIGGER RELEASES
container.getElement("#ffReleases").addEvent("mousedown", function(){

//NEEDS TO SEND THIS DATA TO THE RELEASES PAGE INSTEAD OF INSERT:
//mootoolsInsert('insert_featuredArtistReleases.php?featuredID='+receiveAudioDataArtist+'', 'boxFeaturedArtistMedia');
});

//////////////////////////////////////// TRIGGER AUDIO
container.getElement("#ffAudio").addEvent("mousedown", function(){
																					 
hidediv('ffvideoFullScreen');
showdiv('boxFeaturedArtistAudioList');
var newTimer = insertFlashFeaturedAudio(receiveAudioDataUrl, receiveAudioDataArtist, receiveAudioDataTrack).delay(1100);
});


//////////////////////////////////////// TRIGGER VIDEO
container.getElement("#ffVideo").addEvent("mousedown", function(){
hidediv('boxFeaturedArtistAudioList');

showdiv('ffvideoFullScreen');
var newTimer = insertFlashFeaturedVideo(receiveVideoData).delay(1100);
});

//////////////////////////////////////// TRIGGER VIDEO FULLSCREEN
function removeFeaturedVideo(){
video_control("featuredArtist_video", "stop");
//hidediv('ffvideoFullScreen');
}
container.getElement("#ffvideoFullScreen").addEvent("mousedown", function(){
var newTimer = removeFeaturedVideo.delay(700);
});

////// AUTO START MUSIC STATUS:OFF
//showdiv('boxFeaturedArtistAudioList');
//var newTimer = insertFlashFeaturedAudio(receiveAudioDataUrl, receiveAudioDataArtist, receiveAudioDataTrack).delay(1100);

////// AUTO START VIDEO STATUS:ON
showdiv('ffvideoFullScreen');
var newTimer = insertFlashFeaturedVideo(receiveVideoData).delay(1700);
// END
});

/////////// END WINDOW ADD EVENT
});

//////////////////////////////////////// TRIGGER PHOTO
function loadPhoto(imageFILE){
mootoolsInsert('insert_featuredArtistPhoto.php?photoID='+imageFILE+'', 'boxFeaturedArtistPhotoContainer');
}
setTimeout(function(){
var receivePhotoDATA = document.getElementById('boxFeaturedArtistPhotoContainer').getAttribute('photoINITdata');
loadPhoto(receivePhotoDATA);
}, 2000);

/////////////////////////////////////////////////////////////////////////////////////////////////// AJAX INSERT
function mootoolsInsert(contentDATA, divDATA){
var url = contentDATA;
new Ajax(url, {method: 'get',update: $(divDATA)}).request();
}

/////////////////////////////////////////////////////////////////////////////////////////////////// JUMP MENU SETUP
function MM_jumpMenuGo(objId,targ,restore){ //v9.0
  var selObj = null;  with (document) { 
  if (getElementById) selObj = getElementById(objId);
  if (selObj) eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0; }
}
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}
/////////////////////////////////////////////////////////////////////////////////////////////////// MERCH SLIDE SETUP
function frontMerchSlideNext(){
new SimpleSlide('SimpleSlide',{type: 'scroll', direction: 'forward', duration: 600});
}
function frontMerchSlidePrev(){
new SimpleSlide('SimpleSlide',{type: 'scroll', direction: 'back', duration: 600});
}