window.addEvent('domready', function(){
	// -----------
		/*
			Common logics
		*/


		try {
			// release lang switchers
			$$('a[rel=changelang]').addEvent('click', function(){
				var url = this.get('href');
				var prefix = '&';
				if ( url.indexOf("?") == -1)
					prefix = '?';
				window.location = url + prefix + '_changedef_=1';
				return false;
			});
		} catch(e) {}


		try {
			// embed FLASH movies from '<img alt="flash" src="/flash/[...].swf" />' tag into parent element
			$$('img.swiff').each(function(o){
				if(Browser.Plugins.Flash.version && o.get('alt')) {
					if (o.get('width') && o.get('width') > 0) width = o.get('width');
						else width = '100%';
					if (o.get('height') && o.get('height') > 0) height = o.get('height');
						else height = '100%';
		
					// let's embed it 
					o.movie = new Swiff(o.get('alt'), {
						'width': width,
						'height': height,
						'container': o.getParent(),
						'params': {
							'wMode': 'transparent',
							'allowfullscreen': 'always'
						}
					});
				} else if (o.get('longdesc')) {
					o.setStyle('cursor', 'pointer')
					 .addEvent('click', function(){
						window.location.href = o.get('longdesc');
					 });
				};
				return this;
			});
		} catch(e) {}


		try {
			// release UI LINKS
			$$('a.ui').addEvent('click', function(){
				if (this.get('rel') === 'submit') {
					this.getParent('form').submit();
					return false;			
				} else if (this.get('rel') === 'reset') {
					this.getParent('form').reset();
					return false;
				} else {
					return true;
				}
			});
		} catch(e) {}


		try {
			// release BUTTON as LINKS
			$$('button.ui-link').addEvent('click', function(){
				window.location.href = this.get('name');
				return false;
			});
		} catch(e) {}


		try {
			// release NEW WINDOWED links
			$$('a[rel=new]').each(function(o){
				o.set('target', '_blank');
			});
		} catch(e) {}


		// release autovalue inputs
		try {
			$$('input.autovalue, textarea.autovalue').each(function(o){
				o.store('defaultValue', o.get('value'));
				o.addEvents({
					'focus': function(){
						if( this.get('value') === this.retrieve('defaultValue'))
							this.set('value', '');
						return false;
					},
					'blur': function(){
						if( this.get('value') === '')
							this.set('value', this.retrieve('defaultValue'));
						return false;
					}
				});
				return this;
			});
		} catch(e) {console.log(e);}
		
		

		/*
			Aimed logics
		*/
		try {
			// release twitter
			if ( $('twitter-vat') ) {
				new TWTR.Widget({
					id: 'twitter-vat',
					version: 2,
					type: 'profile',
					rpp: 3,
					interval: 6000,
					width: '100%',
					height: 300,
					theme: {
						shell: {
							background: '#e5e5e5',
							color: '#6cb90b'
							},
						tweets: {
							background: '#e5e5e5',
							color: '#f00',
							links: '#6cb90b'
							}
						},
					features: {
					scrollbar: false,
					loop: false,
					live: false,
					hashtags: true,
					timestamp: true,
					avatars: false,
					behavior: 'all'
					}
				}).render().setUser('SLGlobalService').start();
			}
		} catch(e) {}


	// -----------
});
