/*
---
script: Regio.js
description: Base Class
copyright: Copyright (c) 2011 REGIOCAST
authors: [Marcel Domke]

requires: 
  core:1.3.0: 
  - Array
browsers: FF,IE
...
*/

String.implement({

	sanitize: function(){
		var mystr = this;
		// Replace Whitespaces
		mystr = mystr.replace(/ +|_{2,}/g,'_');
		mystr = mystr.replace(/-/g,'_');
		// replace german special chars
		mystr = mystr.replace(/ä/g,'ae');
		mystr = mystr.replace(/Ä/g,'Ae');
		mystr = mystr.replace(/ü/g,'ue');
		mystr = mystr.replace(/Ü/g,'Ue');
		mystr = mystr.replace(/ö/g,'oe');
		mystr = mystr.replace(/Ö/g,'Oe');
		mystr = mystr.replace(/ß/g,'ss');

		return mystr;

	}

});

window.addEvent('domready', function () {

	var currentUrl = new URI(document.location.href);
	if( currentUrl.getData('firebug') == 'true' ) {
		var TmpRegio = new Regio();
		TmpRegio.getFirebug();
	}

	if(typeof(document.body.addClass) == 'function') {
		document.body.addClass('jsenabled');
	}

});

var Regio = new Class({
	
	Implements: [Options, Events],

	client: null,

	options: {
	},
	
	initialize: function(elements, options) {
		this.setOptions(options);

		if( $type(document.blankoweb_client) !== false ) {
			this.setClient(document.blankoweb_client);
		}

	},

	setClient: function ( strClient ) {
		this.client = strClient;
	},

	getClient: function () {
		return this.client;
	},

	getFirebug: function () {
		if( $chk($('firebug-light')) ) $('firebug-light').destroy();
		new Asset.javascript('https://getfirebug.com/firebug-lite.js', {id: 'firebug-light'});

	}

	
});

/* this is a static variable and you can call this like: RegioToolkit.scrollToElementPosition(); */
var RegioToolkit =  {
	scrollToElementPosition: function (element) {
		var scrollToElement = document.id(element);
		var scrollEffect = new Fx.Scroll(window);
		scrollEffect.toElement(scrollToElement);

	},
	loadYoutubeVideo: function (videoURL) {

		var Container = new Element('div', {
			'id' : 'youtube-video-embed',
			'styles': {
				'width': '520px',
				'height': '340px',
				'position': 'absolute',
				'top': document.getScroll().y + 50,
				'zIndex': '9999999',
				'padding': '5px',
				'background':'#ffffff'
			}
		});
		var width = window.getCoordinates().width;
		var left = (width-Container.getStyle('width').toInt())/2;
		
		Container.setStyle('left',left);
		new Element('iframe', {
			'src': videoURL,
			'styles': {
				'width': '520px',
				'height': '340px'
			}
		}).inject(Container);

		Container.inject(document.body,'top');


		new RegioMask();

		

	}
};
