$(function() {

	// init lightbox
	
	$('#thumbs a').lightBox(); 
				
	// auto tab box

	if ( $("div.autotabbox").length > 0 ) {
		var tabaContainers = $('div.autotabitem');
		tabaContainers.hide().filter(':first').show();
			
		$('div.autotabbox ul li a').click(function () {
			tabaContainers.hide();
			tabaContainers.filter(this.hash).show();
			$('div.autotabbox ul li').removeClass('selected');
			$(this).addClass('selected').blur();
			$(this).parent().addClass('selected').blur();
			return false;
		}).filter(':first').click();
	}

	// tab box
	// solution for correct viewing of google maps

	if ( $("div.tabbox").length > 0 ) {
		var tabContainers = $('div.tabitem');
		tabContainers.addClass("tabhide").filter(':first').removeClass("tabhide");
			
		$('div.tabbox ul li a').click(function () {
			tabContainers.addClass("tabhide");
			tabContainers.filter(this.hash).removeClass("tabhide");
			$('div.tabbox ul li').removeClass('selected');
			$(this).addClass('selected').blur();
			$(this).parent().addClass('selected').blur();
			return false;
		}).filter(':first').click();
	}


	fShowMore = function(o)
	{
		var aC = o.parentNode.parentNode.getElementsByTagName('div');
		var vCName;
		var oDiv;

		// Remove more Button
		o.style.display = "none";
		// process each Div
		for (var i = 0; i < aC.length; i++)
		{
			oDiv = aC[i];
			vCName = oDiv.className;
			// handle only div hide
			if ( ! vCName.match(/hide/) ) continue;
			if ( (oEm = oDiv.getElementsByTagName('em')[0]) )
			{
				var oImg = new Image;
				oImg.src = oEm.firstChild.nodeValue;
				oEm.parentNode.replaceChild(oImg, oEm);
			}
			oDiv.className = vCName.replace(/hide/g,'');
		}
		return true;
	}

	// column sync
	
	//vah = $('#navAlpha').height(); 
	//vph = $('#panorama').height(); 
	//vch = $('.content').height();
	//if ( $("#ibookingpack").length > 0 ) {
	//	$('.content').height("3010px");
	//} else if (vah>(vch+vph+82)) {
	//	$('.content').height(vah-vph-82+30+"px");
	//}	


	// show top sliding panel

	if ( $("#navTools a").length > 0 ) {
			
		$('#navTools a').click(function () {
			var cmsBrand = $("#wrapper").attr('class');
			var cmsInc = '';
			
			if 		(cmsBrand == 'dtravelhouse') 	{ cmsInc = '1719'; }
			else if (cmsBrand == 'dafricantrails') 	{ cmsInc = '2114'; }
			else if (cmsBrand == 'dcaribtours') 	{ cmsInc = '2396'; }
			else if (cmsBrand == 'dfalcontravel') 	{ cmsInc = '6742'; }
			else if (cmsBrand == 'dinditours') 		{ cmsInc = '1711'; }
			else if (cmsBrand == 'doceanstar') 		{ cmsInc = '6749'; }
			else if (cmsBrand == 'dsalinatours') 	{ cmsInc = '6744'; }
			else if (cmsBrand == 'dsierramar') 		{ cmsInc = '6745'; }
			else if (cmsBrand == 'dskytours') 		{ cmsInc = '6746'; }
			else if (cmsBrand == 'dsoleytours') 	{ cmsInc = '6747'; }
			else if (cmsBrand == 'dwettstein') 		{ cmsInc = '6748'; }
			else if (cmsBrand == 'dflugshop') 		{ cmsInc = '6743'; }

			$('#topNav').load('/includes/cmsfiles/f'+cmsInc+'.html').slideDown();
			$('#topNavClose').addClass("showit");
			
			return false;
		});
		
		// Close Editor
		$("#topNavClose").click(function(){
			$(this).removeClass("showit");
			$("#topNav").slideUp(); 
		});
		
		
	}


});
