/* FUNCTION POUR AFFICHERBALADES */

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function ZoneTexteOver(sActionAff, sZoneAff, sZoneCssImg) {
	if(sActionAff == "afficher"){
		var iIndImg = '';
//alert('sActionAff : ' + sActionAff + '; sZoneAff : ' + sZoneAff);
		document.getElementById("ZoneTexteOver").style.display = "block";
		switch (sZoneAff) {
		case "balade01":
			sTexteOver = 'Du Mont Rigaud à la rivière des Outaouais';
			iIndImg = 0;
			break;
		case "balade02":
			sTexteOver = 'Le tour de l\'Île-Perrot';
			iIndImg = 1;
			break;
		case "balade03":
			sTexteOver = 'Chemin des trésors';
			iIndImg = 2;
			break;
		case "balade04":
			sTexteOver = 'Destination Salaberry-de-Valleyfield';
			iIndImg = 3;
			break;
		case "balade05":
			sTexteOver = 'Promenade le long du Canal Soulanges';
			iIndImg = 4;
			break;
		case "balade06":
			sTexteOver = 'Les parcs nature de Beauharnois-Salaberry';
			iIndImg = 5;
			break;
		case "balade07":
			sTexteOver = 'Sur la rive du lac Saint-Louis';
			iIndImg = 6;
			break;
		case "balade08":
			sTexteOver = 'Au fil de la Châteauguay';
			iIndImg = 7;
			break;
		case "balade09":
			sTexteOver = 'Sur les flancs de la Covey Hill';
			iIndImg = 8;
			break;
		case "balade10":
			sTexteOver = 'Sur la rive du lac Saint-François';
			iIndImg = 9;
			break;
		}
		document.getElementById("ZoneTexteOver").innerHTML = sTexteOver;
		if (sZoneCssImg != '') {
			document.getElementById("ZoneImgages").style.display = "inline";
			document.getElementById("ZoneImgages").innerHTML = '<img src="' + b[iIndImg].src + '">';
		}
	} else if(sActionAff == "cacher"){
		sTexteOver = 'Parmi ces 10 Balades, choisissez la vôtre !';
		document.getElementById("ZoneTexteOver").innerHTML = sTexteOver;
		document.getElementById("ZoneTexteOver").style.display = "block";
		if (sZoneCssImg != '') {
			document.getElementById("ZoneImgages").style.display = "none";
		}
	}
}

function AfficherMenuSaisons(sNiveau){
	var sOut = "";
//	var sNiveau = '../';	
	sOut += "<a href=\"" + sNiveau + "../hiver/\" onmouseout=\"MM_swapImgRestore()\" onmouseover=\"MM_swapImage('btHiver','','" + sNiveau + "imag_com/bt_hiver_ov.gif',1)\"><img src=\"" + sNiveau + "imag_com/bt_hiver.gif\" name=\"btHiver\" width=\"86\" height=\"80\" border=\"0\" id=\"btHiver\" /></a><a href=\"" + sNiveau + "../ete/default.asp\" onmouseout=\"MM_swapImgRestore()\" onmouseover=\"MM_swapImage('btEte','','" + sNiveau + "imag_com/bt_ete_ov.gif',1)\"><img src=\"" + sNiveau + "imag_com/bt_ete.gif\" name=\"btEte\" width=\"44\" height=\"80\" border=\"0\" id=\"btEte\" /></a><img src=\"" + sNiveau + "imag_com/bt_automne_ov.gif\" alt=\"automne\" border=\"0\" />\n";
	
/*sOut += "<a href=\"javascript:alert('Cette section nest pas encore complétée. Revenez la visiter à lautomne.');\" onmouseout=\"MM_swapImgRestore()\" onmouseover=\"MM_swapImage('btAutomne','','" + sNiveau + "imag_com/bt_automne_ov.gif',1)\"><img src=\"" + sNiveau + "imag_com/bt_automne.gif\" name=\"btAutomne\" width=\"37\" height=\"80\" border=\"0\" id=\"btAutomne\" /></a>
	

/*sOut += "<a href=\"" + sNiveau + "../hiver/\" onmouseout=\"MM_swapImgRestore()\" onmouseover=\"MM_swapImage('btHiver','','" + sNiveau + "imag_com/bt_hiver_ov.gif',1)"><img src=\"" + sNiveau + "imag_com/bt_hiver.gif\" name=\"btHiver\" width=\"86\" height=\"80\" border=\"0\" id=\"btHiver\" /></a><img src=\"" + sNiveau + "imag_com/bt_ete_ov.gif\" alt=\"&Eacute;t&eacute;\" border=\"0\" /><a href=\"javascript:alert('Cette section n'est pas encore complétée. Revenez la visiter à l'automne.');\" onmouseout=\"MM_swapImgRestore()\" onmouseover=\"MM_swapImage('btAutomne','','" + sNiveau + "imag_com/bt_automne_ov.gif',1)\"><img src=\"" + sNiveau + "imag_com/bt_automne.gif\" name=\"btAutomne\" width=\"37\" height=\"80\" border=\"0\" id=\"btAutomne\" /></a>\n";*/
	return sOut;
}

function AfficherMenuTransport(sNiveau){
	var sOut = '';
	var sNiveau = getpath();	
	sOut += '<a href="http://www.bestgetaways.ca" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage(\'btEnglish\',\'\',\'' + sNiveau + 'automne/imag_com/bt_english_ov.gif\',1)"><img src="' + sNiveau + 'automne/imag_com/bt_english.gif" name="btEnglish" border="0" id="btEnglish" /></a><br><a href="' + sNiveau + 'ete/velo/" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage(\'btVelo\',\'\',\'' + sNiveau + 'automne/imag_com/bt_velo_ov.gif\',1)"><img src="' + sNiveau + 'automne/imag_com/bt_velo.gif" name="btVelo" border="0" id="btVelo" /></a><a href="' + sNiveau + 'ete/auto/default.asp" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage(\'btAuto\',\'\',\'' + sNiveau + 'automne/imag_com/bt_auto_ov.gif\',1)"><img src="' + sNiveau + 'automne/imag_com/bt_auto.gif" name="btAuto" border="0" id="btAuto" /></a><a href="' + sNiveau + 'ete/train/" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage(\'btTrain\',\'\',\'' + sNiveau + 'automne/imag_com/bt_train_ov.gif\',1)"><img src="' + sNiveau + 'automne/imag_com/bt_train.gif" name="btTrain" border="0" id="btTrain" /></a><a href="' + sNiveau + 'ete/eau/" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage(\'btEau\',\'\',\'' + sNiveau + 'automne/imag_com/bt_eau_ov.gif\',1)"><img src="' + sNiveau + 'automne/imag_com/bt_eau.gif" name="btEau" border="0" id="btEau" /></a>\n';
	return sOut;
}

function AfficherMenuBas(sNiveau){
	var sOut = '';
	var sNiveau = getpath();
	sOut += '<table width="866" align="center" border="0" cellspacing="0" cellpadding="0">\n';
	sOut += '<tr align="right" valign="top">\n';
	sOut += '<td align="left" style="padding-top:0px"><a href="' + sNiveau + 'ete/vhsl/" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage(\'btHSL\',\'\',\'' + sNiveau + 'automne/imag_com/bt_HSL_ov.gif\',1)"><img src="' + sNiveau + 'automne/imag_com/bt_HSL.gif" name="btHSL" border="0" id="btHSL"></a></td>\n';
	sOut += '<td style="padding-top:10px;color:#fff"><a href="' + sNiveau + 'infolettre.asp" class="txt-btbas">Infolettre</a> | <a href="' + sNiveau + 'cartes_postales.asp" class="txt-btbas">Cartes postales</a> | <a href="' + sNiveau + 'ete/auto/contact.asp" class="txt-btbas">Nous joindre | Commander vos brochures</a> | <a href="' + sNiveau + 'ete/plan-du-site" class="txt-btbas">Plan du site</a></td>\n';
	//sOut += '<td style="padding-top:10px"><a href="' + sNiveau + 'infolettre.asp" class="txt-btbas">Infolettre</a> | <a href="' + sNiveau + 'cartes_postales.asp" class="txt-btbas">Cartes postales</a> | <a href="' + sNiveau + 'auto/contact.asp" class="txt-btbas">Nous joindre | Commander vos brochures</a> <span class="txt-bold">1 800 378-7648</span> <a href="' + sNiveau + 'auto/pdf/carte_globale.pdf" target="_blank"><img src="' + sNiveau + 'imag_com/bt_carte_balades.gif" border="0" align="texttop"></a></td>\n';
	sOut += '</tr>\n';
	sOut += '</table>\n';
	return sOut;
}

function getpath(){
	var pathname = window.location.pathname;
	var pathlen = pathname.split("/");
	var serverpath = "";
	var hostname = document.location.hostname;
	var faccorrectionniveau = 0;
	if (hostname == '192.168.100.231') {
		faccorrectionniveau = 2;
	}
	var sNiveau = '';
	
//alert(pathlen.length + ' : ' + faccorrectionniveau + ' : ' + pathname + ' = ' +  new String(faccorrectionniveau + 2));
//alert(hostname + ' (' + faccorrectionniveau + ') : ' + pathname+"-------"+pathlen.length);
//	alert("pathlen.length " + pathlen.length + " Path: " +window.location.pathname + " faccorrectionniveau : " + faccorrectionniveau);
	for(i = (faccorrectionniveau + 2); i < ((pathlen.length)); i++) {
		sNiveau +='../';
	}
	
	return sNiveau;
	
}

/* Permet de centraliser l'ouverture des fiches dans le guide en ligne - nous avons normalisé les fiches au niveau des pictogrammes */ 
function GuideEnLigne(iIDSousCategorie, iIDMembre) {
	if ((iIDSousCategorie > 0) && (iIDMembre > 0)) {
//		alert('iIDSousCategorie : ' + iIDSousCategorie + '\niIDMembre : ' + iIDMembre);
		var sUrlReferenceGuideEnLigne = 'http://www.tourisme-suroit.qc.ca/guide_en_ligne/viewfichemembre.asp?idcm=' + iIDSousCategorie + '&id=' + iIDMembre;
		GB_showCenter(document.location.hostname, sUrlReferenceGuideEnLigne, 500, 800)
	}
}


//Ouverture des fiches des membres à partir du site www.tourisme-suroit.qc.ca
function openFiche(sUrl) {
	if (document.location.href.indexOf('balades.ca') != -1) {
		sUrl += '&targetblank=true';
	}
	var intHauteurEcran = screen.height - 75;
	winpopup =	window.open(sUrl,"Fiche", "scrollbars=yes,toolbar=no,menubar=no,location=bo,directories=no,status=no,resizable=yes',width=525,height=" + intHauteurEcran + ", left=0,top=0");
	winpopup.focus();
}
function openFicheGrandeur(sUrl, iWidth, iHeight) {
		winpopup =	window.open(sUrl,"Fiche", "scrollbars=yes,toolbar=no,menubar=no,location=bo,directories=no,status=no,resizable=yes',width=" + iWidth + ",height=" + iHeight + ", left=0,top=0");
		winpopup.focus();
}

// Source: http://lists.evolt.org/archive/Week-of-Mon-20000207/096093.html
// Ferme la fenêtre enfant lorsque nous focussons sur la fenêtre parent sinon la fenêtre reste ouverte
var popupWin = null;
function openWin(url,w,h){
 if (w == 0) {
	w = screen.width - 200;
 }
//alert(screen.width + ':' + w);
 var itop=Math.floor((screen.height-h)/2);
 var ileft=Math.floor((screen.width-w)/2);
 popupWin = window.open(url,"PopupHelp","width="+w+",height="+h+",top="+itop+",left="+ileft+",toolbar=0,resizable=1,menubar=1,scrollbars=1");
  window.name = 'opener';
 }
function scram() {
  if (popupWin != null && popupWin.open) popupWin.close();
 }
window.onfocus=scram;