//Copyright (c) 2008-2009 Andrea Novero
var slide;var slideon;var periodical;window.addEvent('domready',page_loaded);function page_loaded(){$('f_login').addEvent('submit',invia_login);avvia_slide();avvia_comm()}function avvia_slide(){slide=1;slideon=true;periodical=bsgslide.periodical(6000)}function avvia_comm(){var a=new Ticker('TickerVertical',{speed:500,delay:5000,direction:'vertical'});$('stop_scroll').addEvent('click',function(){$('play_scroll_cont').style.display='block';$('stop_scroll_cont').style.display='none';a.pause()});$('play_scroll').addEvent('click',function(){$('stop_scroll_cont').style.display='block';$('play_scroll_cont').style.display='none';a.resume()})}function bsgslide(){if(slideon){$('imgslide'+slide).fade('out');$('txtslide'+slide).fade('out');if(slide==4){slide=1}else{slide++}$('imgslide'+slide).setStyle('display');$('txtslide'+slide).setStyle('display');$('imgslide'+slide).fade('in');$('txtslide'+slide).fade('in')}}function stopslide(){slideon=!slideon;if(slideon){$('lkslide').set('text','Ferma presentazione')}else{$('lkslide').set('text','Avvia presentazione')}}function change(b){if(b=='regok')b='reg&ok=1';if(b!='home')$clear(periodical);var c=new Request({url:'index.php',method:'get',onSuccess:function(a){slideon=false;$('content').setStyle('opacity','0');$('content').set('html',a);$('content').fade('in');if(b=='home'){$('lkslide').setStyle('display');avvia_slide()}else{$('lkslide').setStyle('display','none')}if(b=='reg&ok=1')$('f_registrazione').addEvent('submit',invia_reg);if(b=='rec_pwd')$('f_recupero_password').addEvent('submit',invia_rec_pwd)}}).send('a='+b)}function invia_login(b){b.stop();if(($('login_utente').get('value')!='')&&($('pwd_utente').get('value')!='')){var c=new Request({url:$('f_login').get('action')+'?a=login',onSuccess:function(a){if(a==1){window.location="http://www.bsg08online.net/"}else{$('response').set('text',a);$('response').setStyle('color','red')}},onFailure:function(){alert('Si è verificato un errore.')}}).get($('f_login'))}}function invia_reg(b){b.stop();if(($('reg_login_utente').get('value')!='')&&($('reg_pwd_utente').get('value')!='')){var c=new Request({url:$('f_registrazione').get('action'),onSuccess:function(a){if(a!=''){$('response').set('html',a);$('response').setStyle('color','red')}else{$('response').set('html','');alert('Registrazione avvenuta con successo.\nAttendere la mail di conferma attivazione.');change('home')}},onFailure:function(){alert('Si è verificato un errore.')}}).get($('f_registrazione'))}}function invia_rec_pwd(b){b.stop();var c=$('reg_mail_utente');var d=$('reg_pwd_utente');var e=false;if(c){if($('reg_mail_utente').get('value')!='')e=true}if(d){if($('reg_pwd_utente').get('value')!='')e=true}if(e==true){var f=new Request({url:$('f_recupero_password').get('action'),onSuccess:function(a){if(a!=''){$('response').set('html',a);$('response').setStyle('color','red')}else{$('response').set('html','');if(c){alert('Le istruzioni per avere una nuova password sono state inviate al tuo indirizzo di posta.');change('home')}if(d){alert('La nuova password è stata memorizzata.');change('home')}}},onFailure:function(){alert('Si è verificato un errore.')}}).get($('f_recupero_password'))}}function verifica_login(a){var b=new Request.HTML({onRequest:function(){$('ver_login_result').set('html','Caricamento in corso...')},update:$('ver_login_result'),onFailure:function(){alert('Si è verificato un errore.')}}).get($('f_registrazione').get('action')+"?a=reg&lang=it&verifica_login=1&reg_login_utente="+$('reg_login_utente').get('value')+"&reg_mail_utente="+$('reg_mail_utente').get('value'))}function trim(a){return a.replace(/^\s+|\s+$/g,"")}function verifica_passwd(){var a=$('reg_pwd_utente').get('value');var b;if(trim(a)!=''){if(a.length<=7){$('ver_passwd_result').set('html','non sicura');$('reg_pwd_utente').setStyle('backgroundColor','#FF0000')}else{b=/[^a-zA-Z]/;if(!b.test(a)){$('ver_passwd_result').set('html','poco sicura');$('reg_pwd_utente').setStyle('backgroundColor','#FFAA00')}else{b=/[^0-9]/;if(!b.test(a)){$('ver_passwd_result').set('html','non sicura');$('reg_pwd_utente').setStyle('backgroundColor','#FF0000')}else{$('ver_passwd_result').set('html','buona');$('reg_pwd_utente').setStyle('backgroundColor','#FFFF2A');b=/^(?=(.*[a-z]){1,})(?=(.*[A-Z]){1,})(?=(.*[\d]){1,})(?=(.*[\W]){1,})(?!.*\s).{8,}$/;if(b.test(a)){$('ver_passwd_result').set('html','ottima');$('reg_pwd_utente').setStyle('backgroundColor','#00FF00')}}}}}}var Ticker=new Class({setOptions:function(a){this.options=Object.extend({speed:1500,delay:5000,direction:'vertical',onComplete:Class.empty,onStart:Class.empty},a||{})},initialize:function(c,d){this.setOptions(d);this.el=$(c);this.items=this.el.getElements('li');var w=0;var h=0;if(this.options.direction.toLowerCase()=='horizontal'){h=this.el.getSize().y;this.items.each(function(a,b){w+=a.getSize().x})}else{w=this.el.getSize().x;this.items.each(function(a,b){h+=a.getSize().y})}this.el.setStyles({position:'absolute',top:0,left:0,width:w,height:h});this.fx=new Fx.Morph(this.el,{duration:this.options.speed,onComplete:function(){var i=(this.current==0)?this.items.length:this.current;this.items[i-1].injectInside(this.el);this.el.setStyles({left:0,top:0})}.bind(this)});this.current=0;this.next()},pause:function(){$clear(mytimer);mytimer=null},resume:function(){if(mytimer==null){this.next()}},next:function(){this.current++;if(this.current>=this.items.length)this.current=0;var a=this.items[this.current];this.fx.start({top:-a.offsetTop,left:-a.offsetLeft});mytimer=this.next.bind(this).delay(this.options.delay+this.options.speed)}});
