var docHt=435;
var home=false,providers=false,services=false,info=false,hours=false,contact=false;zoom=false;
var timeout;
var theImg;

function addStyleDef(objectID,styleName,newVal){
	var object = document.getElementById(objectID);
	object.style [styleName] = newVal;
}

function getDocHeight(doc){
  var docHt = 0, sh, oh;
  if (doc.height) docHt = doc.height;
  else if (doc.body) {
    if (doc.body.scrollHeight) docHt = sh = doc.body.scrollHeight;
    if (doc.body.offsetHeight) docHt = oh = doc.body.offsetHeight;
    if (sh && oh) docHt = Math.max(sh, oh);
  }
  if (docHt<=435){
    docHt=435;
  }
  return docHt;
}

function setIframeHeight(iframeName) {
  var iframeWin = window.frames[iframeName];
  var iframeEl = document.getElementById? document.getElementById(iframeName): document.all? document.all[iframeName]: null;
  if ( iframeEl && iframeWin ) {
    iframeEl.style.height = "auto"; // helps resize (for some) if new doc shorter than previous  
    docHt = getDocHeight(iframeWin.document);
    // need to add to height to be sure it will all show
    if (docHt) iframeEl.style.height = docHt + 30 + "px";
  }
}

function loadIframe(iframeName, url,imagename) {
  if(imagename==undefined) alert(imagename, + ": AJAX Error");
  if(imagename!=0){
	  document.di.src=imagename;
  }
  if(imagename=='gal'){
	  randomgallery();
  }
  if(imagename==0) {
	  randomimage();
  }
  if ( window.frames[iframeName] ) {
    window.frames[iframeName].location = url;   
    return false;
  }
  else{
	  setIframeHeight('ifrm');
	  return true;
  }
}

function startindex(){
	if (document.images) {
		var pre = new Array(13);
		for(j=0;j<pre.length;j++) pre[j]= new Image();
		var i = 0;
		pre[i++].src="Exercise.jpg";
		pre[i++].src="Girl.jpg";
		pre[i++].src="LoftWoman.jpg";
		pre[i++].src="MomSon.jpg";
		pre[i++].src="Plane.jpg";
		pre[i++].src="Smiling.jpg";
		pre[i++].src="Supplement.jpg";
		pre[i++].src="KORourke.jpg";
		pre[i++].src="LRay.jpg";
		pre[i++].src="TMarum.jpg";
		pre[i++].src="AlexOConnor-Bunny.jpg";
		pre[i++].src="AlexOConnor-Cows.jpg";
		pre[i++].src="AlexOConnor-Leopard.jpg";

	}
	goSetHeight();
}
function goSetHeight(){
  var theImg = document.getElementById('di');
  addStyleDef('bottomshadow','top',docHt + 136 + 45 + 30 + "px");
  addStyleDef('bottomright','top',docHt + 136 + 45 + 30 + "px");
  addStyleDef('bottomleft','top',docHt + 136 + 45 + 30 + "px");
  addStyleDef('copyright','top',docHt + 136 + 45 + 30 + 20 + "px");
  addStyleDef('sitemap','top',docHt + 136 + 45 + 30 + 40 + "px");
  addStyleDef('mapproviders','top',docHt + 136 + 45 + 30 + 40 + "px");
  addStyleDef('mapservice','top',docHt + 136 + 45 + 30 + 40 + "px");
  addStyleDef('maphours','top',docHt + 136 + 45 + 30 + 40 + "px");
  addStyleDef('mapcontact','top',docHt + 136 + 45 + 30 + 40 + "px");
  var sider = document.getElementById('sr');
  var sidel = document.getElementById('sl');
  sider.height = docHt - 3;
  sidel.height = docHt - theImg.height - 3;
  addStyleDef('sideleft','top',theImg.height + 136 + 80 + "px");
  addStyleDef('displaybottom','top',theImg.height + 216 + "px");
  addStyleDef('displaycorner','top',theImg.height + 216 + "px");
  return true;
}

function homehover(){
	allunhover();
	if(home==false) document.homepic.src='swDFM-Home-Over.gif';
}

function providerhover(){
	addStyleDef('provmenu','visibility','visible');
	document.providerpic.src='swDFM-Providers-Over.gif';
	servunhover();
	hoursunhover();
	infounhover();
	timeout = setTimeout("providerunhover()",5000);
}

function providerunhover(){
	addStyleDef('provmenu','visibility','hidden');
	if(providers==false) document.providerpic.src='swDFM-Providers-Up.gif';
	else document.providerpic.src='swDFM-Providers-Select.gif';
	clearTimeout(timeout);
}

function servhover(){
	addStyleDef('servmenu','visibility','visible');
	document.servicepic.src='swDFM-Services-Over.gif';
	providerunhover();
	hoursunhover();
	infounhover();
	timeout = setTimeout("servunhover()",5000);
}

function servunhover(){
	addStyleDef('servmenu','visibility','hidden');
	if(services==false) document.servicepic.src='swDFM-Services-Up.gif';
	else document.servicepic.src='swDFM-Services-Select.gif';
	clearTimeout(timeout);
}

function infohover(){
	addStyleDef('infomenu','visibility','visible');
	document.infopic.src='swDFM-Information-Over.gif';
	servunhover();
	providerunhover();
	hoursunhover();
	timeout = setTimeout("infounhover()",5000);
	
}

function infounhover(){
	addStyleDef('infomenu','visibility','hidden');
	if(info==false) document.infopic.src='swDFM-Information-Up.gif';
	else document.infopic.src='swDFM-Information-Select.gif';
	clearTimeout(timeout);
}

function hourshover(){
	if(hours==false) document.hourspic.src='swDFM-Hours-Over.gif';
	servunhover();
	providerunhover();
	infounhover();
	timeout = setTimeout("hoursunhover()",5000);
}

function hoursunhover(){
	if(hours==false) document.hourspic.src='swDFM-Hours-Up.gif';
	else document.hourspic.src='swDFM-Hours-Select.gif';
	clearTimeout(timeout);
	
}

function contacthover(){
	allunhover();
	if(contact==false) document.contactpic.src='swDFM-Contact-Over.gif';
}

function allunhover(){
	hoursunhover();
	servunhover();
	providerunhover();
	infounhover();
	if(home==false) document.homepic.src='swDFM-Home-Up.gif';
	if(contact==false) document.contactpic.src='swDFM-Contact-Up.gif';
}
function setactive(name){
	switch(name){
		case 'home':
			activehome();
			break;
		case 'kate':
			activeproviders();
			activekate();
			break;
		case 'orouke':
			activeproviders();
			activeorouke();
			break;
		case 'tmarum':
			activeproviders();
			activetmarum();
			break;
		case 'services':
			activeservices();
			break;
		case 'hours':
			activehours();
			break;
		case 'contact':
			activecontact();
			break;
		case 'info':
			activeinfo();
			break;
	}
	goSetHeight();
	return true;
}
function randomimage(){
	var x = Math.floor(Math.random() * 6);
	switch(x){
		case 0:
			document.di.src="Exercise.jpg";
			goSetHeight();
			break;
		case 1:
			document.di.src="Girl.jpg";
			goSetHeight();
			break;
		case 2:
			document.di.src="LoftWoman.jpg";
			goSetHeight();
			break;
		case 3:
			document.di.src="MomSon.jpg";
			goSetHeight();
			break;
		case 4:
			document.di.src="Plane.jpg";
			goSetHeight();
			break;
		case 5:
			document.di.src="Smiling.jpg";
			goSetHeight();
			break;
		case 6:
			document.di.src="Supplement.jpg";
			goSetHeight();
			break;
	}
	goSetHeight();
	return true;
}
function randomgallery(){
	var x = Math.floor(Math.random() * 3);
	switch(x){
		case 0:
			document.di.src="AlexOConnor-Bunny.jpg";
			goSetHeight();
			break;
		case 1:
			document.di.src="AlexOConnor-Cows.jpg";
			goSetHeight();
			break;
		case 2:
			document.di.src="AlexOConnor-Leopard.jpg";
			goSetHeight();
			break;
	}
}
function activekate(){
	document.di.src="KKulenic.jpg";
	goSetHeight();
}
function activeorouke(){
	document.di.src="KORourke.jpg";
	goSetHeight();
}
function activetmarum(){
	document.di.src="TMarum.jpg";
	goSetHeight();
}
function allfalse(){
	home=false;
	contact=false;
	hours=false;
	providers=false;
	services=false;
	info=false;
	allunhover();
}
function activehome(){
	allfalse();
	home=true;
	document.homepic.src='swDFM-Home-Select.gif';
	//randomimage();
}
function activeproviders(){
	allfalse();
	providers=true;
	document.providerpic.src='swDFM-Providers-Select.gif';
	goSetHeight();
}
function activeservices(){
	allfalse();
	services=true;	
	document.servicepic.src='swDFM-Services-Select.gif';
	//randomimage();
}
function activeinfo(){
	allfalse();
	info=true;
	document.infopic.src='swDFM-Information-Select.gif';
	//randomimage();
}
function activehours(){
	allfalse();
	hours=true;
	document.hourspic.src='swDFM-Hours-Select.gif';
	//randomimage();
}
function activecontact(){
	allfalse();
	contact=true;
	document.contactpic.src='swDFM-Contact-Select.gif';
	//randomimage();
}

