
var webroot = 'http://www.iankellysmusic.com';

$(document).ready(function(){


    $("img[@src$=png], #albums li, tr.bg_45, input.img").pngfix();

	
	
	// rollOver function
	$(".rollover").hover(
	function(){
		if($(this).attr("src").indexOf("-active") == -1) {
			var newSrc = $(this).attr("src").replace(".png","-active.png#hover");
			$(this).attr("src",newSrc);
		}
	},
	function(){
		if($(this).attr("src").indexOf("-active.png#hover") != -1) {
			var oldSrc = $(this).attr("src").replace("-active.png#hover",".png");
			$(this).attr("src",oldSrc);
		}
	}
	);
	
	// HORIZONTAL SCROLL
	$.easing.easeOutQuart = function (x, t, b, c, d) {
			return -c * ((t=t/d-1)*t*t*t - 1) + b;
		};
	$('#scroll').serialScroll(
		{
				items:'li',
				prev:'#left_scroll',
				next:'#right_scroll',
				axis:'x',
				offset:-5, //when scrolling to photo, stop 230 before reaching it (from the left)
				start:0, //as we are centering it, start at the 2nd
				duration:1200,
				force:true,
				stop:true,
				lock:false,
				cycle:false, //don't pull back once you reach the end
				easing:'easeOutQuart', //use this easing equation for a funny effect
				jump: false //click on the images to scroll to them
		}
	);
	
	$('#scroll_extras').serialScroll(
		{
				items:'ul',
				prev:'#left_scroll',
				next:'#right_scroll',
				axis:'x',
				offset:0, //when scrolling to photo, stop 230 before reaching it (from the left)
				start:0, //as we are centering it, start at the 2nd
				duration:1200,
				force:true,
				stop:true,
				lock:false,
				cycle:false, //don't pull back once you reach the end
				easing:'easeOutQuart', //use this easing equation for a funny effect
				jump: false //click on the images to scroll to them
		}
	);
	$('#scroll_opd').serialScroll(
		{
				items:'ul',
				prev:'#left_scroll',
				next:'#right_scroll',
				axis:'x',
				offset:0, //when scrolling to photo, stop 230 before reaching it (from the left)
				start:0, //as we are centering it, start at the 2nd
				duration:1200,
				force:true,
				stop:true,
				lock:false,
				cycle:false, //don't pull back once you reach the end
				easing:'easeOutQuart', //use this easing equation for a funny effect
				jump: false //click on the images to scroll to them
		}
	);
	
	///// VERTICAL SCROLL //////
	$('#media_scroll_comm').serialScroll(
		{
				items:'p',
				prev:'.top_scroll',
				next:'.bottom_scroll',
				axis:'y',
				offset:-10, //when scrolling to photo, stop 230 before reaching it (from the left)
				start:0, //as we are centering it, start at the 2nd
				duration:1200,
				force:true,
				stop:true,
				lock:false,
				cycle:false, //don't pull back once you reach the end
				easing:'easeOutQuart', //use this easing equation for a funny effect
				jump: false //click on the images to scroll to them
		}
	);
	
	$('#bio').serialScroll(
		{
				items:'p',
				prev:'#top_scroll_bio',
				next:'#bottom_scroll_bio',
				axis:'y',
				offset:0, //when scrolling to photo, stop 230 before reaching it (from the left)
				start:0, //as we are centering it, start at the 2nd
				duration:1200,
				force:true,
				stop:true,
				lock:false,
				cycle:false, //don't pull back once you reach the end
				easing:'easeOutQuart', //use this easing equation for a funny effect
				jump: false //click on the images to scroll to them
		}
	);
	
	$('#spectacles_content').serialScroll(
		{
				items:'div',
				prev:'#top_scroll',
				next:'#bottom_scroll',
				axis:'y',
				offset:0, //when scrolling to photo, stop 230 before reaching it (from the left)
				start:0, //as we are centering it, start at the 2nd
				duration:1200,
				force:true,
				stop:true,
				lock:false,
				cycle:false, //don't pull back once you reach the end
				easing:'easeOutQuart', //use this easing equation for a funny effect
				jump: false //click on the images to scroll to them
		}
	);



	
	///// FLASH EMBEDDING //////
	
	$('.embedBabillard').flash(
        { src: webroot+"/medias/flash/babillard.swf", height: 450, width: 850 },
        { version: 8 },
        function(htmlOptions) {
            $this = $(this);
            htmlOptions.wmode = 'transparent';
            this.innerHTML = '';
            $(this).addClass('flashBB').prepend($.fn.flash.transform(htmlOptions));
            return false;
        }
    );
	
	$('.audioExtras').flash(
        { src: webroot+"/medias/flash/audioextras.swf", width: 300, height: 30},
        { version: 8 },
        function(htmlOptions) {
            $this = $(this);
            htmlOptions.flashvars.soundFile = "http://www.audiogram.com/doc/pc_audio/"+$this.attr('rel');
			htmlOptions.flashvars.titles = $this.attr('titre');
			htmlOptions.flashvars.width = "290";
            htmlOptions.flashvars.transparentpagebg = "yes";
			htmlOptions.flashvars.autostart = "yes";
			htmlOptions.flashvars.leftbg = "333333";
			htmlOptions.flashvars.lefticon = $this.attr('color');
			htmlOptions.flashvars.rightbg = "333333";
			htmlOptions.flashvars.righticon = $this.attr('color');
			htmlOptions.flashvars.voltrack = $this.attr('color');
			htmlOptions.flashvars.bg = "111111";
			htmlOptions.flashvars.track = "333333";
			htmlOptions.flashvars.text = $this.attr('color');
			htmlOptions.flashvars.skip = "000000";
			htmlOptions.flashvars.loader = $this.attr('color');
			htmlOptions.flashvars.tracker = "000000";
			htmlOptions.flashvars.border = $this.attr('color');
			htmlOptions.wmode = 'transparent';
            this.innerHTML = '';
            $(this).addClass('mp3player').prepend($.fn.flash.transform(htmlOptions));
            return false;
        }
    );
	
	
	$('.audioPlayer').flash(
        { src: webroot+"/medias/flash/audioplayer.swf", height: 16, width: 40 },
        { version: 7 },
        function(htmlOptions) {
            $this = $(this);
            htmlOptions.flashvars.extrait = $this.attr('id');
            htmlOptions.flashvars.fade = $this.attr('fade');
            htmlOptions.wmode = 'transparent';
            this.innerHTML = '';
            $(this).addClass('mp3player').prepend($.fn.flash.transform(htmlOptions));
            return false;
        }
    );
    

    
    $('.videoPlayer').flash(
        { src: webroot+"/medias/flash/player.swf", height: 315, width: 400 },
        { version: 8 },
        function(htmlOptions) {
            $this = $(this);
            htmlOptions.flashvars.le_id = $this.attr('id');
            htmlOptions.flashvars.le_type = $this.attr('rel');
            htmlOptions.flashvars.a_run = $this.attr('a_run');
            htmlOptions.flashvars.clr = $this.attr('clr');
            htmlOptions.wmode = 'transparent';
            this.innerHTML = '';
            $(this).addClass('flashVideo').prepend($.fn.flash.transform(htmlOptions));
            return false;
        }
    );
	

	$('.spectAnim').flash(
        { src: webroot+"/medias/flash/anim_spect.swf", height: 570, width: 500 },
        { version: 8 },
        function(htmlOptions) {
            $this = $(this);
            htmlOptions.wmode = 'transparent';
            this.innerHTML = '';
            $(this).addClass('flashVideo').prepend($.fn.flash.transform(htmlOptions));
            return false;
        }
    );
    
    $('.photoGallery').flash(
        { src: webroot+"/medias/flash/image_gallery.swf", height: 550, width: 600 },
        { version: 8 },
        function(htmlOptions) {
            $this = $(this);
            htmlOptions.flashvars.xmlFile = '/inc/php/photo_gallery.php?id_gallery='+$this.attr('id');
            htmlOptions.wmode = 'transparent';
            this.innerHTML = '';
            $(this).addClass('flashGallery').prepend($.fn.flash.transform(htmlOptions));
            return false;
        }
    );
		
	 $('#logo_audiogram').flash(
        { src:  webroot+"/medias/flash/logo-audiogram.swf", width: 175, height: 28 },
        { version: 8 },
        function(htmlOptions) {
            $this = $(this);
            htmlOptions.wmode = 'transparent';
            this.innerHTML = '';
            $(this).addClass('logo_audiogram').prepend($.fn.flash.transform(htmlOptions));
            return false;
        }
    );
	
	
	    // SHOW LYRICS
    $('.showLyrics').click(function() {
    	$('.lyrics').hide("fast");
    	var Song = $(this).attr("rel");
    	$.scrollTo('#boxLyrics', 400, { easing:'easeOutQuart' });
    	$('#'+Song).show("slow");
    	return false;
   	});
	
	
	
	// SHOW MEDIA
    $('.showMedias').click(function() {
    	$('.medias').fadeOut("fast");
    	var mediaObject = $(this).attr("rel");
    	$('#password_'+mediaObject).fadeIn("slow");
    	//$('#media_scroll_'+mediaObject).trigger( 'goto', [ 0 ] );
    	return false;
   	});
   	
   	
/// AJAX FUNCTIONS ////////////////////////////////////////////////////////////////
/// AJAX FUNCTIONS ////////////////////////////////////////////////////////////////
/// AJAX FUNCTIONS ////////////////////////////////////////////////////////////////
/// AJAX FUNCTIONS ////////////////////////////////////////////////////////////////
/// AJAX FUNCTIONS ////////////////////////////////////////////////////////////////
/// AJAX FUNCTIONS ////////////////////////////////////////////////////////////////
/// AJAX FUNCTIONS ////////////////////////////////////////////////////////////////
/// AJAX FUNCTIONS ////////////////////////////////////////////////////////////////
/// AJAX FUNCTIONS ////////////////////////////////////////////////////////////////
/// AJAX FUNCTIONS ////////////////////////////////////////////////////////////////
/// AJAX FUNCTIONS ////////////////////////////////////////////////////////////////
	$("#login_dossiers").submit(function()
	{
		//remove all the class add the messagebox classes and start fading
		$("#problem_dossiers").html('').addClass('loading').fadeIn("fast");
		//check the password
		$.post("/ajax/login",{ password:$('#pwdLogin_dossiers').val(), artiste:$('#artiste_dossiers').val(), lang:$('#lang').val() } ,function(data)
		{
		  if(data == 'no' || data == '') {
			$("#problem_dossiers").fadeTo(200,0.1,function() { 
				if( $('#lang').val() == 'fr' )
					$(this).html('<br>Mot de passe invalide!').addClass('error').removeClass('loading').fadeTo(700,1);
				else
					$(this).html('<br>Invalid password!').addClass('error').removeClass('loading').fadeTo(700,1);
			});		
		  }
		  else {
			$("#protected").html(data);
			$('.showMedias').click(function() {
			$('.medias').fadeOut("fast");
				var mediaObject = $(this).attr("rel");
				$('#password_'+mediaObject).fadeIn("slow");
				$('#media_scroll_'+mediaObject).trigger( 'goto', [ 0 ] );
				return false;
			});
			$("#password_dossiers").fadeIn("slow");
		  }
				
		});
		return false; 
	});
	
	$("#login_fichiers").submit(function()
	{
		//remove all the class add the messagebox classes and start fading
		$("#problem_fichiers").html('').addClass('loading').fadeIn("fast");
		//check the password
		$.post("/ajax/login",{ password:$('#pwdLogin_fichiers').val(), artiste:$('#artiste_fichiers').val(), lang:$('#lang').val() } ,function(data)
		{
		  if(data == 'no' || data == '') {
			$("#problem_fichiers").fadeTo(200,0.1,function() { 
				if( $('#lang').val() == 'fr' )
					$(this).html('<br>Mot de passe invalide!').addClass('error').removeClass('loading').fadeTo(700,1);
				else
					$(this).html('<br>Invalid password!').addClass('error').removeClass('loading').fadeTo(700,1);
			});		
		  }
		  else {
			$("#protected").html(data);
			$('.showMedias').click(function() {
			$('.medias').fadeOut("fast");
				var mediaObject = $(this).attr("rel");
				$('#password_'+mediaObject).fadeIn("slow");
				$('#media_scroll_'+mediaObject).trigger( 'goto', [ 0 ] );
				return false;
			});
			$("#password_fichiers").fadeIn("slow");
		  }
				
		});
		return false; 
	});
	
	
	
	
	
	
	
	
	
		// abonnement à la liste d'envoi
		$("#subscribe").submit(function() {
			var $a = $('#adresse').val();
			
			var $lang = $('#lang').val();
			if ($lang == 'fr') { var $wait = 'un instant...'; }
			else { var $wait = 'one moment please...'; }
			
			//loading...
			$("#adresse").val($wait);
				
			//subscribe the user
			$.post("/ajax/subscribe", { adresse:$a, artiste:$('#artiste').val(), lang:$lang }, function(data) {
			  if (data == 'erreur' || data == '') {
				$("#adresse").val('erreur');	
			  } else {
				$("#adresse").val(data);
			  }
			});
			
			return false; 
		});
		
		$("#adresse").focus(function() {
			$("#adresse").val('');
		});
	
		
	});
/// AJAX FUNCTIONS ////////////////////////////////////////////////////////////////
/// AJAX FUNCTIONS ////////////////////////////////////////////////////////////////
/// AJAX FUNCTIONS ////////////////////////////////////////////////////////////////
/// AJAX FUNCTIONS ////////////////////////////////////////////////////////////////
/// AJAX FUNCTIONS ////////////////////////////////////////////////////////////////
/// AJAX FUNCTIONS ////////////////////////////////////////////////////////////////
/// AJAX FUNCTIONS ////////////////////////////////////////////////////////////////
/// AJAX FUNCTIONS ////////////////////////////////////////////////////////////////
/// AJAX FUNCTIONS ////////////////////////////////////////////////////////////////
/// AJAX FUNCTIONS ////////////////////////////////////////////////////////////////
/// AJAX FUNCTIONS ////////////////////////////////////////////////////////////////


//////////////////////////////////////////////////////////////////////////////////////////////////////////////
//	Fonction pour faire changer le player de position
//	Parametre (s) : quel clip
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
var qui = '';

function changeStatus(quelClip)
{
	if (qui == "")
	{
		qui = quelClip;
	}
	else
	{
		document.getElementById(qui).childNodes[0].TGotoFrame("_level0", 4);
		qui = quelClip;
	}
}


//////