/**
* Script für verschiedene klein Funktionen
* @version 2012-01-13
*/

function togIxt(id, subid) {
	if ($(id)._isClosed) {
		$(id).removeClassName('ixtshow');
		$(subid).appear({ duration: 0.3 });
	} else {
		$(id).addClassName('ixtshow');
		$(subid).fade({ duration: 0.3 });
	}
	$(id)._isClosed = !$(id)._isClosed
}


// Google Plus Script
window.___gcfg = {lang: 'de'};

(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/plusone.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();

function showSearchAgentWindow(p) {
	new Ajax.Request('/', {
			parameters: {
				action:	'urlaubswerksearchagents',
				mode:	'showFormAjax',
				p:		p
			},
			evalScripts: true,
			onComplete: function(transport) {
				if ($('searchAgentWindow') != null) $('searchAgentWindow').remove();
				$$('body')[0].insert({bottom: transport.responseText});
				showSearchWindow('searchAgentWindow', true);
			}
		});
}

function showRecommendationWindow(p) {
	new Ajax.Request('/', {
			parameters: {
				action:	'urlaubswerkrecommend',
				mode:	'showInvitationFormAjax',
				type:	'trip',
				p:		p
			},
			evalScripts: true,
			onComplete: function(transport) {
				if ($('recommendationWindow') != null) $('recommendationWindow').remove();
				$$('body')[0].insert({bottom: transport.responseText});
				showSearchWindow('recommendationWindow', true);
			}
		});
}

var nrjAudio;

function playNRJ() {
	if (nrjAudio == null) {
		$('nrj').addClassName('playing');
		
		nrjAudio = new Audio();
		document.body.appendChild(nrjAudio);
		
		nrjAudio.src = '/templates/uw/nrj.' + ((nrjAudio.canPlayType("audio/ogg").match(/maybe|probably/i)) ? 'ogg' : 'mp3');
		
		nrjAudio.play();
		
		nrjAudio.addEventListener('ended', function() {
			$('nrj').removeClassName('playing');
		}, false);
	} else if (nrjAudio.paused) {
		$('nrj').addClassName('playing');
		nrjAudio.play();
	} else {
		$('nrj').removeClassName('playing');
		nrjAudio.pause();
	}
}

// aus hotel_info.tpl
function togNote(id) {
	Effect.toggle(id, 'appear', { duration: 0.2 });
	return false;
}

