////////////////////////////// Browser-Check ////////////////////////////////
function checkBrowser(){
  this.ver=navigator.appVersion
  this.agent=navigator.userAgent
  this.dom=document.getElementById?1:0
  this.opera5=this.agent.indexOf("Opera 5")>-1
  this.opera6=this.agent.indexOf("Opera 6")>-1
  this.opera7=this.agent.indexOf("Opera 7")>-1
  this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom && !this.opera5)?1:0; 
  this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom && !this.opera5)?1:0;
  this.ie7=(this.ver.indexOf("MSIE 7")>-1 && this.dom && !this.opera5)?1:0;
  this.ie8=(this.ver.indexOf("MSIE 8")>-1 && this.dom && !this.opera5)?1:0;
  this.ie4=(document.all && !this.dom && !this.opera5)?1:0;
  this.ie=this.ie4||this.ie5||this.ie6||this.ie7||this.ie8
  this.mac=this.agent.indexOf("Mac")>-1
  this.safari=(this.ver.indexOf("Safari")>-1 && this.dom && this.mac && !this.opera5)?1:0;
  this.ns6=(this.dom && parseInt(this.ver) >= 5) ?1:0; 
  this.ns4=(document.layers && !this.dom)?1:0;
  this.bw=(this.ie8||this.ie7||this.ie6||this.ie5||this.ie4||this.ns4||this.ns6||this.opera5||this.opera6||this.opera7||this.safari)
	return this
}
var bw = new checkBrowser();

//In most cases you want to check if the user is using a supported browser in this step
//and send them to a page saying "sorry you need a 4.x+ browser to see this page" or similar
//Just uncomment the next line and place in the url to your "sorry" page:
//if(bw.bw) alert("Sorry you need a 4.x+ browser to see this page correctly.") //location.href='sorry.html'

////////////////////////////// Stylesheet Installation ////////////////////////////////
var myRoot = location.hostname;
var myScript = '/css/';
function ScriptPath(){
	var myLoc = location.href;
	myPath = myLoc.substring(0,myLoc.lastIndexOf(myRoot))+myRoot;
	return myPath;
}
function installStyleSheets() {
	var stylepath = ScriptPath()+myScript;
	if (bw.mac) { document.write('<link href="' + stylepath + 'mac.css" rel="StyleSheet" type="text/css">'); }
	else
	{
		if (bw.ie) { document.write('<link href="' + stylepath + 'ie.css" rel="StyleSheet" type="text/css">'); }
		else { document.write('<link href="' + stylepath + 'ns.css" rel="StyleSheet" type="text/css">'); }
	}
}
if (bw.bw) installStyleSheets();

////////////////////////////// NetscapeStylesheets Bug ////////////////////////////////
// store window size for Netscape resize fix

if (bw.ns4){
	origWidth = innerWidth;
	origHeight = innerHeight;
	onresize = netscapeResizeFix;
}

myWindowResizetime = 400;

if(!window.saveInnerWidth)
		{
     window.onresize = netscapeResizeFix;
     window.saveInnerWidth = window.innerWidth;
     window.saveInnerHeight = window.innerHeight;
    }

function netscapeResizeFix(){
	if(bw.ns4){
		if (saveInnerWidth != window.innerWidth || saveInnerHeight != window.innerHeight)
		{
			location.reload(); //window.history.go(0); //
			saveInnerWidth = window.innerWidth;
			saveInnerHeight = window.innerHeight;

		}
	}
	if  (bw.ie || bw.dom){
		if (typeof (origWidth) != "number" || typeof (origHeight) != "number") return;
		if (document.body.clientWidth != origWidth || document.body.clientHeight != origHeight) location.reload();
		myWindowResize=setTimeout("netscapeResizeFix()", myWindowResizetime);
	}
}

function ieWindowSize(){
	if  (bw.ie || bw.dom)
	{
		onresize = netscapeResizeFix;
		origWidth = document.body.clientWidth;
		origHeight = document.body.clientHeight;
	}
}

var submitcount = 0, backcount = -1;
function checkFrameSet() {
	if(location.hostname != 'oleron') {
		var client = checkFrameSet.arguments[0];
		if(parent.siteID != location.hostname) {
			top.location.href="/french/?main=/"+client+"/";
		}
	}
}
// NEVER TOUCH THIS FUNCTION!!!
function checkHomeBase(url) {
	if(location.hostname != 'oleron') {
		var home = 'http://'+location.hostname;
		if(parent.siteID != location.hostname) {
			top.location.href=home+url;
		}
	}
}
// Wird nicht mehr verwendet von oleron.org.
function goUp(arg,n) {
	switch(arg)	{
		case 'camping':
			if(history.length > 0) { if(!n) { history.back(); } else { history.go(-2); }}
			else { location.href = "../french/lodging/lodging_camping.php"; }
			break;
		case 'hotel':
			if(history.length > 0) { if(!n) { history.back(); } else { history.go(-2); }}
			else { location.href = "../french/lodging/lodging_hotel.php"; }
			break;
		case 'estate':
			if(history.length > 0) { if(!n) { history.back(); } else { history.go(-2); }}
			else { location.href = "../french/lodging/lodging_estate.php"; }
			break;
		case 'village':
			if(history.length > 0) { if(!n) { history.back(); } else { history.go(-2); }}
			else { location.href = "../french/lodging/lodging_village.php"; }
			break;
		case 'residence':
			if(history.length > 0) { if(!n) { history.back(); } else { history.go(-2); }}
			else { location.href = "../french/lodging/lodging_residence.php"; }
			break;
		case 'tradi':
			if(history.length > 0) { if(!n) { history.back(); } else { history.go(-2); }}
			else { location.href = "../french/resto/resto_tradi.php"; }
			break;
		case 'cycles':
			if(history.length > 0) { if(!n) { history.back(); } else { history.go(-2); }}
			else { location.href = "../french/sport/sport_pistes2.php"; }
			break;
		case 'equi':
			if(history.length > 0) { if(!n) { history.back(); } else { history.go(-2); }}
			else { location.href = "../french/sport/sport_equi3.php"; }
			break;
		case 'nauti':
			if(history.length > 0) { if(!n) { history.back(); } else { history.go(-2); }}
			else { location.href = "../french/sport/sport_nauti2.php"; }
			break;
		default:
			location.href = "../french/home/";
	}
}

// Navigation backwards begin
// This function checks if the referrer is in another directory (returns true if so).
function outsideRef() {
	if (document.referrer) {
		if (document.referrer.indexOf('_toc') < 0) {
			if (document.referrer.substring(0,document.referrer.lastIndexOf("/")) == location.href.substring(0,location.href.lastIndexOf("/"))) {
				return false;
			} else { return true; }
		}
	} else { return false; }
}
function outsideRef_old() {
	if (document.referrer) {
		if (document.referrer.indexOf('_toc') < 0) {
			if (document.referrer.indexOf(location.pathname.substring(0,location.pathname.lastIndexOf("/"))) > -1) {
				return false
			}	else {return true;}
		}
	} else {return false;}
}
function goBack(url) {
	if (outsideRef()) { history.go(backcount); }
	else { document.location.href = url; }
}
function goBack_old(url) {
	if (document.referrer) {
		if (outsideRef()) {
			history.go(backcount);
		}
		else {
			document.location.href = url;
		}
	}
	else {
		document.location.href = './';
	}
}

function printBackbutton(url,img) {
	if(document.layers) {
		document.back.document.open();
		document.back.document.write('<a href="'+url+'"><img src="'+img+'" border=0></a>');
		document.back.document.close();
	} else { document.write('<a href="'+url+'"><img src="'+img+'" border=0></a>'); }
}
// Navigation backwards end

function adjust(num) { if(parent.toc) {parent.toc.doClick(num);} }

// Rollover + Layer show/hide begin

//Usage: onload="loadImages('path1/image1','path2/image2', ....);"
function loadImages() {
  var d=document; if(d.images){ if(!d.p) d.p=new Array();
    var i,j=d.p.length,a=loadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.p[j]=new Image; d.p[j++].src=a[i];}}
}
//Usage: onmouseout="swapImgRestore();" (no params)
function swapImgRestore() {
  var i,x,a=document.sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
//Usage: onmouseover="swapImage('image_name','','imagepath/over_image',1);"
function swapImage() {
  var i,j=0,x,a=swapImage.arguments; document.sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=findObj(a[i]))!=null){document.sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//Usage for show layer: onmouseover="showHideLayers('layername','','show');"
//Usage for hide layer: onmouseout="showHideLayers('layername','','hide');"
function showHideLayers() {
  var i,p,v,obj,args=showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}
//For internal use only - don't use it
function findObj(n, d) {
  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=findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
// Rollover + Layer show/hide end

function sendForm() {
	var x,args; args=sendForm.arguments;
	x=findObj(args[0]);
	x.submit();
}
function validateForm_french() {
  var i,p,q,nm,test,num,min,max,errors='',args=validateForm_french.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' doit contenir une adresse e-mail.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (val!=''+num) errors+='- '+nm+' doit contenir un numéro.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' doit contenir un numéro entre '+min+' et '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' doit être rempli.\n'; }
  } if (errors) {
		alert('Il y a des erreurs:\n'+errors);
	  document.returnValue = (errors == '');
	} else {
		if (submitcount == 0) {
			submitcount++;
	  	document.returnValue = (errors == '');
		} else {
			alert("Vous avez double-cliqué sur le bouton. Une fois suffit.\nCe formulaire était déjà envoyé.  Merci!");
			document.returnValue = false;
}	}	}
function validateForm_english() {
  var i,p,q,nm,test,num,min,max,errors='',args=validateForm_english.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (val!=''+num) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) {
		alert('The following error(s) occurred:\n'+errors);
		document.returnValue = (errors == '');
	} else {
		if (submitcount == 0) {
			submitcount++;
	  	document.returnValue = (errors == '');
		} else {
			alert("You have clicked the send button more then one time. Once ist enough.\nThe form is still sent. Thank you!");
			document.returnValue = false;
}	}	}
function validateForm_german() {
  var i,p,q,nm,test,num,min,max,errors='',args=validateForm_german.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' muss eine Email-Adresse sein.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (val!=''+num) errors+='- '+nm+' muss eine Nummer sein.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' muss eine Nummer zwischen '+min+' und '+max+' sein.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' muss ausgefüllt sein.\n'; }
  } if (errors) {
		alert('Folgende Fehler sind aufgetreten:\n'+errors);
	  document.returnValue = (errors == '');
	} else {
		if (submitcount == 0) {
			submitcount++;
	  	document.returnValue = (errors == '');
		} else {
			alert("Sie haben mehrfach auf Absenden geklickt. Einmal genügt.\nDas Formular wurde bereits versandt. Danke!");
			document.returnValue = false;
}	}	}

function validateForm_fr() {
  var i,p,q,nm,test,num,min,max,errors='',args=validateForm_fr.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' doit contenir une adresse e-mail.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (val!=''+num) errors+='- '+nm+' doit contenir un numéro.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' doit contenir un numéro entre '+min+' et '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' doit être rempli.\n'; }
  } if (errors) {
		alert('Il y a des erreurs:\n'+errors);
	  document.returnValue = (errors == '');
	} else {
		if (submitcount == 0) {
			submitcount++;
	  	document.returnValue = (errors == '');
		} else {
			alert("Vous avez double-cliqué sur le bouton. Une fois suffit.\nCe formulaire était déjà envoyé.  Merci!");
			document.returnValue = false;
}	}	}
function validateForm_en() {
  var i,p,q,nm,test,num,min,max,errors='',args=validateForm_en.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (val!=''+num) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) {
		alert('The following error(s) occurred:\n'+errors);
		document.returnValue = (errors == '');
	} else {
		if (submitcount == 0) {
			submitcount++;
	  	document.returnValue = (errors == '');
		} else {
			alert("You have clicked the send button more then one time. Once ist enough.\nThe form is still sent. Thank you!");
			document.returnValue = false;
}	}	}
function validateForm_de() {
  var i,p,q,nm,test,num,min,max,errors='',args=validateForm_de.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' muss eine Email-Adresse sein.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (val!=''+num) errors+='- '+nm+' muss eine Nummer sein.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' muss eine Nummer zwischen '+min+' und '+max+' sein.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' muss ausgefüllt sein.\n'; }
  } if (errors) {
		alert('Folgende Fehler sind aufgetreten:\n'+errors);
	  document.returnValue = (errors == '');
	} else {
		if (submitcount == 0) {
			submitcount++;
	  	document.returnValue = (errors == '');
		} else {
			alert("Sie haben mehrfach auf Absenden geklickt. Einmal genügt.\nDas Formular wurde bereits versandt. Danke!");
			document.returnValue = false;
}	}	}

function go(selection) {
var url,choice;
	choice = selection.selectedIndex;
	url = selection.options[choice].value;
	if (url == "#nope") {
		document.forms[0].reset();
		document.forms[0].elements[0].blur();
	}
	else {
		document.location=url;
		document.forms[0].reset();
		document.forms[0].elements[0].blur();
	}
}

// Diese beiden Funktionen werden nur noch für das Formular benutzt.
function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt; } }

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1]; } } }


