﻿// common.js

//Shadowbox.init();

if(typeof jQuery != 'undefined') {
	
	// typo3 backend shortcut
	$(document).ready(function() {
		$(document).keyup(function(e) {
			if(e.which == 113)
				window.open('http://' + document.URL.split('/')[2] + '/typo3/');
		});
	});
	
	// load soundmanager
	if(typeof soundManager != 'undefined') {
		soundManager.url = '/fileadmin/web/scripts/libraries/soundmanager/swf/';
		soundManager.debugMode = false;
		soundManager.flashVersion = 9;    
		
		soundManager.defaultOptions = {
			'autoLoad': true,		// enable automatic loading (otherwise .load() will call with .play())
			'stream': true,			// allows playing before entire file has loaded (recommended)
			'multiShot': false		// let sounds "restart" or "chorus" when played multiple times
		}
		
		soundManager.onload = function() {
			if(soundManager.debugMode == true)
				alert('You have to define the function "soundManager.onload()" to enable sound features.');
		}
	}
	
	// default window opener (external)
	$(document).ready(function() {
		$('a[rel~=external]').click(function() {
			relation = $(this).attr('rel');
			
			if($(this).attr('href')) {
				options = '';
				
				address = $(this).attr('href');
				
				if(relation.match(/\[([0-9]{2,4})\,([0-9]{2,4})\]/)) {
					options += '';
					
					size = relation.split('[');
					size = size[1].replace(/\]/, '');
					size = size.split(',');
					
					options += 'width=' + size[0] + ', height=' + size[1] + ',left=200,top=200';
				}
				
				window.open($(this).attr('href'), '', options);
				
				return false;
			}
		});
	});
	
	/*
	// media window opener (media)
	$(document).ready(function() {
		$('a[rel~=media]').live('click', function() {
			if($(this).attr('href')) {
				address = $(this).attr('href');
				
				(function() {
					Shadowbox.__isLoaded = false;
					Shadowbox.__onLoad = function() {};
					var load = Shadowbox.load;
					Shadowbox.load = function() {
						load();
						Shadowbox.__isLoaded = true;
						Shadowbox.__onLoad();
					};
					var open = Shadowbox.open;
					Shadowbox.open = function(options) {
						Shadowbox.__isLoaded ? open(options) : Shadowbox.__onLoad = function() { open(options) };
					}
				})()
				
				Shadowbox.open({
					content: address
				});
				
				return false;
			}
		});
	});
	*/
}
