window.addEvent('domready',function(){
$$('#menu a').addEvent('mouseover',function(){
	this.setStyle('position','relative');
	this.setStyle('top','0x');
	this.setStyle('height','34px');
})

$$('#menu a').addEvent('mouseleave',function(){
	this.setStyle('position','');
	this.setStyle('height','24px');

})

$$('.newsitem').addEvent('mouseover',function(){
			this.setStyle('color','#A40202');
			this.setStyle('');
			this.setStyle('cursor','pointer');
})

$$('.newsitem').addEvent('mouseout',function(){
			this.setStyle('color','#5A5A5A');
			this.setStyle('');
})


	
	myStretch = $$('.newsitem');
	myStretcher = $$('.newscontent');
	
	
	myStretcher.each(function(el){
		el.style.display = '';
	});
	
	
var ac = new Fx.Accordion(myStretch,myStretcher,
  {
		onActive: function(tog){
		tog.setStyle('cursor', 'help');
    },
    onBackground: function(tog){
    },
		alwaysHide: true,
		start : 'all-closed',
		opacity : true			
	});
	
$('form1').onsubmit = function(){
	$('answer').setStyle('visibility','visible');
	$('answer').addClass('wait');
	$('answer').innerHTML = "Please wait... verifying...";
	new Ajax('checkRequesting.php',{ update:'answer', data:this, method:'post', evalScripts:true }).request();
	return false;
}

$$('.ex').each(function(el){
	rel = el.getAttribute('title');
	img = new Element('img');
	img.src = rel;
	el.setAttribute('rev',el.innerHTML);
	el.setStyle('background-image','none');
	el.setStyle('padding-left','0px');
	el.innerHTML = '';
	img.setAttribute('alt',el.innerHTML);
	img.injectInside(el);
})

    	var bod = document.body;
			var width = $(bod).getCoordinates();
			width = width['width'];
			width = (width - 582) / 2;
			$('newsletter').setStyle('left',width +"px");
			$('newsletter').setStyle('position','absolute');

	$('clickme').addEvent('click',function(){
	height = $('bg_news').getStyle('height').toInt();

		if(height == 0){

			$('bg_news').effect('height', { duration: 800, wait:true, transition:Fx.Transitions.Bounce.easeOut }).chain(function(){
			$('contents_newsletter').setStyle('display','block');
			$('answer2').setStyle('display','block');
			}).start('0','130');
		}else{
			$('contents_newsletter').setStyle('display','none');
			$('answer2').setStyle('display','none');
			$('bg_news').effect('height', { duration: 1000, wait:true, transition:Fx.Transitions.Bounce.easeOut }).start('130','0');
		}
	})

	$('form2').addEvent('submit', function(e) {
	new Event(e).stop();
 	var log = $('bg_news').addClass('ajax_loading');
 	new Ajax('check.php', {
			method: 'post',
			update: 'answer2',
			data: this,
			evalScripts:true,
			onComplete: function() {
				log.removeClass('ajax_loading');
			}
		}).request();
	});

})

