var sfvv = {
	privacyTrans: undefined,
	additionalTrans: undefined,

	init: function () {
		if ($('ah')) {
			if (!$('ah').get('checked')) {
				//$('extra').getElement('ol').getLast().setStyles({'height': 0, 'overflow': 'hidden', 'display': 'block'});
				$('message').getParent().setStyles({'height': 0, 'overflow': 'hidden', 'display': 'block'});
			}

			$('ah').addEvent('click', this.showHideMessage.bind(this));
		}
/*
		if ($('privacy')) {
			$('privacy').setStyles({'height': 0, 'overflow': 'hidden', 'zoom': '1'});
			$$('#sendbtn a').addEvent('click', this.showHidePrivacy.bind(this));
		}
*/

		if ($('privacy'))
			this.privacyTrans    = new Fx.Tween($('privacy'), {property: 'height'});

		if ($('message'))
			this.additionalTrans = new Fx.Tween($('message').getParent(), {property: 'height'});

		if ($('join') && $('join').getElement('.feedback-error')) {
			$('join').getElement('.feedback-error').scrollIntoView(true);
		}

		if ($('show-message')) {
			$('show-message').addEvent('click', this.showEmail.bind(this));
		}
		
		if ($('show-privacymessage')) {
			$('show-privacymessage').addEvent('click', this.showPrivacy.bind(this));
		}
	},

	showHidePrivacy: function () {
		var newHeight;

		if ($('privacy').getSize().y == 0) {
			$('privacy').setStyles({'height': 'auto',	'overflow': 'auto'});

			newHeight = $('privacy').getSize().y;

			$('privacy').setStyles({'height': 0, 'overflow': 'hidden'});

			this.privacyTrans.start(0, newHeight);
		} else {
			this.privacyTrans.start($('privacy').getSize().y, 0);
		}
	},

	showHideMessage: function () {
		var newHeight, element;

		element = $('message').getParent();

		if (element.getSize().y == 0) {
			element.setStyles({'height': 'auto', 'display': 'block'});
			newHeight = element.getSize().y;
			element.setStyles({'height': 0, 'display': 'block', 'overflow': 'hidden'});

			this.additionalTrans.start(0, newHeight);
		} else {
			this.additionalTrans.start(element.getSize().y, 0);
		}
	},

	showEmail: function () {
		features = 'channelmode=no,directories=no,fullscreen=no,height=500,width=560,left=200,top=200,location=no,menubar=no,resizeable=no,scrollbars=yes,status=no,toolbar=no';
		window.open('/mailmessage.html', '_blank', features);
	},
	
	showPrivacy: function () {
		features = 'channelmode=no,directories=no,fullscreen=no,height=350,width=560,left=200,top=200,location=no,menubar=no,resizeable=no,scrollbars=yes,status=no,toolbar=no';
		window.open('/privacymessage.html', '_blank', features);
	}
}

window.addEvent('domready', sfvv.init.bind(sfvv));