/*-----------------------------------------------------------------------------------------------------------
	PROGRAM CREDITS
-----------------------------------------------------------------------------------------------------------*/
/*
Author:
		aquafusion studios	(http://www.afstudios.net)
		- aquaflare7		(aquaflare7@gmail.com)
	For:
		Tan Studios			(http://www.tanstudios.com)
		copyright 2005-2006, all rights reserved
	Date:
		Start	- 09 / 17 / 2005
	Notes:
		none
*/

/*-----------------------------------------------------------------------------------------------------------
	INTERNET EXPLORER - functions to fix different aspects of internet explorer that microsoft has broken
-----------------------------------------------------------------------------------------------------------*/
	/* emulates the missing min-width css property in internet explorer */
		function setMinWidth() {
			var minWidth = 730;		//number in pixels, not including the 'px' suffix
			var normalWidth = 75;	//number in percentage, not including the '%' suffix
			var documentWidth = normalWidth * .01 * document.body.clientWidth
			var whichID = "constrain";
			if (documentWidth < (minWidth)) {
				//window width is smaller than the min-width of the specified property
				//so set property to it's min-width
				document.getElementById(whichID).style.width = (minWidth + 'px');
			} else {
				//window width is not smaller than the min-width of the specified property
				//so set property to it's default width
				document.getElementById(whichID).style.width = (normalWidth + '%');
			}
		}

/*-----------------------------------------------------------------------------------------------------------
	DROPDOWN MENUES - functions to control the dropdown menues
-----------------------------------------------------------------------------------------------------------*/
	/* actions for a single menu */
		function menuOne(action,whichID) {
			if (action == 'hide') {
				document.getElementById(whichID).style.display="none";
			} else if (action == 'show') {
				document.getElementById(whichID).style.display="block";
			}
		}
	
	/* actions for all menues */
		function menuAll(action) {
			if (action == 'hide') {
				//hide all menues
				document.getElementById('menu-a').style.display="none";
				document.getElementById('menu-b').style.display="none";
				document.getElementById('menu-c').style.display="none";
				document.getElementById('menu-d').style.display="none";
				document.getElementById('menu-e').style.display="none";
				document.getElementById('menu-f').style.display="none";
			} else if (action == 'show') {
				//show all menues
				document.getElementById('menu-a').style.display="block";
				document.getElementById('menu-b').style.display="block";
				document.getElementById('menu-c').style.display="block";
				document.getElementById('menu-d').style.display="block";
				document.getElementById('menu-e').style.display="block";
				document.getElementById('menu-f').style.display="block";
			}
		}

/*-----------------------------------------------------------------------------------------------------------
	BREAK FRAMES - functions that act if the document is held in a frame
-----------------------------------------------------------------------------------------------------------*/
	/* check if framed */
		function checkIfFramed() {
			var readCookieVal;
			readCookieVal = readCookie('allowBreak');
			if (top.location != location && readCookieVal != 'no') {
				var allowBreak;
				allowBreak = confirm('The site your are trying to access has been confined to a frame.\n\nPress ok to try and break out of it or cancel to leave it in the containing frame.\n\nNote: If you have cookies enabled for afstudios.net and press cancel, we will remember not to ask you again until your next session.');
				if (allowBreak == true) {
					top.location.href = document.location.href;
				} else {
					createCookie('allowBreak','no','');
				}
			}
		}

/*-----------------------------------------------------------------------------------------------------------
	COOKIES - functions that interact with cookies
-----------------------------------------------------------------------------------------------------------*/
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 var 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;
}

/*-----------------------------------------------------------------------------------------------------------
	BOOTUP - actions to take as soon as the page is loaded
-----------------------------------------------------------------------------------------------------------*/
	/* the core function that is loaded when the page loads */
		function bootup() {
			if (checkBrowser('msie')) {
				window.onresize = setMinWidth;
				setMinWidth();
			}
			checkIfFramed();
			setCache();
		}
	
	/* preload objects into the cache */
		function setCache() {
			linkbg		=	new Image();
			linkbg.src	=	'layout/linkbg.gif';

			home1		=	new Image();
			home1.src	=	'layout/nav-home1.gif';
			home2		=	new Image();
			home2.src	=	'layout/nav-home2.gif';
			
			beds1		=	new Image();
			beds1.src	=	'layout/nav-beds1.gif';
			beds2		=	new Image();
			beds2.src	=	'layout/nav-beds2.gif';
			
			packages1		=	new Image();
			packages1.src	=	'layout/nav-packages1.gif';
			packages2		=	new Image();
			packages2.src	=	'layout/nav-packages2.gif';
			
			contactus1		=	new Image();
			contactus1.src	=	'layout/nav-contactus1.gif';
			contactus2		=	new Image();
			contactus2.src	=	'layout/nav-contactus2.gif';
			
			gallery1		=	new Image();
			gallery1.src	=	'layout/nav-gallery1.gif';
			gallery2		=	new Image();
			gallery2.src	=	'layout/nav-gallery2.gif';
		}
		
	/* check for a browser by passing it's identification string through this function */
		function checkBrowser(string) {
			var detect = navigator.userAgent.toLowerCase();
			place = detect.indexOf(string) + 1;
			thestring = string;
			return place;
		}
