/* Analytics */
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-667739-24']);
_gaq.push(['_setDomainName', 'deezup.com']);
_gaq.push(['_trackPageview']);

(function() {
  var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
  ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
  var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

/* Google Fonts */
WebFontConfig = {
  google: { families: [ 'Baumans::latin' ] }
};
(function() {
  var wf = document.createElement('script');
  wf.src = ('https:' == document.location.protocol ? 'https' : 'http') +
	'://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js';
  wf.type = 'text/javascript';
  wf.async = 'true';
  var s = document.getElementsByTagName('script')[0];
  s.parentNode.insertBefore(wf, s);
})(); 

$(function () {
  $("a[rel=twipsy]").twipsy({
	live: true,
	html: true
  })
});

$(function () {
	$("img[rel=twipsy]").twipsy({
		live: true,
		html: true
	})
})

function fermerErreur(modalId){
	$('#'+modalId+'').modal({
		show : false,
		backdrop : true
	});
};

function pasConnecte(){
  $(function(){
	  $('#pasConnectePop').modal({
		  show : true,
		  backdrop : true
	  });
  });
};

function pleinEcran(){
	$("#areaJeu").toggleClass("pleinEcran");
	lancerJeu();
};// pleinEcran

function onLine(id){
  $.post("script.php", { a:"onLine", idUser:id }, function(data){
	  $("#EnLigne").html(data);
  });
  setTimeout("onLine(id)",10000);
}; //fin onLine

function onML(){
	$.get("mailing.php");
}; // onML

function onMLD(){
	$.get("mailingDefis.php");
}; // onMLD

function appli(){
	$("#appliPop").modal({
		show:true,
		backdrop : true
	});
};

function about(){
	$("#aboutPop").modal({
		show:true,
		backdrop : true
	});
};

function shuffle(a){
   var j = 0;
   var valI = '';
   var valJ = valI;
   var l = a.length - 1;
   while(l > -1)
   {
		j = Math.floor(Math.random() * l);
		valI = a[l];
		valJ = a[j];
		a[l] = valJ;
		a[j] = valI;
		l = l - 1;
	}
	return a;
};

/* Gestion des jeux préférés */
function ajouterJeuFavori(ie){
	$.post('scripts/MesJeux_class.php', {a:1, ie:ie}, function( data ){
	  $('#mesJeux').html( data );		
	});
}

/* Gestion des amis */
function demandeAmi(e, iu){
  $.post('scripts/Amis_class.php', {a:1, iu:iu},
   function ( data ){
	$('#demandeAmisPop').remove();	  
	$('body').append( data );
	$(e).addClass('disabled');
	$(e).attr('onClick','javascript:void(0);');
	
	$.post('mailingAmis.php', {idUser:iu});
   }
  );
}

function accepterAmi(ia, iu){
  $.post('scripts/Amis_class.php', { a:2, ia:ia, iu:iu },
   function( data ){
	$('#a'+ia).remove();
	$('#amis').html(data);
   }
  );
}

function ignorerAmi(ia){
  $.post('scripts/Amis_class.php', { a:3, ia:ia},
   function( data ){
	$('#a'+ia).remove();
   }
  );
}

function supprimerAmi(ia, iu, e){
  $.post('scripts/Amis_class.php', {a:4, iu:iu, ia:ia}, 
  function(data){
	  $(e).parent('li').remove();
	  $('#amis').html(data);
  });
}


function afficheAmis(iu){
  $.post('scripts/Amis_class.php', { a:6, iu:iu },
   function( data ){
	 $('#afficheAmisPop').remove();
	 $('body').append( data );
   }
  );
}




