var CP={
	init:function(){
		Tabs.init($(".panels"));
	}
}

var Tabs={
	container:null,
	panels:Array(),
	
	init:function(container){
		Tabs.container=$(container);
		
		$('.panel',Tabs.container).each(function(i){
			var newPanel = {};
			newPanel.element = this;
			newPanel.id = this.id;
			newPanel.index = i;
			newPanel.padding_correction = (i * 1.5) + i;
			Tabs.panels[i] = newPanel;
		})
		Tabs.showPanel(Tabs.panels[0]);
	},
	
	showNextPanel:function(){
		if (Tabs.activePanelIndex<(Tabs.panels.length-1)){
			nextIndex=Tabs.activePanelIndex+1;
		}else{
			nextIndex=0;
		}
		Tabs.showPanel(Tabs.panels[nextIndex]);
	},
	
	showPreviousPanel:function(){
		if (Tabs.activePanelIndex>(0)){
			nextIndex=Tabs.activePanelIndex-1;
		}else{
			nextIndex=Tabs.panels.length-1;
		}
		Tabs.showPanel(Tabs.panels[nextIndex]);
	},	
	
	showPanel:function(panel){
		var l = ( ($(".tab-container")[0].clientWidth)*panel.index ) + panel.padding_correction;
		Tabs.container.animate({left:"-"+l+"px"},"slow","easeboth");
		Tabs.activePanelIndex=panel.index;
	}
}

function expand_image(property_id, current_image_id, image_src){
    if ($("#expanded_image_overflow")[0]){
        $("#expanded_image_overflow")[0].innerHTML = '<a href="#" onclick="MyWindow=window.open(\'http://www.megvanamstel.com/inmoeasy/en/akelos/view_property_images/id/'+property_id+'/current/'+current_image_id+'\', \'MyWindow\', \'directories=0,height=630,left=5,location=0,menubar=0,resizable=1,scrollbars=1,status=0,toolbar=0,top=5,width=990,titlebar=0\'); return false;"><img src="'+image_src+'" /></a>';
    }
}


$(document).ready(function(){
    CP.init();
});