var PropertyMarker = new Class ({

initialize: function(options){
	options = $merge({
		'tabDivName':'tab1',		
		'idAddress':'div_panel_address',
		'idUnitPrice':'div_panel_unitprice',
		'idTotalPrice':'div_panel_totalprice',
		'idMainImg':'div_panel_main_img',
		'idClose': 'div_closer',
		'bt_detail':'bt_detail',
		'onClose': Class.empty,
		'onDetail': Class.empty,
		'idNavigation':'navarrow',		
		'maxOfTab': 3		 
	}, options);
		
	this.tabDivName = options.tabDivName;
	this.tabMarker = Class.empty;
	this.idAddress = options.idAddress;
	this.idUnitPrice = options.idUnitPrice;
	this.idTotalPrice = options.idTotalPrice;
	this.idMainImg = options.idMainImg;
	this.idNavigation = options.idNavigation;
	this.idClose = options.idClose;
	this.onClose = options.onClose;
	this.onDetail = options.onDetail;
	this.maxOfTab = options.maxOfTab;	
	this.src = '/images/inplace/no_foto.jpg';
	this.bt_detail = options.bt_detail;
	this.active = 0;
	this.tabMarker = new TabMarker( { tabDivName:this.tabDivName, 'maxOfTab':this.maxOfTab, onChange: this.onChange.bind(this) });	
//	window.addEvent('load', this.init.bind(this));
},

onChange: function(active){
	this.changeInfo(active);
	
},

init: function(){	
	this.initEvent();
	this.tabMarker.init();
	
},

initEvent: function(){
	$(this.idClose).addEvent('click', this.Close.bind(this));
	$(this.bt_detail).addEvent('click', this.detailClick.bind(this));
},
changeInfo: function(active){	
	this.active = active;	
	$(this.idAddress).innerHTML = this.propertyList[active].address.googleAddress;
	if(this.propertyList[active].unitPrice.htmlPrice == "&pound;0"){
		$(this.idUnitPrice).innerHTML = "&pound;TBC";
		$(this.idTotalPrice).innerHTML = "";	
	}else{
		$(this.idUnitPrice).innerHTML = this.propertyList[active].unitPrice.htmlPrice;
		$(this.idTotalPrice).innerHTML = "("+this.propertyList[active].totalPrice.htmlPrice+")";	
	}
	if(this.propertyList[active].mainRoom!=null) {		
		$(this.idMainImg).src = this.propertyList[active].mainRoom.smallThumbnail.webPath;
	} else {		
		$(this.idMainImg).src = this.src;
	}
},

moveTabRight: function(){
	this.tabMarker.moveTabRight();
},

moveTabLeft: function(){
	this.tabMarker.moveTabLeft();
},

setPropertyList: function(newPropertyList){
	this.propertyList = newPropertyList;
	if(this.propertyList.length>this.maxOfTab) {
		$(this.idNavigation).setStyle('display', 'block');
	}else{
		$(this.idNavigation).setStyle('display', 'none');
	}
	this.tabMarker.setTabList(newPropertyList);
	this.changeInfo(0);
},

Close: function(){
	this.onClose();
},

detailClick: function(){
	this.onDetail(this.propertyList[this.active].id);

}

});
