function afficherSwf(div) {
	document.getElementById(div).innerHTML="";


		document.getElementById(div).innerHTML+="<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0' width='10' height='10' title='image'>";
           document.getElementById(div).innerHTML+=" <param name='movie' value='flash/rectRound.swf' />";
           document.getElementById(div).innerHTML+=" <param name='quality' value='high' />";
           document.getElementById(div).innerHTML+=" <param name='wmode' value='transparent' />";
           document.getElementById(div).innerHTML+=" <embed src='flash/rectRound.swf' width='10' height='10' quality='high' pluginspage='http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash' type='application/x-shockwave-flash' wmode='transparent'></embed>";
         document.getElementById(div).innerHTML+=" </object>";


		scripts = document.getElementById(div).getElementsByTagName("script");
			for(var i=0;i<scripts.length;i++){
			   eval(scripts[i].innerHTML);
			}
}

function displayOnOff(id, idImg, classPlus, classMoins ) {
	if (document.getElementById(id).style.display=='none') {
		document.getElementById(id).style.display='block';
		if (idImg!="") {
			$(idImg).className=classMoins;
		}
	}else{
		document.getElementById(id).style.display='none';
		if (idImg!="") {
			$(idImg).className=classPlus;
		}
	} 
}

function displayOnOffMess(id, btn, txt1, txt2) {
	if (document.getElementById(id).style.display=='none') {
		document.getElementById(id).style.display='block';
		document.getElementById(btn).value = txt2;//"Annuler";
	}else{
		document.getElementById(id).style.display='none';
		document.getElementById(btn).value = txt1;//"Nouveau message";
	} 
}

function changeGolfAssocier(idGolf, id, idGolf1, titreGolf1) {
	urlAjax(CHEMIN_SITEWEB+'includes/inc_ajax_details_stages_golf.php', 'idGolf='+idGolf+'&id='+id+"&idGolf1="+idGolf1+"&titreGolf1="+titreGolf1, 'get', 'ajaxStage');
}

function changeOnglet(onglet, nbr){
	for (i=1;i<nbr+1;i++){
		if ("LienOnglet"+i==onglet) {
			if ($("LienOnglet"+i)) { $("LienOnglet"+i).className="actif"; }
		}else{
			if ($("LienOnglet"+i)) { $("LienOnglet"+i).className="inactif"; }
		}
	}
}

function changeOngletSmall(onglet, nbr){
	for (i=1;i<nbr+1;i++){
		if ( $("LienOnglet"+i) ) {
			if ("LienOnglet"+i==onglet) {
				$("LienOnglet"+i).className="actif small";
				$("bl"+i).className = "left";
				$("br"+i).className = "right";
			}else{
				$("LienOnglet"+i).className="inactif small";
				$("bl"+i).className = "left inactif";
				$("br"+i).className = "right inactif";
			}
		}
	}
}

function changeOngletOver(i){
	if ($("LienOnglet"+i).className!="actif small") {
		$("bl"+i).className = "left";
		$("br"+i).className = "right";
	}
}

function changeOngletOut(i){
	if ($("LienOnglet"+i).className!="actif small") {
		$("bl"+i).className = "left inactif";
		$("br"+i).className = "right inactif";
	}
}


function changeOngletAcc(onglet, divACharger, cat){
	
	if ($("rechercheStageEgf")) {
		$("rechercheStageEgf").style.display="none";
		$("rechercheStageInfo").style.display="none";
		for (i=1;i<5;i++){
			if ("LienOnglet"+i==onglet) {
				if ("LienOnglet"+i=="LienOnglet3") {
					$("LienOnglet"+i).className="infoStages actifInfo";
				}else{
					$("LienOnglet"+i).className="actif";
				}
				$(divACharger).style.display="block";
			}else{
				if ("LienOnglet"+i=="LienOnglet3") {
					$("LienOnglet"+i).className="infoStages inactifInfo";
				}else{
					if ($("LienOnglet"+i)) { $("LienOnglet"+i).className="inactif"; }
				}
			}
		}
		if (cat!=1 && cat!=2 && cat!=3) {
			cat=1;
		}
		if (cat==1) {
			catTitre="egf";	
		}
		if (cat==2) {
			catTitre="formations";	
		}
		if (cat==3) {
			catTitre="etranger";	
		}
		
		$("idStageCategorie2").value=cat;
		if ($("idStageCategorieText")) {
			$("idStageCategorieText").value=catTitre;
		}
		ajaxSearchAccueil('stages', 0);
	}
	
}



function enleverImage(){
	if (document.getElementById('textBloc2')) {
		countTab=document.getElementById('textBloc2').getElementsByTagName('img').length;
		for (i=0;i<countTab;i++) {
			document.getElementById('textBloc2').getElementsByTagName('img')[i].style.display='none';
		}
	}
	if (document.getElementById('textBloc3')) {
		countTab=document.getElementById('textBloc3').getElementsByTagName('img').length;
		for (i=0;i<countTab;i++) {
			document.getElementById('textBloc3').getElementsByTagName('img')[i].style.display='none';
		}
	}
}

function getOffsetHeight(bloc1, bloc2){
	bloc1H=$(bloc1).offsetHeight;
	bloc2H=$(bloc2).offsetHeight;
	if(bloc1H > bloc2H){
		return bloc1H;
	}else{
		return bloc2H;
	}
}

function memeTailleBloc(bloc1, bloc2) {

	if($(bloc1) != undefined && $(bloc2) != undefined){
		if (Prototype.Browser.IE) {
			$(bloc2).style.height = 'auto';
			$(bloc1).style.height = 'auto';
		}else{
			$(bloc1).style.height = "inherit";
			$(bloc2).style.height = "inherit";
		}
		tailleBloc = getOffsetHeight(bloc1, bloc2);
		$(bloc2).style.height=tailleBloc+"px";
		$(bloc1).style.height=tailleBloc+"px";
	}
}


function replaceImgFlash(bloc1, nomPage) {
	
	tabImg=document.getElementById(bloc1).getElementsByTagName('img');
	countTab=tabImg.length;  
	parentDiv = document.getElementById(bloc1); 

	for (i=0;i<countTab;i++) {
		//tabImg=document.getElementById(bloc1).getElementsByTagName('img');
		//parentDiv = document.getElementById(bloc1); 
		//countTab=tabImg.length; 
		//alert(countTab)
		spImg=tabImg[i];
		
		spImg_src = spImg.src;

		tab_spImg_src = spImg_src.split("upload");
		spImg_src=CHEMIN_SITEWEB+"upload"+tab_spImg_src[1];
		spImg_width = spImg.width;
		spImg_height = spImg.height;
		spImg_alt = spImg.alt;
		
		
		div1=document.createElement("div") ;
		if (spImg.className=="floatRightImg") {
			div1.setAttribute("class","myBoxRight block");
		}else{
			div1.setAttribute("class","myBoxLeft block");
		}
		div1.setAttribute("id","flashcontent"+i);

		strong1=document.createElement("strong") ;
		strong1.setAttribute("id","strong"+i);
		
		div1.appendChild(strong1);
		
		//parentDiv.replaceChild(div1, spImg);
		parentDiv.insertBefore(div1, spImg);
		
		
		//parentDiv.removeChild(spImg)
//alert(tabImg[i])
		document.getElementById("strong"+i).innerHTML="<br /><br />Vous devez effectuer la mise à jour de votre Flash Player<br /><br />";

		var so = new SWFObject(CHEMIN_SITEWEB+"flash/rectRound4.swf", "flashcontent"+i, "240", spImg_height, "9", "#FFFFFF");
		so.addParam("wmode", "transparent");
		so.addParam("scalemode", "noScale");
		so.addParam('allowFullScreen','true');
		
		so.addVariable('tabMyPics',spImg_src);
		so.addVariable('widthStage','240');
		so.addVariable('heightStage',spImg_height);
		so.addVariable('diapoActif','false');
		so.addVariable('fullEnabled','false');
		so.useExpressInstall(CHEMIN_SITEWEB+'flash/expressinstall.swf');
		so.setAttribute('xiRedirectUrl', nomPage);
		
		so.write("flashcontent"+i);
	}
}


function effacerImgFlash(bloc1) {
	tabImg=document.getElementById(bloc1).getElementsByTagName('img');	
	countTab=tabImg.length; 
	if (tabImg.length>0) {
		parentDiv = document.getElementById(bloc1); 
		parentDiv.removeChild(tabImg[0])
		effacerImgFlash(bloc1);
	}
}


function makeVideoArticle(bloc1) {
	
	tabImg=document.getElementById(bloc1).getElementsByTagName('object');
	countTab=tabImg.length;  
	

	for (i=0;i<countTab;i++) {
		video=tabImg[0];
		video_src=tabImg[0].data;
		video_src=video_src.replace("http://egf.fr", ""); 

		span1=document.createElement("span") ;
		span1.setAttribute("id","flashcontent"+i);
	
		noeudParent=video.parentNode;

		noeudParent.replaceChild(span1, video);



		var largeur = "320";//560
		var hauteur = "240";//340

		var so = new SWFObject(CHEMIN_SITEWEB+"flash/greentic_player.swf", "flashcontent"+i, largeur, hauteur, "9", "#000000");
		so.addParam("wmode", "transparent");
		so.addParam("scalemode", "noScale");
		so.addParam('allowFullScreen','true');
		
		so.addVariable('logoImg',CHEMIN_SITEWEB+"images/pasimage.jpg");
		so.addVariable('file', video_src);
		so.addVariable('largeur',largeur);
        so.addVariable('hauteur',hauteur);
		so.addVariable('autostart',"false");
		so.addVariable('full',"true");
		so.addVariable('couleur',"6d9401");
		so.addVariable('border',"true");
		so.addVariable('borderRadius',"10");
		so.addVariable('borderColor1',"b9b9b9");
		so.addVariable('borderColor2',"ffffff");
		so.addVariable('bgcolor',"#7CA900");
		so.addVariable('allowfullscreen',"true");
		so.addVariable('allowscriptaccess',"always");

		so.addVariable('hauteur',hauteur);
		so.addVariable('hauteur',hauteur);

		so.write("flashcontent"+i);

	}
	
}

function cornerImage(bloc1) {
	var tabImg=document.getElementById(bloc1).getElementsByTagName('img');
	var countTab=tabImg.length;  
	
	for (i=0;i<countTab;i++) {
		
		img=tabImg[i];
		img_src=tabImg[i].src;
		img_width=tabImg[i].width;
		img_height=tabImg[i].height;
		img_width2=img_width-6;
		img_height2=img_height+4;
		
		imgClass=tabImg[i].className;;
		
		
		
		img_src=img_src.replace("http://egf.fr", ""); 

		span1=document.createElement("span") ;
		span1.setAttribute("id","img"+i);
		//span1.setAttribute("class","bloc_img");
		span1.setAttribute("style","width:"+img_width+"px;height:"+img_height+"px");
		if (imgClass=="imgAGauche") {
			span1.setAttribute("class","bloc_img myBoxLeft");
		}
		if (imgClass=="imgADroite") {
			span1.setAttribute("class"," bloc_img myBoxRight");
		}
		
		b1=document.createElement("b") ;
		span1.appendChild(b1);
		b1.setAttribute("class","corner r1");
		
		b2=document.createElement("b") ;
		span1.appendChild(b2);
		b2.setAttribute("class","corner r2");
		
		span2=document.createElement("span") ;
		span1.appendChild(span2);
		span2.setAttribute("class","ctr_img_top");
		span2.setAttribute("style","width:"+img_width2+"px;height:"+img_height2+"px");
		
		span3=document.createElement("span") ;
		span1.appendChild(span3);
		span3.setAttribute("class","ctr_img_side");
		
		imgCorner=document.createElement("img") ;
		span3.appendChild(imgCorner);
		console.log(img_src);
		imgCorner.setAttribute("src",img_src);
		imgCorner.setAttribute("width",img_width);
		imgCorner.setAttribute("height",img_height);
		//imgCorner.setAttribute("class",imgClass);
		
		b3=document.createElement("b") ;
		span1.appendChild(b3);
		b3.setAttribute("class","corner r3");
		
		b4=document.createElement("b") ;
		span1.appendChild(b4);
		b4.setAttribute("class","corner r4");
		
		noeudParent=img.parentNode;
		noeudParent.replaceChild(span1, img);
	}

}






function changeDep(idRegion, start, table) {

	tabOption=$("idDepartement2").options.length;
	if ($("idGolf2")) {
		tabDep=$("idGolf2").options.length;
	}
	tabDepChange= new Array();
	
	if (idRegion==0) {
		for (k=1;k<tabOption;k++) {
			$("idDepartement2").options[k].style.display="block";
			$("idDepartement2").options[0].selected=true;
		}
		if ($("idGolf") && table=="stages") {
			for (j=1;j<tabDep;j++) {
				$("idGolf2").options[j].style.display="block";
			}
		}
		
	}else{

		//if (tabOption>1) {
			
			for (i=1;i<tabOption;i++) {
				depVal=$("idDepartement2").options[i].value;
				tabDepVal=depVal.split("|")
				if ( tabDepVal[1]==idRegion ) {
					$("idDepartement2").options[i].style.display="block";
					tabDepChange.push(tabDepVal[0]) // pour afficher les golf de la region selectionnée
				}else{
					$("idDepartement2").options[i].style.display="none";
				}
			}
		//}else{
		//	changeGolf("", 1);
		//}
		if (tabDepChange.length==0 && table=="stages") {
			changeGolf("vide", 1, table);

		}else if (table=="stages"){
			changeGolf(tabDepChange, 1, table);
		}
		//if ($("idGolf")) {

		//	changeGolf(tabDepChange, 0);
		//}
		
	}
	if (start==0) {
		$("idDepartement2").options[0].selected=true;
		$("idGolf2").options[0].selected=true;
	}

}


function changeGolf(idDepartement, start, table) {
		
	switch (table) {
		case 1:
		table="stages";
		break;
		case 2:
		table="usersPros";
		break;
		case 3:
		table="usersGolfs";
		break;
		case 4:
		table="usersHotels";
		break;
	}
	
	if (idDepartement.indexOf("|")!=-1) {
		
		lg=idDepartement.split("|");
		
		idDepartement2 = new Array();

		if (lg.length>1) {
			for (u=0;u<lg.length;u++) {
				
				idDepartement2.push(lg[u]);
				u++;
			}	
			idDepartement=idDepartement2;
		}
	}
	

	if ($("idGolf2")) {
		
		tabOption=$("idGolf2").options.length;

		if (idDepartement==0) {
			for (k=1;k<tabOption;k++) {
				$("idGolf2").options[k].style.display="block";
			}

		}else{
			
			//document.stages.idPays.options.selectedIndex = 1;
			
			for (l=1;l<tabOption;l++) {
				$("idGolf2").options[l].style.display="none";
			}
			if (idDepartement!="") {
				
				for (i=1;i<tabOption;i++) {
					
					depVal2=$("idGolf2").options[i].value;
					tabDepVal2=depVal2.split("|");

					
					//if (typeof(idDepartement)!="string")  {
						for (n=0;n<=idDepartement.length;n++) {
						//	alert(tabDepVal2[1])
							//alert(idDepartement[n])
							if (tabDepVal2[1]==idDepartement[n]) {
								$("idGolf2").options[i].style.display="block";
							}
						}
					//}else{
					//	depVal=$("idGolf").options[i].value;
					//	tabDepVal=depVal.split("|");
					//	if (tabDepVal[1]==idDepartement) {
					//		$("idGolf").options[i].style.display="block";
					//	}
					//}
				}
			}
		}
		if (start==0) {
			$("idGolf2").options[0].selected=true;
		}
	}
	setTimeout("ajaxSearchAccueil('"+table+"')", 500);
}


////////////////////////////////////fonction flash ////////////////////////////////////
function carteFlash_clicRegion(nbr, table) {
	
	//document.stages.idPays.options.selectedIndex = 1;
	if (nbr!=0 && table!="stages") { document.stages.idPays.options.selectedIndex = 1; }
	tabOption=$("idRegion2").options.length;
	for (o=0;o<tabOption;o++) {
		if ($("idRegion2").options[o].value==nbr) {
			document.stages.idRegion.options.selectedIndex = o;
		}
	}
	urlAjax(CHEMIN_SITEWEB+'includes/inc_ajax_options_departements.php', 'idRegion='+nbr+'&table='+table, 'get', 'listDep', false);
	if (table=="stages") {
		urlAjax(CHEMIN_SITEWEB+'includes/inc_ajax_options_golfs_multiple.php', 'idRegion='+nbr+'&table='+table, 'get', 'listGolf', false);
	}
	

	setTimeout("ajaxSearchAccueil('"+table+"')", 500);
	
}

function carteFlash_clicDepartement(nbr, table, fla) {
	
	//document.stages.idPays.options.selectedIndex = 1;
	
	tabOption=$("idDepartement2").options.length;
	for (d=0;d<tabOption;d++) {
		depVal2=$("idDepartement2").options[d].value;
		tabDepVal2=depVal2.split("|");
		if (tabDepVal2[0]==nbr) {
			document.stages.idDepartement.options.selectedIndex = d;
		}
	}
	
	
	if (table=="stages") {
		urlAjax(CHEMIN_SITEWEB+'includes/inc_ajax_options_golfs.php', 'idDepartement='+nbr, 'get', 'listGolf', false);
		idDepartement = new Array();
		idDepartement.push(nbr);
		changeGolf(idDepartement, 1, table);
	}
	
	sauvSession('', table)
	
	setTimeout("ajaxSearchAccueil('"+table+"', "+fla+")", 500);
}

////////////////////////////////////fonction flash ////////////////////////////////////
function ajaxSearchAccueil2(table) {
	setTimeout("ajaxSearchAccueil('"+table+"')", 500);
}


function changePays(idPays, table) {
	
	if (idPays!=78 && idPays!=0) {
		
		document.stages.idRegion2.options.selectedIndex = 0;
		document.stages.idDepartement2.options.selectedIndex = 0;
		document.stages.idDepartement2.disabled="disabled";
		document.stages.idRegion2.disabled="disabled";
	}else{
		if (table=="stages" || table=="usersPros" || table=="usersGolfs" || table=="usersHotels") {
			document.stages.idRegion2.options.selectedIndex = 0;
			document.stages.idRegion2.disabled="";
			urlAjax(CHEMIN_SITEWEB+'includes/inc_ajax_options_departements.php', 'idRegion=0&table='+table, 'get', 'listDep', false);
		}
	}
	
}


function ajaxSearchAccueil(table, fla) {
	
	if (fla==3) {
		document.stages.idPays.options.selectedIndex=1;		
	}
	
	
	switch (table) {
		case 1:
		table="stages";
		break;
		case 2:
		table="usersPros";
		break;
		case 3:
		table="usersGolfs";
		break;
		case 4:
		table="usersHotels";
		break;
	}
	
	idPays=document.stages.idPays.value;

	idRegion=$("idRegion2").value;

	idDepartement1=$("idDepartement2").value;
	tabIdDepartement=idDepartement1.split("|");
	idDepartement=tabIdDepartement[0];
	
	if ($("idGolf2")) {
		idGolf1=$("idGolf2").value;
		tabIdGolf=idGolf1.split("|");
		idGolf=tabIdGolf[0];
	}else{
		idGolf=0;
	}
	
	//if ($("typeStageCateg")) {
	//	typeStageCateg=$("typeStageCateg").value;
	//}else{
		if ($("typeStageCateg2")) {
			typeStageCateg=$("typeStageCateg2").value;
		}else{
			typeStageCateg=0;
		}
	//}
	
	
	
	idNiveau=$("idNiveau2").value;

	jours=$("jours2").value;

	motcle=$("motcle2").value;


	//prixMinPeriode=$("prixMinPeriode").value;
	idStageCategorieTitreUrl="";
	
	idStageCategorie=$("idStageCategorie2").value;
	
	if (fla==1) {
	if (idStageCategorie==1) {
		idStageCategorieTitreUrl+="egf/";
	}
	if (idStageCategorie==2) {
		idStageCategorieTitreUrl+="formations/";
	}
	}
	
	
	
	if ($("idPays").value!=0) {
		
		idCat=document.stages.idPays.selectedIndex;
		
		titreCat=document.stages.idPays.options[idCat].text;
		
		idStageCategorieTitreUrl+=titreUrlRewriteStage(titreCat);
	}
	if ($("idRegion2").value!=0) {
		if ($("idPays").value!=0) {
			idStageCategorieTitreUrl+="/";
		}
		idCat=document.stages.idRegion2.selectedIndex;
		titreCat=document.stages.idRegion2.options[idCat].text;
		idStageCategorieTitreUrl+=titreUrlRewriteStage(titreCat);
	}
	if ($("idDepartement2").value!="0|0") {
		if ($("idRegion2").value!=0 || $("idPays").value!=0) {
			idStageCategorieTitreUrl+="/";
		}
		idCat=document.stages.idDepartement2.selectedIndex;
		titreCat=document.stages.idDepartement2.options[idCat].text;
		idStageCategorieTitreUrl+=titreUrlRewriteStage(titreCat);
	}
	if (idStageCategorieTitreUrl!="") {
		idStageCategorieTitreUrl="/"+idStageCategorieTitreUrl;
	}
	
	if ($("idStageCategorieTitreUrl")) {
		$("idStageCategorieTitreUrl").value=idStageCategorieTitreUrl;
	}
	
	if (fla==1 && table=="stages") {

			urlAjax(CHEMIN_SITEWEB+'includes/inc_ajax_bloc_search_accueil.php', 'idRegion='+idRegion+'&idDepartement='+idDepartement+'&idGolf='+idGolf+'&idNiveau='+idNiveau+'&jours='+jours+'&idStageCategorie='+idStageCategorie+'&table='+table+'&motcle='+motcle+'&idPays='+idPays+'&typeStageCateg='+typeStageCateg, 'get', '', false, clicDepartementCarte, CHEMIN_SITEWEB+'stages-de-golf'+idStageCategorieTitreUrl);
	}else if (fla==1 && table=="usersGolfs") {
		urlAjax(CHEMIN_SITEWEB+'includes/inc_ajax_bloc_search_accueil.php', 'idRegion='+idRegion+'&idDepartement='+idDepartement+'&idGolf='+idGolf+'&idNiveau='+idNiveau+'&jours='+jours+'&idStageCategorie='+idStageCategorie+'&table='+table+'&motcle='+motcle+'&idPays='+idPays, 'get', '', false, clicDepartementCarte, CHEMIN_SITEWEB+'golfs'+idStageCategorieTitreUrl);
	}else if (fla==1 && table=="usersHotels") {
		urlAjax(CHEMIN_SITEWEB+'includes/inc_ajax_bloc_search_accueil.php', 'idRegion='+idRegion+'&idDepartement='+idDepartement+'&idGolf='+idGolf+'&idNiveau='+idNiveau+'&jours='+jours+'&idStageCategorie='+idStageCategorie+'&table='+table+'&motcle='+motcle+'&idPays='+idPays, 'get', '', false, clicDepartementCarte, CHEMIN_SITEWEB+'hotels-golfs'+idStageCategorieTitreUrl);
	}else if (fla==1 && table=="usersPros") {
		urlAjax(CHEMIN_SITEWEB+'includes/inc_ajax_bloc_search_accueil.php', 'idRegion='+idRegion+'&idDepartement='+idDepartement+'&idGolf='+idGolf+'&idNiveau='+idNiveau+'&jours='+jours+'&idStageCategorie='+idStageCategorie+'&table='+table+'&motcle='+motcle+'&idPays='+idPays, 'get', '', false, clicDepartementCarte, CHEMIN_SITEWEB+'enseignants-golf'+idStageCategorieTitreUrl);
	}else{
		urlAjax(CHEMIN_SITEWEB+'includes/inc_ajax_bloc_search_accueil.php', 'idRegion='+idRegion+'&idDepartement='+idDepartement+'&idGolf='+idGolf+'&idNiveau='+idNiveau+'&jours='+jours+'&idStageCategorie='+idStageCategorie+'&table='+table+'&motcle='+motcle+'&idPays='+idPays+'&typeStageCateg='+typeStageCateg, 'get', 'nbrResultStage', false, afficheBtSearchAccueil, '');
		
	
	}
}

function sauvSession(TitreLien, table) {
	idPays=$("idPays").value;
	
	idRegion=$("idRegion2").value;
	
	idDepartement1=$("idDepartement2").value;
	tabIdDepartement=idDepartement1.split("|");
	idDepartement=tabIdDepartement[0];
	
	if ($("idGolf2")) {
		idGolf1=$("idGolf2").value;
		tabIdGolf=idGolf1.split("|");
		idGolf=tabIdGolf[0];
	}else{
		idGolf=0;
	}
	
	//if ($("typeStageCateg")) {
	//	typeStageCateg=$("typeStageCateg").value;
	//}else{
		if ($("typeStageCateg2")) {
			typeStageCateg=$("typeStageCateg2").value;
		}else{
			typeStageCateg=0;
		}
	//}
	
	idNiveau=$("idNiveau2").value;

	jours=$("jours2").value;
	
	motcle=$("motcle2").value;
	if (TitreLien!="") {
		urlAjax(CHEMIN_SITEWEB+'includes/inc_ajax_stage_sauv_session.php', 'idRegion='+idRegion+'&idDepartement='+idDepartement+'&idGolf='+idGolf+'&idNiveau='+idNiveau+'&jours='+jours+'&idStageCategorie='+idStageCategorie+'&table='+table+'&motcle='+motcle+'&idPays='+idPays+'&typeStageCateg='+typeStageCateg, 'get', '', false, refreshPageSeul, TitreLien+$('idStageCategorieTitreUrl').value);
	}else{
		urlAjax(CHEMIN_SITEWEB+'includes/inc_ajax_stage_sauv_session.php', 'idRegion='+idRegion+'&idDepartement='+idDepartement+'&idGolf='+idGolf+'&idNiveau='+idNiveau+'&jours='+jours+'&idStageCategorie='+idStageCategorie+'&table='+table+'&motcle='+motcle+'&idPays='+idPays+'&typeStageCateg='+typeStageCateg, 'get', '', false);
	}
}

function viderAjaxSearchAccueil(table) {
	document.stages.idDepartement2.options.selectedIndex = 0;
	document.stages.idRegion2.options.selectedIndex = 0;
	if(document.stages.idGolf2.type!="hidden") {
		document.stages.idGolf2.options.selectedIndex = 0;
	}
	$("idNiveau2").value=0;
	$("jours2").value=0;
	$("motcle2").value="";
	setTimeout("ajaxSearchAccueil('"+table+"')", 500);
}


function afficheBtSearchAccueil() {
	if ($("nbrResultStage").innerHTML==0) {
		$("btSearch").disabled=true;
	}else{
		$("btSearch").disabled=false;
	}	
}


function setDashedHeight(){
	var mc = document.getElementById('dashed_wrap');
	var hgt = mc.offsetHeight;
	while(hgt%6 != 0){
		hgt++;
		mc.style.height = hgt+"px";
	}
}


function afficheDivCalendar(choixId, nbrId){
	for (i=1;i<=nbrId;i++){
		if ("divCalendar"+i==choixId) {
			$("divCalendar"+i).style.display="block";
		}else{
			$("divCalendar"+i).style.display="none";
		}
	}
}



function afficherSousMenu (sousMenu) {
	$(sousMenu).style.display="block";
	/*if (Prototype.Browser.IE) {
		$("advanced_search").style.display="none";
		$("formIe6").style.display="block";
	}*/
}

function cacherSousMenu (sousMenu) {
	$(sousMenu).style.display="none";
	/*if (Prototype.Browser.IE) {
		$("advanced_search").style.display="block";
		$("formIe6").style.display="none";
	}*/
}

function overMenu(id,param) {
	var menuItem = document.getElementById(id);
	if(param){
		menuItem.className = "overMenu";
	}else{
		menuItem.className = "";
	}
}



function oxylaneClic(dateClic, ip, idUser, idUserClic, typeClic) {
	urlAjax(CHEMIN_SITEWEB+'includes/inc_ajax_oxylane.php', 'dateClic='+dateClic+'&ip='+ip+'&idUser='+idUser+'&idUserClic='+idUserClic+'&typeClic='+typeClic, 'get', 'nbrResultStage', false);
}






function verifMail(z) {
	var reg = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]{2,}[.][a-zA-Z]{2,4}$/
	if (reg.exec(z)==null){
		return false;
	}else{
		return true;
	}
}


function inscriptionProClick(idUserCategorie) {
	if ($("idUserCategorie")) {
		$("idUserCategorie").value=idUserCategorie;
		switch (idUserCategorie) {
		case 4:
			titre="HOTEL ";
			break;
		case 2:
			titre="PRO ";
			break;
		case 3: 
			titre="GOLF ";
			break;
		}
		//if ($("titreUserCategorie")) {
		//	$("titreUserCategorie").innerHTML=titre;
		//}
	}
	$("blocInscription").style.display="block";
}

function check() {
	if ($('suppr')) {
		if ($('suppr').checked == true) {
			choix=true;
		}else{
			choix=false;
		}
		field=document.getElementsByName('idSuppr[]');
		for (i = 0; i < field.length; i++) 
		{
			field[i].checked = choix;
		}
	}
	if ($('supprPeriode')) {
		if ($('supprPeriode').checked == true) {
			choix=true;
		}else{
			choix=false;
		}
		field=document.getElementsByName('idSupprPeriode[]');
		for (i = 0; i < field.length; i++) 
		{
			field[i].checked = choix;
		}
	}
}


var TextareaLong = function TextareaLong(Objet,TailleMax)
{
    TailleObj = Objet.value.length
    if (TailleObj > TailleMax )
    {
        Objet.value = Objet.value.substring(0,TailleMax);
        TailleObj = TailleMax;
    }
}

 
function afficheDivAgenda(idProfesseur, dateChoix) {
	
  // crée un nouvel élément div
  // et lui donne un peu de contenu
  divAgenda = document.createElement("div");
	divAgendaBackGround = document.createElement("div");
	divAgendaContenue = document.createElement("div");
	
	divAgenda.className = 'divAgenda';
	divAgendaBackGround.className = 'divAgendaBackGround';
	divAgendaContenue.className = 'divAgendaContenue';
	divAgendaBackGround.style.opacity = 0.7;
	divAgendaBackGround.style.filter = 'alpha(opacity=70)';
	
	$tailleFenetre=getPageSize();
	divAgenda.style.height=$tailleFenetre[1]+"px";
	divAgenda.style.width=$tailleFenetre[0]+"px";
	divAgendaBackGround.style.height=$tailleFenetre[1]+"px";
	divAgendaBackGround.style.width=$tailleFenetre[0]+"px";
	
	divAgenda.setAttribute("id","divAgenda");
	divAgendaBackGround.setAttribute("id","divAgendaBackGround");
	divAgendaContenue.setAttribute("id","divAgendaContenue");
	
	
	var myBoxL=document.getElementsByClassName("myBoxLeft");
	var nbrL=myBoxL.length;
	
	for (i=0;i<nbrL;i++) {
		myBoxL[i].style.display='none';
	}
	
	var myBoxR=document.getElementsByClassName("myBoxRight");
	var nbrR=myBoxR.length;
	
	for (i=0;i<nbrR;i++) {
		myBoxR[i].style.display='none';
	}
	
	var myForm = document.getElementsByTagName('form');
	
	var nbrF=myForm.length;
	for (i=0;i<nbrF;i++) {
		myForm[i].style.display='none';
	}
  // ajoute l'élément qui vient d'être créé et son contenu au DOM
  mon_div = document.getElementById("global");
	document.body.appendChild(divAgenda);
  //document.body.insertBefore(divAgenda, mon_div);
	divAgenda.appendChild(divAgendaBackGround);
	divAgenda.appendChild(divAgendaContenue);
	
	urlAjax(CHEMIN_SITEWEB+'agenda_pro.php', 'idProfesseur='+idProfesseur+'&dateChoix='+dateChoix, 'get', 'divAgendaContenue', false);
	
}



function fermerDivAgenda() {
	//document.body.className='';
	var myBoxL=document.getElementsByClassName("myBoxLeft");
	var nbrL=myBoxL.length;
	
	for (i=0;i<nbrL;i++) {
		myBoxL[i].style.display='block';
	}
	
	var myBoxR=document.getElementsByClassName("myBoxRight");
	var nbrR=myBoxR.length;
	
	for (i=0;i<nbrR;i++) {
		myBoxR[i].style.display='block';
	}
	
	var myForm = document.getElementsByTagName('form');
	
	var nbrF=myForm.length;
	for (i=0;i<nbrF;i++) {
			if(myForm[i].id != "new_mess"){
				myForm[i].style.display='block';
			}
	}
	
	parentDiv= document.body;
	divAgenda = $('divAgenda');
	
	parentDiv.removeChild(divAgenda)

}


function choixCatArticle(cat, recharge) {
	a=1;
	tabOption=$('selectArticle').options.length;
	
	/*
	tabIdArticle=idArticle.split("|");
	tailleTabIdArticle=idArticle.length;
				if (idArticle!="") {
					$("selectArticle").options[i].style.display="block";
				}else{
					$("selectArticle").options[i].style.display="none";
				}*/
	for (i=0;i<tabOption;i++) {
		if (cat==0) {
			$("selectArticle").options[i].style.display="block";
			if (recharge==1) {
				$("selectArticle").options[0].selected='true';
			}
		}else{
			tabCat=$("selectArticle").options[i].value.split("|");
			
			if (tabCat[1]==cat) {

				$("selectArticle").options[i].style.display="block";
				if (a!=0 && recharge==1) {
					$("selectArticle").options[i].selected='true';
					a=0;
				}
			}else{
				$("selectArticle").options[i].style.display="none";
			}
		}
	}
	if (cat!=0) {
		urlAjax(CHEMIN_SITEWEB+'includes/inc_ajax_requeteCat.php', 'idCat='+cat, 'get', '', false, choixArticleAffiche, cat);
	}
}

function choixArticleAffiche(retourAjax, cat) {

	tabOptionLength=$('selectArticle').options.length;
	tabRetourAjax=retourAjax.split("|");
	for (i=0;i<tabOptionLength;i++) {
		
		tabCat=$("selectArticle").options[i].value.split("|");
	
		for (h=0;h<tabOptionLength;h++) {
			if (tabRetourAjax[h]==tabCat[0]) {
				$("selectArticle").options[i].style.display="block";
			}
		}
		
	}
	
}

function selectArticle(id) {
	tabId=id.split("|");
	tabOption=$('selectArticle').options.length;
	for (i=0;i<tabOption;i++) {
		if ($("selectArticle").options[i].value==tabId[0]) {
			$("selectArticle").options[i].selected='true';
		}
	}
}

function selectCatArticle(cat) {
	tabOption=$('catArticle').options.length;
	for (i=0;i<tabOption;i++) {
		if ($("catArticle").options[i].value==cat) {
			$("catArticle").options[i].selected='true';
		}
	}
	
}

function choix1Article(id) {
	tabOption=$('selectArticle').options.length;
	tabId=id.split("|");
	for (i=0;i<tabOption;i++) {
		if ($("selectArticle").options[i].value==tabId[0]) {
			$("selectArticle").options[i].style.display="block";
		}
	}
}

function imprime_zone(titre, obj) {
	// Définie la zone à imprimer
	var zi = document.getElementById(obj).innerHTML;

	// Ouvre une nouvelle fenetre
	var f = window.open("", "ZoneImpr", "");
	
	// Définit le Style de la page
	///f.document.body.style.color = '#000000';
	//f.document.body.style.backgroundColor = '#FFFFFF';
	//f.document.body.style.padding = "10px";
	/*var headID = f.document.getElementsByTagName("head")[0];         
	var cssNode = f.document.createElement('link');
	cssNode.type = 'text/css';
	cssNode.rel = 'stylesheet';
	cssNode.href = 'css/styles_agenda.css';
	cssNode.media = 'screen';
	headID.appendChild(cssNode);*/
	// Ajoute les Données
	f.document.body.style.fontSize = "0.7em";
	f.document.title = titre;

	f.document.body.innerHTML += " " + zi + " ";
	
	// Imprime et ferme la fenetre
	f.window.print();
	f.window.close();

	return true;
} 


function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = window.innerWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	
//	console.log(self.innerWidth);
//	console.log(document.documentElement.clientWidth);

	if (self.innerHeight) {	// all except Explorer
		if(document.documentElement.clientWidth){
			windowWidth = document.documentElement.clientWidth; 
		} else {
			windowWidth = self.innerWidth;
		}
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

//	console.log("xScroll " + xScroll)
//	console.log("windowWidth " + windowWidth)

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = xScroll;		
	} else {
		pageWidth = windowWidth;
	}
//	console.log("pageWidth " + pageWidth)

	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

function afficheRegion(numCat) {
	if (numCat==3) {
		$("idRegion").disabled="disabled";
	}else{
		$("idRegion").disabled="";
	}
}

function details_videoClick(nomVideo) { // on recharge le blo descriptino detail video
	urlAjax(CHEMIN_SITEWEB+'includes/inc_ajax_detail_video.php', 'nomVideo='+nomVideo, 'get', 'divDescriptionVideo');
}


function retourModifAnalyse() { // pour l'ajout de periode
	document.getElementById("retourModif").value=1;
}
function retourModifUsers() { // pour l'ajout de periode/article
	document.getElementById("retourModif").value=2;
}



function ouvrirTableau(id) { // pour l'ajout de periode/article
	if (Prototype.Browser.IE) {
		$(id).style.display='block';
	}else {
		$(id).style.display='table-row';
	}	
}



///////////////////////////////////// url rewrite ////////////////////////////////////

function formAction(chemin, typeCat, rep) { 



	switch (typeCat) {
	case 'catArticle':
		
		idCatIndex=document.formChoixCateg.idCategorie.selectedIndex;
		
		titreCat=document.formChoixCateg.idCategorie.options[idCatIndex].text;
		idCat=document.formChoixCateg.idCategorie.options[idCatIndex].value;

		titreCat=titreUrlRewrite(titreCat);
		$('formChoixCateg').action=chemin+'cours-de-golf/'+titreCat+'/'+idCat;
		break;
	case 'catArticleVideo':
		idCatIndex=document.formChoixCateg.idCategorie.selectedIndex;
		titreCat=document.formChoixCateg.idCategorie.options[idCatIndex].text;
		idCat=document.formChoixCateg.idCategorie.options[idCatIndex].value;
		titreCat=titreUrlRewrite(titreCat);
		$('formChoixCateg').action=chemin+'videos-de-golf/'+titreCat+'/'+idCat;
		break;
	case '3': alert ('1, 2 ou 3');
	
	case '4':
	case '5':
	case '6': alert ('4, 5 ou 6');
	
	default: alert('autre');
	} 


	
}


function titreUrlRewrite(titre) {
	titre=encodeUtf8Perso(titre);
	titre=virerPonctuation(titre);
	titre=titre.toLowerCase();
	return titre;
}

function titreUrlRewriteStage(titre) {

	titre=encodeUtf8Perso(titre);

	titre=virerPonctuation(titre);
	titre=titre.toLowerCase();

	return titre;
}


function virerPonctuation(chaine) {
	
	var exp = /\W|_/gi; //enleve touts les caracteres speciaux
	 
	chaine = chaine.replace(exp," "); 
	
	chaine = chaine.replace(/^\s+/g,'').replace(/\s+$/g,'') 
	chaine = chaine.replace(" ","-"); 
	chaine = chaine.replace(" ","-"); 
	chaine = chaine.replace(" ","-"); 
	chaine = chaine.replace(" ","-"); 
	chaine = chaine.replace(" ","-"); 
	chaine = chaine.replace(" ","-"); 
	chaine = chaine.replace(" ","-"); 
	return chaine;
}



function noaccentUtf8(titre) {
  titre = titre.replace("Ã¨","e"); //è
  titre = titre.replace("Ã¨","e"); //è
  titre = titre.replace("Ã¨","e"); //è
  titre = titre.replace("Ã´","o"); //ô
  titre = titre.replace("Ã´","o"); //ô
  titre = titre.replace("Ã´","o"); //ô
  titre = titre.replace("Ã©","e"); //é 
  titre = titre.replace("Ã©","e"); //é 
  titre = titre.replace("Ã©","e"); //é 
  return titre;
  
}

/////////////////////// encode UTF8 /////////////////////////////////////////////////
function encodeUtf8Perso(string) {
	string = string.replace(/\r\n/g,"\n");
	var utftext = "";

	for (var n = 0; n < string.length; n++) {

		var c = string.charCodeAt(n);

		if (c >= 242 && c<=246) { 
			utftext += "o";
		}else if (c >= 232 && c<=235 ){ 
			utftext += "e";
		}else if (c >= 224 && c<=229 ){ 
			utftext += "a";
		}else if (c >= 236 && c<=239 ){ 
			utftext += "i";
		}else if (c >= 249 && c<=252 ){ 
			utftext += "u";
		}else{
			utftext += String.fromCharCode(c);
		}
		


	}

	return utftext;
}

function encodeUtf8(string) {
	string = string.replace(/\r\n/g,"\n");
	var utftext = "";

	for (var n = 0; n < string.length; n++) {

		var c = string.charCodeAt(n);

		if (c < 128) {
			utftext += String.fromCharCode(c);
		}
		else if((c > 127) && (c < 2048)) {
			utftext += String.fromCharCode((c >> 6) | 192);
			utftext += String.fromCharCode((c & 63) | 128);
		}
		else {
			utftext += String.fromCharCode((c >> 12) | 224);
			utftext += String.fromCharCode(((c >> 6) & 63) | 128);
			utftext += String.fromCharCode((c & 63) | 128);
		}
		
	}

	return utftext;
}

// public method for url decoding
function decodeUtf8(utftext) {
	var string = "";
	var i = 0;
	var c = c1 = c2 = 0;

	while ( i < utftext.length ) {

		c = utftext.charCodeAt(i);

		if (c < 128) {
			string += String.fromCharCode(c);
			i++;
		}
		else if((c > 191) && (c < 224)) {
			c2 = utftext.charCodeAt(i+1);
			string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
			i += 2;
		}
		else {
			c2 = utftext.charCodeAt(i+1);
			c3 = utftext.charCodeAt(i+2);
			string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
			i += 3;
		}

	}

	return string;
}

/////////////////////// decode UTF8 /////////////////////////////////////////////////

function viderInputLog(txtInput, input) {
	if (txtInput=="Votre pseudo" || txtInput=="Mot de passe") {
		$(input).value="";
	}
}

function rechargeAdvancedSearch(value, idPays) {
	if (idPays==78) {
		urlAjax(CHEMIN_SITEWEB+'includes/inc_advancedSearch_ajax_region.php', 'cat='+value, 'get', 'ajaxRegionAdvanced');
	}
}

function changePaysAdvancedSearch(value) {
	if (value==0) {
		document.advanced_search.idNiveau.disabled="disabled";
		document.advanced_search.idRegion.disabled="disabled";
	}else{
		document.advanced_search.idNiveau.disabled="";
		document.advanced_search.idRegion.disabled="";
	}
}




// ******************************************************************
// Impression d'une zone DOM: IE5+ Mozilla NN6 Win
// ******************************************************************

function PSR_imprimer (div) {
	var PSR_f1 = null;
	var PSR_content=document.getElementById(div).innerHTML;
	if (PSR_f1) {if(!PSR_f1.closed) PSR_f1.close();}
	PSR_f1 = window.open ('',"PSR_f1", "height=500,width=600,menubar=yes,scrollbars=yes,resizable=yes,,left=10,top=10");
	PSR_f1.document.open();
	var newText = PSR_content.replace(/display: none/g, "display: block");
	newText = newText.replace(/Plus d'infos/g, "");
	newText = newText.replace("setDashedHeight();","");
	newText = newText.replace('id="autreStage" style="display: block;"','id="autreStage" style="display: none;"');
	newText = newText.replace("height:","width:");
	newText = newText.replace(/Haut de page/g,'')

	PSR_f1.document.write("<html><head><title>L'ECOLE DU GOLF FRANCAIS</title><script type='text/javascript' src='"+CHEMIN_SITEWEB+"js/swfobject.js'></script><link href='"+CHEMIN_SITEWEB+"css/print.css' rel='stylesheet' type='text/css'></head><body bgcolor='#ffffff'><a href='#' onclick='window.print();' class='orangeNoir'>Imprimer cette page</a><br /><br /><img src='"+CHEMIN_SITEWEB+"images/logo_egf.jpg' width='136' height='155' alt='EGF' />"+newText+"</body></html>");
	PSR_f1.document.close();
	PSR_f1.focus();
}