var cookie;
var title;
var testFrom;

testFrom = 0;

function fontsizeup() {
  createCookie("style", 'size +', 365);
  setActiveStyleSheet('size +');
  //active = getActiveStyleSheet();
  //switch (active) {
  //  case 'normal' : 
  //    setActiveStyleSheet('size +');
  //    break;
  //  case 'size +' : 
  //    setActiveStyleSheet('size +');
  //    break;
  //  default :
  //    setActiveStyleSheet('size +');
  //    break;
  //}
}

function fontsizedown() {
  createCookie("style", 'normal', 365);
  setActiveStyleSheet('normal');
  //active = getActiveStyleSheet();
  //switch (active) {
  //  case 'size +' : 
  //    setActiveStyleSheet('normal');
  //    break;
  //  case 'normal' : 
  //     setActiveStyleSheet('normal');
  //     break;
  //  default :
  //    setActiveStyleSheet('normal');
  //    break;
  //}
}

function setActiveStyleSheet(title) {
  var i, a, main;

  if (document.getElementById('buffer')) {
    for(i=0; (a = window.buffer.document.getElementsByTagName("link")[i]); i++) {
      if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
        a.disabled = true;
        if(a.getAttribute("title") == title) a.disabled = false;
      }
    }
  } else {
    for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
      if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
        a.disabled = true;
        if(a.getAttribute("title") == title) a.disabled = false;
      }
    }
  }
}

function getActiveStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
  }
  return null;
}

function getPreferredStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1
       && a.getAttribute("rel").indexOf("alt") == -1
       && a.getAttribute("title")
       ) {
	return a.getAttribute("title");
    }
  }
  return 'normal';
}

function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires=+10h";
  }
  else 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;
}

//var cookie = readCookie("style");
//var title = cookie ? cookie : 'normal';

window.onload = function(e) {
  var test = readCookie("style");
  var style = test ? test : 'normal';
  setActiveStyleSheet(style);
//    cookie = readCookie("style");
//    title = cookie ? cookie : getPreferredStyleSheet();
//    setActiveStyleSheet(getPreferredStyleSheet());
//    createCookie("style", getPreferredStyleSheet(), 365);
//    cookie = readCookie("style");
}

//----- PARTIE IMAGE ZOOM -----

var img_zoom;
var div_zoom = null;
var img_1_zoom = null;
var img_2_zoom = null;
var isNS_zoom = null;

function getZoom(image) {
	if (img_zoom==null) {
		img_zoom = new Image();
		div_zoom = document.getElementById? document.getElementById('zoom_image'): document.all? document.all['zoom_image']: null;
		img_1_zoom = document.getElementById? document.getElementById('big_image_1_zoom'): document.all? document.all['big_image_1_zoom']: null;
		img_2_zoom = document.getElementById? document.getElementById('big_image_2_zoom'): document.all? document.all['big_image_2_zoom']: null;
		isNS_zoom = navigator.userAgent.toLowerCase().indexOf('netscape') + 1;
	}

	if (img_1_zoom.src!=image) {
		img_1_zoom.src = '';
		img_2_zoom.src = '';
		img_1_zoom.style.width = 'auto';
		img_1_zoom.style.height = 'auto';
		img_2_zoom.style.width = 'auto';
		img_2_zoom.style.height = 'auto';

		img_zoom.src = image;

		img_1_zoom.src = image;
		img_2_zoom.src = image;

		if (isNS_zoom) {
			div_zoom.style.display = 'block';
		}
	} else {
		div_zoom.style.display = 'block';
	}
}

function checkSize() {
	if (img_zoom.width>img_zoom.height) {
		if (img_zoom.width>640) {
			img_1_zoom.style.width = 640;
			img_2_zoom.style.width = 640;
		}
	} else {
		if (img_zoom.height>480) {
			img_1_zoom.style.height = 480;
			img_2_zoom.style.height = 480;
		}
	}

	if (isNS_zoom) {
		document.getElementById('div_fond_zoom').style.width = '100%';
		document.getElementById('div_image_zoom').style.width = '100%';
	}

	div_zoom.style.display = 'block';
}


//----- PARTIE FLASH -----


/**
 * Display a flash element with an image in case no flash installed
 */
function displayFlash(flash,image,width,height) {
	document.write('         <div id="objFlash">');
	document.write('			<!-- Image Map --><!-- map id="AK" name="AK"></map-->');
	var UseFlash = 0; 
	if (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"] ) { 
		var plugin = navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin; 
		if (plugin && parseInt(plugin.description.substr(plugin.description.indexOf(".")-2,2))>=3 ) UseFlash = 1; 
	} else if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {
		UseFlash = 1; 
	}
	if ( UseFlash ) {
		document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+width+'" height="'+height+'"><param name="movie" value="'+flash+'" /><param name="quality" value="high" /><param name="wmode" value="transparent" /><embed src="'+flash+'" width="'+width+'" height="'+height+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash"></embed></object>');
	} else if (!(navigator.appName && navigator.appName.indexOf("Netscape")>=0 && navigator.appVersion.indexOf("2.")>=0)) {
		document.write('<img src="'+image+'" alt="'+title+'" title="'+title+'" border="0"> '); }
	document.write('			<NOEMBED><img alt="Image" src="'+image+'" usemap="#AK" border="0" /></NOEMBED>');
	document.write('			<noscript><img alt="Image" src="'+image+'" usemap="#AK" border="0" /></noscript>');
	document.write('		</div>');
}

function displayFlash(flash,image,width,height,title,style) {
	title = title || 'image';
	document.write('         <div id="objFlash"'+style+'>');
	document.write('			<!-- Image Map --><!-- map id="AK" name="AK"></map-->');
	var UseFlash = 0; 
	if (navigator.mimeTypes && navigator.mimeTypes["application/x-shockwave-flash"] ) { 
		var plugin = navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin; 
		if (plugin && parseInt(plugin.description.substr(plugin.description.indexOf(".")-2,2))>=3 ) UseFlash = 1; 
	} else if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {
		UseFlash = 1; 
	}
	if ( UseFlash ) {
		document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+width+'" height="'+height+'"><param name="movie" value="'+flash+'" /><param name="quality" value="high" /><param name="wmode" value="transparent" /><param name="allowFullScreen" value="true"><embed src="'+flash+'" width="'+width+'" height="'+height+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" allowfullscreen="true"></embed></object>');
	} else if (!(navigator.appName && navigator.appName.indexOf("Netscape")>=0 && navigator.appVersion.indexOf("2.")>=0)) {
		document.write('<img src="'+image+'" alt="'+title+'" title="'+title+'" border="0"> '); }
	document.write('			<NOEMBED><img alt="'+title+'" src="'+image+'" usemap="#AK" border="0" /></NOEMBED>');
	document.write('			<noscript><img alt="'+title+'" src="'+image+'" usemap="#AK" border="0" /></noscript>');
	document.write('		</div>');
}



//----- PARTIE AVIATION -----

function slideAviation() {
	if (document.getElementById('aviation')) {
		if (document.getElementById('objFlash').style.display=='block') {
			document.getElementById('objFlash').style.display = 'none';
		} else {
			document.getElementById('objFlash').style.display = 'block';
		}
	}
}