var total_commande = 0 ;

/***
* ENVOI AUTO DES FORMULAIRES
***/
document.onkeydown = gere_touche;
function gere_touche(e){
	if(codeTouche(e) == "13")
	{
		// fomulaire d'authentification
		if(document.getElementById("login").value != "")
			verifLogin();
	}
}
function suche_glisser(){
	Effect.toggle('suche', 'slide');
}

// verifie la validite d'un email
function validemail(champ)
{
	
 test = document.formulaire.elements[""+champ+""].value;
 valeur = test.indexOf("@");
 valeur2 = test.lastIndexOf(".");
 valeur3 = valeur2 + 1;
 longueur = test.length;
 ext = test.substring(valeur3,longueur);
 ok=0;
 temp = ext.length;
 if ( temp==2 || temp==3 ) 
    { ok=1; }
 else
    { ok=0; }
 if ( valeur2 == (valeur + 1) )
     { ok=0; }
 if (valeur==0)
     { ok=0; }
 if (valeur==-1 || valeur2==-1 || ok==0)
    { alert(get_trad_champ("email"));
      return false; }
 else
    { return true; }   
    
}

// verifie la validite d'un email
function validemail_bis(test)
{
	
 valeur = test.indexOf("@");
 valeur2 = test.lastIndexOf(".");
 valeur3 = valeur2 + 1;
 longueur = test.length;
 ext = test.substring(valeur3,longueur);
 ok=0;
 temp = ext.length;
 if ( temp==2 || temp==3 ) 
    { ok=1; }
 else
    { ok=0; }
 if ( valeur2 == (valeur + 1) )
     { ok=0; }
 if (valeur==0)
     { ok=0; }
 if (valeur==-1 || valeur2==-1 || ok==0)
    { alert(get_trad_champ("email"));
      return false; }
 else
    { return true; }   
    
}

// verifie les champs obligatoire d'un formulaire
valider_formulaire = function () {
	var tab = valider_formulaire.arguments;

	taille = tab.length;

	for (i=0;i<taille;i++) {
		if (tab[i]=="email") {
			if (!validemail(tab[i])) {
				return 0; 
			}
		}else{
			if ((document.formulaire.elements[tab[i]].value=="") || (document.formulaire.elements[tab[i]].value==" ")) {
				str_temp = tab[i].replace(/_/g," ");
				alert(get_trad_champ(str_temp));
				return 0; 
			}
		}
	}
	
	document.formulaire.submit();
}

function empechechar()
{
	if( event.keyCode < 48 || event.keyCode > 57 )
 	{ 
 		alert(get_trad_champ("numeric") );
   		event.returnValue = false;
   	}
}

// fonction qui fait apparaitre le sablier sur soumission de formulaire un peu long..

// Variable témoin de la validation effectuée ou pas
var deja = 0;

function valider(nom_form) {
	// Si on n'a pas déjà validé
	if ( deja == 0 ) {

		// On marque qu'on valide
		deja = 1;
					
		// On affecte le style 'sablier' au corps de la page
		document.body.className = 'sablier';
		
		// On lance la soumission du formulaire
		eval('document.'+nom_form+'.submit()');
	} /*else {
		alert('Le formulaire est déjà validé, veuillez patienter.'); */
}
function show_alert_img_repl(){
	document.getElementById("alert_img_repl").style.display = "block";
	document.getElementById("alert_img_repl").style.visibility = "visible";
	
}
function hide_alert_img_repl(){
	document.getElementById("alert_img_repl").style.display = "none";
	document.getElementById("alert_img_repl").style.visibility = "hidden";
	
}
function show_sablier() {
	document.body.className = 'sablier';
}

function hide_sablier() {
	document.body.className = '';
}

function login(mylog,mypass) {
	show_sablier();
	checkLogin(mylog,mypass);
}

function showCritaire(param) {
	document.getElementById(param).style.display = "block";
}

function showCurrentRub(){
	if(document.getElementById("sousmenu_"+current_rub) != null)
		document.getElementById("sousmenu_"+current_rub).style.visibility = "visible";
}
function showSousmenu(id) {
	if(document.getElementById("sousmenu_"+id) != null)
		document.getElementById("sousmenu_"+id).style.visibility = "visible";
}
function hideSousmenu(id) {
	document.getElementById("sousmenu_"+id).style.visibility = "hidden";
	
}
function hideAllSousmenus() {
	for(i=0;i<70;i++)
	if(document.getElementById("sousmenu_"+i) != null)
		document.getElementById("sousmenu_"+i).style.visibility = "hidden";
	
}
function showDecinaison(param) {
	document.getElementById("visuProd").src = param;
	
	var index = param.indexOf("produits/")+9;
	var tmp = param.substr(index,param.length);
	tmp = tmp.replace(".jpg","");
	document.getElementById("refProd").innerHTML = tmp;
	// alert();
}

function imprimer() {
	window.print();
}
var ajaxRespVar = false;
var ajaxParamsTab = new Array();
var ajaxRespVar2 = false;
var ajaxParamsTab2 = new Array();

function ajax_response_publish(transport)
{
	
	var tmp_tab = new Array();
	if(transport.responseText.indexOf('ok') > -1){
		ajaxRespVar = true;
		tmp_tab = transport.responseText.split("|");
		for(i=1;i<=tmp_tab.length;i++){
			if(i%2 == 0){
				ajaxParamsTab[tmp_tab[i-1]] = tmp_tab[i];
			}
				
		}
				
	}
	else
		ajaxRespVar = false;
	

}
function ajax_response2_publish(transport)
{
	var tmp_tab = new Array();
	if(transport.responseText.indexOf('ok') > -1){
		ajaxRespVar = true;
		tmp_tab = transport.responseText.split("|");
		for(i=1;i<=tmp_tab.length;i++){
			if(i%2 == 0){
				ajaxParamsTab2[tmp_tab[i-1]] = tmp_tab[i];
			}
				
		}
				
	}
	else
		ajaxRespVar2 = false;
}

function add2selection(id_produits,is_promo){
	// alert(is_promo);
	var url = 'ajax/add2selection.php';
			new Ajax.Request(
			url, {asynchronous:false,method: 'get',  parameters: "id_produits="+id_produits+"&promo="+is_promo, onComplete: ajax_response_publish});
	if(document.getElementById('identifie').style.display == 'none'){
		document.location = "./login.php";
	}
	else{
		
		document.getElementById('total_selection').innerHTML = ajaxParamsTab['total_selection'];
		document.getElementById('head_tot_sel').innerHTML = ajaxParamsTab['total_selection'];		
	}
}

function del2selection(id_produits,is_promo){
	var url = 'ajax/del2selection.php';
			new Ajax.Request(
			url, {asynchronous:false,method: 'get',  parameters: "id_produits="+id_produits+"&promo="+is_promo, onComplete: ajax_response_publish});
	
		document.getElementById("produit_"+id_produits).innerHTML = "";
		document.getElementById("produit_"+id_produits).style.display = "none";
		$('total_selection').innerHTML = $('total_selection').innerHTML - 1;
		$('head_tot_sel').innerHTML = $('total_selection').innerHTML;
	
}

function add2commande(id_produits,index_config,id_tailles,id_couleurs,quantite,is_promo){
	var url = 'ajax/add2commande.php';
			new Ajax.Request(
			url, {asynchronous:false,method: 'get',  parameters: "id_produits="+id_produits+"&index_config="+index_config+"&id_tailles="+id_tailles+"&id_couleurs="+id_couleurs+"&quantite="+quantite+"&promo="+is_promo, onComplete: ajax_response_publish});
	if(document.getElementById('identifie').style.display == 'none'){
		document.location = "./inscription.php";
	}
	else{
		
		//	popup_alert_panier(id_produits);
		if(document.getElementById('head_tot_com'))
			document.getElementById('head_tot_com').innerHTML = ajaxParamsTab['total_commande'];	
		document.getElementById('total_commande').innerHTML = "&nbsp;"+ajaxParamsTab['total_commande']+"";
		// document.getElementById('pre_code').innerHTML = "<a href='selection.php' style='text-decoration: underline' class='tblanc12'>";
		// document.getElementById('post_code').innerHTML = "</a>";
		document.location.replace('commande.php?Rub=2&id_univ=1');
		
	}
}
function del2commande(id_produits,is_promo){
	
	var url = 'ajax/del2commande.php';
			new Ajax.Request(
			url, {asynchronous:false,method: 'get',  parameters: "id_produits="+id_produits+"&promo="+is_promo, onComplete: ajax_response_publish});
	if(is_promo == "promo"){
		
		document.getElementById("promo_"+id_produits).innerHTML = "";
		document.getElementById("promo_"+id_produits).style.display = "none";
		document.getElementById('total_commande').innerHTML = "&nbsp;"+ajaxParamsTab['total_commande']+"";
		$('head_tot_com').innerHTML = ajaxParamsTab['total_commande'];
	}
	else{
		
		document.getElementById("produit_"+id_produits).innerHTML = "";
		document.getElementById("produit_"+id_produits).style.display = "none";
		document.getElementById('total_commande').innerHTML = "&nbsp;"+ajaxParamsTab['total_commande']+"";
		$('head_tot_com').innerHTML = ajaxParamsTab['total_commande'];
		
	}
	
	var url = 'ajax/get_total_commande.php';
			new Ajax.Request(
			url, {asynchronous:false,method: 'get',  parameters:"&trompeCache="+new Date().getTime(), onComplete: ajax_response_publish});
	
	
	$('commande_total').innerHTML = ajaxParamsTab['total_commande'] +" Euro";
	
}


function del2commande_line(id_line,id_produits,is_promo){
	
	var url = 'ajax/del2commande_line.php';
			new Ajax.Request(
			url, {asynchronous:false,method: 'get',  parameters: "id_line="+id_line+"&id_produits="+id_produits+"&promo="+is_promo, onComplete: ajax_response_publish});
	
	
	if (ajaxParamsTab['del_produit'] == "yes" ) {
		
			if(is_promo == "promo"){				
				document.getElementById("promo_"+id_produits).innerHTML = "";
				document.getElementById("promo_"+id_produits).style.display = "none";
				document.getElementById('total_commande').innerHTML = "&nbsp;"+ajaxParamsTab['total_commande']+"";				
				//$('head_tot_com').innerHTML = ajaxParamsTab['total_commande'];
				if (document.getElementById('total_commande_toto') != null)	document.getElementById('total_commande_toto').innerHTML =  ajaxParamsTab['total_commande'];
			}
			else{
				
				document.getElementById("produit_"+id_produits).innerHTML = "";
				document.getElementById("produit_"+id_produits).style.display = "none";
				document.getElementById('total_commande').innerHTML = "&nbsp;"+ajaxParamsTab['total_commande']+"";
				//$('head_tot_com').innerHTML = ajaxParamsTab['total_commande'];				
				if (document.getElementById('total_commande_toto') != null)	document.getElementById('total_commande_toto').innerHTML =  ajaxParamsTab['total_commande'];
			}
	}
	else {			
			document.getElementById("line_"+id_line).innerHTML = "";
	}
	
	
	var tot_prod = ajaxParamsTab['total_commande'] ;
	
	var url = 'ajax/get_total_commande.php';
			new Ajax.Request(
			url, {asynchronous:false,method: 'get',  parameters:"&trompeCache="+new Date().getTime(), onComplete: ajax_response_publish});
	
	$('commande_total').innerHTML = ajaxParamsTab['total_commande'] +" Euro";
	
	
	//commande vide retour a la home
	if (tot_prod == 0 ) {
		popup_alert_panier_vide("lib_panier_vide");				
	}		
	eval(calc_total());
	
	
}


function updatecommande(id_produits,index_config,id_tailles,id_couleurs,quantite,is_promo,prix,obj){
	var retour;	
	retour = isNaN(quantite);
	
	if(retour == true)
	{
		popup_alert(quantite_NAN);
		obj.value = 1;
		updatecommande(id_produits,index_config,id_tailles,id_couleurs,1,is_promo,prix,obj);
	}
	else{
		if(quantite != "" && quantite=='0')
		{
			popup_alert(quantite_nulle_interdite);
			obj.value = 1;
			updatecommande(id_produits,index_config,id_tailles,id_couleurs,1,is_promo,prix,obj);
		}
		else
		{
			var url = 'ajax/updatecommande.php';
					new Ajax.Request(
					url, {asynchronous:false,method: 'get',  parameters: "id_produits="+id_produits+"&index_config="+index_config+"&id_tailles="+id_tailles+"&id_couleurs="+id_couleurs+"&quantite="+quantite+"&promo="+is_promo+"&prix="+prix+"&trompeCache="+new Date().getTime(), onComplete: ajax_response_publish});
			
			var pre = "";			
			
			if(is_promo != "promo")
			{	
				if(id_couleurs != "")
					$(pre+id_produits+'_id_couleurs_'+index_config).innerHTML = "<img valign='bottom' src='"+ajaxParamsTab['couleur_path']+"' alt='"+ajaxParamsTab['couleur_libelle']+"' title='"+ajaxParamsTab['couleur_libelle']+"'> ";				
				if(id_tailles != "")
					$(pre+id_produits+'_id_tailles_'+index_config).innerHTML = "<b>"+ajaxParamsTab['taille']+"</b>";				
			}
			else
			{
				pre = "promo_";
				if(id_couleurs != "")
					$(pre+id_produits+'_id_couleurs_'+index_config).innerHTML = "<img valign='bottom' src='"+ajaxParamsTab['couleur_path']+"' alt='"+ajaxParamsTab['couleur_libelle']+"' title='"+ajaxParamsTab['couleur_libelle']+"'> ";
				if(id_tailles != "")				
					$(pre+id_produits+'_id_tailles_'+index_config).innerHTML = "<b>"+ajaxParamsTab['taille']+"</b>";					
			}						
			
			if ( is_promo == "" )  is_promo = "''";
			else is_promo = "'promo'";			
			$('fill_produits').innerHTML = "fill_total_produit("+id_produits+","+is_promo+");";			
			eval($('fill_produits').innerHTML);
			//alert($('fill_produits').innerHTML);
			//fill_total_produit(id_produits,is_promo);
		}
	}	
}
function register_comments(){
	
	var url = 'ajax/register_comments.php';
			new Ajax.Request(
			url, {asynchronous:false,method: 'post',  parameters: "comments="+document.getElementById("comments").innerHTML+"&trompeCache="+new Date().getTime(), onComplete: ajax_response_publish});
	
	
}
function fill_total_produit(id_produits,is_promo){
	//alert("|"+id_produits+"|"+is_promo);
	var url = 'ajax/get_total_produit.php';
			new Ajax.Request(
			url, {asynchronous:false,method: 'get',  parameters: "id_produits="+id_produits+"&promo="+is_promo+"&trompeCache="+new Date().getTime(), onComplete: ajax_response_publish});
	
	if(is_promo == "promo"){
			$("promo_"+id_produits+'_total').innerHTML = ajaxParamsTab['total_montant']+"&euro;";
	}
	else{		
		$("produit_"+id_produits+'_total').innerHTML = ajaxParamsTab['total_produit']+"&euro;";
	}	
	
	var url = 'ajax/get_total_commande.php';
			new Ajax.Request(
			url, {asynchronous:false,method: 'get',  parameters:"&trompeCache="+new Date().getTime(), onComplete: ajax_response_publish});
		
	
	$('commande_total').innerHTML = ajaxParamsTab['total_commande'] +"&euro;";		
	
	if (document.getElementById('total_commande_toto') != null)
		document.getElementById('total_commande_toto').innerHTML =  ajaxParamsTab['total_commande'];
	else  total_commande = ajaxParamsTab['total_commande'];
	

}

function fill_quantite(id_produits,incr_num){
	var url = 'ajax/get_quantite_produit.php';
			new Ajax.Request(
			url, {asynchronous:false,method: 'get',  parameters: "id_produits="+id_produits+"&incr_num="+incr_num+"&trompeCache="+new Date().getTime(), onComplete: ajax_response_publish});
	
	
	if($(id_produits+'_qte_'+incr_num) != null){
		$(id_produits+'_qte_'+incr_num).value = ajaxParamsTab['quantite_produit'];
		// alert(incr_num);
	}
	//#{$id_produits}#_qte_#{$incr_num}#
}
// + lorsque l'on a quitté la commande et qu'on y retourne cette fontion reconstruit le panier
function build_commande(){
	
	
	
}
// à l'arrivée sur le panier calcule le total par défaut
function calc_total(){
	var divs = document.getElementsByTagName("div");
	for(var i = 0;i<divs.length;i++){
		if(divs[i].id.indexOf("produit_") > -1 && divs[i].id.indexOf("_config")==-1){
			var id_produit = divs[i].id.substr(8,divs[i].id.length);
			if(id_produit != "")
			fill_total_produit(id_produit,"");
		}
		else if(divs[i].id.indexOf("promo_") > -1 && divs[i].id.indexOf("_config")==-1){
			var id_produit = divs[i].id.substr(6,divs[i].id.length);
			// alert('uu'+id_produit);
			if(id_produit != "")
			fill_total_produit(id_produit,"promo");
		}
	}
	

	

	/*
	if(ajaxParamsTab['incr_num'] > 0){
		for(i=1;i<=ajaxParamsTab['incr_num'];i++)
			fill_quantite(id_produits,i);
	}
	*/
	
}
function verif_panier_not_empty(link){
	var url = 'ajax/alert.php';
			new Ajax.Request(
			url, {asynchronous:false,method: 'get',  parameters: "is_panier_not_empty=action&trompeCache="+new Date().getTime(), onComplete: ajax_response_publish});
	
	if(ajaxParamsTab['msg'] != "")
		alert(ajaxParamsTab['msg']);
	else
		document.location = link;
	
}

function verif_commande(link){
	
	if(document.getElementById('id_proclub') != null)
		var id_pro_club = document.getElementById('id_proclub').value;
	
	var url = 'ajax/alert.php';
			new Ajax.Request(
			url, {asynchronous:false,method: 'get',  parameters: "verif_commande=action&id_proclub="+id_pro_club + "&trompeCache="+new Date().getTime(), onComplete: ajax_response_publish});
	if(ajaxParamsTab['msg'] == "no_error"){
		document.location = link + "?id_proclub=" + id_pro_club;
	}
	else{
		alert(ajaxParamsTab['msg']);
	}
		
	
}


function newline_config_produit(id_produits,is_promo,id_pere){
	var url = 'ajax/config_produit.php';
			new Ajax.Request(
			url, {asynchronous:false,method: 'get',  parameters: "id_produits="+id_produits+"&promo="+is_promo+"&id_pere="+id_pere+"&trompeCache="+new Date().getTime(), onComplete: ajax_response_publish});		
	
	if(is_promo == "promo"){
		//document.getElementById("promo_"+id_produits+"_config").innerHTML = document.getElementById("promo_"+id_produits+"_config").innerHTML + ajaxParamsTab['content'];							
	 	newDiv = document.createElement("div");
	 	newDiv.setAttribute("id", "line_"+ajaxParamsTab['incr_num']);
	  	newDiv.innerHTML = ajaxParamsTab['content'];	
		document.getElementById("promo_"+id_produits+"_config").appendChild(newDiv); 
	}
	else{
		//document.getElementById("produit_"+id_produits+"_config").innerHTML = document.getElementById("produit_"+id_produits+"_config").innerHTML + ajaxParamsTab['content'];		
		newDiv = document.createElement("div");
	 	newDiv.setAttribute("id", "line_"+ajaxParamsTab['incr_num']);
	  	newDiv.innerHTML = ajaxParamsTab['content'];	
		document.getElementById("produit_"+id_produits+"_config").appendChild(newDiv); 
	}
		
	eval(calc_total());	
}

function restore_ids(){
	// #{$id_produits}#_qte_#{$incr_num}#
	var url2 = 'ajax/restore_ids.php';
	var inputs;
	inputs = document.getElementsByTagName("input");
	expression = new RegExp("(.*)_qte_(.*)","i")
	//alert(inputs.length);
	for(var i=0;i<inputs.length;i++){
		if(inputs[i].type == "text"){
			val = document.getElementById(inputs[i].id).value;
			regs = expression.exec(inputs[i].id);
			id_produits = regs[1];
			num_incr = regs[2];
			new Ajax.Request(
			url2, {asynchronous:false,method: 'get',  parameters: "id_produits="+id_produits+"&num_incr"+num_incr, onComplete: ajax_response2_publish});
			
		}
	}
	
}
function selcolor(id_sel){
	voiddd = "";
	
	
}
var titre_popup;
function popup_couleurs(id_produits,titre,index_config,is_promo,promo_id)
{
	// alert(index_config);
	titre_popup = titre;
	var url = 'ajax/popup_couleurs.php';
	var parametre = new String();
	parametre = "id_produits="+id_produits+"&index_config="+index_config+"&promo="+is_promo+"&promo_id="+promo_id;


	new Ajax.Request(
		url, {asynchronous:false,method: 'get',  parameters: parametre+"&trompeCache="+new Date().getTime(), onComplete: ajax_response_couleurs});

}
function popup_tailles(id_produits,titre,index_config,is_promo,promo_id)
{
	//alert(index_config);
	titre_popup = titre;
	var url = 'ajax/popup_tailles.php';
	var parametre = new String();
	parametre = "id_produits="+id_produits+"&index_config="+index_config+"&promo="+is_promo+"&promo_id="+promo_id;


	new Ajax.Request(
		url, {asynchronous:false,method: 'get',  parameters: parametre+"&trompeCache="+new Date().getTime(), onComplete: ajax_response_tailles});

}
function ajax_response_tailles(transport)
{
	var w =200;
	var h=250;
	var chaine = new String(transport.responseText);
	win = new Window({className: "alphacube", title: ""+titre_popup, width:w, height:h, destroyOnClose: true, recenterAuto:false});
	win.getContent().update(chaine);
	win.showCenter();
}
function ajax_response_couleurs(transport)
{
	var w =200;
	var h=250;
	var chaine = new String(transport.responseText);
	win = new Window({className: "alphacube", title: ""+titre_popup, width:w, height:h, destroyOnClose: true, recenterAuto:false});
	win.getContent().update(chaine);
	win.showCenter();
}

/*----------------------------------------------------*/
var SU;
var SD;
function SUp(){
document.getElementById('ScrollZone').scrollTop+=1;
//document.getElementById('CursorZone').scrollTop+=5;
}
function SDown(){
document.getElementById('ScrollZone').scrollTop-=1;
//document.getElementById('CursorZone').scrollTop-=5;
}
 
function ScrollUp(Speed){

SU = setInterval('SUp()',Speed);
}
 
function ScrollDown(Speed){
SD = setInterval('SDown()',Speed);
}
 
function clearScroll(way){
clearInterval(way)}
/*----------------------------------------------------*/
var SU_C;
var SD_C;
function SUp_C(){
document.getElementById('ScrollZone_C').scrollTop+=1;
//document.getElementById('CursorZone').scrollTop+=5;
}
function SDown_C(){
document.getElementById('ScrollZone_C').scrollTop-=1;
//document.getElementById('CursorZone').scrollTop-=5;
}
 
function ScrollUp_C(Speed_C){

SU_C = setInterval('SUp_C()',Speed_C);
}
 
function ScrollDown_C(Speed_C){
SD_C = setInterval('SDown_C()',Speed_C);
}
 
function clearScroll_C(way_C){
clearInterval(way_C)}
/*----------------------------------------------------*/
var SU_3;
var SD_3;
function SUp_3(){
document.getElementById('ScrollZone_3').scrollTop+=1;
}
function SDown_3(){
document.getElementById('ScrollZone_3').scrollTop-=1;
}
 
function ScrollUp_3(Speed_3){

SU_3 = setInterval('SUp_3()',Speed_3);
}
 
function ScrollDown_3(Speed_3){
SD_3 = setInterval('SDown_3()',Speed_3);
}
 
function clearScroll_3(way_3){
clearInterval(way_3)}
/*----------------------------------------------------*/
var SU_4;
var SD_4;
function SUp_4(){
document.getElementById('ScrollZone_4').scrollTop+=1;
}
function SDown_4(){
document.getElementById('ScrollZone_4').scrollTop-=1;
}
 
function ScrollUp_4(Speed_4){

SU_4 = setInterval('SUp_4()',Speed_4);
}
 
function ScrollDown_4(Speed_4){
SD_4 = setInterval('SDown_4()',Speed_4);
}
 
function clearScroll_4(way_4){
clearInterval(way_4)}
/*----------------------------------------------------*/
function nothing(){
	
	bidule = "truc";
}

/*---------------ENCODAGE/DECODAGE BASE64------------------*/
function urlDecode(str){
    str=str.replace(new RegExp('\\+','g'),' ');
    return unescape(str);
}
function urlEncode(str){
    str=escape(str);
    str=str.replace(new RegExp('\\+','g'),'%2B');
    return str.replace(new RegExp('%20','g'),'+');
}

var END_OF_INPUT = -1;

var base64Chars = new Array(
    'A','B','C','D','E','F','G','H',
    'I','J','K','L','M','N','O','P',
    'Q','R','S','T','U','V','W','X',
    'Y','Z','a','b','c','d','e','f',
    'g','h','i','j','k','l','m','n',
    'o','p','q','r','s','t','u','v',
    'w','x','y','z','0','1','2','3',
    '4','5','6','7','8','9','+','/'
);

var reverseBase64Chars = new Array();
for (var i=0; i < base64Chars.length; i++){
    reverseBase64Chars[base64Chars[i]] = i;
}

var base64Str;
var base64Count;
function setBase64Str(str){
    base64Str = str;
    base64Count = 0;
}
function readBase64(){    
    if (!base64Str) return END_OF_INPUT;
    if (base64Count >= base64Str.length) return END_OF_INPUT;
    var c = base64Str.charCodeAt(base64Count) & 0xff;
    base64Count++;
    return c;
}
function encodeBase64(str){
    setBase64Str(str);
    var result = '';
    var inBuffer = new Array(3);
    var lineCount = 0;
    var done = false;
    while (!done && (inBuffer[0] = readBase64()) != END_OF_INPUT){
        inBuffer[1] = readBase64();
        inBuffer[2] = readBase64();
        result += (base64Chars[ inBuffer[0] >> 2 ]);
        if (inBuffer[1] != END_OF_INPUT){
            result += (base64Chars [(( inBuffer[0] << 4 ) & 0x30) | (inBuffer[1] >> 4) ]);
            if (inBuffer[2] != END_OF_INPUT){
                result += (base64Chars [((inBuffer[1] << 2) & 0x3c) | (inBuffer[2] >> 6) ]);
                result += (base64Chars [inBuffer[2] & 0x3F]);
            } else {
                result += (base64Chars [((inBuffer[1] << 2) & 0x3c)]);
                result += ('=');
                done = true;
            }
        } else {
            result += (base64Chars [(( inBuffer[0] << 4 ) & 0x30)]);
            result += ('=');
            result += ('=');
            done = true;
        }
        lineCount += 4;
        if (lineCount >= 76){
            result += ('\n');
            lineCount = 0;
        }
    }
    return result;
}
function readReverseBase64(){   
    if (!base64Str) return END_OF_INPUT;
    while (true){      
        if (base64Count >= base64Str.length) return END_OF_INPUT;
        var nextCharacter = base64Str.charAt(base64Count);
        base64Count++;
        if (reverseBase64Chars[nextCharacter]){
            return reverseBase64Chars[nextCharacter];
        }
        if (nextCharacter == 'A') return 0;
    }
    return END_OF_INPUT;
}

function ntos(n){
    n=n.toString(16);
    if (n.length == 1) n="0"+n;
    n="%"+n;
    return unescape(n);
}

function decodeBase64(str){
    setBase64Str(str);
    var result = "";
    var inBuffer = new Array(4);
    var done = false;
    while (!done && (inBuffer[0] = readReverseBase64()) != END_OF_INPUT
        && (inBuffer[1] = readReverseBase64()) != END_OF_INPUT){
        inBuffer[2] = readReverseBase64();
        inBuffer[3] = readReverseBase64();
        result += ntos((((inBuffer[0] << 2) & 0xff)| inBuffer[1] >> 4));
        if (inBuffer[2] != END_OF_INPUT){
            result +=  ntos((((inBuffer[1] << 4) & 0xff)| inBuffer[2] >> 2));
            if (inBuffer[3] != END_OF_INPUT){
                result +=  ntos((((inBuffer[2] << 6)  & 0xff) | inBuffer[3]));
            } else {
                done = true;
            }
        } else {
            done = true;
        }
    }
    return result;
}

//------------------------------------------------------------------------------------------------------------------------------
function popup_alert_panier_vide(texte)
{
	url  = 'ajax/panier_vide.php';
	new Ajax.Request(
			url, {asynchronous:false,method: 'get',  parameters: "texte="+texte, onComplete: ajax_response_panier_vide});
}


function ajax_response_panier_vide(transport)
{
	var tableau=transport.responseText.split('|');

 	var fermer = tableau[0];
	var texte = tableau[1];
	
	var w = 300;
	var h = 120;
	var titre = "uhlsport";
	
	win = new Window({className: "alphacube",  title: titre, width:w, height:h, destroyOnClose: true, recenterAuto:false});
	win.getContent().update("<br>"+texte+"<br><br><div align='center' class='alert_buttons'><input type='button' value='"+fermer+"' onclick='location.replace(\"produit.php?Rub=21&id_univ=1\");'/></div>");
	win.showCenter();
}

//------------------------------------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------------------
function popup_alert(texte)
{
	url  = 'ajax/verif_langue.php';
	new Ajax.Request(
			url, {asynchronous:false,method: 'get',  parameters: "texte="+texte, onComplete: ajax_response_verif_langue});
}


function ajax_response_verif_langue(transport)
{
	var tableau=transport.responseText.split('|');

 	var fermer = tableau[0];
	var texte = tableau[1];
	
	var w = 300;
	var h = 120;
	var titre = "uhlsport";
	
	win = new Window({className: "alphacube",  title: titre, width:w, height:h, destroyOnClose: true, recenterAuto:false});
	win.getContent().update("<br>"+texte+"<br><br><div align='center' class='alert_buttons'><input type='button' value='"+fermer+"' onclick='Dialog.okCallback()'/></div>");
	win.showCenter();
}

//-------------------------------------------------------------------------------------------------------------

function popup_alert_panier(id_produit)
{
	url  = 'ajax/alerte_panier.php';
	new Ajax.Request(
			url, {asynchronous:false,method: 'get',  parameters: "id_produit="+id_produit, onComplete: ajax_response_alerte_panier});
}

function ajax_response_alerte_panier(transport)
{
	var tableau=transport.responseText.split('|');

 	var fermer = tableau[0];
	var texte = tableau[1];
	
	var w = 310;
	var h = 150;
	var titre = "uhlsport";
	
	win = new Window({className: "alphacube",  title: titre, width:w, height:h, destroyOnClose: true, recenterAuto:false});
	win.getContent().update("<br>"+texte+"<br><br><div align='center' class='alert_buttons'><input type='button' value='"+fermer+"' onclick='Dialog.okCallback()'/></div>");
	win.showCenter();
}

/*---------------------------------------------------------------------------------*/
function retailer(id)
{
	url  = 'ajax/retailer.php';
	new Ajax.Request(
			url, {asynchronous:false,method: 'get',  parameters: "id_retailer="+id+"&premium=0", onComplete: ajax_response_retailer});
}

function retailer_premium()
{
	url  = 'ajax/retailer_advantage.php';
	new Ajax.Request(
			url, {asynchronous:false,method: 'get',  parameters: "", onComplete: ajax_response_retailer});
}

function ajax_response_retailer(transport)
{
	var tableau=transport.responseText.split('|');

 	var titre = tableau[0];
	var texte = tableau[1];
	

	var w = '300';
	var h = '300';
	
	win = new Window({className: "alphacube", title: titre, width:w, height:h, destroyOnClose: true, recenterAuto:false});
	win.getContent().update(texte);
	win.showCenter();
		
}
/*---------------------------------------------------------------------------------*/
function Filter_Proclub()
{
	
	var zipcode=document.getElementById('clubzipcode').value;
	//var city=document.getElementById('clubcity').value;
	
	var ajax_url  = 'ajax/filter_proclub.php';
	new Ajax.Request(
			//ajax_url, {asynchronous:false,method: 'get',  parameters: "zipcode="+zipcode+"&city="+city+ "&trompeCache="+new Date().getTime(), onComplete: ajax_response_publish});
			ajax_url, {asynchronous:false,method: 'get',  parameters: "zipcode="+zipcode+"&trompeCache="+new Date().getTime(), onComplete: ajax_response_publish});
		
	var tableau_id  = ajaxParamsTab['idlist'].split(',');		
	var tableau_val = ajaxParamsTab['vallist'].split(',');
	var tableau_val_city = ajaxParamsTab['vallistcity'].split(',');

	
	if(ajaxParamsTab['idlist'] != "" && ajaxParamsTab['vallist'] != "")
	{
		if(tableau_id.length == tableau_val.length)
		{
			document.getElementById('proclub').style.display="block";
			document.getElementById('proclub_info').style.display="none";
			
			for (i=document.getElementById('proclub').length - 1;i >=0 ;i--)
			{
				document.getElementById('proclub').options[i] = null;
			}	
		
			for (j=0; j < tableau_id.length;j++)
			{
				nouvel_element = new Option(tableau_val[j],tableau_id[j],false);
				document.getElementById('proclub').options[j] = nouvel_element;
			}
		}
	}
	
	if(ajaxParamsTab['vallistcity'] != "")
	{
		document.getElementById('proclub_city').style.display="block";
		document.getElementById('proclub_city_info').style.display="none";
			
		for (i=document.getElementById('proclub_city').length - 1;i >=0 ;i--)
		{
			document.getElementById('proclub_city').options[i] = null;
		}	
		
		for (j=0; j < tableau_val_city.length;j++)
		{
			nouvel_element = new Option(tableau_val_city[j],tableau_val_city[j],false);
			document.getElementById('proclub_city').options[j] = nouvel_element;
		}
	}
}

function Filter_Proclub_City()
{
	
	var selectedIndex = document.getElementById('proclub_city').selectedIndex;
	var city=document.getElementById('proclub_city').options[selectedIndex].value;
	
	
	
	//var city=document.getElementById('clubcity').value;
	
	var ajax_url  = 'ajax/filter_proclub_city.php';
	new Ajax.Request(
			//ajax_url, {asynchronous:false,method: 'get',  parameters: "zipcode="+zipcode+"&city="+city+ "&trompeCache="+new Date().getTime(), onComplete: ajax_response_publish});
			ajax_url, {asynchronous:false,method: 'get',  parameters: "city="+city+"&trompeCache="+new Date().getTime(), onComplete: ajax_response_publish});
		
	var tableau_id  = ajaxParamsTab['idlist'].split(',');		
	var tableau_val = ajaxParamsTab['vallist'].split(',');

	
	if(ajaxParamsTab['idlist'] != "" && ajaxParamsTab['vallist'] != "")
	{
		if(tableau_id.length == tableau_val.length)
		{
			document.getElementById('proclub').style.display="block";
			document.getElementById('proclub_info').style.display="none";
			
			for (i=document.getElementById('proclub').length - 1;i >=0 ;i--)
			{
				document.getElementById('proclub').options[i] = null;
			}	
		
			for (j=0; j < tableau_id.length;j++)
			{
				nouvel_element = new Option(tableau_val[j],tableau_id[j],false);
				document.getElementById('proclub').options[j] = nouvel_element;
			}
		}
	}
}

function Filter_Plz(){
	
	document.getElementById('wrong_retailer').style.display='none';
	document.getElementById('lbl_retailer').style.display='none';
	document.getElementById('lbl_retailer_city').style.display='none';
	document.getElementById('retailer_city').style.display='none';
	document.getElementById('retailer').style.display='none';
	document.getElementById('retailer').selectedIndex = 0;
	document.getElementById('retailer').options[0].value = 0;
	
	if(document.getElementById('retailercountry').selectedIndex != 0 ){
		document.getElementById('retailerzipcode').style.display='block';		
		document.getElementById('lbl_retailerzipcode').style.display='block';
	
		document.getElementById('retailerpremium').style.display='block';	
		document.getElementById('lbl_retailerpremium').style.display='block';
	}else{
		document.getElementById('retailerzipcode').style.display='none';		
		document.getElementById('lbl_retailerzipcode').style.display='none';
	
		document.getElementById('retailerpremium').style.display='none';	
		document.getElementById('lbl_retailerpremium').style.display='none';
	}
}

function Filter_Retailer()
{
	
	document.getElementById('wrong_retailer').style.display='none';
	document.getElementById('lbl_retailer').style.display='none';
	document.getElementById('lbl_retailer_city').style.display='none';
	document.getElementById('retailer_city').style.display='none';
	document.getElementById('retailer').style.display='none';
	document.getElementById('retailer').selectedIndex = 0;
	document.getElementById('retailer').options[0].value = 0;
	
	
	
	var zipcode=document.getElementById('retailerzipcode').value;
	var country = document.getElementById('retailercountry').options[document.getElementById('retailercountry').selectedIndex].value;
	var premium = ( document.getElementById('retailerpremium').checked)? 1 : 0 ;
	/*if(document.getElementById('retailer_city').options.length > 0){	
		var city = document.getElementById('retailer_city').options[document.getElementById('retailer_city').selectedIndex].value;
	}else{
		var city = 0;
	}*/
	var ajax_url  = 'ajax/filter_retailer.php';
	new Ajax.Request(
			//ajax_url, {asynchronous:false,method: 'get',  parameters: "zipcode="+zipcode+"&city="+city+ "&trompeCache="+new Date().getTime(), onComplete: ajax_response_publish});
			ajax_url, {asynchronous:false,method: 'get',  parameters: "zipcode="+zipcode+"&premium="+premium+"&country="+country+"&trompeCache="+new Date().getTime(), onComplete: ajax_response_publish});
			
	var tableau_id  = ajaxParamsTab['idlist'].split(',');		
	var tableau_val = ajaxParamsTab['vallist'].split(',');
	var tableau_val_city = ajaxParamsTab['vallistcity'].split(',');

	
	if(ajaxParamsTab['idlist'] != "" && ajaxParamsTab['vallist'] != "")
	{
		if(tableau_id.length == tableau_val.length)
		{
			document.getElementById('retailer').style.display="block";
			document.getElementById('lbl_retailer').style.display="block";
			document.getElementById('retailer_info').style.display="none";
			
			for (i=document.getElementById('retailer').length - 1;i >=0 ;i--)
			{
				document.getElementById('retailer').options[i] = null;
			}	
		
			for (j=0; j < tableau_id.length;j++)
			{
				nouvel_element = new Option(tableau_val[j],tableau_id[j],false);
				document.getElementById('retailer').options[j] = nouvel_element;
			}
		}
	}
	
	if(ajaxParamsTab['vallistcity'] != "")
	{
		document.getElementById('retailer_city').style.display="block";
		document.getElementById('lbl_retailer_city').style.display="block";
		document.getElementById('retailer_city_info').style.display="none";
			
		for (i=document.getElementById('retailer_city').length - 1;i >=0 ;i--)
		{
			document.getElementById('retailer_city').options[i] = null;
		}	
		//insertion d'un ligne vide
		nouvel_element = new Option("---","",false);
		document.getElementById('retailer_city').options[0] = nouvel_element;
		for (j=0; j < tableau_val_city.length;j++)
		{
			nouvel_element = new Option(tableau_val_city[j],tableau_val_city[j],false);
			document.getElementById('retailer_city').options[j+1] = nouvel_element;
		}
	}
}

function Filter_Retailer_City()
{
	
	var selectedIndex = document.getElementById('retailer_city').selectedIndex;
	var city=document.getElementById('retailer_city').options[selectedIndex].value;
	var zipcode = document.getElementById('retailerzipcode').value;
	var country = document.getElementById('retailercountry').options[document.getElementById('retailercountry').selectedIndex].value;
	var premium = ( document.getElementById('retailerpremium').checked)? 1 : 0 ;
	
	//var city=document.getElementById('clubcity').value;
	
	var ajax_url  = 'ajax/filter_retailer_city.php';
	new Ajax.Request(
			//ajax_url, {asynchronous:false,method: 'get',  parameters: "zipcode="+zipcode+"&city="+city+ "&trompeCache="+new Date().getTime(), onComplete: ajax_response_publish});
			ajax_url, {asynchronous:false,method: 'get',  parameters: "city="+city+"&country="+country+"&premium="+premium+"&zipcode="+zipcode+"&trompeCache="+new Date().getTime(), onComplete: ajax_response_publish});	
		
	var tableau_id  = ajaxParamsTab['idlist'].split(',');		
	var tableau_val = ajaxParamsTab['vallist'].split(',');

	
	if(ajaxParamsTab['idlist'] != "" && ajaxParamsTab['vallist'] != "")
	{
		if(tableau_id.length == tableau_val.length)
		{
			document.getElementById('retailer').style.display="block";
			document.getElementById('lbl_retailer_city').style.display="block";
			document.getElementById('retailer_info').style.display="none";
			
			for (i=document.getElementById('retailer').length - 1;i >=0 ;i--)
			{
				document.getElementById('retailer').options[i] = null;
			}	
		
			for (j=0; j < tableau_id.length;j++)
			{
				nouvel_element = new Option(tableau_val[j],tableau_id[j],false);
				document.getElementById('retailer').options[j] = nouvel_element;
			}
		}
	}
}


function Verif_numero()
{

	url  = 'verif_numero.php';
	new Ajax.Request(
			url, {asynchronous:false,method: 'get',  parameters: "&numero="+$('numero_affiliation').value+"&club="+document.forms['formulaire'].club.value, onComplete: ajax_response_verif_num});
}

function ajax_response_verif_num(transport)
{
	var reponse = new String(transport.responseText);
		if(reponse != "OK")
			popup_alert("Votre numéro de ligue ne correspond pas à votre club.")
		
}

function verif_and_color_formulaire(objForm,args){
	tab = args.split(",")
	var all_right = true;
	var alertcolor="#1397e9"
	for (i=0;i<tab.length;i++)
	{
				if(objForm.elements[tab[i]].type == null)
				{
					popup_alert("information de déboguage : "+tab[i] + " n'existe pas");
				}
				else
				{					
										if(objForm.elements[tab[i]].type!="radio")
										{
											objForm.elements[tab[i]].style.border="0px solid";
											objForm.elements[tab[i]].style.background="#3D3C3C";
										}

											// si c'est un champ date on colorise le div caché
										if(objForm.elements[tab[i]].name.indexOf("date") > -1)
										{
											if (objForm.elements[tab[i]].value == "")
											{
													// document.getElementById(tab[i]+"_display").style.color=alertcolor;
													document.getElementById(tab[i]+"_display").innerHTML="<font color='"+alertcolor+"'><b> ! </b></font>";
													all_right = false;
											}

										}
										// si c'est un champ téléphone
										if(objForm.elements[tab[i]].name.indexOf("_tel") > -1 || objForm.elements[tab[i]].name.indexOf("mobile") > -1)
										{
											var tmpval = objForm.elements[tab[i]].value.replace(' ','');
											if (! (/[0-9]{5}[0-9]+/.test(tmpval)))
											{
												objForm.elements[tab[i]].style.border="2px solid "+alertcolor;	
												all_right = false;
											}

										}
										
										//alert(objForm.elements[tab[i]].name.indexOf("email"));
										if(objForm.elements[tab[i]].name.indexOf("email") > -1)
										{	
											var tmpval = objForm.elements[tab[i]].value.replace(' ','');																										
											
											 //if (!(/^\w+([\.-]?\w*)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(tmpval)))
											if (!(/^[a-zA-Z.0-9_-]+@[a-zA-Z.0-9_-]{2,}[.][a-zA-Z]{2,3}$/.test(tmpval)))											
											{
													objForm.elements[tab[i]].style.border="2px solid "+alertcolor;
													all_right = false;
											}
										}
										if(objForm.elements[tab[i]].type=="select-one")
										{			
													if(objForm.elements[tab[i]].selectedIndex==0)
													{
														objForm.elements[tab[i]].style.border="2px solid "+alertcolor;
														objForm.elements[tab[i]].style.background= alertcolor;
														all_right = false;
													}

										}
										if(objForm.elements[tab[i]].type=="checkbox")
										{
											if(objForm.elements[tab[i]].checked == false)
											{

													document.getElementById(tab[i]+"_display").innerHTML="<font color='"+alertcolor+"'><b> ! </b></font>";
													all_right = false;
											}
										}
										if ((objForm.elements[tab[i]].value=="") || (objForm.elements[tab[i]].value==" "))
										{
												objForm.elements[tab[i]].style.border="2px solid "+alertcolor;
												all_right = false;
										}
				}
		}
		return all_right;
}
/*---------------FIN ENCODAGE/DECODAGE BASE64------------------*/

/*-----------------------------------------------------------------------------*/
function Popup_liste_proclub_fr()
{
	var url = 'ajax/popup_proclub_liste_fr.php';
	new Ajax.Request(
		url, {asynchronous:false,method: 'get',  parameters: "trompeCache="+new Date().getTime(), onComplete: ajax_response_liste_proclub});
}
function ajax_response_liste_proclub(transport)
{
	
	var tableau=transport.responseText.split('|');

 	var titre = tableau[0];
	var texte = tableau[1];
	

	var w = '500';
	var h = '250';
	
	win = new Window({className: "alphacube", title: titre, width:w, height:h, destroyOnClose: true, recenterAuto:false});
	win.getContent().update(texte);
	win.showCenter();
}


function Popup_choix_proclub()
{
	var url = 'ajax/popup_choix_proclub.php';
	new Ajax.Request(
		url, {asynchronous:false,method: 'get',  parameters: "trompeCache="+new Date().getTime(), onComplete: ajax_response_choix_proclub});
}

function Popup_choix_retailer()
{
	var url = 'ajax/popup_choix_retailer.php';
	new Ajax.Request(
		url, {asynchronous:false,method: 'get',  parameters: "trompeCache="+new Date().getTime(), onComplete: ajax_response_choix_retailer});
}

function ajax_response_choix_proclub(transport)
{
	var larg = 400;
	var haut = 150;
	var titre = new String('Choix du proclub');
	var chaine = new String(transport.responseText);
	win = new Window({className: "alphacube", title: ""+titre, width:larg, height:haut, destroyOnClose: true, recenterAuto:false});
	win.getContent().update(chaine);
	win.showCenter();
}
	
	
function ajax_response_choix_retailer(transport)
{
	var larg = 400;
	var haut = 150;
	var titre = new String('Ihre Auswahl');
	var chaine = new String(transport.responseText);
	win = new Window({className: "alphacube", title: ""+titre, width:larg, height:haut, destroyOnClose: true, recenterAuto:false});
	win.getContent().update(chaine);
	win.showCenter();
}
//-----------------------------------------------------------------------------
function Inscription(rub,query)
{
	var url = 'ajax/inscription.php';	
	new Ajax.Request(
		url, {asynchronous:false,method: 'get',  parameters: "rub="+rub+"&query="+query+"&trompeCache="+new Date().getTime(), onComplete: ajax_response_inscription});
}
function ajax_response_inscription(transport)
{
	//alert(transport.responseText)
	window.location.href = transport.responseText;
}
//-----------------------------------------------------------------------------	
function Choix_proclub(id)
{
	var selectedIndex = document.getElementById('proclub').selectedIndex;
	var proclub=document.getElementById('proclub').options[selectedIndex].value;
	
	var url = 'ajax/choix_proclub.php';	
	new Ajax.Request(
		url, {asynchronous:false,method: 'get',  parameters: "proclub_id="+proclub+"&trompeCache="+new Date().getTime(), onComplete: ajax_response_zoom});
}
function ajax_response_zoom(transport)
{

	$('votre_choix').style.display='block';
	$('proclub_choix_definitif').innerHTML = transport.responseText;
	Dialog.okCallback();
}
function Choix_proclub_2(id)
{
	var selectedIndex = document.getElementById('proclub').selectedIndex;
	var proclub=document.getElementById('proclub').options[selectedIndex].value;
	
	var url = 'ajax/choix_proclub.php';	
	new Ajax.Request(
		url, {asynchronous:false,method: 'get',  parameters: "proclub_id="+proclub+"&trompeCache="+new Date().getTime(), onComplete: ajax_response_zoom_2});
}

function ajax_response_zoom_2(transport)
{

	//$('votre_choix').style.display='block';
	$('proclub_choix_definitif').innerHTML = transport.responseText;
	//Dialog.okCallback();
}
//-----------------------------------------------------------------------------
function Choix_Retailer()
{
	
	var selIndex = document.getElementById('retailer').selectedIndex;
	var proclub = document.getElementById('retailer').options[selIndex].value;
	
	if(proclub != 0)
	{
		var url = 'ajax/choix_retailer.php';	
		new Ajax.Request(
		url, {asynchronous:false,method: 'get',  parameters: "retailer_id="+proclub+"&trompeCache="+new Date().getTime(), onComplete: ajax_response_zoom});
	}
	else
	{
		document.getElementById('wrong_retailer').style.display='block';
	}
	
}



function Lexique(id,id_univers)
{
	
	var url = 'ajax/content_lexique.php';

	var parametre = "id_univers="+id_univers+"&Rub="+id;

	new Ajax.Request(
			url, {asynchronous:false,method: 'get',  parameters: parametre+"&trompeCache="+new Date().getTime(), onComplete: ajax_response_lexique});
}

function ajax_response_lexique(transport)
{
	
	var tableau=transport.responseText.split('|');

 	var titre = tableau[0];
	var texte_ = tableau[1];
	

	var w = '500';
	var h = '500';
	
	win = new Window({className: "alphacube", title: titre, width:w, height:h, destroyOnClose: true, recenterAuto:false});
	win.getContent().update(texte_);
	win.showCenter();
}

function Popup_texte_al(w,h,titre,id_produit)
{
	var url = 'ajax/content_envoi_ami.php';

	var parametre = "id_produit="+id_produit;

	new Ajax.Request(
			url, {asynchronous:false,method: 'get',  parameters: parametre+"&trompeCache="+new Date().getTime(), onComplete: ajax_response_envoi_ami_1});
	

}

function ajax_response_envoi_ami_1(transport)
{

	var w = '400';
	var h = '250';
	var tableau=transport.responseText.split('|');

 	var titre = tableau[0];
	var texte = tableau[1];
	
	win = new Window({className: "alphacube", title: titre, width:w, height:h, destroyOnClose: true, recenterAuto:false});
	win.getContent().update(texte);
	win.showCenter();
}

function Popup_texte(w,h,titre,id_produit)
{
	var url = 'ajax/content_envoi_ami.php';

	var parametre = "id_produit="+id_produit;

	new Ajax.Request(
			url, {asynchronous:false,method: 'get',  parameters: parametre+"&trompeCache="+new Date().getTime(), onComplete: ajax_response_envoi_ami_1});
	
}
/*-----------------------------------------------------------------------------*/
function Envoi_ami(id_produit)
{
	var url = 'ajax/envoi_ami.php';
	var parametre = new String();
	parametre = "id_produit="+id_produit+"&email="+$('email').value+"&email_proprio="+$('email_proprio').value+"&commentaires="+$('commentaires').value;
	new Ajax.Request(url, {asynchronous:false,method: 'get',  parameters: parametre+"&trompeCache="+new Date().getTime(), onComplete: ajax_response_envoi_ami});
}
function ajax_response_envoi_ami(transport)
{
	var w =300;
	var h=150;
	var tableau=transport.responseText.split('|');

 	var titre = tableau[0];
	var texte = tableau[1];
	Dialog.okCallback();
	win = new Window({className: "alphacube", title: titre, width:w, height:h, destroyOnClose: true, recenterAuto:false});
	win.getContent().update(texte);
	win.showCenter();
}
/*-----------------------------------------------------------------------------*/
function Insert_jeu()
{
	
	var url = 'ajax/jeux_concours.php';
	var parametre = new String();
	parametre = "id_jeu="+$('id_jeu').value+"&email="+$('email').value+"&reponse="+$('reponse').value+"&nom="+$('nom').value+"&prenom="+$('prenom').value;
	new Ajax.Request(url, {asynchronous:false,method: 'get',  parameters: parametre+"&trompeCache="+new Date().getTime(), onComplete: ajax_response_jeu});

}

function ajax_response_jeu(transport)
{
	var w =300;
	var h=150;
	
	var tableau=transport.responseText.split('|');

 	var titre = tableau[0];
	var texte = tableau[1];


	
	win = new Window({className: "alphacube", title: titre, width:w, height:h, destroyOnClose: true, recenterAuto:false});
	win.getContent().update(texte);
	win.showCenter();
}
function print_popup(){
	
	var a = window. open('','','scrollbars=yes,width=300,height=300');
	
	a.document.open("text/html");
	a.document.write('<html><head><link rel="stylesheet" href="lycee-professionnel-nimes.css" /><style type="text/css">#frame{background-image:none;background-color:#FFFFFF;}</style></head><body style="padding-left:20px;background-image:none;background-color:#FFFFFF;">');
	a.document.write(document.getElementById('print').innerHTML);
	a.document.write('</body></html>');
	a.document.close();
	
	a.print();
	a.close();
	
	
	
}
function Oubli_Passe()
{
	var url = 'ajax/content_oubli_passe.php';

	new Ajax.Request(
		url, {asynchronous:false,method: 'get',  parameters: "trompeCache="+new Date().getTime(), onComplete: ajax_response_mot_passe});

}

function ajax_response_mot_passe(transport)
{

	var w =320;
	var h=180;
	
	var tableau=transport.responseText.split('|');

 	var titre = tableau[0];
	var texte = tableau[1];
	
	
	win = new Window({className: "alphacube", title: titre, width:w, height:h, destroyOnClose: true, recenterAuto:false});
	win.getContent().update(texte);
	win.showCenter();
}
function Envoi_mot_passe()
{
	//alert($('email').value);
	Dialog.okCallback();
	var url = 'ajax/envoi_passe.php';

	var parametre = new String();

	parametre = "email="+$('email').value;


	new Ajax.Request(
		url, {asynchronous:false,method: 'get',  parameters: parametre+"&trompeCache="+new Date().getTime(), onComplete: ajax_response_envoi_passe});
	
}
function ajax_response_envoi_passe(transport)
{
	
	
	var tableau=transport.responseText.split('|');
	var titre = tableau[0];
	var texte = tableau[1];
	
	var w =320;
	var h=100;
	
	win = new Window({className: "alphacube", title: titre, width:w, height:h, destroyOnClose: true, recenterAuto:false});
	win.getContent().update(texte);
	win.showCenter();
	
}
