
function swapImgRestore() { 
  var i,x,a=document.sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function preloadImages() { 
  var d=document; if(d.images){ if(!d.p) d.p=new Array();
    var i,j=d.p.length,a=preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.p[j]=new Image; d.p[j++].src=a[i];}}
}
function findObj(n, d) { 
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}
function swapImage() { 
  var i,j=0,x,a=swapImage.arguments; document.sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=findObj(a[i]))!=null){document.sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function showHideLayers() {
  var i,p,v,obj,args=showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style	; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}

Array.prototype.shuffle = function (){    
     for(var rnd, tmp, i=this.length; i; rnd=parseInt(Math.random()*i), tmp=this[--i], this[i]=this[rnd], this[rnd]=tmp);
};
function isImageOk(img) {
    // During the onload event, IE correctly identifies any images
    // that weren't downloaded as not complete. Others should too.
    // Gecko-based browsers act like NS4 in that they report this
    // incorrectly: they always return true.
    if (!img.complete) {
        return false;
    }

    // However, they do have two very useful properties: naturalWidth
    // and naturalHeight. These give the true size of the image. If
    // it failed to load, either of these should be zero.
    if (typeof img.naturalWidth != "undefined" && img.naturalWidth == 0) {
        return false;
    }

    // No other way of checking: assume it's ok.
    return true;
}

function selectRandomBackground(){
  	var randomnumber=(maxBackgrounds>0) ? (Math.floor(Math.random()*maxBackgrounds)) : maxBackgrounds;
	document.getElementById("backimg").src=thePath+"/backgrounds/background"+randomnumber+".jpg";
    return (randomnumber);
}
//Animate Text
var loadCount=0;
var crntBackground=0;
function toggleImages(){
  if(thePath!="SafetyCove/images/home/"){
	var textNum = selectRandomBackground();
	}
    //if(colorText==true){
        //document.getElementById("level10").style.color = textColor[textNum];
    //}
	//loadInt = setInterval("loader()",10);
	document.getElementById("speheading").innerHTML = specialsHeading;
	document.getElementById("spemessage").innerHTML = specialsMessage;
	document.getElementById("headingsc").innerHTML = heading_sc;
	document.getElementById("descriptionsc").innerHTML = description_sc+"<br>Double - "+double_sc+"<br>Single - "+single_sc+"<br>Additional person - "+additional_sc+"<br>Capacity - "+capacity_sc;
	document.getElementById("headingbb").innerHTML = heading_bb;
	document.getElementById("descriptionbb").innerHTML = description_bb+"<br>Double - "+double_bb+"<br>Single - "+single_bb+"<br>Capacity - "+capacity_bb;
	document.getElementById("itenmessage").innerHTML = "<strong>Day 1</strong><br>"+dayOne+"<br><br><strong>Day 2</strong><br>"+dayTwo+"<br><br><strong>Day 3</strong><br>"+dayThree;
	
	loader();
}
function nextImage(){
    crntBackground=crntBackground+1;
	if(crntBackground >=maxBackgrounds){ crntBackground=0;}
	document.getElementById("backimg").src=thePath+"backgrounds/background"+crntBackground+".jpg";
}
function loader(){
	//loadCount+=10;
	//if(isImageOk(document.images.bbimg)){
	    //alert(document.images.bbimg.height);
	    //document.getElementById("copyright").style.top = document.images.bbimg.height+"px";
	//	clearInterval(loadInt);
		DisplayPage();
	//}		
}
function setOpacity(obj, opacity) {
  var aopacity = (opacity == 100)?99.999:opacity;
  
  // IE/Win
  obj.style.filter = "alpha(opacity:"+aopacity+")";
  
  // Safari<1.2, Konqueror
  obj.style.KHTMLOpacity = aopacity/100;
  
  // Older Mozilla and Firefox
  obj.style.MozOpacity = aopacity/100;
  
  // Safari 1.2, newer Firefox and Mozilla, CSS3
  obj.style.opacity = aopacity/100;
}
function showMenu2(){document.getElementById("menu2").style.visibility="visible"; }
function hideMenu2(){document.getElementById("menu2").style.visibility="hidden";}
function showMenu(men){document.getElementById(men).style.visibility="visible";}
function hideMenu(men){document.getElementById(men).style.visibility="hidden";}


	