$(document).ready(function(){
	$("a.iframe").fancybox({
		"overlayShow" : false,
		"zoomSpeedIn" : 500,
		"zoomSpeedOut" : 500,
		"easingIn" : "easeOutBack",
		"easingOut" : "easeInBack",
		"centerOnScroll" : true,
		"frameWidth" : 850,
		"frameHeight" : 500,
		"hideOnContentClick" : false
	});
});


var submit_form1 = 0;
function submit_form(formulaire) {
	if (submit_form1 == 1) {
		alert("Vous avez déjà clické une fois, merci de patienter...");
	}
	else {
		submit_form1 = 1;
		document.forms[formulaire].submit();
	}
	
}

function checkNum(e) { 
	var event = e ? e : window.event;
	var target = e ? event.target : event.srcElement;
	var key = event.keyCode;

    if ( (key<48 || key>57) && key!=13)  { return false; }
	return true;
}


function SelectAll(formulaire) {
	len = document.forms[formulaire].elements.length;
	var i=0;
	for( i=0; i<len; i++) {
		if (document.forms[formulaire].elements[i].type=="checkbox") {
			document.forms[formulaire].elements[i].checked = !document.forms[formulaire].elements[i].checked;
		}
	}
}

function insert_flash(name,url,width,height,param) {
	document.write('<object name="'+name+'" id="'+name+'" type="application/x-shockwave-flash" data="'+url+'" width="'+width+'" height="'+height+'"><param name="movie" value="'+url+'" />'+param+'</object>');
}

function showMel(email) {
	if (email == 'noreply') {
		coded = "fRA1sdW@h8A12z.XA"
		key = "te4yzLTDfojQP03dMv1HWpCEaXRhcbUw8SrK6qsZI2Yk9JGiOm7AFnxNBVgul5"
  	}
	else {
		coded = "RmQ69R6@3qYn9T.ZY"
		key = "gDxu7ZqEY0zLhmIQ5pVFSUjWivNaCcT8Oy1MHBt3GPbe92RlAXfdsr46JkownK"
	}
	shift=coded.length;
	link="";
	for (i=0; i<coded.length; i++) {
		if (key.indexOf(coded.charAt(i))==-1) {
			ltr = coded.charAt(i)
			link += (ltr)
		}
		else {     
			ltr = (key.indexOf(coded.charAt(i))-shift+key.length) % key.length
			link += (key.charAt(ltr))
		}
	}
	document.write("<a href='mailto:"+link+"'>"+link+"</a>");
}

function confirmation(ttl,msg) {
	$("#dialog_confirm").remove();
	$("body").prepend('<div id="dialog_confirm">'+msg+'</div>');
	$("#dialog_confirm").dialog({
		title:ttl,
		height: 100,
		minHeight: 100,
		bgiframe: true,
		autoOpen: true,
		modal:true
	});
	
}
function flasher(pseudo) {
	if(confirm('Etes-vous sûr de vouloir flasher sur '+pseudo+' ?')) {
		$.post("/js/ajax_flash.php", { valid:1, pseudo:pseudo }, function(xml) {
			ttl = $("ttl",xml).text();
			msg = $("msg",xml).text()
			confirmation(ttl,msg);
		},"xml");
	}
}

function selection_add(pseudo) {
	if(confirm('Etes-vous sûr de vouloir ajouter '+pseudo+' à votre sélection ?')) {
		$.post("/js/ajax_selection.php", { valid:1, pseudo:pseudo }, function(xml) {
			ttl = $("ttl",xml).text();
			msg = $("msg",xml).text()
			confirmation(ttl,msg);
		},"xml");
	}
}

function blacklist_add(pseudo) {
	if(confirm('Etes-vous sûr de vouloir ajouter '+pseudo+' à votre liste noire ?')) {
		$.post("/js/ajax_blacklist.php", { valid:1, pseudo:pseudo }, function(xml) {
			ttl = $("ttl",xml).text();
			msg = $("msg",xml).text()
			confirmation(ttl,msg);
		},"xml");
	}
}

