var createTopic,windows,layer,entrarValidator;
var formShow = false;

var entrarValidator;
var entrar = function(e){
	if(!entrarValidator.test()){
		new Event(e).stop();
		entrarValidator.showInvalid(true);
	}
}

var showTopicForm = function(){
	var sizes = $('cont2').getCoordinates();
	createTopic.setStyles({
		'top':sizes.top+'px',
		'left':sizes.left+'px',
		'width':'760px',
		'height':(sizes.height-155)+'px'
	});
	layer.setStyles({
		'opacity':'.7',
		'height':(sizes.height-155)+'px'
	});

	createTopic.removeClass('hidden');
	
}

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

	new sIFR('#cont2 h1','css/italic.swf',{fontSize:16,shadowColor: 'ffffff',shadowDistanceX: 0,	shadowDistanceY: 0});
	if(Browser.Engine.trident4){
		$$('#cont3 tbody tr').addEvents({
			'mouseenter':function(){
				this.addClass('hover');
			},
			'mouseleave':function(){
				this.removeClass('hover');
			}
		})
	}
	createTopic = $('createtopic');
	windows = $('window');
	layer = $('layer');
	if(createTopic){
		createTopic.inject(document.body);
		entrarValidator = new iValidator(createTopic.getElements('textarea, input[type=text]'));
		createTopic.getElement('form').addEvent('submit',entrar);
		
		$$('a.new').addEvent('click',function(e){
			new Event(e).stop();
			showTopicForm();
		});
		
		createTopic.getElement('input[type=button]').addEvent('click',function(){
			createTopic.addClass('hidden')
		});
		
		if(postReplyAction){
			showTopicForm();
		}
	}
});