// counters

var Countable = new Class({
initialize: function(inputId, options) {
this.setOptions($merge(this.indexOptions, options));
var input = $(inputId);
if(input){
this.handle = new Element('p', {'class': 'charscounter'});
this.handle.setHTML('&nbsp;').injectBefore(input);
input.addEvent('keydown', this.onKeyPress.bindWithEvent(this));
input.addEvent('keyup', this.onKeyPress.bindWithEvent(this));
this.input = input;
}
},
onKeyPress: function(event) {
event = new Event(event);
if(!event.shift && !event.control && !event.alt && !event.meta) {
this.update();
}
},
update: function() {
if (this.input.value.length > this.options.maximum) {
this.input.value = this.input.value.substring(0, this.options.maximum);
}
if (this.input.value.length > (this.options.maximum - this.options.offset)) {
var count = this.options.maximum - this.input.value.length;
if (count == 0) {
var string = 'CARATTERI ESAURITI';
} else if (count == 1) {
var string = '<em>1</em> CARATTERE RIMANENTE';
} else {
var string = '<em>' + count + '</em> CARATTERI RIMANENTI';
}
this.handle.setHTML(string);
}
}
});
Countable.implement(Options.prototype);


// domready

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

// tips

var tips = new Tips($$('.tips'), {
initialize:function(){
this.fx = new Fx.Style(this.toolTip, 'opacity', {duration: 500, wait: false}).set(0);
},
onShow: function(toolTip) {
this.fx.start(1);
},
onHide: function(toolTip) {
this.fx.start(0);
}
});


// shoutbox commercio

$('shoutform').addEvent('submit', function(e){
new Event(e).stop();
var updateshout = $('shoutbox');
var shoutwait = updateshout.empty().addClass('wait');
this.send({
evalScripts: true,
update: shoutwait,
onComplete: function(){		
new Ajax('shoutupdate.php', {
method: 'get',
update: $('shoutbox')
}).request();				
shoutwait.removeClass('wait');
return;
//MOOdalBox.scanAnchors('shoutbox a', boolForceInsideMOOdalBox);		
}		
});
});


// password reminder

if($("reminder")){
$('reminder').addEvent('click', function(re) {			
geturl = this.getProperty('href');
splitting = geturl.split('?');
vars = splitting[1];
new Event(re).stop();
var loadevent = $('console').empty().addClass('wait');
new Ajax('profile.php', {
method: 'get',
postBody: vars,
update: $('console'),
onComplete: function() {
loadevent.removeClass('wait');
}
}).request();
});
};


// counters
new Countable("shoutmess", {maximum: 160, offset: 161});
new Countable("mixname", {maximum: 24, offset: 25});


// slidebox
myShow = new Slideshow('slidebox', { type: 'pan', duration: [3000, 6000], width: 908, height: 309, images: ['slidecomm_a.jpg', 'slidecomm_b.jpg', 'slidecomm_c.jpg'], hu: 'assets/images/slidebox/' });

});
