var startURL="diedomaine.php";
var WindowWidth;
var WindowHeight;
var imgWidth;
var imgHeight;
var n=1;
var slidePict;
var theRandNumber;
var imgH;
var imgW;
var brLang;

var loadCtrl=0;
function answerLoading()
{
loadCtrl++;
if(loadCtrl==5)
	{
	setTimeout("start()",1000);
	setTimeout("fade('fadeImage1')",3000);
	setTimeout("fade ('main')",2200);
	setTimeout("fade ('div1')",2200);
	}
}

if(window.innerHeight)
{
randNumber=Math.floor (Math.random() *Startfotos.length);
theRandNumber=randNumber;
fileString=Startfotos[randNumber];
a=fileString.indexOf("*");
b=fileString.indexOf("+");
slidePict="Startfotos/"+fileString.substring(0,a);
var pctLoad = new Array(1)
pctLoad[0] = new Image(); pctLoad[0].src=slidePict;
theSize=fileString.substring(a+1,b);
theTitleString=fileString.substring(b+1);
a=theSize.indexOf(",");
imgW=theSize.substring(a+1);
imgH=theSize.substring(0,a);
}
function loadIndexFotos()
{
for(i=0;i<4;i++)
	{
	imgSc=Domaine[i];
	m=imgSc.indexOf("*");
	document.getElementById("F"+i).src="Domaine/"+imgSc.substring(0,m);
	}
}
window.onload=function() {

loadIndexFotos();

if(navigator.appVersion.indexOf("MSIE")=="-1")
	{
	WindowWidth=window.innerWidth;
	WindowHeight=window.innerHeight;
	brLang=navigator.language;
	}
else
	{
	WindowWidth=document.getElementById("bodyWindow").offsetWidth;
	WindowHeight=document.getElementsByTagName('html')[0].offsetHeight;
	brLang=navigator.browserLanguage;
	}

if(brLang.indexOf("de")!="-1")
	document.getElementById("L1").style.fontWeight="bold";

if(brLang.indexOf("en")!="-1")
	{
	startURL="domain.php";
	document.getElementById("fewo").innerHTML="<img src='layout/holidays.png' style='height:30px;width:206px' alt=''/>";
	document.title="La Bartassi&egrave;re - Holiday Flats in Southern France";
	document.getElementById("L2").style.fontWeight="bold";
	}
if(brLang.indexOf("fr")!="-1")
	{
	startURL="domaine.php";
	document.getElementById("fewo").innerHTML="<img src='layout/gites.png' style='height:30px;width:206px' alt=''/>";
	document.title="La Bartassi&egrave;re - Logements de Vacances au Midi de la France";
	document.getElementById("L3").style.fontWeight="bold";
	}

if(!window.innerHeight)
	setTimeout("location.href=startURL;",1000);
else
	{
	document.getElementById("main").style.display="block";
	/*start();
	setTimeout("fade('fadeImage1')",3000);
	setTimeout("fade ('main')",2200);
	setTimeout("fade ('div1')",2200);*/
	}
}
function start()
{
imgWidth=WindowWidth;		
prozent=Math.round(imgWidth/(imgW/100));
imgHeight=Math.round((imgH/100)*prozent);

if(imgHeight<WindowHeight-155)
	{
	imgHeight=WindowHeight-155;		
	prozent=Math.round(imgHeight/(imgH/100));
	imgWidth=Math.round((imgW/100)*prozent);
	}
imgHeight=imgHeight+"px";
imgWidth=imgWidth+"px";

document.getElementById("fadeImage"+n).innerHTML="<a href="+startURL+"><img id='starttitle' src="+slidePict+" style='position:absolute;left:0px;bottom:0px;width:"+imgWidth+";height:"+imgHeight+";border:0px' onload='updateImage()' alt=''/></a>";
document.getElementById("fadeImage"+n).style.overflowY="hidden";
document.getElementById("fadeImage"+n).style.overflowX="hidden";
setTimeout("nextImage()",10000);
}
function updateImage()
{
getRandImage();
document.getElementById("preload").src=slidePict;
}
function nextImage()
{
fade('fadeImage'+n);
if(n==1)
	n=2;
else
	n=1;
fade('fadeImage'+n);
document.getElementById("fadeImage"+n).innerHTML="<a href="+startURL+"><img id='starttitle' src="+slidePict+" style='position:absolute;left:0px;bottom:0px;width:"+imgWidth+";height:"+imgHeight+";border:0px' alt=''/></a>";
document.getElementById("fadeImage"+n).style.overflowY="hidden";
document.getElementById("fadeImage"+n).style.overflowX="hidden";
updateImage();
setTimeout("nextImage()",7000);
}
function getRandImage()
{
randNumber=Math.floor (Math.random() *Startfotos.length);
if(theRandNumber==randNumber)
	getRandImage();
else
	{
	theRandNumber=randNumber;
	fileString=Startfotos[randNumber];
	a=fileString.indexOf("*");
	b=fileString.indexOf("+");
	slidePict="Startfotos/"+fileString.substring(0,a);
	theSize=fileString.substring(a+1,b);
	theTitleString=fileString.substring(b+1);
	a=theSize.indexOf(",");

	imgW=theSize.substring(a+1);
	imgH=theSize.substring(0,a);a
	
	imgWidth=WindowWidth;		
	prozent=Math.round(imgWidth/(imgW/100));
	imgHeight=Math.round((imgH/100)*prozent);

	if(imgHeight<WindowHeight-155)
		{
		imgHeight=WindowHeight-155;		
		prozent=Math.round(imgHeight/(imgH/100));
		imgWidth=Math.round((imgW/100)*prozent);
		}
	imgHeight=imgHeight+"px";
	imgWidth=imgWidth+"px";
	}
}
