// JavaScript Document


// xHeight, Copyright 2001-2005 Michael Foster (Cross-Browser.com)
// Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL


function xGetElementById(e)
{
  if(typeof(e)!='string') return e;
  if(document.getElementById) e=document.getElementById(e);
  else if(document.all) e=document.all[e];
  else e=null;
  return e;
}

function xNum()
{
  for(var i=0; i<arguments.length; ++i){if(isNaN(arguments[i]) || typeof(arguments[i])!='number') return false;}
  return true;
}

function xDef()
{
  for(var i=0; i<arguments.length; ++i){if(typeof(arguments[i])=='undefined') return false;}
  return true;
}

function xStr(s)
{
  for(var i=0; i<arguments.length; ++i){if(typeof(arguments[i])!='string') return false;}
  return true;
}

function xGetComputedStyle(oEle, sProp, bInt)
{
  var s, p = 'undefined';
  var dv = document.defaultView;
  if(dv && dv.getComputedStyle){
    s = dv.getComputedStyle(oEle,'');
    if (s) p = s.getPropertyValue(sProp);
  }
  else if(oEle.currentStyle) {
    // convert css property name to object property name for IE
    var a = sProp.split('-');
    sProp = a[0];
    for (var i=1; i<a.length; ++i) {
      c = a[i].charAt(0);
      sProp += a[i].replace(c, c.toUpperCase());
    }   
    p = oEle.currentStyle[sProp];
  }
  else return null;
  return bInt ? (parseInt(p) || 0) : p;
}

function xHeight(e,h)
{
  if(!(e=xGetElementById(e))) return 0;
  if (xNum(h)) {
    if (h<0) h = 0;
    else h=Math.round(h);
  }
  else h=-1;
  var css=xDef(e.style);
  if (e == document || e.tagName.toLowerCase() == 'html' || e.tagName.toLowerCase() == 'body') {
    h = xClientHeight();
  }
  else if(css && xDef(e.offsetHeight) && xStr(e.style.height)) {
    if(h>=0) {
      var pt=0,pb=0,bt=0,bb=0;
      if (document.compatMode=='CSS1Compat') {
        var gcs = xGetComputedStyle;
        pt=gcs(e,'padding-top',1);
        if (pt !== null) {
          pb=gcs(e,'padding-bottom',1);
          bt=gcs(e,'border-top-width',1);
          bb=gcs(e,'border-bottom-width',1);
        }
        // Should we try this as a last resort?
        // At this point getComputedStyle and currentStyle do not exist.
        else if(xDef(e.offsetHeight,e.style.height)){
          e.style.height=h+'px';
          pt=e.offsetHeight-h;
        }
      }
      h-=(pt+pb+bt+bb);
      if(isNaN(h)||h<0) return;
      else e.style.height=h+'px';
    }
    h=e.offsetHeight;
  }
  else if(css && xDef(e.style.pixelHeight)) {
    if(h>=0) e.style.pixelHeight=h;
    h=e.style.pixelHeight;
  }
  return h;
}


function adjustLayout()  
{  
 
 // Get natural heights  
 var cHeight = xHeight("middle");  
 var lHeight = xHeight("left");  
 var rHeight = xHeight("right");
 
 
 // Find the maximum height  
 var maxHeight =  
   Math.max(cHeight, Math.max(lHeight, rHeight));  
 
 // Assign maximum height to all columns  
 xHeight("contents", maxHeight);  
 xHeight("leftshadow", maxHeight);  
 xHeight("rightshadow", maxHeight); 
 
 
 // Show the footer  
 //xShow("footer");  
}


window.onload = function()  
{  
 xAddEventListener(window, "resize",  
   adjustLayout, false);  
 adjustLayout();
   
}  


// rollover gallery 

var cap = ['Chattel Village','Oistens','The 10th Fairway','Mullins','Bathsheba','Poolside<br /><span class="subquote">The villa has its own pool/hot tub  and sun deck with outside dining area. There is also a portable BBQ available. The private garden backs onto the 10th fairway.</span>','The Lounge<br /><span class="subquote">Light and airy with 42" plaza TV together with stereo unit.</span>','The Front<br /><span class="subquote">The Villa Spinalonga has its own private entrance on Coconut Grove with parking for 2 vehicles.','The Dinning Room<br /><span class="subquote">The large circular coral dining table can seat up to eight people.</span>','Bedroom 1 of 4<br /><span class="subquote">There are 4 ensuite bedrooms at Spinalonga all with Air Conditioning, 3 of which have TV, DVD and CD.</span>','The Clubhouse','The Sanctuary Pool','The Courts','View from The Crane Hotel','Spectacular coastal scenery','Calabaza Restaurant','Miles of golden sands','Spectacular surroundings','Enjoy a round','Explore the island','Gym facilities', 'Relax at the Sanctuary','Improve your game'];

function changeImage(n) {
var thisImage=document.getElementById('galleryImg');
	
	thisImage.className= 'img'+n;
	document.getElementById('caption').innerHTML = cap[n];
	//alert(thisImage.className);
	
}

function tourContent(p) {
        var tour = document.getElementById('virtual-tour');
 
        tour.innerHTML = p;
 
        var clip = [];
 
        clip['pool'] = '<embed src="../media/COCONUT-GROVE-1-360-REAR-EXT-OVER-POOL-360.mov" width="500" height="416" border="0" autohref="true" controller="true"></embed>';
 
        clip['living'] = '<embed src="../media/COCONUT-GROVE-1-360-LIVING-360.mov" width="500" height="416" border="0" autohref="true" controller="true"></embed>';
		
		clip['front'] = '<embed src="../media/COCONUT-GROVE-1-360-FRONT-EXT.mov" width="500" height="416" border="0" autohref="true" controller="true"></embed>';
		
		clip['dine'] = '<embed src="../media/COCONUT-GROVE-1-360-DINE-360.mov" width="500" height="416" border="0" autohref="true" controller="true"></embed>';
		
		clip['bed2'] = '<embed src="../media/COCONUT-GROVE-1-360-BED2-360.mov" width="500" height="416" border="0" autohref="true" controller="true"></embed>';
		
		clip['bed1'] = '<embed src="../media/COCONUT-GROVE-1-360-BED1-360.mov" width="500" height="416" border="0" autohref="true" controller="true"></embed>';
		
		clip['bath'] = '<embed src="../media/COCONUT-GROVE-1-360-BATH.mov" width="500" height="416" border="0" autohref="true" controller="true"></embed>';
 
        document.getElementById('virtual-tour').innerHTML = clip[p];
        }
 