window.onload = function() {
	membershipcards_onLoad();
	printpage_onLoad();
	loolocator_onLoad();
	pagemenu_onLoad();
	smp_onLoad();
	core_admin_onLoad();
	members_onLoad();
	addresses_onLoad();
}

window.onunload = function() {
	loolocator_onUnLoad();
}

/* files/javascript/membershipcards.js */

function membershipcards_onLoad() {
	if((membershipCards = document.getElementById('membershipcards')) && (membershipCardsLink = document.getElementById('membershipcardslink'))) {
		membershipCards.setAttribute('openMemberShipCards', 'false');
		membershipCards.style.display = 'none';
		membershipCardsLink.innerHTML = '<span class="hidden">[</span><a href="javascript:showMembershipCards();" title="show: membership cards">Unsure where to find your membership number? Click here</a><span class="hidden">]</span>';
	}
}

function showMembershipCards() {
	if((membershipCards = document.getElementById('membershipcards')) && (membershipCardsLink = document.getElementById('membershipcardslink'))) {
		if(membershipCards.getAttribute('openMemberShipCards') == 'false') {
			membershipCards.setAttribute('openMemberShipCards', 'true');
			membershipCards.style.display = 'inline';
			membershipCardsLink.innerHTML = '<span class="hidden">[</span><a href="javascript:showMembershipCards();" title="hide: membership cards">Want to hide details about membership cards? Click here</a><span class="hidden">]</span>';
		}
		else {
			membershipCards.setAttribute('openMemberShipCards', 'false');
			membershipCards.style.display = 'none';
			membershipCardsLink.innerHTML = '<span class="hidden">[</span><a href="javascript:showMembershipCards();" title="show: membership cards">Unsure where to find your membership number? Click here</a><span class="hidden">]</span>';
		}
	}
}

/* files/javascript/printpage.js */

function printpage_onLoad() {
	var userAgent = navigator.userAgent.toLowerCase();
	if(userAgent.indexOf('firefox') != -1 ) {
		document.readyState = 'complete';
	}
}

function printPage(pagePath) {
	if(!document.getElementById('print_frame')) {
		var printFrame = document.createElement('iframe');
		printFrame.id = 'print_frame';
		printFrame.name = 'print_frame';
		printFrame.style.width = '0px';
		printFrame.style.height = '0px';
		printFrame.style.top = '-100px';
		printFrame.style.left = '-100px';
		printFrame.style.position = 'absolute';
		
		document.getElementById('sitebody').appendChild(printFrame);
		print_frame.location.href = pagePath;
		
		setTimeout(function() {checkFrame();}, 500);
	}
	else {
		checkFrame();
	}
	
	function checkFrame() {
		if(print_frame.document.readyState == 'complete') {
			openPrintDialog();
			return;
		}
		setTimeout(function() {checkFrame();}, 500);
	}
	
	function openPrintDialog() {
		print_frame.document.getElementById('sitebody').style.backgroundImage = 'none';
		print_frame.document.getElementById('pagecontainer').style.left = '0px';
		print_frame.document.getElementById('pagecontainer').style.marginTop = '0px';
		print_frame.document.getElementById('pagecontainer').style.marginLeft = '0px';
		print_frame.document.getElementById('pagecontainer').style.backgroundColor = 'rgb(255,255,255)';
		print_frame.document.getElementById('taglineimage').style.display = 'none';
		print_frame.document.getElementById('pagemenu').style.display = 'none';
		if(headerImage = print_frame.document.getElementById('headerimage')) {
			headerImage.style.display = 'none';
		}
		print_frame.document.getElementById('sidebar_container').style.display = 'none';
		print_frame.document.getElementById('printpage').style.display = 'none';
		print_frame.document.getElementById('pagefooter').style.display = 'none';
		print_frame.focus();
		print_frame.print();
	}
}

/* files/javascript/loolocator.js */

var _local_mapsLoaded = false, _local_xmlHTTP, _local_googleMap, _local_existingLoo, _local_newLoo, _local_newMarker, _local_existingMarkers, _local_lastPoint, _local_toiletID, _local_moveListener, _local_zoomListener;

if(window.location.href.substr(-10) == 'loolocator') {
	document.write('<script type="text/javascript" src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAtESVcU4VdBHuwlROQyUnWBS118dZ4VY9tt8WNIp7u4ljtpHJoRSgedh-8gjn8dOZquIy2Q45ie3-Lg"><\/script>');
	_local_mapsLoaded = true;
}

function loolocator_onLoad() {
	if(_local_mapsLoaded) {
		if(window.XMLHttpRequest) {
			_local_xmlHTTP = new XMLHttpRequest();
		}
		else {
			_local_xmlHTTP = new ActiveXObject("Microsoft.XMLHTTP");
		}
		if(GBrowserIsCompatible()) {
			if(mapCanvas = document.getElementById('map_canvas')) {
				var searchCriteria = document.getElementById('searchCriteria');
				var searchGeoDB = document.getElementById('searchGeoDB');
				
				searchCriteria.onfocus = function() {
					if(this.value == 'search criteria') {
						this.value = '';
					}
				}
				
				if(searchCriteria.addEventListener) {
					searchCriteria.addEventListener('keydown', _local_monitorSearchCriteria, true);
				}
				else if(searchCriteria.attachEvent) {
					searchCriteria.attachEvent('onkeydown', _local_monitorSearchCriteria);
				}
				else {
					searchCriteria.onkeydown = _local_monitorSearchCriteria;
				}
				
				searchGeoDB.onclick = function() {
					var geoCoder = new GClientGeocoder();
					geoCoder.getLatLng(document.getElementById('searchCriteria').value, _local_setMapPoint);
				}
				
				var userLatitude = document.getElementById('userLatitude').value;
				var userLongitude = document.getElementById('userLongitude').value;
				if(userLatitude == '' || userLongitude == '') {
					_local_xmlHTTP.open('GET', '/_action/local/loolocator/geocode_search', false);
					_local_xmlHTTP.send(null);
					if(_local_xmlHTTP.responseText != '' && _local_xmlHTTP.responseText != null) {
						var responseData = (_local_xmlHTTP.responseText.substr(1, (_local_xmlHTTP.responseText.length - 2))).split('","');
						userLatitude = responseData[0];
						userLongitude = responseData[1];
					}
					else {
						userLatitude = '51.500152';
						userLongitude = '-0.126236';
					}
				}
				_local_setMapPoint(new GLatLng(userLatitude, userLongitude));
				
				/*_local_googleMap = new GMap2(mapCanvas);
				_local_googleMap.addControl(new GLargeMapControl());
				//_local_googleMap.addControl(new GMapTypeControl());
				//_local_googleMap.enableContinuousZoom();
				
				var userLatitude = document.getElementById('userLatitude').value;
				var userLongitude = document.getElementById('userLongitude').value;
				if(userLatitude == '' || userLongitude == '') {
					_local_xmlHTTP.open('GET', '/_action/local/loolocator/geocode_search', false);
					_local_xmlHTTP.send(null);
					if(_local_xmlHTTP.responseText != '' && _local_xmlHTTP.responseText != null) {
						var responseData = (_local_xmlHTTP.responseText.substr(1, (_local_xmlHTTP.responseText.length - 2))).split('","');
						userLatitude = responseData[0];
						userLongitude = responseData[1];
					}
					else {
						userLatitude = '51.500152';
						userLongitude = '-0.126236';
					}
				}
				_local_googleMap.setCenter(new GLatLng(userLatitude, userLongitude), 15);
				
				_local_existingLoo = new GIcon();
				_local_existingLoo.image = '/_files/images/loolocator/markers/marker_existing.png';
				_local_existingLoo.shadow = '/_files/images/loolocator/markers/marker_shadow.png';
				_local_existingLoo.iconSize = new GSize(40, 50);
				_local_existingLoo.shadowSize = new GSize(66, 50);
				_local_existingLoo.iconAnchor = new GPoint(21, 45);
				_local_existingLoo.infoWindowAnchor = new GPoint(21, 0);
				
				_local_newLoo = new GIcon();
				_local_newLoo.image = '/_files/images/loolocator/markers/marker_new.png';
				_local_newLoo.shadow = '/_files/images/loolocator/markers/marker_shadow.png';
				_local_newLoo.iconSize = new GSize(40, 50);
				_local_newLoo.shadowSize = new GSize(66, 50);
				_local_newLoo.iconAnchor = new GPoint(21, 45);
				_local_newLoo.infoWindowAnchor = new GPoint(21, 0);
				
				_local_drawToiletMarkers();
				_local_moveListener = GEvent.addListener(_local_googleMap, 'moveend', _local_drawToiletMarkers);
				_local_zoomListener = GEvent.addListener(_local_googleMap, 'zoomend', _local_drawToiletMarkers);*/
			}
		}
	}
}

function loolocator_onUnLoad() {
	if(_local_mapsLoaded) {
		GUnload();
	}
}

function _local_monitorSearchCriteria(event) {
	if(event.keyCode == 13) {
		document.getElementById('searchGeoDB').click();
	}
}

function _local_setMapPoint(mapPoint) {
	if(mapPoint) {
		_local_googleMap = new GMap2(mapCanvas);
		_local_googleMap.addControl(new GLargeMapControl());
		//_local_googleMap.addControl(new GMapTypeControl());
		//_local_googleMap.enableContinuousZoom();
		
		_local_googleMap.setCenter(mapPoint, 15);
		
		_local_existingLoo = new GIcon();
		_local_existingLoo.image = '/_files/images/loolocator/markers/marker_existing.png';
		_local_existingLoo.shadow = '/_files/images/loolocator/markers/marker_shadow.png';
		_local_existingLoo.iconSize = new GSize(40, 50);
		_local_existingLoo.shadowSize = new GSize(66, 50);
		_local_existingLoo.iconAnchor = new GPoint(21, 45);
		_local_existingLoo.infoWindowAnchor = new GPoint(21, 0);
		
		_local_newLoo = new GIcon();
		_local_newLoo.image = '/_files/images/loolocator/markers/marker_new.png';
		_local_newLoo.shadow = '/_files/images/loolocator/markers/marker_shadow.png';
		_local_newLoo.iconSize = new GSize(40, 50);
		_local_newLoo.shadowSize = new GSize(66, 50);
		_local_newLoo.iconAnchor = new GPoint(21, 45);
		_local_newLoo.infoWindowAnchor = new GPoint(21, 0);
		
		_local_drawToiletMarkers();
		_local_moveListener = GEvent.addListener(_local_googleMap, 'moveend', _local_drawToiletMarkers);
		_local_zoomListener = GEvent.addListener(_local_googleMap, 'zoomend', _local_drawToiletMarkers);
		
		/*_local_googleMap.setCenter(mapPoint, 15);
		
		GEvent.addListener(_local_googleMap, 'moveend', _local_drawToiletMarkers);
		GEvent.addListener(_local_googleMap, 'zoomend', _local_drawToiletMarkers);
		
		document.getElementById('toiletbox_container').style.display = 'none';
		
		//_local_newMarker = new GMarker(mapPoint, {icon: _local_newLoo, draggable: true, bouncy: false});
		//_local_googleMap.addOverlay(_local_newMarker);
		//document.getElementById('markerLat').value = _local_newMarker.getLatLng().lat();
		//document.getElementById('markerLng').value = _local_newMarker.getLatLng().lng();
		
		//GEvent.addListener(_local_newMarker, 'dragend', function() {
			//document.getElementById('markerLat').value = _local_newMarker.getLatLng().lat();
			//document.getElementById('markerLng').value = _local_newMarker.getLatLng().lng();
		//});
		/*document.getElementById('retrieveMarker').onclick = function() {
			_local_newMarker.setLatLng(new GLatLng(_local_googleMap.getCenter().lat(), _local_googleMap.getCenter().lng()));
			//document.getElementById('markerLat').value = _local_newMarker.getLatLng().lat();
			//document.getElementById('markerLng').value = _local_newMarker.getLatLng().lng();
		}
		_local_drawToiletMarkers();*/
	}
}

function _local_drawToiletMarkers() {
	var toiletLocations = new Array();
	var mapBounds = _local_googleMap.getBounds();
	_local_xmlHTTP.open('POST', '/_action/local/loolocator/search_toilet', false);
	_local_xmlHTTP.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	_local_xmlHTTP.send('neLat='+ (mapBounds.getNorthEast().lat() + 0.15) +'&neLng='+ (mapBounds.getNorthEast().lng() + 0.15) +'&swLat='+ (mapBounds.getSouthWest().lat() - 0.15) +'&swLng='+ (mapBounds.getSouthWest().lng() - 0.15));
	if(_local_xmlHTTP.responseText != '' && _local_xmlHTTP.responseText != null) {
		var responseData = (_local_xmlHTTP.responseText.substr(1, (_local_xmlHTTP.responseText.length - 2))).split('","');
		for(dataCount = 0; dataCount < responseData.length; dataCount++) {
			toiletLocations[toiletLocations.length] = responseData[dataCount].split(':');
		}
	}
	if(typeof(_local_existingMarkers) == 'object') {
		for(markerCount = 0; markerCount < _local_existingMarkers.length; markerCount++) {
			_local_googleMap.removeOverlay(_local_existingMarkers[markerCount]);
		}
	}
	_local_existingMarkers = new Array();
	for(locationCount = 0; locationCount < toiletLocations.length; locationCount++) {
		var markerIndex = _local_existingMarkers.length;
		_local_existingMarkers[markerIndex] = new GMarker(new GLatLng(toiletLocations[locationCount][1], toiletLocations[locationCount][2]), {icon: _local_existingLoo});
		_local_existingMarkers[markerIndex]['_toiletID'] = toiletLocations[locationCount][0];
		_local_googleMap.addOverlay(_local_existingMarkers[markerIndex]);
		GEvent.addListener(_local_existingMarkers[markerIndex], 'click', function() {
			_local_toiletID = this['_toiletID'];
			_local_lastPoint = _local_googleMap.getCenter();
			var locationPoint = _local_googleMap.fromLatLngToDivPixel(new GLatLng(this.getLatLng().lat(), this.getLatLng().lng()));
			if(typeof(_local_moveListener) == 'object') {
				GEvent.removeListener(_local_moveListener);
			}
			_local_moveListener = GEvent.addListener(_local_googleMap, 'moveend', function() {setTimeout(function() {_local_displayToilet();}, 100);});
			_local_googleMap.panTo(_local_googleMap.fromDivPixelToLatLng(new GPoint(locationPoint.x + 203, locationPoint.y - 25)));
		});
	}
}

function _local_displayToilet() {
	_local_xmlHTTP.open('POST', '/_action/local/loolocator/display_toilet', false);
	_local_xmlHTTP.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	_local_xmlHTTP.send('toiletID='+ _local_toiletID);
	if(_local_xmlHTTP.responseText != '' && _local_xmlHTTP.responseText != null) {
		document.getElementById('toiletbox_container').style.display = 'block';
		var responseData = (_local_xmlHTTP.responseText.substr(1, (_local_xmlHTTP.responseText.length - 2))).split('","');
		if(toiletName = document.getElementById('toilet_name')) {
			toiletName.innerHTML = '<span style="background-image: url('+ responseData[1] +');"><span class="hidden">'+ responseData[0] +'</span></span>';
		}
		if(toiletType = document.getElementById('toilet_type')) {
			toiletType.innerHTML = responseData[2];
		}		
		if(toiletLocation = document.getElementById('toilet_location')) {
			toiletLocation.innerHTML = responseData[3];
		}
		if(openingTimes = document.getElementById('opening_times')) {
			openingTimes.innerHTML = responseData[4];
		}
		if(toiletRating = document.getElementById('toilet_rating')) {
			var ratingStars = new Array();
			for(ratingCount = 0; ratingCount < parseInt(responseData[5]); ratingCount++) {
				ratingStars[ratingStars.length] = '<span class="rating_star"><span class="hidden">*</span></span>';
			}
			toiletRating.innerHTML = ratingStars.join('');
		}
		if(toiletInformation = document.getElementById('toilet_information')) {
			var informationIcons = new Array(
				new Array('toileticon_warning', 'Warning: Toilet has reported problems'),
				new Array('toileticon_menonly', 'Men Only Facilities'),
				new Array('toileticon_womenonly', 'Women Only Facilities'),
				new Array('toileticon_radar', 'Radar Key Access'),
				new Array('toileticon_disabledfacilities', 'Disabled Facilities Available'),
				new Array('toileticon_stepaccess', 'Step Access Only'),
				new Array('toileticon_washingfacilities', 'Washing Facilities Available'),
				new Array('toileticon_wastedisposal', 'Waste Disposal Facilities Available')
				);
			var iconList = new Array();
			var toiletIcons = responseData[6].split(',');
			for(iconCount = 0; iconCount < toiletIcons.length; iconCount++) {
				if(toiletIcons[iconCount] == '1') {
					iconList[iconList.length] = '<span id="'+ informationIcons[iconCount][0] +'"><span class="hidden">'+ informationIcons[iconCount][1] +'</span></span>';
				}
			}
			toiletInformation.innerHTML = iconList.join('');
		}
		if(toiletWarning = document.getElementById('toilet_warning')) {
			toiletWarning.innerHTML = responseData[7];
		}
		if(toiletRecentComments = document.getElementById('toilet_recentcomments')) {
			toiletRecentComments.innerHTML = responseData[8];
		}
	}
}

function _local_closeToiletBox() {
	if(typeof(_local_moveListener) == 'object') {
		GEvent.removeListener(_local_moveListener);
	}
	_local_googleMap.panTo(_local_lastPoint);
	_local_moveListener = GEvent.addListener(_local_googleMap, 'moveend', _local_defaultMapBehaviour);
	document.getElementById('toiletbox_container').style.display = 'none';
}

function _local_defaultMapBehaviour() {
	if(typeof(_local_moveListener) == 'object') {
		GEvent.removeListener(_local_moveListener);
	}
	_local_moveListener = GEvent.addListener(_local_googleMap, 'moveend', _local_drawToiletMarkers);
}

/* files/javascript/pagemenu.js */

var _local_subMenus = new Array(), _local_menuTimer, _local_menuTimerOn;

function pagemenu_onLoad() {
	if(window.XMLHttpRequest) {
		xmlHTTP = new XMLHttpRequest();
	}
	else {
		xmlHTTP = new ActiveXObject("Microsoft.XMLHTTP");
	}
	if(mainMenu = document.getElementById('mainmenu')) {
		if(subMenu = document.getElementById('submenu')) {
			menuItems = mainMenu.getElementsByTagName('span');
			for(itemCount = 0; itemCount < menuItems.length; itemCount++) {
				if(menuItems[itemCount].getAttribute('mmItem')) {
					subItems = new Array();
					selectedImage = new Image();
					selectedImage.src = '/_files/images/pagemenus/mainmenu/'+ menuItems[itemCount].getAttribute('mmColour') +'/'+ menuItems[itemCount].getAttribute('mmItem') +'.gif';
					xmlHTTP.open('POST', '/_action/local/pagemenu/print_submenu_items', false);
					xmlHTTP.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
					xmlHTTP.send('menuName='+ menuItems[itemCount].getAttribute('mmItem') +'&menuColour='+ menuItems[itemCount].getAttribute('mmColour'));
					if(xmlHTTP.responseText != '' && xmlHTTP.responseText != null) {
						menuSubItems = xmlHTTP.responseText.substr(1, (xmlHTTP.responseText.length - 2)).split('","');
						for(itemSubCount = 0; itemSubCount < menuSubItems.length; itemSubCount++) {
							itemAttributes = menuSubItems[itemSubCount].split(',');
							itemName = itemAttributes[0];
							itemLink = itemAttributes[1];
							itemWidth = itemAttributes[2];
							itemHeight = itemAttributes[3];
							itemLabel = itemAttributes[4];
							if(itemAttributes.length > 5) {
								for(labelCount = 5; labelCount < itemAttributes.length; labelCount++) {
									itemLabel += ','+ itemAttributes[labelCount];
								}
							}
							subImage = new Image();
							subImage.src = '/_files/images/pagemenus/submenus/'+ menuItems[itemCount].getAttribute('mmItem') +'/'+ menuItems[itemCount].getAttribute('mmColour') +'/'+ itemName +'.gif';
							subItems[subItems.length] = '<a href="'+ itemLink +'" title="view: '+ itemLabel.toLowerCase() +'"><span class="submenuitem" style="width: '+ itemWidth +'px;height: '+ itemHeight +'px;background-image: url(/_files/images/pagemenus/submenus/'+ menuItems[itemCount].getAttribute('mmItem') +'/'+ menuItems[itemCount].getAttribute('mmColour') +'/'+ itemName +'.gif);"><span class="itemtext">'+ itemLabel +'</span></span></a>';
						}
					}
					_local_subMenus[menuItems[itemCount].getAttribute('mmItem')] = subItems;
					menuItems[itemCount].onmouseover = function() {
						if(_local_menuTimer) {
							clearTimeout(_local_menuTimer);
							_local_menuTimer = null;
							_local_menuTimerOn = false;
						}
						if(oldMenuItem = document.getElementById('mm_'+ document.getElementById('mainitemcontainer').getAttribute('subMenu'))) {
							oldMenuItem.style.backgroundImage = 'url(/_files/images/pagemenus/mainmenu/greystd/'+ oldMenuItem.getAttribute('mmItem') +'.gif)';
						}
						this.style.backgroundImage = 'url(/_files/images/pagemenus/mainmenu/'+ this.getAttribute('mmColour') +'/'+ this.getAttribute('mmItem') +'.gif)';
						document.getElementById('submenu').innerHTML = '<div id="subitemcontainer" class="swatch_'+ this.getAttribute('mmColour') +'_bg">'+ _local_subMenus[this.getAttribute('mmItem')].join('') +'</div>';
						document.getElementById('mainitemcontainer').setAttribute('subMenu', this.getAttribute('mmItem'));
					}
					menuItems[itemCount].onmouseout = function() {
						if(!_local_menuTimerOn) {
							_local_menuTimer = setTimeout(function() {_local_defaultMenu();}, 2000);
							_local_menuTimerOn = true;
						}
					}
				}
			}
			subMenu.onmouseover = function() {
				if(_local_menuTimer) {
					clearTimeout(_local_menuTimer);
					_local_menuTimer = null;
					_local_menuTimerOn = false;
				}			
			}
			subMenu.onmouseout = function() {
				if(!_local_menuTimerOn) {
					_local_menuTimer = setTimeout(function() {_local_defaultMenu();}, 2000);
					_local_menuTimerOn = true;
				}
			}
		}
	}
}

function _local_defaultMenu() {
	if(oldMenuItem = document.getElementById('mm_'+ document.getElementById('mainitemcontainer').getAttribute('subMenu'))) {
		oldMenuItem.style.backgroundImage = 'url(/_files/images/pagemenus/mainmenu/greystd/'+ oldMenuItem.getAttribute('mmItem') +'.gif)';
	}
	newMenu = document.getElementById('mm_'+ document.getElementById('mainitemcontainer').getAttribute('pageDefault'));
	newMenu.style.backgroundImage = 'url(/_files/images/pagemenus/mainmenu/'+ newMenu.getAttribute('mmColour') +'/'+ newMenu.getAttribute('mmItem') +'.gif)';
	document.getElementById('submenu').innerHTML = '<div id="subitemcontainer" class="swatch_'+ newMenu.getAttribute('mmColour') +'_bg">'+ _local_subMenus[newMenu.getAttribute('mmItem')].join('') +'</div>';
	document.getElementById('mainitemcontainer').setAttribute('subMenu', document.getElementById('mainitemcontainer').getAttribute('pageDefault'));
	if(_local_menuTimer) {
		clearTimeout(_local_menuTimer);
		_local_menuTimer = null;
		_local_menuTimerOn = false;
	}
}

/* files/javascript/smp.js */

function smp_onLoad() {
	if(smpMenu = document.getElementById('smp_menu')) {
		clamShells = new Array();
		smpMenu.setAttribute('openClamShell', 'null');
		menuItems = smpMenu.getElementsByTagName('div');
		for(itemCount = 0; itemCount < menuItems.length; itemCount++) {
			if(clamShell = menuItems[itemCount].getAttribute('clamShell')) {
				clamShells[clamShells.length] = menuItems[itemCount];
			}
		}
		if(clamShells.length > 0) {
			pageURL = document.URL.split('/');
			for(shellCount = 0; shellCount < clamShells.length; shellCount++) {
				clamShell = clamShells[shellCount].getAttribute('clamShell')
				if(clamShell == pageURL[4]) {
					clamShells[shellCount].style.display = 'block';
					clamShells[shellCount].setAttribute('clamShellOpen', 'true');
					smpMenu.setAttribute('openClamShell', clamShell);
				}
				else {
					clamShells[shellCount].style.display = 'none';
					clamShells[shellCount].setAttribute('clamShellOpen', 'false');
				}
			}
		}
	}
}

function toggleClamShell(clamShellName) {
	if(smpMenu = document.getElementById('smp_menu')) {
		if(clamShell = document.getElementById('smp_'+ clamShellName)) {
			if(clamShell.getAttribute('clamShellOpen') == 'false') {
				clamShell.setAttribute('clamShellOpen', 'true');
				clamShell.style.display = 'block';
				if(smpMenu.getAttribute('openClamShell') != 'null') {
					document.getElementById('smp_'+ smpMenu.getAttribute('openClamShell')).setAttribute('clamShellOpen', 'false');
					document.getElementById('smp_'+ smpMenu.getAttribute('openClamShell')).style.display = 'none';
				}
				smpMenu.setAttribute('openClamShell', clamShellName);
			}
		}
	}
}

/* files/javascript/swfobject.js */

/**
 * SWFObject v1.5: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
 *
 * SWFObject is (c) 2007 Geoff Stearns and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 */
if(typeof deconcept=="undefined"){var deconcept=new Object();}if(typeof deconcept.util=="undefined"){deconcept.util=new Object();}if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();}deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a){if(!document.getElementById){return;}this.DETECT_KEY=_a?_a:"detectflash";this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);this.params=new Object();this.variables=new Object();this.attributes=new Array();if(_1){this.setAttribute("swf",_1);}if(id){this.setAttribute("id",id);}if(w){this.setAttribute("width",w);}if(h){this.setAttribute("height",h);}if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));}this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion();if(!window.opera&&document.all&&this.installedVer.major>7){deconcept.SWFObject.doPrepUnload=true;}if(c){this.addParam("bgcolor",c);}var q=_7?_7:"high";this.addParam("quality",q);this.setAttribute("useExpressInstall",false);this.setAttribute("doExpressInstall",false);var _c=(_8)?_8:window.location;this.setAttribute("xiRedirectUrl",_c);this.setAttribute("redirectUrl","");if(_9){this.setAttribute("redirectUrl",_9);}};deconcept.SWFObject.prototype={useExpressInstall:function(_d){this.xiSWFPath=!_d?"expressinstall.swf":_d;this.setAttribute("useExpressInstall",true);},setAttribute:function(_e,_f){this.attributes[_e]=_f;},getAttribute:function(_10){return this.attributes[_10];},addParam:function(_11,_12){this.params[_11]=_12;},getParams:function(){return this.params;},addVariable:function(_13,_14){this.variables[_13]=_14;},getVariable:function(_15){return this.variables[_15];},getVariables:function(){return this.variables;},getVariablePairs:function(){var _16=new Array();var key;var _18=this.getVariables();for(key in _18){_16[_16.length]=key+"="+_18[key];}return _16;},getSWFHTML:function(){var _19="";if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","PlugIn");this.setAttribute("swf",this.xiSWFPath);}_19="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\"";_19+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";var _1a=this.getParams();for(var key in _1a){_19+=[key]+"=\""+_1a[key]+"\" ";}var _1c=this.getVariablePairs().join("&");if(_1c.length>0){_19+="flashvars=\""+_1c+"\"";}_19+="/>";}else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");this.setAttribute("swf",this.xiSWFPath);}_19="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\">";_19+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";var _1d=this.getParams();for(var key in _1d){_19+="<param name=\""+key+"\" value=\""+_1d[key]+"\" />";}var _1f=this.getVariablePairs().join("&");if(_1f.length>0){_19+="<param name=\"flashvars\" value=\""+_1f+"\" />";}_19+="</object>";}return _19;},write:function(_20){if(this.getAttribute("useExpressInstall")){var _21=new deconcept.PlayerVersion([6,0,65]);if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){this.setAttribute("doExpressInstall",true);this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));document.title=document.title.slice(0,47)+" - Flash Player Installation";this.addVariable("MMdoctitle",document.title);}}if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){var n=(typeof _20=="string")?document.getElementById(_20):_20;n.innerHTML=this.getSWFHTML();return true;}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}return false;}};deconcept.SWFObjectUtil.getPlayerVersion=function(){var _23=new deconcept.PlayerVersion([0,0,0]);if(navigator.plugins&&navigator.mimeTypes.length){var x=navigator.plugins["Shockwave Flash"];if(x&&x.description){_23=new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}}else{if(navigator.userAgent&&navigator.userAgent.indexOf("Windows CE")>=0){var axo=1;var _26=3;while(axo){try{_26++;axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+_26);_23=new deconcept.PlayerVersion([_26,0,0]);}catch(e){axo=null;}}}else{try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}catch(e){try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");_23=new deconcept.PlayerVersion([6,0,21]);axo.AllowScriptAccess="always";}catch(e){if(_23.major==6){return _23;}}try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}catch(e){}}if(axo!=null){_23=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}}}return _23;};deconcept.PlayerVersion=function(_29){this.major=_29[0]!=null?parseInt(_29[0]):0;this.minor=_29[1]!=null?parseInt(_29[1]):0;this.rev=_29[2]!=null?parseInt(_29[2]):0;};deconcept.PlayerVersion.prototype.versionIsValid=function(fv){if(this.major<fv.major){return false;}if(this.major>fv.major){return true;}if(this.minor<fv.minor){return false;}if(this.minor>fv.minor){return true;}if(this.rev<fv.rev){return false;}return true;};deconcept.util={getRequestParameter:function(_2b){var q=document.location.search||document.location.hash;if(_2b==null){return q;}if(q){var _2d=q.substring(1).split("&");for(var i=0;i<_2d.length;i++){if(_2d[i].substring(0,_2d[i].indexOf("="))==_2b){return _2d[i].substring((_2d[i].indexOf("=")+1));}}}return "";}};deconcept.SWFObjectUtil.cleanupSWFs=function(){var _2f=document.getElementsByTagName("OBJECT");for(var i=_2f.length-1;i>=0;i--){_2f[i].style.display="none";for(var x in _2f[i]){if(typeof _2f[i][x]=="function"){_2f[i][x]=function(){};}}}};if(deconcept.SWFObject.doPrepUnload){if(!deconcept.unloadSet){deconcept.SWFObjectUtil.prepUnload=function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){};window.attachEvent("onunload",deconcept.SWFObjectUtil.cleanupSWFs);};window.attachEvent("onbeforeunload",deconcept.SWFObjectUtil.prepUnload);deconcept.unloadSet=true;}}if(!document.getElementById&&document.all){document.getElementById=function(id){return document.all[id];};}var getQueryParamValue=deconcept.util.getRequestParameter;var FlashObject=deconcept.SWFObject;var SWFObject=deconcept.SWFObject;

/* ../arxcore/modules/core/1.0.0/files/javascript/core_admin.js */

if(window.XMLHttpRequest) {
	var _core_xmlHTTP = new XMLHttpRequest();
}
else {
	var _core_xmlHTTP = new ActiveXObject('Microsoft.XMLHTTP');
}

var _core_oldMouseMove, _core_oldMouseUp, _core_cursorOrigX, _core_cursorOrigY;
var _core_dialogButtons = new Array(), _core_calendarResultFunction;

function core_admin_onLoad() {
	if(navigator.userAgent.toLowerCase().indexOf('safari') != -1) {
		if(iconContainer = document.getElementById('_core_icon_container')) {
			var iconHolders = new Array();
			loginIcons = iconContainer.getElementsByTagName('div');
			for(iconCount = 0; iconCount < loginIcons.length; iconCount++) {
				if(loginIcons[iconCount].getAttribute('iconName') != 'core') {
					iconHolders[iconHolders.length] = loginIcons[iconCount];
				}
				else {
					coreIcon = loginIcons[iconCount];
				}
			}
			loginIcons = new Array();
			loginIcons[0] = coreIcon;
			for(iconCount = 0; iconCount < iconHolders.length; iconCount++) {
				loginIcons[loginIcons.length] = iconHolders[iconCount];
			}
			setTimeout(function(){_core_showIcons(loginIcons, (loginIcons.length - 1), true, -25, 62, 2, 2);}, 1000);
		}
		if(dockHori = document.getElementById('_core_dock_hori')) {
			dockHori.style.marginLeft = '-'+ Math.round(dockHori.offsetWidth / 2) +'px';
			dockHori.style.visibility = 'visible';
		}
	}
}

function _core_showIcons(loginIcons, iconCount, fadeIcon, iconLeft, iconOpacity, imageWidth, imageHeight) {
	currentIcon = loginIcons[iconCount];
	currentIcon.style.left = '50%';
	currentIcon.style.marginLeft = iconLeft;
	if(fadeIcon) {
		iconOpacity = iconOpacity + Math.ceil((100 - iconOpacity) / 2);
		imageWidth = imageWidth + Math.ceil((40 - imageWidth) / 2);
		imageHeight = imageHeight + Math.ceil((40 - imageHeight) / 2);
		
		if(imageWidth >= 40 && imageHeight >= 40) {
			fadeIcon = false;
			iconOpacity = 100;
			imageWidth = 40;
			imageHeight = 40;
		}
		
		iconImages = currentIcon.getElementsByTagName('img');
		for(imageCount = 0; imageCount < iconImages.length; imageCount++) {
			iconImages[imageCount].style.width = imageWidth;
			iconImages[imageCount].style.height = imageHeight;
			iconImages[imageCount].style.marginLeft = '-'+ (imageWidth / 2);
		}
		currentIcon.style.opacity = iconOpacity / 100;
		currentIcon.style.filter = 'alpha(opacity='+ iconOpacity +')';
	}
	else {
		iconPosition = Math.ceil(iconCount / 2);
		if(iconCount % 2 == 0) {
			iconLeft = iconLeft + Math.ceil((((iconPosition * 50) + -25) - iconLeft) / 2);
			if(iconLeft >= (iconPosition * 50) + -25) {
				iconCount--;
				fadeIcon = true;
				iconOpacity = 62;
				imageWidth = 2;
				imageHeight = 2;
				iconLeft = (iconPosition * 50) + -25;
			}
		}
		else {
			iconLeft = iconLeft + Math.floor((((iconPosition * -50) + -25) - iconLeft) / 2);
			if(iconLeft <= (iconPosition * -50) + -25) {
				iconCount--;
				fadeIcon = true;
				iconOpacity = 62;
				imageWidth = 2;
				imageHeight = 2;
				iconLeft = (iconPosition * -50) + -25;
			}
		}
		currentIcon.style.marginLeft = iconLeft;
		if(fadeIcon) {
			iconLeft = -25;
		}
	}
	if(iconCount >= 0) {
		setTimeout(function(){_core_showIcons(loginIcons, iconCount, fadeIcon, iconLeft, iconOpacity, imageWidth, imageHeight);}, 30);
	}
	else {
		if(loginContainer = document.getElementById('_core_logincontainer')) {
			targetWidth = loginContainer.offsetWidth;
			loginContainer.style.width      = '0px';
			loginContainer.style.visibility = 'visible';
			_core_openLoginContainer(loginContainer, targetWidth, 0);
		}
	}
}

function _core_openLoginContainer(loginContainer, targetWidth, fieldOpacity) {
	if(loginContainer.offsetWidth < targetWidth) {
		loginContainer.style.width      = loginContainer.offsetWidth + Math.round((targetWidth - loginContainer.offsetWidth) / 2) +'px';
		loginContainer.style.marginLeft = '-'+ Math.round(loginContainer.offsetWidth / 2) +'px';
		setTimeout(function(){_core_openLoginContainer(loginContainer, targetWidth, fieldOpacity);}, 60);
	}
	else {
		document.getElementById('_core_loginerror').style.visibility  = 'visible';
		document.getElementById('_core_loginfields').style.visibility = 'visible';
	}
}

function _core_submitLoginForm(loadedIcons, iconCount, iconOpacity) {
	iconOpacity -= 10;
	loadedIcons[iconCount].style.opacity = iconOpacity / 100;
	loadedIcons[iconCount].style.filter  = 'alpha(opacity='+ iconOpacity +')';
	if(iconOpacity > 0) {
		setTimeout(function(){_core_submitLoginForm(loadedIcons, iconCount, iconOpacity);}, 20);
	}
	else {
		if(iconCount < (loadedIcons.length - 1)) {
			setTimeout(function(){_core_submitLoginForm(loadedIcons, (iconCount + 1), 100);}, 20);
		}
		else {
			document.getElementById('frmLogin').submit();
		}
	}
}

/* local/1.0.0/files/javascript/members.js */

var _local_xmlHTTP;

function members_onLoad() {
	if(window.XMLHttpRequest) {
		_local_xmlHTTP = new XMLHttpRequest();
	}
	else {
		_local_xmlHTTP = new ActiveXObject("Microsoft.XMLHTTP");
	}
	
	if((databaseDownload = document.getElementById('_local_frmDatabaseDownload'))) {
		for(optionCount = 0; optionCount < databaseDownload._local_rdbDownloadType.length; optionCount++) {
			databaseDownload._local_rdbDownloadType[optionCount].onclick = function() {_local_changeDatabaseDownload(document.getElementById('_local_frmDatabaseDownload'), this.value)};
			if(databaseDownload._local_rdbDownloadType[optionCount].checked) {
				var selectedButton = optionCount;
			}
		}
		_local_changeDatabaseDownload(databaseDownload, databaseDownload._local_rdbDownloadType[selectedButton].value);
	}
	
	if(paymentMethod = document.getElementById('_local_sltPaymentMethod')) {
		if(paymentMethod.value == 'Honourary') {
			if(memberDiscount = document.getElementById('_local_sltMemberDiscount')) {
				memberDiscount.selectedIndex = 0;
			}
			if(memberAmount = document.getElementById('_local_txtMemberAmount')) {
				memberAmount.value = '0.00';
			}
		}
		else {
			switch(paymentMethod.value) {
				case 'Credit Card':
					if(cardFields = document.getElementById('_local_paymentmethod_card')) {
						cardFields.style.display = 'inline';
					}
					paymentMethod.paymentFields = cardFields;
				break;
				case 'Cheque':
					if(chequeFields = document.getElementById('_local_paymentmethod_cheque')) {
						chequeFields.style.display = 'inline';
					}
					paymentMethod.paymentFields = chequeFields;
				break;
			}
			if(memberDiscount = document.getElementById('_local_sltMemberDiscount')) {
				if(memberDiscount.value == 'Helping Hand') {
					var amountValue = '12.00';
				}
				else {
					var amountValue = '24.00';
				}
			}
			if(memberAmount = document.getElementById('_local_txtMemberAmount')) {
				if(memberAmount.value == '0.00' || memberAmount.value == '') {
					memberAmount.value = amountValue;
				}
			}
		}
		paymentMethod.onchange = function() {
			this.paymentFields.style.display = 'none';
			if(this.value == 'Honourary') {
				if(memberDiscount = document.getElementById('_local_sltMemberDiscount')) {
					memberDiscount.selectedIndex = 0;
				}
				if(memberAmount = document.getElementById('_local_txtMemberAmount')) {
					memberAmount.value = '0.00';
				}
			}
			else {
				switch(this.value) {
					case 'Credit Card':
						if(cardFields = document.getElementById('_local_paymentmethod_card')) {
							cardFields.style.display = 'inline';
						}
						this.paymentFields = cardFields;
					break;
					case 'Cheque':
						if(chequeFields = document.getElementById('_local_paymentmethod_cheque')) {
							chequeFields.style.display = 'inline';
						}
						this.paymentFields = chequeFields;
					break;
				}
				if(memberDiscount = document.getElementById('_local_sltMemberDiscount')) {
					if(memberDiscount.value == 'Helping Hand') {
						var amountValue = '12.00';
					}
					else {
						var amountValue = '24.00';
					}
				}
				if(memberAmount = document.getElementById('_local_txtMemberAmount')) {
					if(memberAmount.value == '0.00') {
						memberAmount.value = amountValue;
					}
				}
			}
		}
	}
	if(memberDiscount = document.getElementById('_local_sltMemberDiscount')) {
		memberDiscount.onchange = function() {
			if(paymentMethod = document.getElementById('_local_sltPaymentMethod')) {
				if(paymentMethod.value != 'Honourary') {
					switch(this.value) {
						case 'N/A':
							if(memberAmount = document.getElementById('_local_txtMemberAmount')) {
								memberAmount.value = '24.00';
							}
						break;
						case 'Helping Hand':
							if(memberAmount = document.getElementById('_local_txtMemberAmount')) {
								memberAmount.value = '12.00';
							}					
						break;
					}
				}
			}
		}
	}
	
	if((showCardAddress = document.getElementById('_local_frmAddMember')) || (showCardAddress = document.getElementById('_local_frmAddAction'))) {
		for(optionCount = 0; optionCount < showCardAddress._local_rdbShowCardAddress.length; optionCount++) {
			showCardAddress._local_rdbShowCardAddress[optionCount].onclick = function() {_local_showCardAddress(this.value)};
			if(showCardAddress._local_rdbShowCardAddress[optionCount].checked) {
				var selectedButton = optionCount;
			}
		}
		_local_showCardAddress(showCardAddress._local_rdbShowCardAddress[selectedButton].value);
	}
	
	if(actionType = document.getElementById('_local_sltActionType')) {
		switch(actionType.value) {
			case 'E-mail Received':
			case 'E-mail Sent':
			case 'General Comment':
			case 'Telephone Call':
				if(contactFields = document.getElementById('_local_addaction_contact')) {
					contactFields.style.display = 'inline';
					actionType.actionFields = contactFields;
				}
			break;
			case 'Member Deceased':
				if(deceasedNotice = document.getElementById('_local_addaction_deceased')) {
					deceasedNotice.style.display = 'inline';
					actionType.actionFields = deceasedNotice;
				}
			break;
			case 'Renew Membership':
				if(renewFields = document.getElementById('_local_addaction_renew')) {
					renewFields.style.display = 'inline';
					actionType.actionFields = renewFields;
				}
			break;
		}
		actionType.onchange = function() {
			this.actionFields.style.display = 'none';
			switch(this.value) {
				case 'E-mail Received':
				case 'E-mail Sent':
				case 'General Comment':
				case 'Telephone Call':
					if(contactFields = document.getElementById('_local_addaction_contact')) {
						contactFields.style.display = 'inline';
						this.actionFields = contactFields;
					}
				break;
				case 'Member Deceased':
					if(deceasedNotice = document.getElementById('_local_addaction_deceased')) {
						deceasedNotice.style.display = 'inline';
						this.actionFields = deceasedNotice;
					}
				break;
				case 'Renew Membership':
					if(renewFields = document.getElementById('_local_addaction_renew')) {
						renewFields.style.display = 'inline';
						this.actionFields = renewFields;
					}
				break;
			}
		}
	}
	
	if(searchMembers = document.getElementById('_local_frmSearchMembers')) {
		searchMembers.onsubmit = function() {
			if(memberCriteria = document.getElementById('_local_txtMemberCriteria')) {
				_local_xmlHTTP.open('POST', '/_action/local/members/search_members', false);
				_local_xmlHTTP.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
				_local_xmlHTTP.send('memberCriteria='+ (memberCriteria.value.replace(/&/g, '%26')).replace(/\+/g, '%2B'));
				if(memberList = document.getElementById('_local_searchmembers_results')) {
					memberList.innerHTML = _local_xmlHTTP.responseText;
					return false;
				}
			}
		}
	}
	if(memberEdit = document.getElementById('_local_btnMemberEdit')) {
		memberEdit.onclick = function() {
			_local_xmlHTTP.open('POST', '/_action/local/members/edit_member', false);
			_local_xmlHTTP.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			_local_xmlHTTP.send('membershipNumber='+ document.getElementById('_local_hdnMembershipNumber').value);
			if(_local_xmlHTTP.responseText != '' && _local_xmlHTTP.responseText != null) {
				if(memberEditView = document.getElementById('_local_member_editview')) {
					memberEditView.innerHTML = _local_xmlHTTP.responseText;
				}
			}
		}
	}
	/*if(historyAdd = document.getElementById('_local_btnHistoryAdd')) {
		historyAdd.onclick = function() {
			if(historySubject = document.getElementById('_local_sltHistorySubject')) {
				if(historyDescription = document.getElementById('_local_sltHistoryDescription')) {
					_local_xmlHTTP.open('POST', '/_action/local/members/add_history', false);
					_local_xmlHTTP.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
					_local_xmlHTTP.send('membershipNumber='+ document.getElementById('_local_hdnMembershipNumber').value +'&historySubject='+ (historySubject.value.replace(/&/g, '%26')).replace(/\+/g, '%2B') +'&historyDescription='+ (historyDescription.value.replace(/&/g, '%26')).replace(/\+/g, '%2B'));
					if(_local_xmlHTTP.responseText != '' && _local_xmlHTTP.responseText != null) {
						if(historyList = document.getElementById('_local_historylist')) {
							historyList.innerHTML = _local_xmlHTTP.responseText;
						}
					}
				}
			}
		}
	}*/
}

function _local_changeDatabaseDownload(fieldForm, fieldValue) {
	if(databaseDownload = document.getElementById(fieldForm.getAttribute('downloadType'))) {
		databaseDownload.style.display = 'none';
	}
	switch(fieldValue) {
		case 'ALL':
			if(databaseDownload = document.getElementById('_local_databasedownload_all')) {
				databaseDownload.style.display = 'inline';
				fieldForm.setAttribute('downloadType', '_local_databasedownload_all');
			}
		break;
		case 'NEW_MEMBERS':
			if(databaseDownload = document.getElementById('_local_databasedownload_newmembers')) {
				databaseDownload.style.display = 'inline';
				fieldForm.setAttribute('downloadType', '_local_databasedownload_newmembers');
			}
		break;		
		case 'RENEWALS':
		case 'SUBSCRIBERS':
			if(databaseDownload = document.getElementById('_local_databasedownload_renewalssubscribers')) {
				databaseDownload.style.display = 'inline';
				fieldForm.setAttribute('downloadType', '_local_databasedownload_renewalssubscribers');
			}
		break;
		default:
			fieldForm.setAttribute('downloadType', '_local_databasedownload_null');
	}
}

function _local_showCardAddress(showAddress) {
	if(cardAddress = document.getElementById('_local_carddetails_address')) {
		switch(showAddress) {
			case 'No':
				cardAddress.style.display = 'none';
			break;
			case 'Yes':
				cardAddress.style.display = 'inline';
			break;
		}
	}
}

/* local/1.0.0/files/javascript/addresses.js */

var _local_autoAddresses, _local_manualAddresses, _local_addressLines;

if(window.XMLHttpRequest) {
	var _local_pafHTTP = new XMLHttpRequest();
}
else {
	var _local_pafHTTP = new ActiveXObject("Microsoft.XMLHTTP");
}

function addresses_onLoad() {
	_local_setupAddresses();
}

function _local_setupAddresses() {
	_local_autoAddresses = new Object();
	_local_manualAddresses = new Object();
	_local_addressLines = new Object();
	var pageElements = document.getElementsByTagName('*');
	for(elementCount = 0; elementCount < pageElements.length; elementCount++) {
		switch(pageElements[elementCount].getAttribute('addressType')) {
			case 'auto':
				_local_autoAddresses[pageElements[elementCount].getAttribute('addressID')] = pageElements[elementCount];
			break;
			case 'manual':
				_local_manualAddresses[pageElements[elementCount].getAttribute('addressID')] = pageElements[elementCount];
				_local_addressLines[pageElements[elementCount].getAttribute('addressID')] = new Object();
			break;
		}
	}
	for(elementCount = 0; elementCount < pageElements.length; elementCount++) {
		if(pageElements[elementCount].getAttribute('addressLine') != undefined) {
			_local_addressLines[pageElements[elementCount].getAttribute('addressID')][pageElements[elementCount].getAttribute('addressLine')] = pageElements[elementCount];
			if(pageElements[elementCount].getAttribute('addressLine') == 'address_list') {
				pageElements[elementCount].style.display = 'none';
			}
		}
	}
	for(addressID in _local_autoAddresses) {
		if(_local_addressLines[addressID]['line1'].value == 'address line 1' && _local_addressLines[addressID]['town'].value == 'town' && _local_addressLines[addressID]['postcode'].value == 'postcode') {
			_local_autoAddresses[addressID].style.display = 'inline';
			_local_manualAddresses[addressID].style.display = 'none';
		}
		_local_addressLines[addressID]['search_button'].onclick = function() {_local_searchAddresses(this.getAttribute('addressID'));}
	}
}

function _local_searchAddresses(addressID) {
	_local_pafHTTP.open('POST', '/_action/local/addresses/print_search_addresses', false);
	_local_pafHTTP.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	_local_pafHTTP.send('postCode='+ (_local_addressLines[addressID]['search_text'].value.toUpperCase()).replace(/ /g, ''));
	
	_local_addressLines[addressID]['address_list'].options[_local_addressLines[addressID]['address_list'].options.length] = new Option('<Choose your Address>', 'address line 1,address line 2,locality,town,postcode');
	if(_local_pafHTTP.responseText != '' && _local_pafHTTP.responseText != null) {
		searchAddresses = (_local_pafHTTP.responseText.substr(1, (_local_pafHTTP.responseText.length - 2))).split('","');
		for(addressCount = 0; addressCount < searchAddresses.length; addressCount++) {
			addressDetails = searchAddresses[addressCount].split(':');
			_local_addressLines[addressID]['address_list'].options[_local_addressLines[addressID]['address_list'].options.length] = new Option(addressDetails[1], addressDetails[0]);
		}
	}
	_local_addressLines[addressID]['address_list'].options[_local_addressLines[addressID]['address_list'].options.length] = new Option('ENTER ADDRESS MANUALLY', 'address line 1,address line 2,locality,town,postcode');
	
	_local_addressLines[addressID]['address_list'].onchange = function() {
		addressDetails = this.value.split(',');
		_local_addressLines[this.getAttribute('addressID')]['line1'].value = addressDetails[0];
		_local_addressLines[this.getAttribute('addressID')]['line2'].value = addressDetails[1];
		_local_addressLines[this.getAttribute('addressID')]['locality'].value = addressDetails[2];
		_local_addressLines[this.getAttribute('addressID')]['town'].value = addressDetails[3];
		_local_addressLines[this.getAttribute('addressID')]['postcode'].value = addressDetails[4];
		_local_manualAddresses[this.getAttribute('addressID')].style.display = 'inline';
	}
	
	_local_addressLines[addressID]['search_button'].value = 'Reset Search';
	_local_addressLines[addressID]['search_button'].onclick = function() {
		_local_addressLines[this.getAttribute('addressID')]['search_text'].style.display = 'inline';
		_local_addressLines[this.getAttribute('addressID')]['address_list'].style.display = 'none';
		
		_local_addressLines[this.getAttribute('addressID')]['line1'].value = 'address line 1';
		_local_addressLines[this.getAttribute('addressID')]['line2'].value = 'address line 2';
		_local_addressLines[this.getAttribute('addressID')]['locality'].value = 'locality';
		_local_addressLines[this.getAttribute('addressID')]['town'].value = 'town';
		_local_addressLines[this.getAttribute('addressID')]['postcode'].value = 'postcode';
		
		_local_addressLines[this.getAttribute('addressID')]['search_text'].value = 'search postcode';
		_local_addressLines[this.getAttribute('addressID')]['search_button'].value = 'Search Addresses';
		_local_addressLines[this.getAttribute('addressID')]['address_list'].options.length = 0;
		
		_local_resetAddresses(this.getAttribute('addressID'));
	}
	_local_addressLines[addressID]['search_text'].style.display = 'none';
	_local_addressLines[addressID]['address_list'].style.display = 'inline';
}

function _local_resetAddresses(addressID) {
	_local_autoAddresses[addressID].style.display = 'inline';
	_local_manualAddresses[addressID].style.display = 'none';
	_local_addressLines[addressID]['search_button'].onclick = function() {_local_searchAddresses(this.getAttribute('addressID'));}
}

