function InitPage() {
PositionMainDiv()
startSlideShow()
//window.onresize = InitPage
}

function PositionMainDiv() {
	MainDivObj = document.getElementById('maindiv');
	WindowInnerHeight = getWindowInnerHeight();
	DivClientHeight = document.getElementById('maindiv').offsetHeight;
	TargetTopMargin = ((WindowInnerHeight - DivClientHeight) * .45)
	TopMarginMin = 20
	if (TargetTopMargin < TopMarginMin) {
		TargetTopMargin = TopMarginMin
	}
	MainDivObj.setAttribute('style', 'margin-top:' + TargetTopMargin + 'px')
	MainDivObj.style.marginTop = TargetTopMargin + 'px'
	
	WindowInnerWidth = getWindowInnerWidth();
	DivClientWidth = document.getElementById('maindiv').offsetWidth;
	if (DivClientWidth * 1.05 > WindowInnerWidth) {
		TargetDivWidth = WindowInnerWidth * 0.8
		MainDivObj.setAttribute('style', 'width:' + TargetDivWidth + 'px')
		MainDivObj.style.width = TargetDivWidth + 'px'
	
	}
}

function donothing() {}
function getWindowInnerHeight() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  //window.alert( 'Width = ' + myWidth );
  //window.alert( 'Height = ' + myHeight );
  return myHeight;
}

function getWindowInnerWidth() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  //window.alert( 'Width = ' + myWidth );
  //window.alert( 'Height = ' + myHeight );
  return myWidth;
}

var picTable = new Array
// List the pictures in the slideshow here
(
	"images/GrandparentsAndChild-200wx118h.jpg"
	,"images/Therapy-200wx118h.jpg"
	,"images/Dining-200wx118h.jpg"
	,"images/GrandparentsAndChild-200wx118h.jpg"
	,"images/Therapy-200wx118h.jpg"
	,"images/Dining-200wx118h.jpg"
);
var captionTable = new Array
// List the captions in the slideshow here
(
	"Make Springhurst Pines your home"
	,"Therapy at Springhurst Health and Rehab"
	,"Dining at Parr's at Springhurst"
	,"Make Springhurst Pines your home"
	,"Therapy at Springhurst Health and Rehab"
	,"Dining at Parr's at Springhurst"
);
 
var slide0 = new Image();
var slide1 = new Image();
var slide2 = new Image();
var slide3 = new Image();
var slide4 = new Image();
var slide5 = new Image();
 
if (navigator.userAgent.indexOf("MSIE") != -1){
	slide0.onload = loadSlide1;
	slide1.onload = loadSlide2;
	slide2.onload = loadSlide3;
	slide3.onload = loadSlide4;
	slide4.onload = loadSlide5;
} else {
	slide0.onload = loadSlide1();
	slide1.onload = loadSlide2();
	slide2.onload = loadSlide3();
	slide3.onload = loadSlide4();
	slide4.onload = loadSlide5();
}
 
function loadSlide0() {
	self.status = "Downloading picture 0";
	self.defaultstatus = "Downloading picture 0";
    slide0.src = picTable[0];
}
function loadSlide1(evt) {
	self.status = "Downloading picture 1";
	self.defaultstatus = "Downloading picture 1";
    slide1.src = picTable[1];
}
function loadSlide2(evt) {
	self.status = "Downloading picture 2";
	self.defaultstatus = "Downloading picture 2";
    slide2.src = picTable[2];
}
function loadSlide3(evt) {
	self.status = "Downloading picture 3";
	self.defaultstatus = "Downloading picture 3";
    slide3.src = picTable[3];
}
function loadSlide4(evt) {
	self.status = "Downloading picture 4";
	self.defaultstatus = "Downloading picture 4";
    slide4.src = picTable[4];
}
function loadSlide5(evt) {
	self.status = "Downloading picture 5";
	self.defaultstatus = "Downloading picture 5";
    slide5.src = picTable[5];
}
 
loadSlide0();
var picNo = 0;
 
function startSlideShow() {
    showSlide();
 
	// Time is in thousands of a second
    setInterval("showSlide()", 10000);
}
 
function showSlide() {
    switch (picNo) {
	    case 0 :
		    if (slide0.complete) {
                document["slide"].src = slide0.src;
				document.getElementById('caption').innerHTML = captionTable[picNo];
				self.status = "Picture " + picNo;
				self.defaultstatus = "Picture " + picNo;
				picNo++;
			} else {
				self.status = "Still downloading picture " + picNo;
				self.defaultstatus = "Still downloading picture " + picNo;
			}
		    break;
	    case 1 :
		    if (slide1.complete) {
                document["slide"].src = slide1.src;
				document.getElementById('caption').innerHTML = captionTable[picNo];
				self.status = "Picture " + picNo;
				self.defaultstatus = "Picture " + picNo;
				picNo++;
			} else {
				self.status = "Still downloading picture " + picNo;
				self.defaultstatus = "Still downloading picture " + picNo;
			}
		    break;
 
	    case 2 :
		    if (slide2.complete) {
                document["slide"].src = slide2.src;
				document.getElementById('caption').innerHTML = captionTable[picNo];
				self.status = "Picture " + picNo;
				self.defaultstatus = "Picture " + picNo;
				picNo++;
			} else {
				self.status = "Still downloading picture " + picNo;
				self.defaultstatus = "Still downloading picture " + picNo;
			}
		    break;
 
	    case 3 :
		    if (slide3.complete) {
                document["slide"].src = slide3.src;
				document.getElementById('caption').innerHTML = captionTable[picNo];
				self.status = "Picture " + picNo;
				self.defaultstatus = "Picture " + picNo;
				picNo++;
			} else {
				self.status = "Still downloading picture " + picNo;
				self.defaultstatus = "Still downloading picture " + picNo;
			}
		    break;
 
	    case 4 :
		    if (slide4.complete) {
                document["slide"].src = slide4.src;
				document.getElementById('caption').innerHTML = captionTable[picNo];
				self.status = "Picture " + picNo;
				self.defaultstatus = "Picture " + picNo;
				picNo++;
			} else {
				self.status = "Still downloading picture " + picNo;
				self.defaultstatus = "Still downloading picture " + picNo;
			}
		    break;
 
	    case 5 :
		    if (slide5.complete) {
                document["slide"].src = slide5.src;
				document.getElementById('caption').innerHTML = captionTable[picNo];
				self.status = "Picture " + picNo;
				self.defaultstatus = "Picture " + picNo;
				picNo = 0;
			} else {
				self.status = "Still downloading picture " + picNo;
				self.defaultstatus = "Still downloading picture " + picNo;
			}
		    break;
 
      }
}

