var pbeSwapped = false;
var toSwap = null;

function swapPBE() {

       document.getElementById('pbeFrame').src = srcPBE; 
       toSwap = window.setTimeout('postSwap()',2000);
      
}

function postSwap() {
     window.clearTimeout(toSwap);
     
     document.getElementById('tempFrame').style.display = 'none';
     document.getElementById('pbeFrame').style.display = 'block';
      
     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');
	}
	
	
}





// legacy code
function init() {
    var ck = readCookie('pbe');
    
   if (ck == null) {
        triggerPBE(false, 0.8);
   } 
   if (ck == 'block')  {
        swapPBE();    
   } 
   
   
}




// create random splash image for home page
function rnd_splash(whatlang){
	var myimages=new Array()
		//specify random images below. You can have as many as you wish
		myimages[1]="splash1.jpg"
		myimages[2]="splash2.jpg"
		myimages[3]="splash3.jpg"
		//myimages[4]="splash4.jpg"
	
	var ry=Math.floor(Math.random()*myimages.length)
	
	if (ry==0)
		ry=1
		document.write('<img src="/_img/' + whatlang + '/home/'+myimages[ry]+'" alt="Scoprite il Canada" class="splashImage" usemap="#mapDestinations" />')
}



// language switch replace "en" with "fr" and vice versa
function switchurl(url){
	//baseurl=document.location.href;
	//if(baseurl.indexOf('www.airtransat.com')!=-1){document.location=url;}else{window.open(url);}
	document.location=url;
}

var debut, fin, langid, lastid

// fonction qui permet de passer a la page equivalente dans une autre langue 
var langRedirect = 0;
function changelangue(langid,lastid)
	{
	var template = document.location.href;
	debut  =  template.slice(0,template.lastIndexOf(lastid));
	debut  += langid;
	fin    =  template.slice((template.lastIndexOf(lastid) + 4),template.length);
	if(langRedirect) fin = fin.substring(0,fin.indexOf("?"));
	if(template.indexOf("Eschedule") != -1 ) {
		template = template.substring(0,template.indexOf("Eschedule")+10);
		
		document.location = template + "esched2-" + langid.substring(1,3) + ".asp";
		}
	else document.location.href = (debut + fin);
	} 




// fonction open window pour la sous-section "notre flotte"

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 showPDF(zepdf) {
	zepdf = window.open(zepdf,'PDF','width=700,height=500,scrollbars=yes,resizable=yes');
	zepdf.focus();
}

function xmltarget(url) {
	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",'width=790,height=500,toolbar=1,location=1,directories=1,status=1,menubar=1,resizable=1,scrollbars=1')
}





// here is the function for the tv spots
function showSlide (divID) {
	document.getElementById(divID).className="slideShow";
}

function hideSlide (divID) {
	document.getElementById(divID).className="slideHide";
}

// end function





// Use a variable to reference the embedded SWF.
var flashVideoPlayer;

var ns4 = (document.layers)? true:false;         //NS 4
var ie4 = (document.all)? true:false;         //IE 4
var dom = (document.getElementById)? true:false;   //NS 6 ou IE 5
var ie = navigator.appName.indexOf("Microsoft") != -1;

function callFlashPlayVideo(url, ztime) {
	var so = new SWFObject("/_flash/tvspot/VideoShell.swf", "theFlvVideo", "400", "350", "8", "#ffffff");
	so.addParam("quality", "high");
	so.addParam("wmode", "transparent");
	so.addParam("allowScriptAccess", "sameDomain");
	so.write("zvideo");

	flashVideoPlayer = (ie) ? window['theFlvVideo'] : document['theFlvVideo'];
	
	if (flashVideoPlayer!=undefined) {
		document.getElementById("loading").style.visibility="visible";
		document.getElementById("loading").style.zIndex="99";
		setTimeout('ReallyStardVid("'+url+'", "'+ztime+'")',500);
	}
}
function ReallyStardVid(url, ztime) {
	flashVideoPlayer.playVideo(url, ztime);
}
function callFlashStopVideo() {
	if (flashVideoPlayer!=undefined) {
		flashVideoPlayer.stopVideo();
	}
}

function unLoadFlashVideo() {

  if (dom) {
      document.getElementById("zvideo").innerHTML = " ";
         return;
      }
      if (ie4) {
          document.all["zvideo"].innerHTML = " ";
         return;
      }
      if (ns4) {
          with (eval('document.'+zvideo+'.document')) {
             open();
             write(" ");
             close();
         }
         return;
      }
}

function hideWaitText() {
	document.getElementById("loading").style.visibility="hidden";
}








// 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];}}
}


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);
}

// fonction open window pour la 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')}

// fonction open window 
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')
}

// fonction open map
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')
}




