// JavaScript Document for miraval hotel

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}


// ------------------------------------------
// Function for setting the active stylesheet
// ------------------------------------------
function sizewissel() {
	var actievestijl = getActiveStyleSheet();
	if(actievestijl != null){
		if(actievestijl = "Large"){
			link = '<img src=\"http://www.hotelmiraval.ch/im/size_arrow_down.gif\" />';
			stijlnaam = '';
			titel ='smaller';
			}		
		}
	else {
		link = '<img src=\"http://www.hotelmiraval.ch/im/size_arrow.gif\" />';
		stijlnaam = 'Large';
		titel ='larger';
	}
    document.getElementById("styles").innerHTML ='<a href="#" title="' + titel+ '" onclick="setActiveStyleSheet(\'' + stijlnaam + '\', 1);pageTracker._trackPageview(\'/sizewissel\');">' + link + '</a>';
}


// -----------------------------------------------------------
// Functions for the rotating photos and texts on the homepage
// -----------------------------------------------------------
// Set slideShowSpeed (milliseconds)
var slideShowSpeed = 3000;
// Duration of crossfade (seconds)
var crossFadeDuration = 2;
// Specify the image files
var Pic = new Array();

Pic[0] = ["im/150/terrasse_hotel_mira_val.jpg", "Terrasse Hotel Mira Val"]
Pic[1] = ["im/150/frigo_family.jpg", "Adriano, Maaike und Renee Frigo"]
Pic[2] = ["im/150/mira_val_garten.jpg", "Garten Hotel Mira Val"]
Pic[3] = ["im/150/RUPA_189_150x150.JPG", "Eingang"]

var t;
var j = 0;
var p = Pic.length;
var preLoad = new Array();
for (i = 0; i < p; i++) {
	preLoad[i] = new Image();
	preLoad[i].src = Pic[i][0];
}

function runSlideShow() {
	if (document.all) {
		document.images.SlideShow.style.filter="blendTrans(duration=2)";
		document.images.SlideShow.style.filter="blendTrans(duration=crossFadeDuration)";
		document.images.SlideShow.filters.blendTrans.Apply();
	}
	document.images.SlideShow.src = preLoad[j].src;
	document.images.SlideShow.alt = Pic[j][1];
	if (document.all) {
		document.images.SlideShow.filters.blendTrans.Play();
	}
	//document.getElementById("rotatetext").innerHTML ="<p><strong>" + Pic[j][1] + "</strong></p>";
	j = j + 1;
	if (j > (p - 1)) j = 0;
	t = setTimeout('runSlideShow()', slideShowSpeed);
}

function nextphoto() {
	j = j + 1;
	if (j > (p - 1)) j = 0;
	document.images.SlideShow.src = preLoad[j].src;
	document.images.SlideShow.alt = Pic[j][1];
}



<!--
<!--//--><![CDATA[//><!--
	// Function to make the :hovers over <li>-elements work in IE; needed for css-pullouts.
	startList = function() {
		if (document.all&&document.getElementById) {
			navRoot = document.getElementById("menubuttons");
			for (i=0; i<navRoot.childNodes.length; i++) {
				node = navRoot.childNodes[i];
				if (node.nodeName=="LI") {
					node.onmouseover=function() {
						this.className+=" over"; }
					node.onmouseout=function() {
						this.className=this.className.replace(" over", ""); }
				}
			}
		}
	}
	//--><!]]>
//-->


<!--
// ----------------------------------------------
// StyleSwitcher functions written by Paul Sowden
// http://www.idontsmoke.co.uk/ss/
// - - - - - - - - - - - - - - - - - - - - - - -
// For the details, visit ALA:
// http://www.alistapart.com/stories/alternate/

function setActiveStyleSheet(title) {
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      a.disabled = true;
      if(a.getAttribute("title") == title) a.disabled = false;
    }
  }
  setTimeout("sizewissel()", 500);
}

function getActiveStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
  }
  return null;
}

function getPreferredStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1
       && a.getAttribute("rel").indexOf("alt") == -1
       && a.getAttribute("title")
       ) return a.getAttribute("title");
  }
  return null;
}

function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}

window.onload = function(e) {
  var cookie = readCookie("style");
  var title = cookie ? cookie : getPreferredStyleSheet();
  setActiveStyleSheet(title);
<!--
<!--//--><![CDATA[//><!--
	// start function to make the :hovers over <li>-elements work in IE; needed for css-pullouts.
	startList();
	//--><!]]>
//-->
   runSlideShow();
}

window.onunload = function(e) {
  var title = getActiveStyleSheet();
  createCookie("style", title, 365);
}

var cookie = readCookie("style");
var title = cookie ? cookie : getPreferredStyleSheet();
setActiveStyleSheet(title);

//-->
