$(document).ready(function() {
						   
	
/*******************************************************/
/* Quicklinks
/*******************************************************/	
	
	$('#quicklinks-triggerbutton a').click(function(){
		if($('#quicklinks-triggerbutton').hasClass("collapsed")) {
			$('#quicklinks-content').slideDown('slow', function(){
				$('#quicklinks-triggerbutton').removeClass('collapsed');
				//$('#quicklinks-triggerbutton a img').attr("src","/asset3372.aspx");
			});
			
		} else {
			$('#quicklinks-content').slideUp('slow', function(){
				$('#quicklinks-triggerbutton').addClass('collapsed');
				//$('#quicklinks-triggerbutton a img').attr("src","/asset3371.aspx");
			});
		}
		return false;
	});
	
	$('#quicklinks-close a').click(function(){
		$('#quicklinks-content').slideUp('slow', function(){
			$('#quicklinks-triggerbutton').addClass('collapsed');
			//$('#quicklinks-triggerbutton a img').attr("src","/asset3371.aspx");
		});
		return false;
	});
	
	

	
/*******************************************************/
/* Text Resize
/*******************************************************/

	var sitefunctions = {
	textresize : function(){
		
		var $cookie_name = "sitename-FontSize";
		var originalFontSize = $("html").css("font-size");
		// if exists load saved value, otherwise store it
		if($.cookie($cookie_name)) {
			var $getSize = $.cookie($cookie_name);
			$("html").css({fontSize : $getSize + ($getSize.indexOf("px")!=-1 ? "" : "px")}); // IE fix for double "pxpx" error
		} else {
			$.cookie($cookie_name, originalFontSize);
		}
		
		// text "+" link
		$("#textsize-increase").bind("click", function() {
		  var currentFontSize = $("html").css("font-size");
		  var currentFontSizeNum = parseFloat(currentFontSize, 16);
		   var newFontSize = currentFontSizeNum+2;
		  if (newFontSize < 22) {
			$("html").css("font-size", newFontSize);
			$.cookie($cookie_name, newFontSize);
		  }
		  return false;
		});
		$("#textsize-decrease").bind("click", function() {
		  var currentFontSize = $("html").css("font-size");
		  var currentFontSizeNum = parseFloat(currentFontSize, 16);
		  var newFontSize = currentFontSizeNum-2;
		  if (newFontSize, 11) {
			$("html").css("font-size", newFontSize);
			$.cookie($cookie_name, newFontSize);
		  }
		  return false;
		});
		}
	
	}
	sitefunctions.textresize();	



/*******************************************************/
/* Set Homepage Image 
/*******************************************************/

if($.cookie("visited")) {
	
	// Show random image if visitor has already viewed this page today
	
	$.randomImage = {
		defaults: {
			path: 'http://www.banff.ca', //change this to the path of your images
			myImages: ['/asset3941.aspx', '/asset3942.aspx', '/asset3943.aspx', '/asset3944.aspx', '/asset3945.aspx', '/asset3946.aspx', '/asset3947.aspx' ] 	
		}			
	}
	
	$.fn.extend({
			randomImage:function(config) {
				
				var config = $.extend({}, $.randomImage.defaults, config); 
				 return this.each(function() {
						var imageNames = config.myImages;
						//get size of array, randomize a number from this
						// use this number as the array index
	
						var imageNamesSize = imageNames.length;
						var lotteryNumber = Math.floor(Math.random()*imageNamesSize);
						var winnerImage = imageNames[lotteryNumber];
						var fullPath = config.path + winnerImage;
						//alert (fullPath);
						
						//put this image into DOM at class of randomImage
									
						$.backstretch(fullPath);
	
				
				});	
			}
		
		});
		
		
		$("body").randomImage();
	

} else {

	// Show proper image if visitor has never viewed this page before
	
	 $.cookie('visited', 'yes', {expires: 1}); 
	 
	//alert ("undefined!");
	
	var date = new Date(); 
	
	switch (date.getDay()) {
		case 1 :
		 $.backstretch("http://www.banff.ca/asset3941.aspx");
		  break;
		case 2 :
		$.backstretch("http://www.banff.ca/asset3942.aspx");
		  break;
		case 3 :
		$.backstretch("http://www.banff.ca/asset3943.aspx");
		  break;
		case 4 :
		$.backstretch("http://www.banff.ca/asset3944.aspx");
		  break;
		case 5 :
		$.backstretch("http://www.banff.ca/asset3945.aspx");
		  break;
		case 6 :
		$.backstretch("http://www.banff.ca/asset3946.aspx");
		  break;
		case 7 :
		$.backstretch("http://www.banff.ca/asset3947.aspx");
		  break;
	  }
	
}
	
});




