/*
Position
 - x,y
 - transition (N,W,S,E)
 - preloadlist
 
*/


function Position(x,y,preloadList){
	this.x = x,
	this.y = y,
	this.preloadList = preloadList,
	this.transitions = {N:null,W:null,S:null,E:null},
	this.addTransition = function(direction, position){
		eval('this.transitions.'+direction+' = position;');
	},
	this.preloadImages = function(){
		this.preloadListImpl = new Array(this.preloadList.length);
		for(i=0;i<this.preloadList.length;i++){
			this.preloadListImpl[i] = new Image();
			this.preloadListImpl[i].src = this.preloadList[i];
		}
	}
	
}




var timer = null;
var timerRunning = false;




Map = {
	currentPosition:null,
	goN:function(){
		this.executePosition(this.currentPosition.transitions.N);
	},
	goS:function(){
		this.executePosition(this.currentPosition.transitions.S);
	},
	goW:function(){
		this.executePosition(this.currentPosition.transitions.W);
	},
	goE:function(){
		this.executePosition(this.currentPosition.transitions.E);
	},
	executePosition:function(position){
		this.currentPosition = position;
		$('#mapsurrogate').animate({top:position.y,left:position.x},'fast','linear',function(){Map.currentPosition.preloadImages();});
		if(position.transitions.N !== null){
			$('#arrowN').show();
		}else{
			$('#arrowN').hide();
		}
		
		if(position.transitions.W !== null){
			$('#arrowW').show();
		}else{
			$('#arrowW').hide();
		}
		
		if(position.transitions.E !== null){
			$('#arrowE').show();
		}else{
			$('#arrowE').hide();
		}
		
		if(position.transitions.S !== null){
			$('#arrowS').show();
		}else{
			$('#arrowS').hide();
		}
	}
}


