var checkcanc = 0;

function cancella() {
	if (!checkcanc) {
		document.imp_login.imapuser.value='';
		document.imp_login.pass.value=''
	}
	checkcanc = 1;
}

var FormValidator = new Class ({
	Implements: [Options, Events],
	options: {
		formName: '',
		campi: [],
		addTextInto: true // aggiunge il testo all'interno del box
	},
	initialize: function (options) {
		
	}
	
});

/*
Script: Tips.js
	Class for creating nice tips that follow the mouse cursor when hovering an element.

License:
	MIT-style license.
*/

var Tips = new Class({
	Implements: [Events, Options],
	options: {
		onShow: function(tip){
			tip.setStyle('visibility', 'visible');
		},
		onHide: function(tip){
			tip.setStyle('visibility', 'hidden');
		},
		showDelay: 100,
		hideDelay: 100,
		className: null,
		offsets: {x: 16, y: 16},
		fixed: false
	},
	initialize: function(){
		var params = Array.link(arguments, {options: Object.type, elements: $defined});
		this.setOptions(params.options || null);
		this.tip = new Element('div').inject(document.body);
		if (this.options.className) this.tip.addClass(this.options.className);
		var top = new Element('div', {'class': 'tip-top'}).inject(this.tip);
		this.container = new Element('div', {'class': 'tip'}).inject(this.tip);
		var bottom = new Element('div', {'class': 'tip-bottom'}).inject(this.tip);
		this.tip.setStyles({position: 'absolute', top: 0, left: 0, visibility: 'hidden'});
		if (params.elements) this.attach(params.elements);
	},
	attach: function(elements){
		$$(elements).each(function(element){
			var title = element.retrieve('tip:title', element.get('title'));
			var text = element.retrieve('tip:text', element.get('rel') || element.get('href'));
			var enter = element.retrieve('tip:enter', this.elementEnter.bindWithEvent(this, element));
			var leave = element.retrieve('tip:leave', this.elementLeave.bindWithEvent(this, element));
			element.addEvents({mouseenter: enter, mouseleave: leave});
			if (!this.options.fixed){
				var move = element.retrieve('tip:move', this.elementMove.bindWithEvent(this, element));
				element.addEvent('mousemove', move);
			}
			element.store('tip:native', element.get('title'));
			element.erase('title');
		}, this);
		return this;
	},
	detach: function(elements){
		$$(elements).each(function(element){
			element.removeEvent('mouseenter', element.retrieve('tip:enter') || $empty);
			element.removeEvent('mouseleave', element.retrieve('tip:leave') || $empty);
			element.removeEvent('mousemove', element.retrieve('tip:move') || $empty);
			element.eliminate('tip:enter').eliminate('tip:leave').eliminate('tip:move');
			var original = element.retrieve('tip:native');
			if (original) element.set('title', original);
		});
		return this;
	},
	elementEnter: function(event, element){
		$A(this.container.childNodes).each(Element.dispose);
		var title = element.retrieve('tip:title');
		if (title){
			this.titleElement = new Element('div', {'class': 'tip-title'}).inject(this.container);
			this.fill(this.titleElement, title);
		}
		var text = element.retrieve('tip:text');
		if (text){
			this.textElement = new Element('div', {'class': 'tip-text'}).inject(this.container);
			this.fill(this.textElement, text);
		}
		this.timer = $clear(this.timer);
		this.timer = this.show.delay(this.options.showDelay, this);
		this.position((!this.options.fixed) ? event : {page: element.getPosition()});
	},
	elementLeave: function(event){
		$clear(this.timer);
		this.timer = this.hide.delay(this.options.hideDelay, this);
	},
	elementMove: function(event){
		this.position(event);
	},
	position: function(event){
		var size = window.getSize(), scroll = window.getScroll();
		var tip = {x: this.tip.offsetWidth, y: this.tip.offsetHeight};
		var props = {x: 'left', y: 'top'};
		for (var z in props){
			var pos = event.page[z] + this.options.offsets[z];
			if ((pos + tip[z] - scroll[z]) > size[z]) pos = event.page[z] - this.options.offsets[z] - tip[z];
			this.tip.setStyle(props[z], pos);
		}
	},
	fill: function(element, contents){
		(typeof contents == 'string') ? element.set('html', contents) : element.adopt(contents);
	},
	show: function(){
		this.fireEvent('show', this.tip);
	},
	hide: function(){
		this.fireEvent('hide', this.tip);
	}
});

var MooTabber = new Class ({
	Implements: [Options, Events],
	options: {
		tab: '',
		startIndex: 0,
		buttons: '.tButtons ul > li',
		bRollOver: true
	},
	initialize: function(options) {
		this.setOptions(options);
		//this.addSlides(this.options.slides);
		
		
		var tabButtons = $(this.options.tab).getElements(this.options.buttons);
		var tabContents = $(this.options.tab).getElements('.tContent > div');
		tabButtons.set('morph', {duration: 0});
		tabContents.set('morph');
		tabButtons.each(function (button, i, tabButtons) { // sistemo i bottoni
			// Prendo il colore
			var posColor = button.getProperty('class').search('color');
			button.store('myBgColor', button.getProperty('class').substring(posColor+6, posColor+6+7));
			button.store('myAColor', button.getElement('a').getStyle('color'));
			// Setto il 'mouseover/leave' dei bottoni sul 'li'
			if (this.options.bRollOver) {
				button.addEvents({
					'mouseenter': function() {
						if (button.retrieve('myBtSelected') != 'si') {
							button.setStyles({'background-color': '#ffffff'});
							button.getElement('a').setStyle('color', button.retrieve('myBgColor'));
						}
					},
					'mouseleave': function() {
						if (button.retrieve('myBtSelected') != 'si') {
							button.setStyles({'background-color': button.retrieve('myBgColor')});
							button.getElement('a').setStyles({'color': '#ffffff'});
						}
					}
				});
			}
			// Setto il 'click' dei bottoni sull 'a'
			button.getElement('a').addEvent('click', function (e) {
				if (this.get('href').search(/index.php/) < 0) return true;
			  e.stop();
				tabButtons.each(function(button, f) {
					if (i != f) {
						button.setStyles({
							'background-color': button.retrieve('myBgColor'),
							'height': '20px'
						});
						button.getElement('a').setStyles({'color': '#ffffff'});
						button.store('myBtSelected', 'no');
					} else {
						button.setStyles({
							'background-color': '#ffffff',
							'height': '21px'
						});
						button.getElement('a').setStyles({'color':  button.retrieve('myBgColor')});
						button.store('myBtSelected', 'si');
					}
				});
				//if (!i) index = 0;
				tabContents.each(function(content, g) {
					if (i != g) {
						content.setStyles({
							opacity: '0',
							display: 'none'
						});
					} else {
						content.setStyles({
							opacity: '1',
							display: 'block'
						});
					}
				});
			});
			// Nascondo tutti i contenuti
		},this);
		
		this.SetButtonsContents(this.options.startIndex); // Sistemo i contenuti
		//this.SetButtons(this.options.startIndex); // Sistemo il bottone attivo
	},
	SetButtonsContents: function (index) {
		
		var tabButtons = $(this.options.tab).getElements('ul li');
		var tabContents = $(this.options.tab).getElements('.tContent > div');
		if (!(index > 0)) index = 0;
		
		tabButtons.each(function(button, f) {
			if (index != f) {
				button.setStyles({
					'background-color': button.retrieve('myBgColor'),
					'height': '20px'
				});
				button.getElement('a').setStyles({'color': '#ffffff'});
				button.store('myBtSelected', 'no');
			} else {
				button.setStyles({
					'background-color': '#ffffff',
					'height': '21px'
				});
				button.getElement('a').setStyles({'color': button.retrieve('myBgColor')});
				button.store('myBtSelected', 'si');
			}
		});
		if (!index) index = 0;
		tabContents.each(function(content, i) {
			if (index != i) {
				content.setStyles({
					opacity: '0',
					display: 'none'
				});
			} else {
				content.setStyles({
					opacity: '1',
					display: 'block'
				});
			}
		});
	}
});



var MooWEBCAMS = new Class ({
	Implements: [Options, Events],
	options: {
		tab: '',
		startIndex: 0,
		buttons: '.tButtons ul > li'
	},
	initialize: function(options) {
		this.setOptions(options);
		//this.addSlides(this.options.slides);
		
		
		var tabButtons = $(this.options.tab).getElements(this.options.buttons);
		var tabContents = $(this.options.tab).getElements('.tContent > div');
		tabButtons.set('morph', {duration: 0});
		tabContents.set('morph');
		tabButtons.each(function (button, i, tabButtons) { // sistemo i bottoni
			// Prendo il colore
			var posColor = button.getProperty('class').search('color');
			button.store('myBgColor', button.getProperty('class').substring(posColor+6, posColor+6+7));
			button.store('myAColor', button.getElement('a').getStyle('color'));
			// Setto il 'mouseover/leave' dei bottoni sul 'li'
			button.addEvents({
				'mouseenter': function() {
					if (button.retrieve('myBtSelected') != 'si') {
						button.setStyles({'background-color': '#ffffff'});
						button.getElement('a').setStyle('color', button.retrieve('myBgColor'));
					}
				},
				'mouseleave': function() {
					if (button.retrieve('myBtSelected') != 'si') {
						button.setStyles({'background-color': button.retrieve('myBgColor')});
						button.getElement('a').setStyles({'color': '#ffffff'});
					}
				}
			});
			// Setto il 'click' dei bottoni sull 'a'
			button.getElement('a').addEvent('click', function (e) {
				location.href(button.getElement('a').get('href'));
			    e.stop();
				tabButtons.each(function(button, f) {
					if (i != f) {
						button.setStyles({
							'background-color': button.retrieve('myBgColor'),
							'height': '20px'
						});
						button.getElement('a').setStyles({'color': '#ffffff'});
						button.store('myBtSelected', 'no');
					} else {
						button.setStyles({
							'background-color': '#ffffff',
							'height': '21px'
						});
						button.getElement('a').setStyles({'color':  button.retrieve('myBgColor')});
						button.store('myBtSelected', 'si');
					}
				});
				//if (!i) index = 0;
				tabContents.each(function(content, g) {
					if (i != g) {
						content.setStyles({
							opacity: '0',
							display: 'none'
						});
					} else {
						content.setStyles({
							opacity: '1',
							display: 'block'
						});
					}
				});
			});
			// Nascondo tutti i contenuti
		},this);
		
		this.SetButtonsContents(this.options.startIndex); // Sistemo i contenuti
		//this.SetButtons(this.options.startIndex); // Sistemo il bottone attivo
	},
	SetButtonsContents: function (index) {
		
		var tabButtons = $(this.options.tab).getElements('ul li');
		var tabContents = $(this.options.tab).getElements('.tContent > div');
		if (!(index > 0)) index = 0;
		
		tabButtons.each(function(button, f) {
			if (index != f) {
				button.setStyles({
					'background-color': button.retrieve('myBgColor'),
					'height': '20px'
				});
				button.getElement('a').setStyles({'color': '#ffffff'});
				button.store('myBtSelected', 'no');
			} else {
				button.setStyles({
					'background-color': '#ffffff',
					'height': '21px'
				});
				button.getElement('a').setStyles({'color': button.retrieve('myBgColor')});
				button.store('myBtSelected', 'si');
			}
		});
		if (!index) index = 0;
		tabContents.each(function(content, i) {
			if (index != i) {
				content.setStyles({
					opacity: '0',
					display: 'none'
				});
			} else {
				content.setStyles({
					opacity: '1',
					display: 'block'
				});
			}
		});
	}
});




var MooSimpleTabber = new Class ({
	Implements: [Options, Events],
	options: {
		tab: '',
		startIndex: 0,
		tabAprire: 0
	},
	initialize: function(options){
		this.setOptions(options);
		//this.addSlides(this.options.slides);
		
		var tabButtons = $(this.options.tab).getElements('h3 a');
		var tabContents = $$('.tContent > div');
		tabButtons.each(function (button, i, tabButtons) { 
			button.addEvent('click', function (e) {
				e.stop();
				tabContents.each(function(content, g) {
					if (i != g) {
						content.setStyles({
							display: 'none'
						});
					} else {
						content.setStyles({
							display: 'block'
						});
					}
				});
			});
			// Nascondo tutti i contenuti
		},this);
		
		this.SetButtonsContents(this.options.startIndex); // Sistemo i contenuti
		//this.SetButtons(this.options.startIndex); // Sistemo il bottone attivo
	},
	SetButtonsContents: function (index) {
		
		var tabContents = $$('.tContent > div');
		if (!(index > 0)) index = 0;
		if (!index) index = 0;
		tabContents.each(function(content, i) {
			if (index != i) {
				content.setStyles({
					display: 'none'
				});
			} else {
				content.setStyles({
					display: 'block'
				});
			}
		});
	}
});

window.addEvent('domready', function () {
	$$('.bannerClick').addEvent('click', function (e) {
		var listVars = this.get('id').split("-");
		// 0 Gruppo, 1 Posizione, 2 idBanner
		var myRequest = new Request({
			url: '../banner.php',
			method: 'get',
			data: 'p=' + listVars[1] + '&g=' + listVars[0] + '&bn=' + listVars[2],
			onFailure: function (xhr) {
				
			},
			onComplete: function(responseText, responseXML) {
		    
			}
		}).send();


	});
});