	
	var StoreDetails = new Class({
		initialize: function()	{
			this.storeId = $("store");
			this.storeName = $("storeName");
			this.storeAddress = $('storeAddress');
			this.storeNameNote = $('storeNameNote');
			this.storeType = $('storeType');
			this.partyRoom = $('partyRoom');
			this.partyRoomBalloon = $('partyRoomBalloon');
			this.mcCafe = $('mcCafe');
			this.carSpaces = $('carSpaces');
			this.wheelChairAccess = $('wheelchairAccess');
			this.babyChangeFacility = $('babyChangeFacility');
			this.highChairsAvailable = $('highChairsAvailable');
			this.playLand = $('playLand');
			this.driveThru = $('driveThru');
			this.specialoffers = $('specialoffers');			// special offer block
			this.specialOffersHeader = $('specialOfferHeader');	// header of the special offer
			this.specialOffersText = $('specialOfferText');		// content of the special offer
			this.partyLength = $('partyLength');
			this.maxPartySize = $('maxPartySize');

			this.empty = {
				'storeId':' ',
				'name':' ',
				'address':' ',
				'StoreType':' ',
				'HavePartyRoom':' ',
				'HaveMcCafe':' ',
				'TotalCarSpace':' ',
				'HaveWheelChairAccess': ' ',
				'HaveBabyRoom':' ',
				'TotalHighChairs':' ',
				'HavePlayLand':' ',
				'SpecailOfferName':''
			};
		},
		update: function(item) {
			var specialoffer = item.SpecailOfferName;
			if(this.storeId != null){this.storeId.set('value', item.storeId);}
			if(this.storeName != null){this.storeName.set('text', item.name);}
			if(this.storeAddress != null){this.storeAddress.set('text', item.address);}
			if(this.storeNameNote != null) {
				if(item.name.trim().charAt(item.name.trim().length-1)=='*'){
					this.storeNameNote.set('text', '( * at the end of a Restaurant name is a Multiple Party Room restaurant)');
				}else{
					this.storeNameNote.set('text','');
				}
			}
			if(this.storeType != null){this.storeType.set('text', item.StoreType);}	
			if(this.partyRoom != null){
				// appears balloon of the number of rooms
				this.partyRoomBalloon.empty();
				this.partyRoom.set('text', '');

				if(String(item.HavePartyRoom).trim() != ''){
					this.partyRoom.set('text', '(' + item.HavePartyRoom + ')' );
					for(var i=0; i<item.HavePartyRoom; i++){
						new Element('div', {'class':'party-room-balloon'}).inject(this.partyRoomBalloon);
					}
				}
			}
			if(this.mcCafe != null){
				this.mcCafe.empty();
				if(String(item.HaveMcCafe).toLowerCase() == 'yes'){
					new Element('div', {'class':'party-room-tick'}).inject(this.mcCafe);
				}
			}
			if(this.carSpaces != null){this.carSpaces.set('text', item.TotalCarSpace);}

			if(this.wheelChairAccess != null){
				this.wheelChairAccess.empty();
				if(String(item.HaveWheelChairAccess).toLowerCase() == 'yes'){
					new Element('div', {'class':'party-room-tick'}).inject(this.wheelChairAccess);
				}
			}
			if(this.babyChangeFacility != null){
				this.babyChangeFacility.empty();
				if(String(item.HaveBabyRoom).toLowerCase() == 'yes'){
					new Element('div', {'class':'party-room-tick'}).inject(this.babyChangeFacility);
				}
			}
			if(this.highChairsAvailable != null){this.highChairsAvailable.set('text', item.TotalHighChairs);}				

			if(this.playLand != null){
				this.playLand.empty();
				if(String(item.HavePlayLand).toLowerCase() == 'yes'){
					new Element('div', {'class':'party-room-tick'}).inject(this.playLand);
				}
			}
			if(this.partyLength != null) {
				// check party length if it's nothing
				this.partyLength.set('text', item.partyDuration);
			}
			if(this.maxPartySize != null) {
				this.maxPartySize.set('text', item.maxPartySize);
			}
			if(this.driveThru != null){
				this.driveThru.empty();
				// check drive thru
				if((String(item.StoreType).trim()).toLowerCase() == 'drive thru'){
					new Element('div', {'class':'party-room-tick'}).inject(this.driveThru);
				}
			}
			if((this.specialoffers != null) && (String(specialoffer).trim() != '')){
				// insert text
				this.specialOffersHeader.set('html', 'SPECIAL OFFERS AT <br/>' + item.name);
				this.specialOffersText.set('html', item.SpecailOfferName);

				// display special offers box
				this.specialoffers.addClass('special-offer-show');
				/*
				// reload style from sIFR
				var specialofferStyle = {
					src: 'sIFR/specialoffer.swf',
					wmode: 'transparent'
				};
				
				// reload style for header
				sIFR.activate(specialofferStyle);
				sIFR.replace(specialofferStyle, {
				  selector: 'p.special-offer-header'
				  ,css: { '.sIFR-root': { 'color': '#FFFFFF', 'background': 'none', 'letter-spacing': 0, 'text-align': 'center', 'font-size': '17px' } }
				});
				// reload style for text
				sIFR.replace(specialofferStyle, {
				  selector: 'p.special-offer-text'
				  ,css: { '.sIFR-root': { 'color': '#FFFFFF', 'background': 'none', 'letter-spacing': 0, 'text-align': 'center', 'font-size': '13px' } }
				});
				*/
			} else {
				this.specialoffers.removeClass('special-offer-show');
			}
		},
		getStore: function() {
			return this.storeId;
		},
		clear: function() {
			this.update(this.empty);
		}
		
	});// end class StoreDetails

// add dom ready on this class
window.addEvent('domready', function(){
	// detect numric key
	function numericBox(textbox){
		textbox.addEvent('keydown', function(key){
			if(key.code == 9){ // tab
				return true;
			} else if(!((key.code>=48 && key.code<=57) || (key.code>=96 && key.code<=105) || (key.code==8) || (key.code==46) || (key.code>=37 && key.code<=40))){
				return false;
			}
		});
	}
	// NumericBox
	if($chk($('numberOfGuests'))){
		numericBox($('numberOfGuests'));
	}
	// NumricBox
	if($chk($('partyDetailGuestNumber'))){
		numericBox($('partyDetailGuestNumber'));
	}
	// NumericBox
	if($chk($('contactNumberBooking'))){
		numericBox($('contactNumberBooking'));
	}
	
	if($chk($('alternateContactBooking'))){
		numericBox($('alternateContactBooking'));
	}
	
	if($chk($('contactNumber'))){
		numericBox($('contactNumber'));
	}
	
	if($chk($('alternateContact'))){
		numericBox($('alternateContact'));
	}
	
	
	// NumericBox
	if($chk($('postCode'))){
		numericBox($('postCode'));
	}
});
