/********************************************************************************************************************************************************
	TOOLTIP
*********************************************************************************************************************************************************/

function tipz() {
	
		$$('.tipz').each(function(element,index) {
		    var content = element.get('title');
		    element.store('tip:title', content);
		});
		
		//create the tooltips
		var tipz = new Tips('.tipz',{
		    className: 'tipz',
		    fixed: false,
		    showDelay: 0,
		    hideDelay: 0
		});
		  
}

/********************************************************************************************************************************************************
	MOVE X Y
*********************************************************************************************************************************************************/

function moveItemNoY(item,x,t){

	item.set('tween', {duration: t});
	item.tween('margin-left', x);
				
}

function moveItemNoX(item,y,t){

	item.set('tween', {duration: t});
	item.tween('margin-top', y);
				
}

/********************************************************************************************************************************************************
	GO PAGE
*********************************************************************************************************************************************************/

function goPage(p,b){
	
	if(b == 1) {
	window.open(p);
	}else {
	window.location.href=''+p+'';
	}

}

/********************************************************************************************************************************************************
	TOT (pagecat)
*********************************************************************************************************************************************************/

function tot(i){
	
	$('tot').set('text',i);

}


/********************************************************************************************************************************************************
	MENU
*********************************************************************************************************************************************************/

function moveMenuTextInit() {
		
		var myMenu = new MenuMatic({/*options here*/});  
		    
		/*
		var pageActive = $('pageActive').value;
		var pageActiveColor = $('pageActiveColor').value;
		
		var s = pageActive.split('||');
		
		(function wait() {
			
			var menuHidden = $('menuHidden').value ;
			    
		    if(menuHidden == 0) {
		    		
		    		var menuTextBG = new Fx.Morph('menuTextBG', {duration: 0});
		    		menuTextBG.start({'width': s[0], 'margin-left': s[1], 'backgroundColor': pageActiveColor});
		    		
		    		$('menuTextBG').style.visibility = 'visible';
		    
		    }
		
		}).delay(150);
		*/
		
}


function moveMenuTextBG(w,ml,c) {

		var menuTextBG = new Fx.Morph('menuTextBG', {duration: 0});
		menuTextBG.start({'width': w, 'margin-left': ml, 'backgroundColor': '#'+c});
		
}


/********************************************************************************************************************************************************
	HOMEPAGE
*********************************************************************************************************************************************************/

function blocJaune(img,i) {
	
	for(z=1;z<=3;z++) {
	
	$('clic'+z).style.display = 'none';
	
	}
	
	$('clic'+i).style.display = 'inline';
	
	$('homepage_bloc_jaune_central').set('html','<img src="'+img+'" height="200" style="margin-top:10px;">');

}


/********************************************************************************************************************************************************
	PAGES (Coloriages - Bricolages - Recettes - Jeux)
*********************************************************************************************************************************************************/

function pageOpenMenu(id) {

	var page_menuOpen = $('page_menuOpen'+id).value;
	
	if(page_menuOpen == 0) {
		
		$('page_menuOpen'+id).value = 1;
		
		$('arrow'+id).className = 'page_tinyArrowDown';
		
		$('page_sousMenu'+id).style.display = 'inline';
	
	} else {
		
		$('page_menuOpen'+id).value = 0;
		
		$('arrow'+id).className = 'page_tinyArrowRight';
		
		$('page_sousMenu'+id).style.display = 'none';
	
	}



}

function moveDraft(d) {
		
		var pNow = $('pNow').value;
		var pMax = $('pMax').value;

		if(d == 'R') {
			
				var nPage = parseFloat(pNow)+1;
				
				if(nPage < pMax) {				
						
						var step = nPage*556;
						
						moveItemNoY($('page_move'),-step,500);
						
						$('pNow').value = nPage;
			
				}
		
		}
		
		if(d == 'L') {
			
				var nPage = parseFloat(pNow)-1;
				
				if(nPage >= 0) {				
						
						var step = nPage*556;
						
						moveItemNoY($('page_move'),-step,500);
						
						$('pNow').value = nPage;
			
				}
		
		}

}

function moveDraft2(d) {
		
		var pNow2 = $('pNow2').value;
		var pMax2 = $('pMax2').value;

		if(d == 'R') {
			
				var nPage = parseFloat(pNow2)+1;
				
				if(nPage < pMax2) {				
						
						var total2 = parseFloat(parseFloat(nPage+1))*3;
						$('total2').set('text',total2);
						
						var step = nPage*249;
						
						moveItemNoY($('page_move2'),-step,500);
						
						$('pNow2').value = nPage;
			
				}
		
		}
		
		if(d == 'L') {
			
				var nPage = parseFloat(pNow2)-1;
				
				if(nPage >= 0) {				
						
						var total2 = parseFloat(parseFloat(nPage+1))*3;
						$('total2').set('text',total2);
						
						var step = nPage*249;
						
						moveItemNoY($('page_move2'),-step,500);
						
						$('pNow2').value = nPage;
			
				}
		
		}

}

function moveDraft3(d) {
		
		var pNow3 = $('pNow3').value;
		var pMax3 = $('pMax3').value;

		if(d == 'R') {
			
				var nPage = parseFloat(pNow3)+1;
						
				if(nPage < pMax3) {				
						
						var total3 = parseFloat(parseFloat(nPage+1))*3;
						$('total3').set('text',total3);
						
						var step = nPage*249;
						
						moveItemNoY($('page_move3'),-step,500);
						
						$('pNow3').value = nPage;			
				}
		
		}
		
		if(d == 'L') {
			
				var nPage = parseFloat(pNow3)-1;
						
				if(nPage >= 0) {				
						
						var total3 = parseFloat(parseFloat(nPage+1))*3;
						$('total3').set('text',total3);
						
						var step = nPage*249;
						
						moveItemNoY($('page_move3'),-step,500);
						
						$('pNow3').value = nPage;
			
				}
		
		}

}



function pageGoCat(name,ids,alias,sID){
			
			new Request({
			url: 'pageSetSession.php?name='+name+'&ids='+ids+'&sID='+sID+''
			}).send();
		
		(function wait() {
		
			goPage(alias+'/theme.html',0);
		
		}).delay(300);

}

function pageIndexAlpha(l,templateID,open,alias,sID) {
		
		if(open == 1) {
				
				$('alphabetAjax').empty();
				
				$('arrowDownIA').style.visibility = 'visible';
				
				moveItemNoX($('colosIA'),-135,250);
				
				(function wait() {
				
					var colosIA = new Fx.Morph('colosIA', {duration: 250});
					colosIA.start({'height': 255});
									
				}).delay(250);
				
				(function wait() {
				
					new Request({
					url: 'pageIndexAlphaAjax.php?l='+l+'&templateID='+templateID+'&alias='+alias+'&sID='+sID+'', 
					evalScripts: true,
					onComplete: function(response) {
					    
					       $('alphabetAjax').set('html', response);
					        		       		    
					}}).send();
				
				}).delay(300);
		
		} else {
				
				$('alphabetAjax').empty();
				
				$('arrowDownIA').style.visibility = 'hidden';
				
				var colosIA = new Fx.Morph('colosIA', {duration: 250});
				colosIA.start({'height': 100});
				
				(function wait() {
				
					moveItemNoX($('colosIA'),0,250);
				
				}).delay(250);
		
		}

}

/********************************************************************************************************************************************************
	SEND TO FRIEND
*********************************************************************************************************************************************************/

function stf() {
	
	var stfHidden = $('stfHidden').value;
	
	if(stfHidden == 0) {
	
			$('stf').style.display = 'inline';
			
			$('stfHidden').value = 1;
			
				new FormCheck('form_stf', {
				ajaxEvalScripts : true,
				submitByAjax : true,
				ajaxResponseDiv : 'reponse'
				});
	
	} else {
	
			$('stf').style.display = 'none';
			
			$('stfHidden').value = 0;
	
	}

}


/********************************************************************************************************************************************************
	MENU PAGE
*********************************************************************************************************************************************************/

function difficulty(sID) {

		var s = $('comboDifficulty').selectedIndex;
		var z = $('comboDifficulty').options[s].value;
		
		if(z == 0) {var d = 'Tous';}
		if(z == 1) {var d = 'Facile';}
		if(z == 2) {var d = 'Moyen';}
		if(z == 3) {var d = 'Difficile';}
		
		// Petite illusion d'un ajax
		
		$('mCat').style.visibility = 'hidden';
		$('ajaxLoader').style.display = 'inline';
		
		// Petit cookie au passage
		
		new Request({
		url: 'pageSetSession.php?z='+z+'&f=difficulty&sID='+sID+''
		}).send();
		
		// ================================================
		
		var all = $('All_difficulty_IDs').value;
		
		if(d != 'Tous') {
		
				var v 	= $(d+'_IDs').value;
				
				// On display none de Tout
				
				if(all != '') {
				
						var s = all.split('-');
						
						var c = s.length;
						
						for(i=0;i<c;i++) {
							
							$('difficulty'+s[i]).style.display = 'none';
						
						}
				
				}
				
				// Ensuite on affiche les ID de la difficultŽ cliquŽ
				
				if(v != '') {
				
						var s = v.split('-');
						
						var c = s.length;
						
						for(i=0;i<c;i++) {
							
							$('difficulty'+s[i]).style.display = 'inline';
						
						}
				
				}
				
				// Pour finir, si le menu principal est vide on le display none
		
				var m = $('countMenu').value;
				
				for(i=0;i<m;i++) {
				
						var D_ID = $('D_ID'+i).value;
								
								var s = D_ID.split('-');
								
								// Facile
								if(z == 1) {
								    	
								    	if(s[0] > 0) {
								    		
								    		$('difficulty'+i).style.display = 'inline';
								    	
								    	} else {
								    	
								    		$('difficulty'+i).style.display = 'none';
								    	
								    	}
								
								}
								
								// Moyen
								if(z == 2) {
								    	
								    	if(s[1] > 0) {
								    		
								    		$('difficulty'+i).style.display = 'inline';
								    	
								    	} else {
								    	
								    		$('difficulty'+i).style.display = 'none';
								    	
								    	}
								
								}
								
								// Difficile
								if(z == 3) {
								    	
								    	if(s[2] > 0) {
								    		
								    		$('difficulty'+i).style.display = 'inline';
								    	
								    	} else {
								    	
								    		$('difficulty'+i).style.display = 'none';
								    	
								    	}
								
								}
								
						
						
				}
				
		
		} else {
		
				// On display inline de Tout
				
				if(all != '') {
				
						var s = all.split('-');
						
						var c = s.length;
						
						for(i=0;i<c;i++) {
							
							$('difficulty'+s[i]).style.display = 'inline';
						
						}
				
				}
				
				var m = $('countMenu').value;
				
				for(i=0;i<m;i++) {
				
				
						$('difficulty'+i).style.display = 'inline';
				
				}
		
		}
		
		(function wait() {
			
			$('ajaxLoader').style.display = 'none';
			$('mCat').style.visibility = 'visible';
			
			
		}).delay(250);
		
		

}

function age(sID) {
		
		var s = $('comboAge').selectedIndex;
		var z = $('comboAge').options[s].value;
		
		if(z == 0) {var d = 'Tous';}
		if(z == 1) {var d = 'age04';}
		if(z == 2) {var d = 'age57';}
		if(z == 3) {var d = 'age810';}
		if(z == 4) {var d = 'age10';}
				
		// Petite illusion d'un ajax
		
		$('mCat').style.visibility = 'hidden';
		$('ajaxLoader').style.display = 'inline';
		
		// Petit cookie au passage
		
		new Request({
		url: 'pageSetSession.php?z='+z+'&f=age&sID='+sID+''
		}).send();
		
		// ================================================
		
		var all = $('All_age_IDs').value;
		
		if(d != 'Tous') {
				
				var v = $(d+'_IDs').value;
				
				// On display none de Tout
				
				if(all != '') {
				
						var s = all.split('-');
						
						var c = s.length;
						
						for(i=0;i<c;i++) {
							
							$('age'+s[i]).style.display = 'none';
						
						}
				
				}
				
				// Ensuite on affiche les ID de la difficultŽ cliquŽ
				
				if(v != '') {
				
						var s = v.split('-');
						
						var c = s.length;
						
						for(i=0;i<c;i++) {
							
							$('age'+s[i]).style.display = 'inline';
						
						}
				
				}
				
				// Pour finir, si le menu principal est vide on le display none
		
				var m = $('countMenu').value;
				
				for(i=0;i<m;i++) {
				
						var A_ID = $('A_ID'+i).value;
								
								var s = A_ID.split('-');
								
								// 0-4 ans
								if(z == 1) {
								    	
								    	if(s[0] > 0) {
								    		
								    		$('age'+i).style.display = 'inline';
								    	
								    	} else {
								    	
								    		$('age'+i).style.display = 'none';
								    	
								    	}
								
								}
								
								// 5-7 ans
								if(z == 2) {
								    	
								    	if(s[1] > 0) {
								    		
								    		$('age'+i).style.display = 'inline';
								    	
								    	} else {
								    	
								    		$('age'+i).style.display = 'none';
								    	
								    	}
								
								}
								
								// 8-10 ans
								if(z == 3) {
								    	
								    	if(s[2] > 0) {
								    		
								    		$('age'+i).style.display = 'inline';
								    	
								    	} else {
								    	
								    		$('age'+i).style.display = 'none';
								    	
								    	}
								
								}
								
								// + de 10 ans
								if(z == 4) {
								    	
								    	if(s[3] > 0) {
								    		
								    		$('age'+i).style.display = 'inline';
								    	
								    	} else {
								    	
								    		$('age'+i).style.display = 'none';
								    	
								    	}
								
								}
								
						
						
				}
				
		
		} else {
				
				// On display inline de Tout
				
				if(all != '') {
				
						var s = all.split('-');
						
						var c = s.length;
						
						for(i=0;i<c;i++) {
							
							$('age'+s[i]).style.display = 'inline';
						
						}
				
				}
				
				var m = $('countMenu').value;
				
				for(i=0;i<m;i++) {
				
				
						$('age'+i).style.display = 'inline';
				
				}
		
		}
		
		// On remontre le menu
		
		(function wait() {
			
			$('ajaxLoader').style.display = 'none';
			$('mCat').style.visibility = 'visible';
			
		}).delay(250);
		
		

}

function preparation(sID) {
		
		var s = $('comboPreparation').selectedIndex;
		var z = $('comboPreparation').options[s].value;
		
		if(z == 0) {var d = 'Tous';}
		if(z == 1) {var d = 'preparation15';}
		if(z == 2) {var d = 'preparation1530';}
		if(z == 3) {var d = 'preparation3045';}
		if(z == 4) {var d = 'preparation4560';}
		if(z == 5) {var d = 'preparation1';}
		
		// Petite illusion d'un ajax
		
		$('mCat').style.visibility = 'hidden';
		$('ajaxLoader').style.display = 'inline';
		
		// Petit cookie au passage
		
		new Request({
		url: 'pageSetSession.php?z='+z+'&f=preparation&sID='+sID+''
		}).send();
		
		// ================================================
		
		var all = $('All_preparation_IDs').value;
		
		if(d != 'Tous') {
		
				var v = $(d+'_IDs').value;
				
				// On display none de Tout
				
				if(all != '') {
				
						var s = all.split('-');
						
						var c = s.length;
						
						for(i=0;i<c;i++) {
							
							$('preparation'+s[i]).style.display = 'none';
						
						}
				
				}
				
				// Ensuite on affiche les ID de la preparation clique
				
				if(v != '') {
				
						var s = v.split('-');
						
						var c = s.length;
						
						for(i=0;i<c;i++) {
							
							$('preparation'+s[i]).style.display = 'inline';
						
						}
				
				}
				
				// Pour finir, si le menu principal est vide on le display none
		
				var m = $('countMenu').value;
				
				for(i=0;i<m;i++) {
				
						var P_ID = $('P_ID'+i).value;
								
								var s = P_ID.split('-');
								
								// - de 15 min
								if(z == 1) {
								    	
								    	if(s[0] > 0) {
								    		
								    		$('preparation'+i).style.display = 'inline';
								    	
								    	} else {
								    	
								    		$('preparation'+i).style.display = 'none';
								    	
								    	}
								
								}
								
								// 15 - 30 min
								if(z == 2) {
								    	
								    	if(s[1] > 0) {
								    		
								    		$('preparation'+i).style.display = 'inline';
								    	
								    	} else {
								    	
								    		$('preparation'+i).style.display = 'none';
								    	
								    	}
								
								}
								
								// 30 - 45 min
								if(z == 3) {
								    	
								    	if(s[2] > 0) {
								    		
								    		$('preparation'+i).style.display = 'inline';
								    	
								    	} else {
								    	
								    		$('preparation'+i).style.display = 'none';
								    	
								    	}
								
								}
								
								// 45 - 60 ans
								if(z == 4) {
								    	
								    	if(s[3] > 0) {
								    		
								    		$('preparation'+i).style.display = 'inline';
								    	
								    	} else {
								    	
								    		$('preparation'+i).style.display = 'none';
								    	
								    	}
								
								}
								
								// + de 1 heure
								if(z == 5) {
								    	
								    	if(s[4] > 0) {
								    		
								    		$('preparation'+i).style.display = 'inline';
								    	
								    	} else {
								    	
								    		$('preparation'+i).style.display = 'none';
								    	
								    	}
								
								}
								
						
						
				}
				
		
		} else {
		
				// On display inline de Tout
				
				if(all != '') {
				
						var s = all.split('-');
						
						var c = s.length;
						
						for(i=0;i<c;i++) {
							
							$('preparation'+s[i]).style.display = 'inline';
						
						}
				
				}
				
				var m = $('countMenu').value;
				
				for(i=0;i<m;i++) {
				
				
						$('preparation'+i).style.display = 'inline';
				
				}
		
		}
		
		// On remontre le menu
		
		(function wait() {
			
			$('ajaxLoader').style.display = 'none';
			$('mCat').style.visibility = 'visible';
			
		}).delay(250);
		
		

}

function lieu(sID) {
		
		var s = $('comboLieu').selectedIndex;
		var z = $('comboLieu').options[s].value;
		
		if(z == 0) {var d = 'Tous';}
		if(z == 1) {var d = 'lieuIn';}
		if(z == 2) {var d = 'lieuOut';}
		
		// Petite illusion d'un ajax
		
		$('mCat').style.visibility = 'hidden';
		$('ajaxLoader').style.display = 'inline';
		
		// Petit cookie au passage
		
		new Request({
		url: 'pageSetSession.php?z='+z+'&f=lieu&sID='+sID+''
		}).send();
		
		// ================================================
		
		var all = $('All_lieu_IDs').value;
		
		if(d != 'Tous') {
		
				var v = $(d+'_IDs').value;
				
				// On display none de Tout
				
				if(all != '') {
				
						var s = all.split('-');
						
						var c = s.length;
						
						for(i=0;i<c;i++) {
							
							$('lieu'+s[i]).style.display = 'none';
						
						}
				
				}
				
				// Ensuite on affiche les ID de la difficultŽ cliquŽ
				
				if(v != '') {
				
						var s = v.split('-');
						
						var c = s.length;
						
						for(i=0;i<c;i++) {
							
							$('lieu'+s[i]).style.display = 'inline';
						
						}
				
				}
				
				// Pour finir, si le menu principal est vide on le display none
		
				var m = $('countMenu').value;
				
				for(i=0;i<m;i++) {
				
						var L_ID = $('L_ID'+i).value;
								
								var s = L_ID.split('-');
								
								// Intérieur
								if(z == 1) {
								    	
								    	if(s[0] > 0) {
								    		
								    		$('lieu'+i).style.display = 'inline';
								    	
								    	} else {
								    	
								    		$('lieu'+i).style.display = 'none';
								    	
								    	}
								
								}
								
								// Extérieur
								if(z == 2) {
								    	
								    	if(s[1] > 0) {
								    		
								    		$('lieu'+i).style.display = 'inline';
								    	
								    	} else {
								    	
								    		$('lieu'+i).style.display = 'none';
								    	
								    	}
								
								}
						
				}
				
		
		} else {
		
				// On display inline de Tout
				
				if(all != '') {
				
						var s = all.split('-');
						
						var c = s.length;
						
						for(i=0;i<c;i++) {
							
							$('lieu'+s[i]).style.display = 'inline';
						
						}
				
				}
				
				var m = $('countMenu').value;
				
				for(i=0;i<m;i++) {
				
						$('lieu'+i).style.display = 'inline';
				
				}
		
		}
		
		// On remontre le menu
		
		(function wait() {
			
			$('ajaxLoader').style.display = 'none';
			$('mCat').style.visibility = 'visible';
			
		}).delay(250);
		
		

}


/********************************************************************************************************************************************************
	MOVE X Y
*********************************************************************************************************************************************************/

function moveCat2(i) {
	
	var step = parseFloat(i)*236;
	
	var numPHidden = $('numPHidden').value;
	
	for(z=0;z<numPHidden;z++) {
	
		$('numP'+z).style.backgroundColor = '#F2F2F2';
	
	}
	
		$('numP'+i).style.backgroundColor = '#fcd69b';
	
	moveItemNoX($('page_ImgAllContainer_move'),-step,500);

}

/********************************************************************************************************************************************************
	E-CARTE
*********************************************************************************************************************************************************/

function eCardsImprimer(i,k) {

	if(i == 1) {
		
		if(k == 1) {$('test').style.display = 'none';}
		$('all').style.display = 'none';
		$('apercuImprimer').style.display = 'inline';
		
	} else {
		
		$('all').style.display = 'inline';
		$('apercuImprimer').style.display = 'none';
	
	}


}

function eCardsButtons() {
	
	$('b1').style.display = 'none';
	$('b2').style.display = 'none';
	
	(function wait() {window.print();}).delay(250);
	
	(function wait() {
	
		$('b1').style.display = 'inline';
		$('b2').style.display = 'inline';
	
	}).delay(1000);
		

}

/********************************************************************************************************************************************************
	PAGE
*********************************************************************************************************************************************************/

function pageImprimer(i) {

	if(i == 1) {
		
		$('all').style.display = 'none';
		$('printContainer').style.display = 'inline';
		
	} else {
		
		$('all').style.display = 'inline';
		$('printContainer').style.display = 'none';
	
	}


}

function pageButtons() {
	
	$('b1').style.display = 'none';
	$('b2').style.display = 'none';
	$('subMenusContainer').style.display = 'none';
	
	(function wait() {window.print();}).delay(250);
	
	(function wait() {
	
		$('b1').style.display = 'inline';
		$('b2').style.display = 'inline';
		$('subMenusContainer').style.display = 'block';
	
	}).delay(1000);
		

}
