
CD3.Behaviors({
	'body': {
		'focus:in': {
			'input[type=text]': function(){
				if (this.getValue() == this.getAttribute('title')) this.setValue('');
				this.up().style.backgroundPosition = 'left bottom';
			}
		},
		'focus:out': {
			'input[type=text]': function(){
				if (this.getValue().length == 0) this.setValue(this.getAttribute('title') || '');
				this.up().style.backgroundPosition = 'left top';
			}
		}
	},
	'input[type=submit]': {
		mouseover: function(){
			this.style.backgroundPosition = 'right bottom';
		},
		mouseout: function(){
			this.style.backgroundPosition = 'right top';
		}
	}
});



CD3.Behaviors({
	'#slide_num a:click': function (a){
		a.stop();
		
		var getBg = this.href,
			image = $('longimage');
			
			$('slide_num').select('a.selected').invoke('removeClassName', 'selected');
			this.addClassName('selected');
			
			if( image.getStyle('display') == 'none'){
				image.style.background = ' url(' + getBg  + ') no-repeat center center ';
				image.style.display = 'block';
			}else{
				image.style.background = ' url(' + getBg  + ') no-repeat center center ';
			}
			
	},
	'#playslide':function(){
		this.store('poller', poller = new PeriodicalExecuter(slideshow, 5));
	},
	'#playslide:click': function(){
		this.toggleClassName('selected');
		var poller = this.retrieve('poller');
			poller[poller.timer ? 'stop' : 'registerCallback']();
	}
});

function slideshow(){
	var container	= $('slide_num'),
		current		= container.down('a.selected').removeClassName('selected'),
		selected	= (current.up().next('dt') || container.down('dt')).down('a').addClassName('selected'),
		image 		= $('longimage'),
		image2		= $('longimage_2');
		
		if( image.getStyle('display') == 'block' ){
				image2.style.backgroundImage = 'url(' +  selected.href + ')';
				image.fade({duration: .5});
		}else{
				image.style.backgroundImage = 'url(' +  selected.href + ')';
				image.appear({duration: .5});
		}
};

CD3.Behaviors({
	'.opener': {
		mouseover: function(){
			if(this.down('div'))
			this.down('div').show();
			this.addClassName('hover');
		},
		mouseout: function(){
			if(this.down('div'))
			this.down('div').hide();
			this.removeClassName('hover');
		}
	}
});

