/*
AdventurerInn.com Rollover Functions
by: Russell Brooks

XHTML Strict and W3C DOM compliancy using getElementById()
and smarter preloads
*/

var preloadFlag = false;
function preloadImages() {
	if (document.images) {
		// Conditional preloads -
		// If path does not begin with / or /default, then preload subpage images.
		if (window.location.pathname != "/" && window.location.pathname != "/default.aspx")
			strImgSubPath = 'subpage/sub_';
		else
			strImgSubPath = '';
		
		toolbar_home_off = new Image();toolbar_home_off.src = '/images/' + strImgSubPath + 'toolbar_home.gif';
		toolbar_home_on = new Image();toolbar_home_on.src = '/images/' + strImgSubPath + 'toolbar_home_on.gif';
		toolbar_rooms_off = new Image();toolbar_rooms_off.src = '/images/' + strImgSubPath + 'toolbar_rooms.gif';
		toolbar_rooms_on = new Image();toolbar_rooms_on.src = '/images/' + strImgSubPath + 'toolbar_rooms_on.gif';
		toolbar_packages_off = new Image();toolbar_packages_off.src = '/images/' + strImgSubPath + 'toolbar_packages.gif';
		toolbar_packages_on = new Image();toolbar_packages_on.src = '/images/' + strImgSubPath + 'toolbar_packages_on.gif';
		toolbar_groups_off = new Image();toolbar_groups_off.src = '/images/' + strImgSubPath + 'toolbar_groups.gif';
		toolbar_groups_on = new Image();toolbar_groups_on.src = '/images/' + strImgSubPath + 'toolbar_groups_on.gif';
		toolbar_events_off = new Image();toolbar_events_off.src = '/images/' + strImgSubPath + 'toolbar_events.gif';
		toolbar_events_on = new Image();toolbar_events_on.src = '/images/' + strImgSubPath + 'toolbar_events_on.gif';
		toolbar_maps_off = new Image();toolbar_maps_off.src = '/images/' + strImgSubPath + 'toolbar_maps.gif';
		toolbar_maps_on = new Image();toolbar_maps_on.src = '/images/' + strImgSubPath + 'toolbar_maps_on.gif';
		toolbar_brochure_off = new Image();toolbar_brochure_off.src = '/images/' + strImgSubPath + 'toolbar_brochure.gif';
		toolbar_brochure_on = new Image();toolbar_brochure_on.src = '/images/' + strImgSubPath + 'toolbar_brochure_on.gif';

		preloadFlag = true;
	}
}

var transitionToggle = 0;
function changeImages() {
	if (document.getElementById && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			id = changeImages.arguments[i];
			name = changeImages.arguments[i+1];
			document.getElementById(id).filters[0].Apply();
			// After setting Apply(), changes to the object are not displayed until Play() is called.
			if (transitionToggle) {
				transitionToggle = 0;
				document.getElementById(id).src = eval(name+".src");
			}
			else {
				transitionToggle = 1;
				document.getElementById(id).src = eval(name+".src");
			}
			document.getElementById(id).filters[0].Play();
		}
	}
}
