//var descId = 'sunDesc';
//var descTypeId = '';
//
//var infos = {
//	'sunDesc_superiorJuniorSuite': {
//		'left':100,
//		'top':-120,
//		'image':'images/volgadream/accomodations/cabins/1.jpg',
//		'header':'Superior Junior Suite',
//		'text':'<p><b>Cabin size:</b> 15.1 to 15.8 sq m 163 to 170 sq ft</p><p><b>Bed:</b> 1 Double, 180X200 cm 71X79 inches</p><p><b>Additional furniture:</b> Wadrobe, Minibar, Safe Box, Sofa, Chair, Desk</p>'
//	},
//	'sunDesc_juniorSuite': {
//		'left':60,
//		'top':-120,
//		'image':'images/volgadream/accomodations/cabins/1.jpg',
//		'header':'Superior Junior Suite',
//		'text':'<p><b>Cabin size:</b> 15.1 to 15.8 sq m 163 to 170 sq ft</p><p><b>Bed:</b> 1 Double, 180X200 cm 71X79 inches</p><p><b>Additional furniture:</b> Wadrobe, Minibar, Safe Box, Sofa, Chair, Desk</p>'
//	},
//	'sunDesc_superiorStateroom': {
//		'left':0,
//		'top':-120,
//		'image':'images/volgadream/accomodations/cabins/1.jpg',
//		'header':'Superior Junior Suite',
//		'text':'<p><b>Cabin size:</b> 15.1 to 15.8 sq m 163 to 170 sq ft</p><p><b>Bed:</b> 1 Double, 180X200 cm 71X79 inches</p><p><b>Additional furniture:</b> Wadrobe, Minibar, Safe Box, Sofa, Chair, Desk</p>'
//	},
//	'sunDesc_deluxeSingle': {
//		'left':-40,
//		'top':-90,
//		'image':'images/volgadream/accomodations/cabins/1.jpg',
//		'header':'Superior Junior Suite',
//		'text':'<p><b>Cabin size:</b> 15.1 to 15.8 sq m 163 to 170 sq ft</p><p><b>Bed:</b> 1 Double, 180X200 cm 71X79 inches</p><p><b>Additional furniture:</b> Wadrobe, Minibar, Safe Box, Sofa, Chair, Desk</p>'
//	},
//	'promenadeDesc_juniorSuite': {
//		'left':-10,
//		'top':-85,
//		'image':'images/volgadream/accomodations/cabins/1.jpg',
//		'header':'Superior Junior Suite',
//		'text':'<p><b>Cabin size:</b> 15.1 to 15.8 sq m 163 to 170 sq ft</p><p><b>Bed:</b> 1 Double, 180X200 cm 71X79 inches</p><p><b>Additional furniture:</b> Wadrobe, Minibar, Safe Box, Sofa, Chair, Desk</p>'
//	},
//	'promenadeDesc_ownerSuite': {
//		'left':295,
//		'top':-115,
//		'image':'images/volgadream/accomodations/cabins/1.jpg',
//		'header':'Superior Junior Suite',
//		'text':'<p><b>Cabin size:</b> 15.1 to 15.8 sq m 163 to 170 sq ft</p><p><b>Bed:</b> 1 Double, 180X200 cm 71X79 inches</p><p><b>Additional furniture:</b> Wadrobe, Minibar, Safe Box, Sofa, Chair, Desk</p>'
//	},
//	'promenadeDesc_deluxeStateroom': {
//		'left':0,
//		'top':-120,
//		'image':'images/volgadream/accomodations/cabins/1.jpg',
//		'header':'Superior Junior Suite',
//		'text':'<p><b>Cabin size:</b> 15.1 to 15.8 sq m 163 to 170 sq ft</p><p><b>Bed:</b> 1 Double, 180X200 cm 71X79 inches</p><p><b>Additional furniture:</b> Wadrobe, Minibar, Safe Box, Sofa, Chair, Desk</p>'
//	},
//	'promenadeDesc_single': {
//		'left':-215,
//		'top':-120,
//		'image':'images/volgadream/accomodations/cabins/1.jpg',
//		'header':'Superior Junior Suite',
//		'text':'<p><b>Cabin size:</b> 15.1 to 15.8 sq m 163 to 170 sq ft</p><p><b>Bed:</b> 1 Double, 180X200 cm 71X79 inches</p><p><b>Additional furniture:</b> Wadrobe, Minibar, Safe Box, Sofa, Chair, Desk</p>'
//	},
//	'mainDesc_superiorStateroom': {
//		'left':0,
//		'top':-140,
//		'image':'images/volgadream/accomodations/cabins/1.jpg',
//		'header':'Superior Junior Suite',
//		'text':'<p><b>Cabin size:</b> 15.1 to 15.8 sq m 163 to 170 sq ft</p><p><b>Bed:</b> 1 Double, 180X200 cm 71X79 inches</p><p><b>Additional furniture:</b> Wadrobe, Minibar, Safe Box, Sofa, Chair, Desk</p>'
//	},	
//	'cabinDesc_standardStateroom': {
//		'left':0,
//		'top':-140,
//		'image':'images/volgadream/accomodations/cabins/1.jpg',
//		'header':'Superior Junior Suite',
//		'text':'<p><b>Cabin size:</b> 15.1 to 15.8 sq m 163 to 170 sq ft</p><p><b>Bed:</b> 1 Double, 180X200 cm 71X79 inches</p><p><b>Additional furniture:</b> Wadrobe, Minibar, Safe Box, Sofa, Chair, Desk</p>'
//	}					
//}

$(document).ready(function(){
	$('#rightMenu>ul>li>a').click(function()
	{	
		freeDescTypes();			
		descId = $(this).parent().attr('id').replace('rightMenu_','');
		curDeck = descId.replace('Desc', '');
		$('#profileImage').attr('src', '/images/volgadream/accomodations/cabins/profile/' + curDeck +'.png');
		showDesc();	
		return false;				
	});	
	$('table.descTypeTable').mouseover(function()
	{	
		//freeDescTypes();
		var tmpDescId = $(this).attr('id').replace('Table','');
		if (tmpDescId != descId) {
			descId = $(this).attr('id').replace('Table', '');
			showDesc();
		}
	});		
	showDesc();
});

var showDesc = function()
{
	//processProfile();
	processDesc();	
	processTable();	
}

var processProfile = function()
{
	freeAllProfiles();	
	$('#'+descId+'Profile').css('visibility','visible');	
}

var freeAllProfiles = function()
{
	$('div.profileHover').css('visibility','hidden');	
}


var processDesc = function()
{
	freeAllDescs();	
	$('#rightMenu>ul>li#rightMenu_'+descId+'>a').addClass('current');	
	$('#pageBnBlock2>ul>li.'+descId).show();
	processDescTypes();
}

var freeAllDescs = function()
{
	descTypeId = '';
	$('#rightMenu>ul>li>a').removeClass('current');
	$('#pageBnBlock2>ul>li').hide();	
}

var processDescTypes = function() 
{
	var descTypes = $('li.'+descId+'>div[class^="'+descId+'_hover_"]');
	descTypes.bind("mouseenter", function()
	{
		var tmpDescTypeId=$(this).attr('class').replace(descId+'_hover_','').replace(/_[0-9]/,'');
		//if (tmpDescTypeId != descTypeId) {
			descTypeId = tmpDescTypeId;
			showDescType();
		//}
	});
	descTypes.click(function() {
		processLink();
	});
	
	descTypes.bind("mouseleave", function()
	{	
		hideDescType();			
	});		
}

var processDescType = function() 
{
	freeDescTypes();
	curDeck = descId.replace('Desc', '');
	$('#profileImage').attr('src', '/images/volgadream/accomodations/cabins/profile/' + curDeck +'.png');
	$('div.'+descId+'_bg_'+descTypeId).css('visibility','visible');
	$('td#'+descTypeId).parent().addClass('active');	
}

var freeDescTypes = function()
{
	$('div[class^="'+descId+'_bg_"]').css('visibility','hidden');
}

var showDescType = function()
{
	processDescType();
	processInfo();
}

var hideDescType = function()
{
	$('div.'+descId+'_bg_'+descTypeId).css('visibility','hidden');
	$('#info').css('visibility','hidden');
	$('td#'+descId+'Types_'+descTypeId).parent().removeClass('active');	
	//descTypeId = '';				
}

var processTable = function() 
{
	freeAllTables();	
	$('#'+descId+'Table').addClass('current');
	$('table.current tr.typeData').bind("mouseenter", function()
	{
		parentTable = $(this).parents('table.descTypeTable').eq(0);
		if (parentTable.hasClass('current')) {
			descId = parentTable.attr('id').replace('Table', '');
			var tmpDescTypeId = $(this).find('td').eq(0).attr('id');
			//if (tmpDescTypeId != descTypeId) {				
				descTypeId = tmpDescTypeId;
				processDescType();
			//}
		}		 						
	});
	
	$('table.current tr.typeData').bind("mouseleave", function()
	{
		$(this).removeClass('active');
		hideDescType();		
	});	
	$('table.current tr.typeData').click(function()
	{
		location.href=$(this).attr('rel');
	});		
};
var freeAllTables = function() 
{
	$('.descTypeTable').removeClass('current');
};

var processInfo = function()
{
	var id = descId+'_'+descTypeId;
	if (infos && infos[id])
	{
		$('#infoImage>img').attr('src', infos[id]['image']);
		$('#infoDescHeader').html(infos[id]['header']);
		$('#infoDescText').html(infos[id]['text']);		
		$('#info').css('top',infos[id]['top']+'px');
		$('#info').css('left',infos[id]['left']+'px');		
		$('#info').css('visibility','visible');
	}			
}

var processLink = function() {
	var id = descId+'_'+descTypeId;
	if (infos && infos[id]) {
		window.location.href = '/cruise/accommodations/item' + infos[id]['id'] + '.html';		
	}
}

