//////////////////////////////////////////////////////////////
// clsLocationInfo
//////////////////////////////////////////////////////////////
function clsLocationInfo() {
	var self = this;
	this.pAjax = null;
	this.pSwapFade = new clsSwapFade( 1, 1 );
	
	// Cache Images
	this.pSwapFade.cacheImage('page/location/barbican.jpg');
	this.pSwapFade.cacheImage('page/location/marineaquarium.jpg');
	this.pSwapFade.cacheImage('page/location/pavilions.jpg');
	this.pSwapFade.cacheImage('page/location/thehoe.jpg');
	this.pSwapFade.cacheImage('page/location/golfcourses.jpg');
	this.pSwapFade.cacheImage('page/location/dartmoor.jpg');
	this.pSwapFade.cacheImage('page/location/ferry.jpg');
	this.pSwapFade.cacheImage('page/location/fishing.jpg');
	this.pSwapFade.cacheImage('page/location/theatres.jpg');
	this.pSwapFade.cacheImage('page/location/towncentre.jpg');
	this.pSwapFade.cacheImage('page/location/coach.jpg');
	this.pSwapFade.cacheImage('page/location/railway.jpg');
	this.pSwapFade.cacheImage('page/location/mayflowersteps.jpg');
	this.pSwapFade.cacheImage('page/location/airport.jpg');
	
	this.image = getObject('imgLocation');
	this.output = getObject('divLocation');
	
	this.update = function( name, hasImage ) {
		if( this.pAjax ) {
			return false;
		}
		
		this.hasImage = hasImage;
					 
		this.pAjax = new clsAJAX( 'page/location/' + name + '.php', 'GET' );
		this.pAjax.pComplete = function(){ self.update_Callback( name ); };
		return this.pAjax.start();
	};
	
	this.update_Callback = function( name ) {
		if( this.hasImage ) {
			if( this.image ) {
				this.pSwapFade.swapImage( this.image, 'page/location/' + name + '.jpg' );
			}
		}
		if( this.output ) {
			this.output.innerHTML = self.pAjax.xmlhttp.responseText
		}
		this.pAjax = null;
	}
};


//////////////////////////////////////////////////////////////
// clsRoomsInfo
//////////////////////////////////////////////////////////////
function clsRoomsInfo() {
	var self = this;
	this.pAjax = null;
	this.pSwapFade = new clsSwapFade( 1, 1 );
	
	// Cache Images
	this.pSwapFade.cacheImage('page/rooms/001_m.jpg');
	this.pSwapFade.cacheImage('page/rooms/002_m.jpg');
	this.pSwapFade.cacheImage('page/rooms/003_m.jpg');
	this.pSwapFade.cacheImage('page/rooms/004_m.jpg');
	this.pSwapFade.cacheImage('page/rooms/005_m.jpg');
	this.pSwapFade.cacheImage('page/rooms/006_m.jpg');
	this.pSwapFade.cacheImage('page/rooms/007_m.jpg');
	this.pSwapFade.cacheImage('page/rooms/008_m.jpg');
	this.pSwapFade.cacheImage('page/rooms/009_m.jpg');
	
	this.name = '001';
	this.info = 'room_1';
	this.pSiteLayer = new clsSiteLayer();
	
	this.image = getObject('imgLocation');
	this.output = getObject('divLocation');
	
	this.update = function( name, info ) {
		if( this.pAjax ) {
			return false;
		}
		
		this.name = name;
		this.info = info;
					 
		this.pAjax = new clsAJAX( 'page/rooms/' + info + '.php', 'GET' );
		this.pAjax.pComplete = function(){ self.update_Callback( name ); };
		if( this.pAjax.start() == false ) return true;
		
		return false;
	};
	
	this.update_Callback = function( name ) {
		//if( this.hasImage ) {
			if( this.image ) {
				this.pSwapFade.swapImage( this.image, 'page/rooms/' + name + '_m.jpg' );
			}
		//}
		if( this.output ) {
			this.output.innerHTML = self.pAjax.xmlhttp.responseText
		}
		this.pAjax = null;
	}
	
	this.displayImage = function() {
		this.pSiteLayer.loadPage(this.name);
	};
	
	this.closeImage = function() {
		this.pSiteLayer.closeSite();
	};
};

//////////////////////////////////////////////////////////////
// clsFindusImg
//////////////////////////////////////////////////////////////
function clsFindusImg() {
	var self = this;
	
	this.zoom = 4;
	this.pSwapFade = new clsSwapFade( 1, 1 );
	
	// Cache Images
	this.pSwapFade.cacheImage('gfx/map/mapA.gif');
	this.pSwapFade.cacheImage('gfx/map/mapB.gif');
	this.pSwapFade.cacheImage('gfx/map/mapC.gif');
	this.pSwapFade.cacheImage('gfx/map/mapD.gif');
	this.pSwapFade.cacheImage('gfx/map/mapF.gif');

	this.image = getObject('imgFindus');
	
	this.update = function() {
		if( this.image ) {
			switch( this.zoom ) {
				case 1:
					this.pSwapFade.swapImage( this.image, 'gfx/map/mapF.gif' );
					break;
					
				case 2:
					this.pSwapFade.swapImage( this.image, 'gfx/map/mapD.gif' );
					break;		
					
				case 3:
					this.pSwapFade.swapImage( this.image, 'gfx/map/mapC.gif' );
					break;		
					
				case 4:
					this.pSwapFade.swapImage( this.image, 'gfx/map/mapB.gif' );
					break;		
					
				case 5:
					this.pSwapFade.swapImage( this.image, 'gfx/map/mapA.gif' );
					break;			
			}
		}
	};
	
	this.zoomIn = function() {
		this.zoom++;
		if( this.zoom > 5 ) this.zoom = 5;
		
		this.update();
	};
	
	this.zoomOut = function() {
		this.zoom--;
		if( this.zoom < 1 ) this.zoom = 1;
		
		this.update();
	};
};

/////////////////////////////////////////////////////////////////////////////////
// Class clsSiteLayer
/////////////////////////////////////////////////////////////////////////////////
function clsSiteLayer() {
	var self = this;
	
	this.v_id = 0;
	this.pAjax = null;
	
	this.pDiv = document.createElement('div');
	this.pDiv.style.visibility = "hidden";
	this.pDiv.style.position = "absolute";
	this.pDiv.style.left = "0px";
	this.pDiv.setAttribute('id','clsSiteLayerDiv');
	
	var pDivAttach = getObject( 'divLayer' );
	if( pDivAttach ) {
		pDivAttach.style.visibility = 'visible';
		pDivAttach.appendChild(this.pDiv);
	}
	
	this.closeSite = function() {
		this.pDiv.style.visibility = "hidden";
	}

	this.loadPage = function( v_id ) {	
		if( this.pAjax ) {
			alert('loadPage: Operation already in progress!');
			return;
		}
		
		this.v_id = v_id;
		this.pAjax = new clsAJAX( '/ajax/site/site_' + v_id + '.php' );
		this.pAjax.pComplete = function(){ self.loadPage_Callback(); };
		this.pAjax.start();
	};

	this.loadPage_Callback = function() {	
		this.pDiv.innerHTML = this.pAjax.xmlhttp.responseText;
		this.pDiv.style.visibility = "visible";
		
		//this.pDiv.style.top = MyScrollY() + "px";
		this.pDiv.style.top = "80px";
		this.pDiv.style.left = MyCentreX(820) + "px";
		
		this.pAjax = null;
	};
};

//////////////////////////////////////////////////////////////
// clsComments
//////////////////////////////////////////////////////////////
function clsComments() {
	var self = this;
	this.pAjax = null;
	
	// Create the layer to display results
	this.pDiv = document.createElement('div');
	this.pDiv.style.visibility = "hidden";
	this.pDiv.style.position = "absolute";
	this.pDiv.style.left = "0px";
	this.pDiv.setAttribute('id','clsCommentDiv');
	//
	var pDivAttach = getObject( 'divLayer' );
	if( pDivAttach ) {
		pDivAttach.style.visibility = 'visible';
		pDivAttach.appendChild(this.pDiv);
	}
	
	this.closeCommentAdd = function() {
		this.pDiv.style.visibility = "hidden";
	}
	
	this.loadCommentAdd = function() {	
		if( this.pAjax ) {
			alert('loadPage: Operation already in progress!');
			return false;
		}
		
		this.pAjax = new clsAJAX( '/ajax/comment_add.php' );
		this.pAjax.pComplete = function(){ self.loadCommentAdd_Callback(); };
		return this.pAjax.start();
	};
	this.loadCommentAdd_Callback = function() {	
		this.pDiv.innerHTML = this.pAjax.xmlhttp.responseText;
		this.pDiv.style.visibility = "visible";
		
		this.pDiv.style.top = MyScrollY() + 20 + "px";
		this.pDiv.style.left = MyCentreX(755) + "px";
		
		this.pAjax = null;
	};
	
	/*
	this.addComment = function() {
		if( this.pAjax ) {
			alert('addComment: Operation already in progress!');
			return false;
		}
		
		if( getObject('txtLocation').value.length == 0 ) return true;
		if( getObject('txtComment').value.length == 0 ) return true;

		this.pAjax = new clsAJAX2( '/ajax/comment_add.php?process=add', 'POST', 2 );
		this.pAjax.addParam('name', getObject('txtName').value);
		this.pAjax.addParam('location', getObject('txtLocation').value);
		this.pAjax.addParam('comment', getObject('txtComment').value);
		this.pAjax.pComplete = function(){ self.addComment_Callback(); };
		return this.pAjax.start();
	};
	this.addComment_Callback = function() {
		if( this.pAjax.xmlhttp.responseText.length > 0 ) {
			alert( this.pAjax.xmlhttp.responseText );
			this.pAjax = null;
			return false;
		}
		
		this.pAjax = null;
		this.closeCommentAdd();
	};
	*/
}