// JavaScript Document
function flipImage(newImageURL)
{
	var img = document.getElementById("themeImage");
	img.src = newImageURL;
}

function randomizeImage()
{
	images =  
	[ 
	 "man1.jpg",  
	 "woman1.jpg",  
	 "woman2.jpg" 

	];

	var img = images[Math.floor(Math.random()*images.length)] 
	flipImage("/images/"+img);
}

function showMap()
{
	var mapDiv = document.getElementById("mapWindow");
	if(mapDiv.style.display != "block")
	{
		showAddress("324 A-3980 Shelbourne St, Victoria BC, V8N 6J3");
		mapDiv.style.display = "block";
	}
}

function hideMap()
{
	var mapDiv = document.getElementById("mapWindow");
	if(mapDiv.style.display != "none")
		mapDiv.style.display = "none";
}

var map = null;
var geocoder = null;
function load()
{
	if (GBrowserIsCompatible())
	{
		map = new GMap2(document.getElementById("googleMap"), {draggableCursor: 'pointer', draggingCursor: 'move'});
		map.setCenter(new GLatLng(48.469494,-123.33271), 10);
		map.addControl(new GLargeMapControl(), new GControlPosition(G_ANCHOR_TOP_LEFT));
		map.addControl(new GMapTypeControl(), new GControlPosition(G_ANCHOR_TOP_RIGHT));
		map.setMapType(G_NORMAL_MAP);
		map.addControl(new GScaleControl(), new GControlPosition(G_ANCHOR_TOP_LEFT));
		map.enableDoubleClickZoom();

		keyboardhandler = new GKeyboardHandler(map);
		geocoder = new GClientGeocoder();
	}
}

function showAddress(address)
{
	if (geocoder)
	{
		geocoder.getLatLng(
			address,
			function(point)
			{
				if (!point)
				{
					alert(address + " not found");
				}
				else
				{
					map.setCenter(point, 13);
					var marker = new GMarker(point);
					map.addOverlay(marker);
					marker.openInfoWindowHtml("<div align='left'><strong>Always August Tanning</strong><br/>"+address.replace(",", "<br/>")+"</div>");
				}
			}
		);
	}
}

//function used by online booking engine	
function addbooking(dateTimeStr, bedStr)
{
	window.open('/bookonline/addOnAppointment.php?dateTime='+encodeURI(dateTimeStr)+'&staffName='+encodeURI(bedStr),'bookingWindow','width=450,height=150');
}

function datetime()
{
	calendar = new Date();
	day = calendar.getDay();
	month = calendar.getMonth();
	date = calendar.getDate();
	year = calendar.getYear();
	if (year < 1000)
	year+=1900
	cent = parseInt(year/100);
	g = year % 19;
	k = parseInt((cent - 17)/25);
	i = (cent - parseInt(cent/4) - parseInt((cent - k)/3) + 19*g + 15) % 30;
	i = i - parseInt(i/28)*(1 - parseInt(i/28)*parseInt(29/(i+1))*parseInt((21-g)/11));
	j = (year + parseInt(year/4) + i + 2 - cent + parseInt(cent/4)) % 7;
	l = i - j;
	emonth = 3 + parseInt((l + 40)/44);
	edate = l + 28 - 31*parseInt((emonth/4));
	emonth--;
	var dayname = new Array ("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");
	var monthname =
	new Array ("January","February","March","April","May","June","July","August","September","October","November","December" );
	document.write("<div id='dateArea' class='dateArea'>");
	document.write(dayname[day] + ", ");
	document.write(monthname[month] + " ");
	if (date< 10) document.write("0" + date + ", ");
	else document.write(date + ", ");

	// Easter
	if ((month == emonth) && (date == edate)) document.write("Easter Sunday (Western) ");
	// January
	if ((month == 0) && (date == 1)) document.write("New Year's Day");

	if ((month == 0) && (date == 27)) document.write("Wolfgang Amadeus Mozart born (1756)");

	// February
	if ((month == 1) && (date == 2)) document.write("Groundhog Day");
	if ((month == 1) && (date == 8)) document.write("Jules Verne born (1828)");

	if ((month == 1) && (date== 12)) document.write("Lincoln's Birthday");
	if((month == 1) && (date == 14)) document.write("St. Valentine's Day");
	if ((month == 1) && (date == 15)) document.write("Galileo Galilei born (1564)");

	if ((month == 1) && (date == 29)) document.write("Leap Day");
	// March

	if ((month == 2) && (date == 17)) document.write("St. Patrick's Day");
	if ((month == 2) && (date == 21)) document.write("J.S. Bach born (1685)");
	// April
	if ((month == 3) && (date == 1)) document.write("April Fools' Day");

	if ((month == 3) && (day == 0) && (date > 0) && (date< 8)) document.write("Daylight Savings Time Begins");
	// May

	if ((month == 4) && (date == 14)) document.write("Independence Day (Paraguay)");
	if ((month == 4) && (day == 0) && (date > 7) && (date< 16)) document.write("Mother's Day");

	// June

	if ((month == 5) && (date == 21)) document.write("Summer Solstice");

	if ((month == 5) && (day == 0) && (date > 15) && (date< 24)) document.write("Father's Day");
	// July
	if ((month == 6) && (date == 1)) document.write("Canada Day");

	// September
	if ((month == 8) && (day== 1)&& (date > 0) && (date< 8)) document.write("Labour Day ");
	// October


	if ((month == 9) && (day == 0) && (date > 24) && (date< 31)) document.write("Daylight Savings Time Ends");
	if ((month == 9) && (day == 0) && (date == 31)) document.write("Daylight Savings Time Ends<BR>");
	if ((month == 9) && (date == 24)) document.write("United Nations Day");
	if ((month == 9) && (date == 31)) document.write("Halloween");
	// November
	if ((month == 10) && (date == 1)) document.write("All Saints Day");
	if ((month == 10) && (date == 2)) document.write("All Souls Day");

	if ((month == 10) && (date == 11)) document.write(" Remembrance Day");


	// December
	if ((month == 11) && (date == 10)) document.write("Human Rights Day");
	if ((month == 11) && (date == 21)) document.write("Winter Solstice");
	if ((month == 11) && (date == 24)) document.write("Christmas Eve");
	if ((month == 11) && (date == 25)) document.write("Christmas");
	if ((month == 11) && (date == 26)) document.write("Boxing Day");
	if ((month == 11) && (date == 31)) document.write("New Year's Eve");
	document.write("</div>");
}
