function init_NewWindowLinks(){		
	if($('.targetblank')!=null)
	$('.targetblank').click(function(){
		window.open( $(this).attr("href") );
		return false;
	});
}

// Initialize functions
$(function(){
	init_NewWindowLinks();
});


function showArtistImage(image_src) {

	var img = new Image();
    $(img).load(function () {
		$("#artist_big img").attr('src', image_src);
    }).error(function () {
    }).attr('src', image_src);
}

function showTellafriend() {

	var win = window.open('tellafriend1.html', '_blank', 'width=750,height=550,status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=1,scrollbars=0');
	win.focus();
	return false;

}

function open_game(url) {

	var left = (screen.width/2)-(850/2);
	var top = (screen.height/2)-(490/2);
	
	var win = window.open(url, '_blank', 'width=850,height=490,top='+top+',left='+left+',status=0,toolbar=0,location=0,menubar=0,directories=0,resizable=1,scrollbars=0');
	win.focus();
	return false;
}

function current_nav() {	
	var element = $(".current a");
	if(element==null){
		jQuery.noConflict();
		element=jQuery(".current a");
	}
	if(element.parent().attr('id')!="nav_link_home")		
		element.css({backgroundPosition: 'center -102px'});
}


$().ready(function() {
	current_nav();
});


/* countdown */

var TargetDate = "01/14/2009 23:59:59";
var CountActive = true;
var CountStepper = -1;
var LeadingZero = true;

function calcage(secs, num1, num2) {
  s = ((Math.floor(secs/num1))%num2).toString();
  if (LeadingZero && s.length < 2)
    s = "0" + s;
  return s;
}

function CountBack(secs) {
  if (secs < 0) {
	  diff_dd = '00';
	  diff_hh = '00';
	  diff_mm = '00';
	  CountActive = false;;
  } else {
	  diff_dd = calcage(secs,86400,100000);
	  diff_hh = calcage(secs,3600,24);
	  diff_mm = calcage(secs,60,60);
  }

  if (!document.getElementById('countdown_dd')) {
  	return;
  }
  
  var div_dd = $("#countdown_dd");
  div_dd.html('<span>' + diff_dd + '</span><br />jj');


  var div_hh = $("#countdown_hh");
  div_hh.html('<span>' + diff_hh + '</span><br />hh');


  var div_mm = $("#countdown_mm");
  div_mm.html('<span>' + diff_mm + '</span><br />mm');
  
  if (CountActive)
    setTimeout("CountBack(" + (secs+CountStepper) + ")", 1000);
}


$().ready(function() {

	CountStepper = Math.ceil(CountStepper);
	if (CountStepper == 0)
	  CountActive = false;
	var dthen = new Date(TargetDate);
	var dnow = new Date();
	ddiff = new Date(dthen-dnow);
	gsecs = Math.floor(ddiff.valueOf()/1000);
	CountBack(gsecs);

});

/********************
 * Artists slideshow*
 ********************/

var _globalArtistIndex=0;
var _totalArtists=0;
var _globalblock=0;

function artisteSlideShowInit(){
	updateArtisteSlideShow(1);	
	$("#box23 .next").click(function(){
		if(_globalArtistIndex+3<=_totalArtists && _globalblock == 0){
			_globalblock=1;
			_globalArtistIndex++;
			var last1=$("#box_23_artist1 #box_23_artist12 a:last");
			var last2=$("#box_23_artist2 #box_23_artist23 a:last");
			var last3=$("#box_23_artist3 #box_23_artist34 a:last");			
			updateArtisteSlideShow(1);
			if(last1.length>0){				
				last1.animate({marginLeft:"-92px"},"slow",function(){last1.remove();});
				last2.animate({marginLeft:"-92px"},"slow",function(){last2.remove();});
				last3.animate({marginLeft:"-92px"},"slow",function(){last3.remove();_globalblock=0});
			}
		}
	});	
	$("#box23 .prev").click(function(){
		if(_globalArtistIndex>0 && _globalblock == 0){
			_globalblock=1;
			_globalArtistIndex--;				
			var last1=$("#box_23_artist1 #box_23_artist12 a:last");
			var last2=$("#box_23_artist2 #box_23_artist23 a:last");
			var last3=$("#box_23_artist3 #box_23_artist34 a:last");			
			updateArtisteSlideShow(-1);
			if(last1.length>0){
				$("#box_23_artist1 #box_23_artist12  a:first").animate({marginLeft:"0px"},"slow",function(){last1.remove();});
				$("#box_23_artist2 #box_23_artist23  a:first").animate({marginLeft:"0px"},"slow",function(){last2.remove();});
				$("#box_23_artist3 #box_23_artist34  a:first").animate({marginLeft:"0px"},"slow",function(){last3.remove();_globalblock=0});
			}
		}
	});
}

function updateArtisteSlideShow(direct){	
	if(direct==1){		
	$("#all_artists_list a").each(function(i){
		_totalArtists=i;		
		if(i==_globalArtistIndex){			
			$("#box_23_artist1 #box_23_artist12").append($(this).clone());			
		}else if(i==_globalArtistIndex+1){
			$("#box_23_artist2 #box_23_artist23").append($(this).clone());			
		}else if(i==_globalArtistIndex+2){
			$("#box_23_artist3 #box_23_artist34").append($(this).clone());
		}		
	});
	}else{				
		$("#all_artists_list a").each(function(i){
			_totalArtists=i;		
			if(i==_globalArtistIndex){									
				$("#box_23_artist1 #box_23_artist12").prepend($(this).clone().css("margin-left","-92px"));			
			}else if(i==_globalArtistIndex+1){
				$("#box_23_artist2 #box_23_artist23").prepend($(this).clone().css("margin-left","-92px"));			
			}else if(i==_globalArtistIndex+2){
				$("#box_23_artist3 #box_23_artist34").prepend($(this).clone().css("margin-left","-92px"));
			}		
		});
	}
	$("a.zoom1").fancybox({
		'overlayOpacity'	:	0.7,
		'overlayColor'		:	'#000'
	});	
}


function pause_general(flashId){
	var flash = getFlashObject(flashId);
	flash.SetVariable("player:jsStop", "");	
}

function pause_general_b(){	
	$("div.video_border object")[0].SetVariable("player:jsPause", "");
}

function pause_marraine(){
	var flash = getFlashObject("monFlash");
	if(flash==undefined)
		return;
	flash.SetVariable("player:jsPause", "");			
}

function getFlashObject(movieName) {
     if (window.document[movieName]) {
         return window.document[movieName];
     }
     if (navigator.appName.indexOf("Microsoft Internet") == -1) {
         if (document.embeds && document.embeds[movieName])
             return document.embeds[movieName];
     } else {
         return document.getElementById(movieName);
     }
}	

function mp3player_onclick(){		
	$("#dewplayer").click(function(){		
		pause_general_b();		
	});														
} 