/*
	moo.rd - A lightweight Mootools extension [http://www.moord.it/]
	
	Author: Riccardo Degni
	License: GNU GPL License
	Copyright: 2007 Riccardo Degni

*/

var Moo = {};

Moo.Rd = {
	version: '1.2',
	author: 'Riccardo Degni'
};


/*
	Author: Riccardo Degni, <http://www.riccardodegni.it/>
	
	License: GNU GPL License
	
	Filename: moo.rd_constructors.js
	
	Constructors: Custom, Table, Make

*/

var Custom = {};
var Table;
var Make = {};


/*
	Author: Riccardo Degni, <http://www.riccardodegni.it/>
	
	License: GNU GPL License
	
	Filename: moo.rd_phpstring.js
	
	Class: String

*/

String.extend({
			
			stripTags: function () {
   				return this.replace(/<([^>]+)>/g,'');
			},

			addslashes: function() {
				return this.replace(/['"]/g, function(match){
					return ('\\' + match.charAt(0) + match.charAt(1));
				});
			},
			
			nl2br: function() {
				return this.replace(/\\n/g, '<br />');
			},
			
			stripslashes: function() {
				return this.replace(/\\['"]{1,}/g, function(match){
					return (match.charAt(1));
				});
			},
			
			htmlEntities: function () {
   				return this.replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;');
			},
			
			trim: function() {
				return this.replace(/^\s+|\s+$/g,'');
			},
			
			ltrim: function() {
   				return this.replace(/^\s+/g,'');
			},
			
			rtrim: function() {
   				return this.replace(/\s+$/g,'');
			}		
});


/*
	Author: Riccardo Degni, <http://www.riccardodegni.it/>
	
	License: GNU GPL License
	
	Filename: moo.rd_utility_string.js
	
	Class: String

*/

String.extend({
			  
	upper: function() {
 		return this.toUpperCase();
 	},

 	lower: function() {
 		return this.toLowerCase();
 	},
	
	stripPhp: function() {
		return this.replace(/<\?php|\?>/gi, '');
	},
	
	firstChar: function (n) {	
		return (this.charAt(0)==n) ? true : false;
	},
	
	lastChar: function (n) {	
		return (this.charAt(this.length-1)==n) ? true : false;
	},
	
	hasChar: function (n) {
		for(var i=0; i<=this.length; i++)
			if(this.charAt(i)==n) return true;
		return false;
	},
	
	contains: function (phrase) {
		return (this.indexOf(phrase) != -1) ? true : false;
	},
	
	posOf: function (n) {
		var positions = new Array();
			for (var i=0; i<this.length; i++)
				if(this.charAt(i)==n)
					positions.push(i);
			if(positions.length==0)
				return false;
			else
				return positions;
	},
	
	getFirst: function() {
		return this.charAt(0);
	},
	
	getLast: function() {
		return this.charAt(this.length-1);
	},
	
	globalReplace: function(val, repl, regexAttr) {
		return this.replace(new RegExp(val, regexAttr || 'gi'), repl);
	},
	
	stripScripts: function() {
		return this.replace(/<script[^>]{0,}>|<\/script>/gi, '');
	},
	
	camelize: function() {
		var s = '';
		for(var i=0; i<this.length; i++) {
			if(i%2 == 0) s+= this.charAt(i).upper();
			else s+= this.charAt(i).lower();
		}
		
		return s;
	},
	
	upperFirst: function() {
		return this.replace(this.charAt(0), this.charAt(0).upper());	
	}
			  
});


/*
	Author: Riccardo Degni, <http://www.riccardodegni.it/>
	
	License: GNU GPL License
	
	Filename: moo.rd_utility_array.js
	
	Class: Array

*/

Array.extend({
			
	print_r: function(results) {
		var r = 'Array ( ' + '<br />';
		this.each(function(el, index) {
			r += '[' + index + ']' + ' => ' + el + '<br />';
		});
		r += ')';
		$(results).setHTML(r);
	},
	
	numSort: function() {
		return this.sort(function(a, b) {return a-b;});
	},
			
	rNumSort: function() {
		return this.sort(function(a, b) {return b-a;});
	},
			
	getFirst: function() {
		return this[0];
	},
			
	getLast: function() {
		return this[this.length-1];
	},
			
	asItem: function(item) {
		var a = new Array();
		for(var z=0; z<this.length; z++)
			if(this[z] == item) return true;
	},
			
	asItems: function() {
		var a = new Array();
				
		for(var i=0; i<arguments.length; i++)
			if(this.asItem(arguments[i]))
				a.push(arguments[i]);
				
		return (a.length >= arguments.length);
	},
			
	stripItem: function() {
		var a = new Array();
		for(var z=0; z<this.length; z++)
			for(var i=0; i<arguments.length; i++)
				if(this[z] != arguments[i])
					a.push(this[z]);
		return a;	
	},
			
	stripItems: function() {
		var a = new Array();
		for(var w=0; w<this.length; w++) a.push(this[w]);
				
		for(var z=0; z<this.length; z++) {
			for(var i=0; i<arguments.length; i++)
				if(this[z] == arguments[i])
					a = a.stripItem(arguments[i]);
		}	
		return a;	
	},
			
	posOf: function(item) {
		var a = new Array();
				
		for(var z=0; z<this.length; z++)
			if(this[z] == item)
				a.push(z);
		return a;
	}
});

function print_r(v, results) {
	if($type(v) == 'array') v.print_r(results);
}


/*
	Author: Riccardo Degni, <http://www.riccardodegni.it/>
	
	License: GNU GPL License
	
	Filename: moo.rd_shortcut.js
	
	Class: Element

*/

Element.extend({
			
			getId: function() {
				return this.getProperty('id');
			},
			
			getClass: function() {
				return this.className;
			},
			
			getWidth: function() {
				return this.getStyle('width');
			},
			
			getHeight: function() {
				return this.getStyle('height');
			},
			
			getOpacity: function() {
				return this.getStyle('opacity');
			},
			
			getColor: function() {
				return this.getStyle('color');
			},
			
			getBg: function() {
				return this.getStyle('background-color');
			},
			
			getBorder: function(where) {
				if(where) return this.getStyle('border-' + where);
				else return this.getStyle('border');
			},
			
			getMargin: function(where) {
				if(where) return this.getStyle('margin-' + where);
				else return this.getStyle('margin');
			},
			
			getPadding: function(where) {
				if(where) return this.getStyle('padding-' + where);
				else return this.getStyle('padding');
			}
		
});


/*
	Author: Riccardo Degni, <http://www.riccardodegni.it/>
	
	License: GNU GPL License
	
	Filename: moo.rd_table.js
	
	Class: Table

*/

Table = new Class({
		
				initialize: function(element) {
					this.element = $(element);
				},
		
				zebra: function(color1, color2, firstLine) {
					if(this.element.getTag() != 'table')  return false;
					
					this.cells = this.element.getElements('tr');
					
					this.cells.each(function(cell, index) {
			
						if(index%2 == 0)
							if(firstLine && index == 0) cell.setStyles(firstLine);
							else cell.setStyle('background-color', color1);
						else
							cell.setStyle('background-color', color2);

					});
						
				},
				
				overClickRows: function(color, clickcolor) {
					this.rows = this.element.getElements('tr');
					
					this.rows.each(function(row, index) {
						row.addEvent('mouseover', function() {
							if(!this.init) this.init = row.getStyle('background-color');
							if(this.getStyle('background-color') != clickcolor)
								row.setStyle('background-color', color);
						});
						
						row.addEvent('mouseout', function() {
							if(this.getStyle('background-color') != clickcolor)
								row.setStyle('background-color', this.init);
						});
						
						row.addEvent('click', function() {
							if(this.getStyle('background-color') != clickcolor)
								this.setStyle('background-color', clickcolor);
							else
								this.setStyle('background-color', this.init);
						});
					});
				},
				
				overRows: function(color) {
					this.rows = this.element.getElements('tr');
					
					this.rows.each(function(row, index) {
						row.addEvent('mouseover', function() {
							this.init = row.getStyle('background-color');
							row.setStyle('background-color', color);
						});
						
						row.addEvent('mouseout', function() {
							row.setStyle('background-color', this.init);
						});
					});
				},
				
				clickRows: function(color) {
					this.rows = this.element.getElements('tr');
					this.rows.each(function(row, index) {
					
						row.addEvent('click', function() {
							if(!this.initBc) this.initBc = row.getStyle('background-color');
							if(row.getStyle('background-color') != this.initBc)
								row.setStyle('background-color', this.initBc);
							else
								row.setStyle('background-color', color);	
						});
					});
				},
				
				overClickCells: function(color, clickcolor) {
					this.rows = this.element.getElements('tr');
					this.rows.each(function(row, index) {
						row.getElements('td').each(function(td,index) {
							td.addEvent('mouseover', function() {
								if(!this.init) this.init = td.getStyle('background-color');
								if(this.getStyle('background-color') != clickcolor)
									td.setStyle('background-color', color);
							});
							
							td.addEvent('mouseout', function() {
								if(this.getStyle('background-color') != clickcolor)
									td.setStyle('background-color', this.init);
							});
							
							td.addEvent('click', function() {
								if(this.getStyle('background-color') != clickcolor)
									this.setStyle('background-color', clickcolor);
								else
									this.setStyle('background-color', this.init);
							});
						});
					});
				},
				
				overCells: function(color) {
					this.rows = this.element.getElements('tr');
					this.rows.each(function(row, index) {
						row.getElements('td').each(function(td,index) {
							td.addEvent('mouseover', function() {
								this.init = td.getStyle('background-color');
								td.setStyle('background-color', color);
							});
							
							td.addEvent('mouseout', function() {
								td.setStyle('background-color', this.init);
							});
						});
					});
				},
				
				clickCells: function(color) {
					this.rows = this.element.getElements('tr');
					this.rows.each(function(row, index) {
						row.getElements('td').each(function(td,index) {
							td.addEvent('click', function() {
								if(!this.initC) this.initC = row.getStyle('background-color');
								if(td.getStyle('background-color') != this.initC)
									td.setStyle('background-color', this.initC);
								else
									td.setStyle('background-color', color);
							});
						});
					});
				}	
				
});


/*
	Author: Riccardo Degni, <http://www.riccardodegni.it/>
	
	License: GNU GPL License
	
	Filename: moo.rd_tablecols.js
	
	Class: Table

*/

Table.implement({				
				clickCols: function(color, firstLine) {
					this.rows = this.element.getElements('tr');
					this.rows.each(function(row, indexRow) {
						
						  row.getElements('td').each(function(td,indexTd) {
						  	 
						  	var i = indexTd;
							var tdcolor = td.getStyle('background-color');
							td.addEvent('click', function() {
								this.getParent().getParent().getElements('tr').each(function(r, indexR) {
									
									r.getElements('td').each(function(c, indexC) {
										if(indexC == i)
											if((firstLine) && (indexR==0))
												c.setStyle('background-color', tdcolor);
											else if(c.getStyle('background-color') != color)
												c.setStyle('background-color', color);
											else
												c.setStyle('background-color', tdcolor);
									});
								});
							});
						  
						});		
					});
				},
				
				overCols: function(color, firstLine) {
					this.rows = this.element.getElements('tr');
					this.rows.each(function(row, indexRow) {
						
						  row.getElements('td').each(function(td,indexTd) {
						  	 
						  	var i = indexTd;
							var tdcolor = td.getStyle('background-color');
							td.addEvent('mouseover', function() {
								this.getParent().getParent().getElements('tr').each(function(r, indexR) {
									
									r.getElements('td').each(function(c, indexC) {
										if(indexC == i)
											if((firstLine) && (indexR==0))
												c.setStyle('background-color', tdcolor);
											else if(c.getStyle('background-color') != color)
												c.setStyle('background-color', color);
											else
												c.setStyle('background-color', tdcolor);
									});
								});
							});
							
							td.addEvent('mouseout', function() {
								this.getParent().getParent().getElements('tr').each(function(r, indexR) {
									
									r.getElements('td').each(function(c, indexC) {
										if(indexC == i)
											if(c.getStyle('background-color') == color)
												c.setStyle('background-color', tdcolor);
									});
								});
							});
						  
						});		
					});
				}	
});


/*
	Author: Riccardo Degni, <http://www.riccardodegni.it/>
	
	License: GNU GPL License
	
	Filename: moo.rd_tablecols2.js
	
	Class: Table

*/

Table.implement({		
			overClickCols: function(color, clickcolor, firstLine) {
					this.rows = this.element.getElements('tr');
					this.rows.each(function(row, indexRow) {
						
						  row.getElements('td').each(function(td,indexTd) {
						  	 
						  	var i = indexTd;
							var tdcolor = td.getStyle('background-color');
							td.addEvent('mouseover', function() {
							
								if(!init) var init = td.getStyle('background-color');
								
								this.getParent().getParent().getElements('tr').each(function(r, indexR) {
									
									r.getElements('td').each(function(c, indexC) {
										if(indexC == i)
											if((firstLine) && (indexR==0))
												c.setStyle('background-color', tdcolor);
											else if(c.getStyle('background-color') != clickcolor)
												c.setStyle('background-color', color);
											else
												c.setStyle('background-color', clickcolor);
									});
								});
							});
							
							td.addEvent('mouseout', function() {
								this.getParent().getParent().getElements('tr').each(function(r, indexR) {
									
									r.getElements('td').each(function(c, indexC) {
										if(indexC == i)
											if(c.getStyle('background-color') == color)
												c.setStyle('background-color', tdcolor);
									});
								});
							});
							
							td.addEvent('click', function() {
								this.getParent().getParent().getElements('tr').each(function(r, indexR) {
									
									r.getElements('td').each(function(c, indexC) {
										if(indexC == i)
											if((firstLine) && (indexR!=0))
											  if(c.getStyle('background-color') != clickcolor)
												  c.setStyle('background-color', clickcolor);
											  else
												  c.setStyle('background-color', tdcolor);
											else if((!firstLine))
												 if(c.getStyle('background-color') != clickcolor)
												  c.setStyle('background-color', clickcolor);
											  else
												  c.setStyle('background-color', tdcolor);
									});
								});
							});
							
						  
						});		
					});
				}
});


/*
	Author: Riccardo Degni, <http://www.riccardodegni.it/>
	
	License: GNU GPL License
	
	Filename: moo.rd_make_table.js
	
	Class: Make.Table, Array.makeTable
	
	Functions: make_table

*/

Make.Table = new Class({
			
			initialize: function(id, rows) {
				this.idKey = id;
				this.rows = rows;
			},
			
			make: function() {
				if(!$(this.idKey)) {
				
				this.table = new Element('table', {
					'id': this.idKey
				});
				
				var table = this.table;
				var tbody = new Element('tbody').injectInside(table);
				var first = this.first;
				var l = this.rows.length-1;
				
				this.rows.each(function(row, index) {
	
					var tr = new Element('tr').injectInside(tbody);
					
					row.each(function(cell) {
						if($type(cell) == 'object') {
							tr.setStyles(cell);
						}
						else	new Element('td').appendText(cell).injectInside(tr);
							
					});
				});
				
				return this.table;
				}
				else return;
			}
		
});

Array.extend({
		makeTable: function(id, firstLine) {
			return new Make.Table(id, this, firstLine).make();
		}
});

function make_table(id, rows, firstLine) {
		return new Make.Table(id, rows, firstLine).make();
}


/*
	Author: Riccardo Degni, <http://www.riccardodegni.it/>
	
	License: GNU GPL License
	
	Filename: moo.rd_make_list.js
	
	Class: Make.List, Array.makeList
	
	Functions: make_list

*/


Make.List = new Class({
					  
			options: {
				type: 'ul',
				className: ''
			},
			
			initialize: function(id, items, options) {
				this.idKey = id;
				this.items = items;
				this.setOptions(options);
			},
			
			make: function() {
				if(!$(this.idKey)) {
					
					this.ul = new Element(this.options.type, {
						'id': this.idKey,
						'class': this.options.className
					});
					

					this.items.each(function(li) {
						if($type(li) == 'array') {
							li.each(function(item, i) {
								var mul = new Element('ul');
								if($type(item) == 'object') {
									var a = new Element('a', {
										'href': item.href
									}).appendText(item.text);
									var lis = new Element('li');
									a.injectInside(lis);
									lis.injectInside(mul);
									mul.injectInside(this.ul);
								}			 
								else {
									var mli = new Element('li').appendText(item).injectInside(mul);
									mul.injectInside(this.ul);
								}
							}, this);
						}
						else if($type(li) == 'object') {
							var a = new Element('a', {
								'href': li.href
							}).appendText(li.text);
							var li = new Element('li');
							a.injectInside(li);
							li.injectInside(this.ul);
						}
						else {
							var li = new Element('li').appendText(li);
							li.injectInside(this.ul);
						}
					}, this);
					
					return this.ul;
				
				}
				else return;
			}
		
});

Make.List.implement(new Options);


Array.extend({
		makeList: function(id, options) {
			return new Make.List(id, this, options).make();
		}
});

function make_list(id, items, options) {
		return new Make.List(id, items, options).make();
}


/*
	Author: Riccardo Degni, <http://www.riccardodegni.it/>
	
	License: GNU GPL License
	
	Filename: moo.rd_make_select.js
	
	Class: Make.Select, Array.makeSelect
	
	Functions: make_select

*/


Make.Select = new Class({
			
			initialize: function(id, items, properties) {
				this.idKey = id;
				this.items = items;
				this.props = properties || {};
			},
			
			make: function() {
				if(!$(this.idKey)) {
					this.select = new Element('select', $extend({'id': this.idKey}, this.props));
					
					this.items.each(function(item) {
						if($type(item) == 'array') {
							item.each(function(i, index) {
								if(index == 0) {
									this.group = new Element('optgroup', { 'label': i });
									this.select.adopt(this.group);
								}
								else {
									var opt = new Element('option', {
										'label': i,
										'value': i
									}).appendText(i);
									opt.injectInside(this.group);	
								}
							}, this);	
						}					 
						else {
							var option = new Element('option', {
								'label': item,
								'value': item
							}).appendText(item);
							option.injectInside(this.select);
						}
					}, this);
					
					return this.select;
				
				}
				else return;
			}
		
});


Array.extend({
		makeSelect: function(id, properties) {
			return new Make.Select(id, this, properties).make();
		}
});

function make_select(id, items, properties) {
		return new Make.Select(id, items, properties).make();
}


/*
	Author: Riccardo Degni, <http://www.riccardodegni.it/>
	
	License: GNU GPL License
	
	Filename: moo.rd_custom_alert.js
	
	Class: Custom.Alert

*/

Custom.Alert = new Class({
		
			options: {
				height: '100px',
				width: '300px',
				buttonText: 'OK',
				opacify: true,
				alertbox: null,
				alerthead: null,
				alertbody: null
			},
		
			initialize: function(title, text, options) {
				this.title = title;
				this.text = text;
				this.setOptions(options);
			},
			
			create: function() {
				this.customize();
			},
			
			customize: function() {
				if($('customAlert'))  return false;
				
				this.alertbox = new Element('div', {
					'id': 'customAlert',
					'styles': {
					'position': 'fixed',
					'top': '50%',
					'left': '50%',
					'z-index': 1000,
					'height': this.options.height,
					'width': this.options.width	
					}
				});
				
				this.overlay = new Element('div', {
					'id': 'customAlertOverlay',
					'styles': {
						'position': 'absolute',
						'top': '0px',
						'left': '0px',
						'width': '100%',
						'height': window.getScrollHeight(),
						'background-image':'url(g.gif)',
						'z-index': 900
					}
				});
			
				this.overlay.injectInside($E('body'));
				
				if(this.options['alertbox']) this.alertbox.addClass(this.options['alertbox']);
		
				this.alertbox.setStyles({
					'margin-left': - this.alertbox.getStyle('width').toInt()/2,
					'margin-top': - this.alertbox.getStyle('height').toInt()/2
				});
				
				this.alertbox.injectInside(this.overlay);
				
				if(this.options.opacify) this.alertbox.setStyle('opacity', 0);
				new Fx.Style(this.alertbox, 'opacity', {duration:1000}).start(1);
				
				
				this.head = new Element('div').injectInside(this.alertbox);
				if(this.options.alerthead) this.head.addClass(this.options['alerthead']);
				this.head.appendText(this.title);
				
				this.content = new Element('div').injectInside(this.alertbox);
				if(this.options.alerthead) this.content.addClass(this.options['alertbody']);
				this.content.appendText(this.text);
			
				this.closebox = new Element('div').injectInside(this.alertbox);
				this.closebox.setProperty('align', 'center');
			
				this.button = new Element('a').injectInside(this.closebox);
				this.button.setProperty('href', '#');
				this.button.appendText(this.options.buttonText);
				this.button.addEvent('click', function(event) {
					var event = new Event(event).preventDefault();
				});
				if(this.options.opacify)  this.button.addEvent('click', this.opacify.bind(this));
				else this.button.addEvent('click', this.remove);
				
			},
			
			opacify: function() {
				new Fx.Style(this.alertbox, 'opacity', {duration:1000}).start(0).chain(function() {
					$('customAlert').remove();
					$('customAlertOverlay').remove();
				});
			},
			
			remove: function() {
				$('customAlert').remove();
				$('customAlertOverlay').remove();
			}
});

Custom.Alert.implement(new Options);


/*
	Author: Riccardo Degni, <http://www.riccardodegni.it/>
	
	License: GNU GPL License
	
	Filename: moo.rd_custom_confirm.js
	
	Class: Custom.Confirm

*/

Custom.Confirm = new Class({
		
			options: {
					height: '100px',
					width: '300px',
					confirmText: 'OK',
					cancelText: 'Cancel',
					opacify: true,
					confirmbox: null,
					confirmhead: null,
					confirmbody: null,
					onConfirm: function() {
						return true;	
					},
					onCancel: function() {
						return false;	
					}
			},
		
			initialize: function(title, text, options) {
				this.title = title;
				this.text = text;
				this.setOptions(options);
			},
			
			create: function() {
				this.customize();
			},
			
			customize: function() {
				if($('customConfirm'))  return false;
				
				this.confirmbox = new Element('div', {
					'id': 'customConfirm',
					'styles': {
					'position': 'fixed',
					'top': '50%',
					'left': '50%',
					'z-index': 1000,
					'height': this.options.height,
					'width': this.options.width	
					}
				});
				
				this.overlay = new Element('div', {
					'id': 'customConfirmOverlay',
					'styles': {
						'position': 'absolute',
						'top': '0px',
						'left': '0px',
						'width': '100%',
						'height': window.getScrollHeight(), //window.getHeight() + window.getScrollTop(),
						'background-image':'url(g.gif)',
						'z-index': 900
					}
				});
				
				this.overlay.injectInside($E('body'));
				
				if(this.options['confirmbox']) this.confirmbox.addClass(this.options['confirmbox']);
				this.confirmbox.setStyles({
					'margin-left': - this.confirmbox.getStyle('width').toInt()/2,
					'margin-top': - this.confirmbox.getStyle('height').toInt()/2
				});
				
				this.confirmbox.injectInside(this.overlay);
				
				if(this.options.opacify) this.confirmbox.setStyle('opacity', 0);
				new Fx.Style(this.confirmbox, 'opacity', {duration:1000}).start(1);
				
				
				this.head = new Element('div').injectInside(this.confirmbox);
				if(this.options.confirmhead) this.head.addClass(this.options['confirmhead']);
				this.head.appendText(this.title);
				
				this.content = new Element('div').injectInside(this.confirmbox);
				if(this.options.confirmhead) this.content.addClass(this.options['confirmbody']);
				this.content.appendText(this.text);
			
				this.closebox = new Element('div').injectInside(this.confirmbox);
				this.closebox.setProperty('align', 'center');
			
				this.confirmButton = new Element('a').injectInside(this.closebox);
				this.confirmButton.setProperty('href', '#');
				this.confirmButton.appendText(this.options.confirmText);
				this.confirmButton.addEvent('click', function(event) {
					var event = new Event(event).preventDefault();
				});
				if(this.options.opacify)  this.confirmButton.addEvent('click', this.opacifyConfirm.bind(this));
				else this.confirmButton.addEvent('click', this.confirmRemove.bind(this));
				
				this.cancelButton = new Element('a').injectInside(this.closebox);
				this.cancelButton.setProperty('href', '#');
				this.cancelButton.appendText(this.options.cancelText);
				this.cancelButton.addEvent('click', function(event) {
					var event = new Event(event).preventDefault();
				});
				if(this.options.opacify)  this.cancelButton.addEvent('click', this.opacifyCancel.bind(this));
				else this.cancelButton.addEvent('click', this.cancelRemove.bind(this));
				
			},
			
			opacifyConfirm: function() {
				this.fireEvent('onConfirm');
				new Fx.Style(this.confirmbox, 'opacity', {duration:1000}).start(0).chain(function() {
					$('customConfirm').remove();
					$('customConfirmOverlay').remove();
				});
			},
			
			opacifyCancel: function() {
				this.fireEvent('onCancel');
				new Fx.Style(this.confirmbox, 'opacity', {duration:1000}).start(0).chain(function() {
					$('customConfirm').remove();
					$('customConfirmOverlay').remove();
				});
			},
			
			confirmRemove: function() {
				this.fireEvent('onConfirm');
				$('customConfirm').remove();
				$('customConfirmOverlay').remove();
			},
			
			cancelRemove: function() {
				this.fireEvent('onCancel');
				$('customConfirm').remove();
				$('customConfirmOverlay').remove();
			}
});

Custom.Confirm.implement(new Options);
Custom.Confirm.implement(new Events);


/*
	Author: Riccardo Degni, <http://www.riccardodegni.it/>
	
	License: GNU GPL License
	
	Filename: moo.rd_smooth_scrolling.js
	
	Class: effects classes

*/

var SmoothScrolling = new Class ({
	   
	   initialize: function(options) { 
	   		this.options = options
	   },
	   
	   create: function() {
		   var targets = new Array();
		   var anchors = new Array();
		   var opts = this.options;
	   
		$$('a').each(function(lnk, index) {
			if(lnk.name)
				targets.push(lnk);
		});
				
		$$('a').each(function(lnk, index) {
			if(lnk.href.indexOf('#') != -1) {
	
				anchors.push(lnk);
				
				for(var i=0; i<targets.length; i++) {
					
					if(lnk.href.split('#')[1] == targets[i].name) {
						lnk.targetName = targets[i].name;
						lnk.onclick = function() {
								new Fx.Scroll(window, opts || {}).scrollTo(0,document.getElementsByName(lnk.targetName)[0].getTop());
						};
					}
				}
			}
		});
		
		}
});

/*
	Author: Riccardo Degni, <http://www.riccardodegni.it/>
	
	License: GNU GPL License
	
	Filename: moo.rd_effects.js
	
	Class: effects classes

*/

Fx.Fold = Fx.Base.extend({
			
			initialize: function(element) {
				this.element = $(element);
				this.iniHeight = this.element.offsetHeight;
				this.iniWidth = this.element.offsetWidth;
				this.element.setStyle('overflow', 'hidden');
			},
			
			start: function() {
				var w = this.iniWidth;
				new Fx.Style(this.element, 'height').start(this.iniHeight, 6).chain(function() {
					new Fx.Style(this.element, 'width').start(w, 0);
				});
			}
			
});
		
		
Fx.Squish = Fx.Base.extend({
			
			initialize: function(element) {
				this.element = $(element);
				this.iniHeight = this.element.offsetHeight;
				this.iniWidth = this.element.offsetWidth;
				this.element.setStyle('overflow', 'hidden');
			},
			
			start: function() {
				var w = this.iniWidth;
				new Fx.Styles(this.element, {duration:1000, transition: Fx.Transitions.Back.easeIn}).start({
					'height': [this.iniHeight, 0],
					'width': [this.iniHeight, 0],
					'opacity': [0]
				});
			}
			
});
		
		
Fx.Puff = Fx.Base.extend({
			
			initialize: function(element) {
				this.element = $(element);
				this.iniHeight = this.element.offsetHeight;
				this.iniWidth = this.element.offsetWidth;
				this.iniFont = this.element.getStyle('font-size').toInt() + 'px';
				this.element.setStyle('overflow', 'hidden');
			},
			
			start: function() {
			
				this.element.setStyle('position', 'relative');
				
				new Fx.Styles(this.element, {duration:1000, transition: Fx.Transitions.Back.easeIn}).start({
					'height': [this.iniHeight + 134],
					'width': [this.iniWidth + 140],
					'font-size': [this.iniFont + 4],
					'opacity': [0]
				});
			}
			
});
		
		
Fx.Shrink = Fx.Base.extend({
			
			initialize: function(element) {
				this.element = $(element);
				this.iniFont = this.element.getStyle('font-size');
				this.element.setStyle('overflow', 'hidden');
			},
			
			start: function() {
				
				new Fx.Styles(this.element, {duration:400}).start({
					'height': [0],
					'width': [0],
					'font-size': [this.iniFont, 0]
				}).chain(function() {
					new Fx.Style(this.element, 'opacity').start(1,0).chain(function() {
						this.element.setStyle('position', 'relative');
						this.element.setStyle('display', 'none');
					});
				});
			}
			
});
		
		
Fx.Grow = Fx.Base.extend({
			
			initialize: function(element) {
				this.element = $(element);
				this.iniHeight = this.element.offsetHeight;
				this.iniWidth = this.element.offsetWidth;
				this.iniFont = this.element.getStyle('font-size');
				this.element.setStyle('overflow', 'hidden');
			},
			
			start: function() {
				
				new Fx.Styles(this.element, {duration:400}).start({
					'height': [0, this.iniHeight],
					'width': [0, this.iniWidth],
					'font-size': [0, this.iniFont]
				});
					
			}
			
});


/*
	Author: Riccardo Degni, <http://www.riccardodegni.it/>
	
	License: GNU GPL License
	
	Filename: moo.rd_effects2.js
	
	Class: effects classes

*/

Fx.Glide = Fx.Base.extend({
			
			initialize: function(element) {
				this.element = $(element);
				this.iniHeight = this.element.offsetHeight;
				this.iniWidth = this.element.offsetWidth;
				this.iniFont = this.element.getStyle('font-size');
				this.element.setStyle('overflow', 'hidden');
			},
			
			start: function() {
				
				new Fx.Styles(this.element, {duration:400}).start({
					'height': [0, this.initHeight],
					'width': [0, this.iniWidth],
					'font-size': [0, this.iniFont]
				}).chain(function() {
					new Fx.Style(this.element, 'opacity').start(1,0).chain(function() {
						this.element.setStyle('position', 'static');
						this.element.setStyle('display', 'none');
					});
				});
			}
});
		
		
Fx.ElasticH = Fx.Base.extend({
			
			initialize: function(element) {
				this.element = $(element);
				this.iniHeight = this.element.offsetHeight;
				this.element.setStyle('overflow', 'hidden');
				this.opts = {transition:Fx.Transitions.Elastic.easeInOut, duration: 800};
			},
			
			start: function() {
				var h = this.iniHeight;
				var o = this.opts;
				new Fx.Style(this.element, 'height', this.opts).start(this.iniHeight, 0).chain(function() {
					new Fx.Style(this.element, 'height', o).start(0, h);
				});
			}
});
		
		
Fx.ShakeW = Fx.Base.extend({
			
			initialize: function(element) {
				this.element = $(element);
				this.iniHeight = this.element.offsetHeight;
				this.element.setStyle('overflow', 'hidden');
				this.element.setStyle('position', 'relative');
				this.opts = {duration:100};
			},
			
			start: function() {
				new Fx.Style(this.element, 'left', this.opts).start(10).chain(function() {
					new Fx.Style(this.element, 'left', {duration:200}).start(-10).chain(function() {
							new Fx.Style(this.element, 'left', {duration:200}).start(10).chain(function() {
								new Fx.Style(this.element, 'left', {duration:200}).start(-10).chain(function() {
									new Fx.Style(this.element, 'left', {duration:200}).start(10).chain(function() {
										new Fx.Style(this.element, 'left', {duration:200}).start(0);
										this.element.setStyle('position', 'static');
									});
								});
							});
						});
				});
			}
});
		
		
Fx.SwitchOffH = Fx.Base.extend({
			
			initialize: function(element) {
				this.element = $(element);
				this.iniHeight = this.element.offsetHeight;
				this.element.setStyle('overflow', 'hidden');
				this.opts = {transition:Fx.Transitions.Elastic.easeInOut, duration: 800};
			},
			
			start: function() {
				var h = this.iniHeight;
				var o = this.opts;
				new Fx.Style(this.element, 'opacity', {duration:100}).start(0).chain(function() {
					new Fx.Style(this.element, 'opacity', {duration:100}).start(1).chain(function() {
								new Fx.Style(this.element, 'height', o).start(h, 0)																	
					});
				});
			}
});
		
		
Fx.SwitchOffW = Fx.Base.extend({
			
			initialize: function(element) {
				this.element = $(element);
				this.iniWidth = this.element.offsetWidth;
				this.element.setStyle('overflow', 'hidden');
				this.opts = {transition:Fx.Transitions.Elastic.easeInOut, duration: 800};
			},
			
			start: function() {
				var w = this.iniWidth;
				var o = this.opts;
				new Fx.Style(this.element, 'opacity', {duration:100}).start(0).chain(function() {
					new Fx.Style(this.element, 'opacity', {duration:100}).start(1).chain(function() {
								new Fx.Style(this.element, 'width', o).start(w, 0)																	
					});
				});
			}
});


/*
	Author: Riccardo Degni, <http://www.riccardodegni.it/>
	
	License: GNU GPL License
	
	Filename: moo.rd_effects3.js
	
	Class: effects classes

*/

Fx.Pulsate = Fx.Base.extend({
			
			initialize: function(element) {
				this.element = $(element);
				this.element.setStyle('overflow', 'hidden');
				this.opts = {duration:100};
			},
			
			start: function() {
				new Fx.Style(this.element, 'opacity', this.opts).start(0).chain(function() {
					new Fx.Style(this.element, 'opacity', {duration:200}).start(1).chain(function() {
							new Fx.Style(this.element, 'opacity', {duration:200}).start(0).chain(function() {
								new Fx.Style(this.element, 'opacity', {duration:200}).start(1).chain(function() {
									new Fx.Style(this.element, 'opacity', {duration:200}).start(0).chain(function() {
										new Fx.Style(this.element, 'opacity', {duration:200}).start(1).chain(function() {
											new Fx.Style(this.element, 'opacity', {duration:200}).start(0).chain(function() {
												new Fx.Style(this.element, 'opacity', {duration:200}).start(1);
											});
										});	
									});
								});
							});
						});
				});
			}
			
		});
		
		
		Fx.ElasticW = Fx.Base.extend({
			
			initialize: function(element) {
				this.element = $(element);
				this.iniWidth = this.element.offsetWidth;
				this.element.setStyle('overflow', 'hidden');
				this.opts = {transition:Fx.Transitions.Elastic.easeInOut, duration: 800};
			},
			
			start: function() {
				var w = this.iniWidth;
				var o = this.opts;
				new Fx.Style(this.element, 'width', this.opts).start(this.iniWidth, 0).chain(function() {
					new Fx.Style(this.element, 'width', o).start(0, w);
				});
			}
		});
		
		
		Fx.Gradient = Fx.Base.extend({
			
			initialize: function(element, color) {
				this.element = $(element);
				this.iniColor = this.element.getStyle('background-color');
				this.color= color;
				this.opts = {duration: 1400};
			},
			
			start: function() {
				var c = this.iniColor;
				new Fx.Style(this.element, 'background-color', this.opts).start(this.color).chain(function() {
					new Fx.Style(this.element, 'background-color', {duration: 1400}).start(c);
				});
			}
		});
		
		Fx.FixGradient = Fx.Base.extend({
			
			initialize: function(element, color) {
				this.element = $(element);
				this.iniColor = this.element.getStyle('background-color');
				this.color= color;
				this.opts = {duration: 1400};
			},
			
			start: function() {
				var c = this.iniColor;
				new Fx.Style(this.element, 'background-color', this.opts).start(this.color);
			}
		});
		
		
		// Fx.Rumble - element, positioned (deve essere true se l'elemento è posizionato)
		
		Fx.Rumble = Fx.Base.extend({
			
			initialize: function(element, positioned) {
				this.element = $(element);
				if(!positioned) this.element.setStyle('position', 'relative');
				this.element.setStyle('cursor', 'move');
				this.iniTop = this.element.getStyle('top');
				this.iniLeft = this.element.getStyle('left');
				this.obj = {'top': [this.element.getStyle('top').toInt(), this.iniTop], 
							'left': [this.element.getStyle('left').toInt(), this.iniLeft]
						   };
			},
	
			start: function() {
				var top = this.iniTop;
				var left = this.iniLeft;
				var coord = {'top': (top != 'auto' ? top : 0), 'left': (left != 'auto' ? left : 0)};
				new Drag.Move(this.element, { 
					onComplete: function() {
						new Fx.Styles(this.element, {duration: 800, transition: Fx.Transitions.Elastic.easeOut}).start(coord);
					}
				});		   
			}
			
});
		
		
/*
	Author: Riccardo Degni, <http://www.riccardodegni.it/>
	
	License: GNU GPL License
	
	Filename: moo.rd_effects4.js
	
	Class: effects classes

*/

Fx.ShakeH = Fx.Base.extend({
			
			initialize: function(element) {
				this.element = $(element);
				this.iniHeight = this.element.offsetHeight;
				this.element.setStyle('overflow', 'hidden');
				this.element.setStyle('position', 'relative');
				this.opts = {duration:100};
			},
			
			start: function() {
				new Fx.Style(this.element, 'top', this.opts).start(10).chain(function() {
					new Fx.Style(this.element, 'top', {duration:200}).start(-10).chain(function() {
							new Fx.Style(this.element, 'top', {duration:200}).start(10).chain(function() {
								new Fx.Style(this.element, 'top', {duration:200}).start(-10).chain(function() {
									new Fx.Style(this.element, 'top', {duration:200}).start(10).chain(function() {
										new Fx.Style(this.element, 'top', {duration:200}).start(0);
										this.element.setStyle('position', 'static');
									});
								});
							});
						});
				});
			}
});


Fx.BubbleH = Fx.Base.extend({
			
			initialize: function(element) {
				this.element = $(element);
				this.element.setStyle('overflow', 'hidden');
			},
			
			start: function() {
				
				new Fx.Styles(this.element, {duration:3000}).start({
					'height': [0],
					'font-size': [0],
					'opacity': [0]
				});
			}
});


Fx.BubbleW = Fx.Base.extend({
			
			initialize: function(element) {
				this.element = $(element);
				this.element.setStyle('overflow', 'hidden');
			},
			
			start: function() {
				
				new Fx.Styles(this.element, {duration:3000}).start({
					'width': [0],
					'font-size': [0],
					'opacity': [0]
				});
			}
});


Fx.Morph = Fx.Styles.extend({
 
			start: function(className){
 
				var to = {};
 
				$each(document.styleSheets, function(style){
					var rules = style.rules || style.cssRules;
						$each(rules, function(rule) {
							if (!rule.selectorText.test('\.' + className + '$')) return;
							CSSProperties.each(function(style) {
								if (!rule.style || !rule.style[style]) return;
								var ruleStyle = rule.style[style];
								to[style] = (style.test(/color/i) && ruleStyle.test(/^rgb/)) ? ruleStyle.rgbToHex() : ruleStyle;
							});
						});
				});
				return this.parent(to);
			}
 
		});
 
CSSProperties = ["backgroundColor", "backgroundPosition", "color", "width", "height", "left", "top", "bottom", "right", "fontSize", "letterSpacing", "lineHeight", "textIndent", "opacity"];
 
CSSProperties.extend(Element.Styles.padding);
CSSProperties.extend(Element.Styles.margin); 

Element.Styles.border.each(function(border){
	['Width', 'Color'].each(function(property){
		CSSProperties.push(border + property);
	});
});


Fx.Move = Fx.Base.extend({
			
			initialize: function(element, top, left, options) {
				this.element = $(element);
				this._top = top;
				this._left = left;
				this.options = options;
				this.element.setStyle('postion', 'relative');
			},
			
			start: function() {
				var options = $extend({duration:2000}, this.options || {});
				
				new Fx.Styles(this.element, options).start({
					'top': [this._top],
					'left': [this._left]
				});
			}
});


/*
	Author: Riccardo Degni, <http://www.riccardodegni.it/>
	
	License: GNU GPL License
	
	Filename: moo.rd_toggle.js
	
	Class: Fx.Toggle

*/
Fx.Toggle = new Class({
						   
		initialize: function(element, property, options){
			this.element = $(element);
			this.property = property;
			this.iniWidth = this.element.getStyle('width');
			this.iniHeight = this.element.getStyle('height');
			this.element.setStyle('display', 'block');
			this.options = options;
		},

		toggleH: function() {
			
			this.element.setStyle('overflow','hidden');
  
 			if(this.element.getStyle('height').toInt() > 0)
  				new Fx.Style(this.element, 'height', this.options).start(0);
			else
  			 	new Fx.Style(this.element, 'height', this.options).start(this.iniHeight);
		},
		
		toggleW: function() {
			
			this.element.setStyle('overflow','hidden');
  
 			if(this.element.getStyle('width').toInt() > 0)
				new Fx.Style(this.element, 'width', this.options).start(0);
			else
				new Fx.Style(this.element, 'width', this.options).start(this.iniWidth);
		},
		
		toggleO: function() {
  
 			if(this.element.getStyle('opacity').toInt() > 0)
				new Fx.Style(this.element, 'opacity', this.options).start(0);
			else 
				new Fx.Style(this.element, 'opacity', this.options).start(1);
		},
		
	
	toggleProp: function(from, to) {
			
		this.from = from;
		this.to = to;
		this.element.setStyle('overflow','hidden');
  
  		if(($type(this.from) == 'string') && ($type(this.to) == 'string')) {
 			if((this.element.getStyle(this.property).toString()).indexOf(this.from.toLowerCase()) != -1)
				this.element.setStyle(this.from, this.to);
			else
				this.element.setStyle(this.to, this.from);
		}
		else if(($type(this.from) == 'number') && ($type(this.to) == 'number'))  {
			if(this.element.getStyle(this.property).toInt() == this.from)
				new Fx.Style(this.element, this.property, this.options).start(this.from, this.to);
			else
				new Fx.Style(this.element, this.property, this.options).start(this.to, this.from);
  		}
	},
	
	display: function() {
			
 			if(this.element.getStyle('display') == 'block')
				this.element.setStyle('display','none');
			else if(this.element.getStyle('display') != 'block')
				this.element.setStyle('display','block');
	},
	
	see: function() {
			if (this.element.getStyle('inherit')) 
				this.element.setStyle('visibility','visible');
 			if(this.element.getStyle('visibility') != 'visible')
				this.element.setStyle('visibility','visible');
			else if(this.element.getStyle('visibility') == 'visible')
				this.element.setStyle('visibility','hidden');
	}
			
});


/*
	Author: Riccardo Degni, <http://www.riccardodegni.it/>
	
	License: GNU GPL License
	
	Filename: moo.rd_virtualbox2.0.js
	
	Class: virtualBox

*/

var virtualBox = new Class({
	options: {
		easing: 'elastic',
		duration: 1600,
		position: 'center',
		mode: 'v'
	},
	
	initialize: function(styles, text, options) {
		this.styles = styles;
		this.text = text;
		this.setOptions(options);
	},
	
	customize: function() {
		
		if($('virtualBox2.0')) return;
		
		if(this.options.mode == 'v') {
			this.box = new Element('div', {
				'id': 'virtualBox2.0',
				'class': this.styles,
				'styles': {
					'position': 'absolute',
					'top': '-20%',
					'left': '50%',
					'z-index': 1000
				}
			});
		}
		else if(this.options.mode == 'h') {
			this.box = new Element('div', {
				'id': 'virtualBox2.0',
				'class': this.styles,
				'styles': {
					'position': 'absolute',
					'top': '50%',
					'left': '-20%',
					'z-index': 1000
				}
			});
		}
		
		this.overlay = new Element('div', {
			'id': 'overlay',
			'styles': {
				'position': 'absolute',
				'top': '0px',
				'left': '0px',
				'width': '100%',
				'height': window.getScrollHeight(),
				'background-color':'#333333',
				'opacity': '0.8',
				'z-index': 900
			}
		});
		
		this.page = new Element('div', {
				'id': 'virtualBox2.0page',
				'styles': {
					'position': 'relative',
					'top': window.getScrollTop(),
					'left': '0px',
					'width': window.getWidth() + 'px',
					'height': window.getHeight() + 'px',
					'z-index': 900
				}
		});
		
		if(!window.gecko) {
			this.box.addEvent('click', this.removeElements.bind(this));
			this.box.appendText(this.text);
			this.box.injectInside(this.page);
			this.page.injectInside(this.overlay);
			this.overlay.injectTop($E('body'));
		}
 
		this.box.setStyles({
			'margin-left': - this.box.getStyle('width').toInt()/2,
			'margin-top': - this.box.getStyle('height').toInt()/2
		});
 
 		if(window.gecko) {
			this.box.addEvent('click', this.removeElements.bind(this));
			this.box.appendText(this.text);
			this.box.injectInside(this.page);
			this.page.injectInside(this.overlay);
			this.overlay.injectTop($E('body'));
		}
		
		switch(this.options.easing) {
			case 'elastic': this.transition = Fx.Transitions.Elastic.easeOut; break;
			case 'bounce': this.transition = Fx.Transitions.Bounce.easeOut; break;
			case 'normal': this.transition = Fx.Transitions.Sine.easeInOut; break;
		};
		
		switch(this.options.position) {
			case 'top': this.pos = 20; break;
			case 'center': this.pos = 50; break;
			case 'bottom': this.pos = 80; break;
		};
		
		var opts = {duration: this.options.duration, 
					transition: this.transition,
					unit: '%'			
		};
		
		this.marginY = this.box.getStyle('height').toInt()/2;
		this.marginX = this.box.getStyle('width').toInt()/2;
		
		if(this.options.mode == 'v')
			new Fx.Style(this.box, 'top', opts).start(-20, this.pos);
		else if(this.options.mode == 'h')
			new Fx.Style(this.box, 'left', opts).start(-20, this.pos);
		
	},
	
	start: function() {
		this.customize();	
	},
	
	removeElements: function() {
		var overlay = this.overlay;
		if(this.options.mode == 'v') 
			new Fx.Style(this.box, 'top', {unit: '%'}).start(-this.marginY*4).chain(function() {
				overlay.remove();															
			});
		else if(this.options.mode == 'h')
			new Fx.Style(this.box, 'left', {unit: '%'}).start(-this.marginY*4).chain(function() {
				overlay.remove();															
			});
	}
						   
});

virtualBox.implement(new Options);


/*
	Author: Riccardo Degni, <http://www.riccardodegni.it/>
	
	License: GNU GPL License
	
	Filename: moo.rd_ajaxvirtualbox2.0.js
	
	Class: ajaxVirtualBox

*/

var ajaxVirtualBox = new Class({
							   
	options: {
		easing: 'elastic',
		duration: 1600,
		position: 'center',
		mode: 'v'
	},
	
	initialize: function(styles, closeStyles, page, options) {
		this.styles = styles;
		this.closeStyles = closeStyles;
		this.page = page;
		this.setOptions(options);
	},
	
	customize: function() {
		
		if($('ajaxVirtualBox2.0_RD')) return;

		if(this.options.mode == 'v') {
			this.box = new Element('div', {
				'id': 'ajaxVirtualBox2.0_RD',
				'class': this.styles,
				'styles': {
					'position': 'absolute',
					'top': '-20%',
					'left': '50%',
					'z-index': 1000
				}
			});
		}
		else if(this.options.mode == 'h') {
			this.box = new Element('div', {
				'id': 'ajaxVirtualBox2.0_RD',
				'class': this.styles,
				'styles': {
					'position': 'absolute',
					'top': '50%',
					'left': '-20%',
					'z-index': 1000
				}
			});
		}
		
		this.overlay = new Element('div', {
			'id': 'overlay',
			'styles': {
				'position': 'absolute',
				'top': '0px',
				'left': '0px',
				'width': '100%',
				'height': window.getScrollHeight(),
				'background-color':'#333333',
				'opacity': '0.8',
				'z-index': 900
			}
		});
		
		this.thepage = new Element('div', {
				'id': 'virtualBox2.0page',
				'styles': {
					'position': 'relative',
					'top': window.getScrollTop(), //'0px',
					'left': '0px',
					'width': window.getWidth() + 'px',
					'height': window.getHeight() + 'px',
					'z-index': 900
				}
		});
		
		this.close = new Element('div', {
			'id': 'close_vbox2.0',
			'class': this.closeStyles,
			'styles': {
				'position': 'absolute',
				'top': (window.getScrollTop()>0) ? window.getScrollTop() : '10px',
				'left': '10px',
				'z-index': 900
			}
		});
		
		if(!window.gecko) {
			this.close.addEvent('click', this.removeElements.bind(this));
			this.box.appendText(this.text);
			this.box.injectInside(this.thepage);
			this.thepage.injectInside(this.overlay);
			this.close.appendText(this.closetext || 'close');
			this.close.injectInside(this.overlay);
			this.overlay.injectTop($E('body'));
		}
 
		this.box.setStyles({
			'margin-left': - this.box.getStyle('width').toInt()/2,
			'margin-top': - this.box.getStyle('height').toInt()/2
		});
 
 		if(window.gecko) {
			this.close.addEvent('click', this.removeElements.bind(this));
			this.box.appendText(this.text);
			this.box.injectInside(this.thepage);
			this.thepage.injectInside(this.overlay);
			this.close.appendText(this.closetext || 'close');
			this.close.injectInside(this.overlay);
			this.overlay.injectTop($E('body'));
		}
		
		switch(this.options.easing) {
			case 'elastic': this.transition = Fx.Transitions.Elastic.easeOut; break;
			case 'bounce': this.transition = Fx.Transitions.Bounce.easeOut; break;
			case 'normal': this.transition = Fx.Transitions.Sine.easeInOut; break;
		};
		
		switch(this.options.position) {
			case 'top': this.pos = 20; break;
			case 'center': this.pos = 50; break;
			case 'bottom': this.pos = 80; break;
		};
		
		var opts = {duration: this.options.duration, 
					transition: this.transition,
					unit: '%'			
		};
		
		this.marginY = this.box.getStyle('height').toInt()/2;
		this.marginX = this.box.getStyle('width').toInt()/2;
		
		if(this.options.mode == 'v')
			new Fx.Style(this.box, 'top', opts).start(-20, this.pos);
		else if(this.options.mode == 'h')
			new Fx.Style(this.box, 'left', opts).start(-20, this.pos);
		
		this.ajax = $extend(this.xhr || {}, {
			update: 'ajaxVirtualBox2.0_RD'		 
		});
		
		new Ajax(this.page, this.ajax).request();
		
	},
	
	start: function() {
		this.customize();	
	},
	
	removeElements: function() {
		var overlay = this.overlay;
		if(this.options.mode == 'v') 
			new Fx.Style(this.box, 'top', {unit: '%'}).start(-this.marginY*4).chain(function() {
				overlay.remove();															
			});
		else if(this.options.mode == 'h')
			new Fx.Style(this.box, 'left', {unit: '%'}).start(-this.marginY*4).chain(function() {
				overlay.remove();															
			});
	},
	
	setCloseText: function(text) {
		this.closetext = text;
		return this;
	},
	
	setXhrOptions: function(xhr) {
		this.xhr = xhr;
		return this;
	}
						   
});

ajaxVirtualBox.implement(new Options);



