// JavaScript Document

// Pocket Booking Engine (pbe) effect

//var pbeLoaded=false;
//
//// the onload of the pbe div's iframe will assign the return of this function to var pbeLoaded, 
//// so that the trigger_effect_pbe function doesn't get executed if the frame is not loaded
//// *** could be a temporary solution. Once we switch back google's code this might not be needed anymore (but I doubt it...)
// 
//function fixPbe(){ 
//	var yourStyle;
//	yourStyle = document.getElementById('pbe').style;
//	yourStyle.display="none";
//	yourStyle.position="relative";
//	yourStyle.left="0px";
//	return true;
//}

//function trigger_effect_pbe(src_element,div_id, effect){
//	if (pbeLoaded) {
//		var yourStyle;
//		yourStyle = document.getElementById('pbe').style;
//		yourStyle.position="relative";
//		yourStyle.left="0px";	
//
//        if (vIE() > 0 && vIE() < 7) {
//            var zel = document.getElementById(div_id);
//            zel.style.display =(zel.style.display == 'none')? 'block' : 'none';
//            imagex = src_element.getElementsByTagName('img')[1];
//		    imagex.src = imagex.src.match('/images/icon.less.gif') ? '/images/icon.more.gif' : '/images/icon.less.gif';
//            
//        } else {
//            Effect.toggle(div_id, effect, {duration: .3, afterFinish:function(){
//		    imagex = src_element.getElementsByTagName('img')[1];
//		    imagex.src = imagex.src.match('/images/icon.less.gif') ? '/images/icon.more.gif' : '/images/icon.less.gif';
//		    }});
//        }
//	}
//	return true;
//}


var pbeSwapped = false;
var toSwap = null;

function swapPBE() {

		try {
       document.getElementById('pbeFrame').src = srcPBE; 
       toSwap = window.setTimeout('postSwap()',2000);
      }
	  catch(e) {}
}

function postSwap() {
     window.clearTimeout(toSwap);
     
	 try {
     document.getElementById('tempFrame').style.display = 'none';
     document.getElementById('pbeFrame').style.display = 'block';
      }
	  catch(e) {}
      
     pbeSwapped = true;
}

function triggerPBE(swap, duration){
    secs = (duration == null)? .3 : duration;
    tgt = document.getElementById('pbe');
    
    if (swap && !pbeSwapped ) {
        swapPBE();
    }
    
    if (swap) {
        createCookie('pbe',(tgt.style.display == 'none')?'block':'none',180);
    }
    
	if (vIE() > 0 && vIE() < 7) {
	    if (tgt.style.display == 'block') {
		    tgt.style.display = 'none';
	    } else {
		    tgt.style.display = 'block';
	    }
	} else {
	    Effect.toggle(tgt, 'blind', {duration: secs});
	}
	
	im = document.getElementById('pbeReserve');
	if (im.src.match("pbe.header.min.gif")) {
	    im.src = im.src.replace( "\.min", "");
	} else {
	    im.src = im.src.replace('\.gif','.min.gif');
	}
	
	
}

function trigger_effect(src_element,div_id, effect){


		Effect.toggle(div_id, effect, {duration: .3, afterFinish:function(){
		image = src_element.getElementsByTagName('img')[1];
		image.src = image.src.match('/images/icon.less.gif') ? '/images/icon.more.gif' : '/images/icon.less.gif';
		}});
		return true;
	}

function vIE(){
    return (navigator.appName=='Microsoft Internet Explorer')?parseFloat((new RegExp("MSIE ([0-9]{1,}[.0-9]{0,})")).exec(navigator.userAgent)[1]):-1;
}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}



// Suckerfish (sf) navigation function:

sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);



// create random splash image for home page
function rnd_splash(){
	var myimages=new Array()
		//specify random images below. You can have as many as you wish
		myimages[1]="splash1"
		myimages[2]="splash2"
		myimages[3]="splash3"
		myimages[4]="splash4"
	
	var ry=Math.floor(Math.random()*myimages.length)
	
	if (ry==0)
		ry=1
		document.write('<img src="/fr/images/0_0/' + myimages[ry] + '.jpg'+'" alt="D&eacute;couvrez le Canada" class="splashImage" usemap="#mapDiscover" />')
}





function init()
	{
	
	atpromos_init();
	
	var ck = readCookie('pbe');
    
   if (ck == null) {
        triggerPBE(false, 0.8);
   } 
   if (ck == 'block')  {
        swapPBE();    
   } 
	
	}


function atpromos_init() {
	//stub
}


// fonction pour changer les images des sous sous section 
function rollover(nameid) { document['igs' + nameid].src = "/images/li_l3_on.gif" }
function rollout(nameid) { document['igs' + nameid].src = "/images/li_l3_off.gif" }

// fonction open window pour la sous-section "notre flotte"
function openWin(url,w,h,s){var ow; ow=window.open(url,"win",'toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=' + s + ',resizable=0,width=' + w + ',height=' + h + ',top=20,left=20');ow.focus();}
function openWin2(url,w,h,s){window.open(url,"win2",'toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=' + s + ',resizable=0,width=' + w + ',height=' + h + ',top=20,left=20')}
function openWin3(url,w,h,s){window.open(url,"win3",'toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=' + s + ',resizable=0,width=' + w + ',height=' + h + ',top=20,left=20')}


function showWin(url,w,h,s) {
	var ow; ow=window.open(url,"win",'status=1,scrollbars=' + s + ',width=' + w + ',height=' + h);
	try { ow.focus(); } catch(e) {}
}


function open_window(url,w,h)
{
window.open(url,"win",'toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=0,resizable=0,width=' + w + ',height=' + h + ',top=20,left=20')
}

function open_map(url,w,h)
{
window.open(url,"win",'toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=1,resizable=1,width=' + w + ',height=' + h + ',top=20,left=20')
}

function xmltarget(url)
	{
//	window.open(url,"fromxml",toolbar=1,location=1,directories=1,status=1,menubar=1,resizable=1,'width=' + windowwidth-20 + ',height=' + windowheight + ',top=20,left=20')
	window.open(url,"fromxml",'width=780, height=500,toolbar=1,location=1,directories=1,status=1,menubar=1,resizable=1,scrollbars=1')
	}

function xmlnavtarget(url)
	{
//	window.open(url,"fromxml",toolbar=1,location=1,directories=1,status=1,menubar=1,resizable=1,scrollbars=1,'width=' + windowwidth-20 + ',height=' + windowheight + ',top=20,left=20')
	window.open(url,"fromxml",'width=790,height=500,toolbar=1,location=1,directories=1,status=1,menubar=1,resizable=1,scrollbars=1')
	}



function showPDF(zepdf) {
	zepdf = window.open(zepdf,'PDF','width=700,height=500,scrollbars=yes,resizable=yes');
	zepdf.focus();
}






// code from Dreamweaver
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

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_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_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 MM_showHideLayers() { //v9.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) 
  with (document) if (getElementById && ((obj=getElementById(args[i]))!=null)) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

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];}}
}
