var Controller = new Class({
	options : {	},

    /*
	Constructor: initialize
		Constructor
	
		-
	*/
	initialize : function(options) {
		this.setOptions(options)
		
		this._initClass();
	},
	/*
	Function: _
		Internal method
		
		Parameters:
			
	*/
	_initClass : function() {
		
		/* ----- FORMCHECK ----- */
		if ($('mainform')) 
			fmain = new FormCheck('mainform', {
				display : {
				fadeDuration : 500,
				errorsLocation : 1,
				indicateErrors : 1,
				showErrors : 1
			}});
		
		if ($('signin')) 
			fmain = new FormCheck('signin', {
				display : {
				fadeDuration : 500,
				errorsLocation : 1,
				indicateErrors : 1,
				showErrors : 1
			}});
		
		if ($('address_book')) 
			fmain = new FormCheck('address_book', {
				display : {
				fadeDuration : 500,
				errorsLocation : 1,
				indicateErrors : 1,
				showErrors : 1
			}});
		
		/* ----- BOX ----- */
		new Box({
			skin_name : 'vibes',
			skin_path : 'skins/'
		});
	
		/* ----- LANGUAGE ----- */		
		var myLangMenu = new LangMenu();
		
		/* ----- RATELIST ----- */	
		if ($('lst_rates')) var ratelist = new RateList();
				
		/* ----- REGISTER ----- */			
		if ($('country_chooser')) new Register();	

		/* ----- UPLOAD ----- */		
		if ($('upload_legalfile')) new Upload();
		
		/* ----- CHECKOUT ----- */			
		new Checkout();
		
		/* ----- TELL A FRIEND ----- */
		$ES('.tellafriend','#template').each( function(el_box) {
			$ES('a',el_box).each( function(el) {				
				el.addEvent('click', function(e){
					new Event(e).stop();
					var url = el.getProperty('href') + "&sendinglink=" + document.URL + "&usepublishedpage=no";
					var popup = new Popup();
					popup.open(url);
				}.bind(this));
			},this);				
		},this);
		
		/* ----- CALC ----- */
		if($E('.calc','#template')) {
			calc = new Calc({
				target : $E('.calc','#template'),
				Express : (document.forms['calc-uts'] && document.forms['calc-uts'].product_properties_express && document.forms['calc-uts'].product_properties_express.value == '0') ? false : true,
				'onEnter' : function() {
					this.form.submit();
				}
			});
			
			//calc.setAmount('200');
			//calc.setMode(2);	
		}	
	}	
});

Controller.implement(new Options, new Events);

window.addEvent('domready',function() {
	new Controller();
});/*
	Class:  Box.js
		Let add skinned container to any html containers

	Usage:
		Add a skinned container to any element that match a target css class
				
				
		Options:
			target : the target
			skin : the skin
			
			eTRX SA 
			
						
			
        Exemple:
                (code)
                <script type="text/javascript">
                        window.addEvent('domready', function() {
                                var IFBox = new MooShadow({
									target 	: '.item',
									skin_name : 'vibesbox',
									path_path : 'skins/'
								});
                        });
                </script>
                (end code)
		
        About:
               	Box.js v.1.0 for mootools v1.1 06 / 2007

                by Floor SA (http://www.floor.ch) MIT-style license

                Created by Luca Pillonel and David Mignot
*/


var Box = new Class({
	options : {
		'target_class' : '.box',
		'default_skin' : 'vibes',
		'available_skins' : ['vibes','blue','mini']
	},

	initialize: function(options){
		this.setOptions(options);
		
		//$('content').setStyle('opacity','0');
		
		this._parseDOM();
		
		//var fx = new Fx.Styles($('content'), {duration:700, wait:false});

		//fx.start({
		//	'opacity': '1'
		//});
	},
	
	_parseDOM:function(){
		var boxes = $$(this.options.target_class);

		boxes.each(function(el, n){
			this._addBox(el);
		}.bind(this));
	},
	
	_addBox:function(el){
		
		var iefix = '';
		if(Window.ie6){
			iefix = " png";
		}
		
		var boxclass = '';
		
		this.options.available_skins.each(function(bclass) {
			if (el.hasClass(bclass)) {
				boxclass = 'IFBox-'+bclass;	
			}	
		});
		
		if (!boxclass) { boxclass = 'IFBox-'+this.options.default_skin }

		el.IFBoxTable = new Element('table').addClass(boxclass).injectAfter(el);
		el.IFBoxTBody = new Element('tbody').addClass(boxclass).injectInside(el.IFBoxTable);
		
		el.tr1 = new Element('tr').injectInside(el.IFBoxTBody);
				el.topLeft = new Element('td').addClass('tl'+iefix).injectInside(el.tr1);
				el.shtop = new Element('td').addClass('t'+iefix).injectInside(el.tr1);
				el.topRight = new Element('td').addClass('tr'+iefix).injectInside(el.tr1);
		el.tr2 = new Element('tr').injectInside(el.IFBoxTBody);
				el.shleft = new Element('td').addClass('l'+iefix).injectInside(el.tr2);
				el.shimg = new Element('td').addClass('body').injectInside(el.tr2);
				el.shright = new Element('td').addClass('r'+iefix).injectInside(el.tr2);
		el.tr3 = new Element('tr').injectInside(el.IFBoxTBody);
				el.bottomLeft = new Element('td').addClass('bl'+iefix).injectInside(el.tr3);
				el.shbottom = new Element('td').addClass('b'+iefix).injectInside(el.tr3);
				el.bottomRight = new Element('td').addClass('br'+iefix).injectInside(el.tr3);
		el.injectInside(el.shimg);
	}
});

Box.implement(new Options);

/*window.addEvent('domready', function() {
	new Box({
		skin_name : 'vibes',
		skin_path : 'skins/'
	});
});*/if (!window.ie6) {
	window.addEvent('domready', function() {
		var szNormal = 97, szSmall  = 90, szFull   = 118;
		
		if ($('skwicks')) {
		
			var kwicks = $$("#skwicks .skwick");
			var fx = new Fx.Elements(kwicks, {wait: false, duration: 300, transition: Fx.Transitions.Back.easeOut});
			kwicks.each(function(kwick, i) {
			
				kwick.addEvent("mouseenter", function(event) {
					var o = {};
					o[i] = {width: [kwick.getStyle("width").toInt(), szFull]}
					kwicks.each(function(other, j) {
						if(i != j) {
							var w = other.getStyle("width").toInt();
							if(w != szSmall) o[j] = {width: [w, szSmall]};
						}
					});
					fx.start(o);
				});
			});
			 
			$("skwicks").addEvent("mouseleave", function(event) {
				var o = {};
				kwicks.each(function(kwick, i) {
					var sz = szSmall; 
					if  (kwick.hasClass('s')) { sz = szFull }
					o[i] = {width: [kwick.getStyle("width").toInt(), sz]}
				});
				fx.start(o);
			});
		
		}
	});
}if(!window.ie6) {
	window.addEvent('domready', function() {
		var szNormal = 145, szSmall  = 132, szFull   = 182;
		
		if ($('kwicks')) {
		
			var kwicks = $$("#kwicks .kwick");
			var fx = new Fx.Elements(kwicks, {wait: false, duration: 300, transition: Fx.Transitions.Back.easeOut});
			kwicks.each(function(kwick, i) {
			
				kwick.addEvent("mouseenter", function(event) {
					var o = {};
					o[i] = {width: [kwick.getStyle("width").toInt(), szFull]}
					kwicks.each(function(other, j) {
						if(i != j) {
							var w = other.getStyle("width").toInt();
							if(w != szSmall) o[j] = {width: [w, szSmall]};
						}
					});
					fx.start(o);
				});
			});
			 
			$("kwicks").addEvent("mouseleave", function(event) {
				var o = {};
				kwicks.each(function(kwick, i) {
					o[i] = {width: [kwick.getStyle("width").toInt(), szNormal]}
				});
				fx.start(o);
			});
		
		}
	});
}

var Ticker = new Class({
	setOptions: function(options) {
		this.options = Object.extend({
			speed: 1000,
			delay: 5000,
			direction: 'vertical',
			onComplete: Class.empty,
			onStart: Class.empty
		}, options || {});
	},
	initialize: function(el,options){
		this.setOptions(options);
		this.el = $(el);
		this.items = this.el.getElements('li');
		var w = 0;
		var h = 0;
		if(this.options.direction.toLowerCase()=='horizontal') {
			h = this.el.getSize().size.y;
			this.items.each(function(li,index) {
				w += li.getSize().size.x;
			});
		} else {
			w = this.el.getSize().size.x;
			this.items.each(function(li,index) {
				h += li.getSize().size.y;
			});
		}
		this.el.setStyles({
			position: 'absolute',
			top: 0,
			left: 0,
			width: w,
			height: h
		});
		this.fx = new Fx.Styles(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();
	},
	
	next: function() {
		this.current++;
		if (this.current >= this.items.length) this.current = 0;
		var pos = this.items[this.current];
		this.fx.start({
			top: -pos.offsetTop,
			left: -pos.offsetLeft
		});
		this.next.bind(this).delay(this.options.delay+this.options.speed);
	}
});

/*
Script: languagemenu.js v1.0
		Script appeared countries images.

License:
        MIT-style license.

About:
		languagemenu.js for mootools framework <http://www.mootools.net/> (c) 2007 Valerio Proietti, MIT-style license.
		Class created by Sylvain Barraux, Yvan Cottet and Gregory Paccaud, <http://www.esl.ch/>.
		Last modification, 14 december 2007.

Version: 1.0

Note:
		XHTML doctype is required.
		
*/

/*
Class: LangMenu
		On click on div class "langtitle", show div class "langflags". And use tips for images
		tips see : <http://docs.mootools.net/Plugins/Tips.js>
		
Events:
		click	On button

Example:

		(start code)
		var myLangMenu = new LangMenu();
		(end)
		
Note:
		Don't forget to insert "<script language="Javascript" type="text/javascript" src="js/mootools.js"></script>" into the head page before this js file.
*/

var LangMenu = new Class({
						 	
	initialize : function() {
		this.initMenu();
		this.initTips();
	},
	
	// -----------------------------------------------------------------
	initMenu : function() {
		var lang = $$('.lang');
		
		lang.each(function(slang,i){
			var stitle = $E('.langtitle',slang);
			var smenu = $E('.langflags',slang);
			var state = 'closed';
	   		var fx = new Fx.Style(smenu,'width',{duration:200, wait:false, transition:Fx.Transitions.quadOut});
			
			stitle.addEvent('click', function(e){
				if(state=='closed'){
					fx.start(0,122);
					stitle.addClass('langtitle_s');
					state='open';
				}else{
					fx.start(122,0);
					stitle.removeClass('langtitle_s');
					state='closed';			
				}
			}.bind(this));
		},this);
	},
	
	initTips : function(){
	
			var langtips = new Tips($$('.tooltips'), {
			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);},
			offsets : {'x':-10, 'y':20},
			fixed:true
		});
	}

});var cities = new Array();

cities[1] = new Array([1,'SANDINO'],[2,'MANTUA'],[3,'MINAS DE MATAHAMBRE'],[4,'VIÑALES'],[5,'LA PALMA'],[6,'BAHIA HONDA'],[7,'CANDELARIA'],[8,'SAN CRISTOBAL'],[9,'LOS PALACIOS'],[10,'CONSOLACION DEL SUR'],[11,'PINAR DEL RIO'],[12,'SAN LUIS'],[13,'SAN JUAN Y MARTINEZ'],[14,'GUANES']);
cities[2] = new Array([15,'MARIEL'],[16,'GUANAJAY'],[17,'CAIMITO'],[18,'BAUTA'],[19,'SAN ANTONIO DE LOS BAÑOS'],[20,'BEJUCAL'],[21,'SAN JOSE DE LAS LAJAS'],[22,'JARUCO'],[23,'SANTA CRUZ DEL NORTE'],[24,'MADRUGA'],[25,'NUEVA PAZ'],[26,'SAN NICOLAS'],[27,'GUINES'],[28,'MELENA DEL SUR'],[29,'BATABANO'],[30,'QUIVICAN'],[31,'GUIRA DE MELENA'],[32,'ALQUIZAR'],[33,'ARTEMISA']);
cities[3] = new Array([34,'PLAYA'],[35,'PLAZA DE LA REVOLUCION'],[36,'CENTRO HABANA'],[37,'LA HABANA VIEJA'],[38,'REGLA'],[39,'LA HABANA DEL ESTE'],[40,'GUANABACOA'],[41,'SAN MIGUEL DEL PADRON'],[42,'DIEZ DE OCTUBRE'],[43,'CERRO'],[44,'MARIANAO'],[45,'LA LISA'],[46,'BOYEROS'],[47,'ARROYO NARANJO'],[48,'COTORRO']);
cities[4] = new Array([49,'MATANZAS'],[50,'CARDENAS'],[51,'VARADERO'],[52,'MARTI'],[53,'COLON'],[54,'PERICO'],[55,'JOVELLANOS'],[56,'PEDRO BETANCOURT'],[57,'LIMONAR'],[58,'UNION DE REYES'],[59,'CIENAGA DE ZAPATA'],[60,'JAGUEY GRANDE'],[61,'CALIMETE'],[62,'LOS ARABOS']);
cities[5] = new Array([63,'CORRALILLO'],[64,'QUEMADO DE GUINES'],[65,'SAGUA LA GRANDE'],[66,'ENCRUCIJADA'],[67,'CAMAJUANI'],[68,'CAIBARIEN'],[69,'REMEDIOS'],[70,'PLACETAS'],[71,'SANTA CLARA'],[72,'CIFUENTES'],[73,'SANTO DOMINGO'],[74,'RANCHUELO'],[75,'MANICARAGUA']);
cities[6] = new Array([76,'AGUADA DE PASAJEROS'],[77,'RODAS'],[78,'PALMIRA'],[79,'LAJAS'],[80,'CRUCES'],[81,'CUMANAYAGUA'],[82,'CIENFUEGOS'],[83,'ABREUS']);
cities[7] = new Array([84,'YAGUAJAY'],[85,'JATIBONICO'],[86,'TAGUASCO'],[87,'CABAIGUAN'],[88,'FOMENTO'],[89,'TRINIDAD'],[90,'SANCTI SPIRITUS'],[91,'LA SIERPE']);
cities[8] = new Array([92,'CHAMBAS'],[93,'MORON'],[94,'BOLIVIA'],[95,'PRIMERO DE ENERO'],[96,'CIRO REDONDO'],[97,'FLORENCIA'],[98,'MAJAGUA'],[99,'CIEGO DE AVILA'],[100,'VENEZUELA'],[101,'BARAGUA']);
cities[9] = new Array([102,'CARLOS MANUEL DE CESPEDES'],[103,'ESMERALDA'],[104,'SIERRA DE CUBITAS'],[105,'MINAS'],[106,'NUEVITAS'],[107,'GUAIMARO'],[108,'SIBANICU'],[109,'CAMAGUEY'],[110,'FLORIDA'],[111,'VERTIENTES'],[112,'JIMAGUAYU'],[113,'NAJASA'],[114,'SANTA CRUZ DEL SUR']);
cities[10] = new Array([115,'MANATI'],[116,'PUERTO PADRE'],[117,'JESUS MENENDEZ'],[118,'MAJIBACOA'],[119,'LAS TUNAS'],[120,'JOBABO'],[121,'COLOMBIA'],[122,'AMANCIO']);
cities[11] = new Array([123,'GIBARA'],[124,'RAFAEL FREIRE'],[125,'BANES'],[126,'ANTILLA'],[127,'BAGUANOS'],[128,'HOLGUIN'],[129,'CALIXTO GARCIA'],[130,'CACOCUM'],[131,'URBANO NORIS'],[132,'CUETO'],[133,'MAYARI'],[134,'FRANK PAIS'],[135,'SAGUA DE TANAMO'],[136,'MOA']);
cities[12] = new Array([137,'RIO CAUTO'],[138,'CAUTO CRISTO'],[139,'JIGUANI'],[140,'BAYAMO'],[141,'YARA'],[142,'MANZANILLO'],[143,'CAMPECHUELA'],[144,'MEDIA LUNA'],[145,'NIQUERO'],[146,'PILON'],[147,'BARTOLOME MASO'],[148,'BUEY ARRIBA'],[149,'GUISA']);
cities[13] = new Array([150,'CONTRAMAESTRE'],[151,'MELLA'],[152,'SAN LUIS'],[153,'SEGUNDO FRENTE'],[154,'SONGO - LA MAYA'],[155,'SANTIAGO DE CUBA'],[156,'PALMA SORIANO'],[157,'TERCER FRENTE'],[158,'GUAMA']);
cities[14] = new Array([159,'EL SALVADOR'],[160,'GUANTANAMO'],[161,'YATERAS'],[162,'BARACOA'],[163,'MAISI'],[164,'IMIAS'],[165,'SAN ANTONIO DEL SUR'],[166,'MANUEL TAMES'],[167,'CAIMANERA'],[168,'NICETO PEREZ']);
cities[15] = new Array([169,'NUEVA GERONA']);

/*
	Class: Calculator
		
	Usage:
		Use to manage UTS rate calculatore
		
	Parameters:
		- 
		
	Exemple:
	
	About:
		Calculator.js v.1.0 for mootools v1.1 05 / 2007
		
		by Floor SA (http://www.floor.ch) MIT-style license
		
		last modified by Denis Schneiter 22.10.2007
*/
var Calc = new Class({
	options : {
		'form_name' 	: 'mainform',
		'mode' : 1,
		'amount' : 200,
		'draggable' 	: false,
		
		'Taxes'			: new Array(
							new Array(30,0.18),
							new Array(50,0.11),
							new Array(300,0.1),
							new Array(600,0.09)
						),
		'ExpressCharge'			: 0.01,
		'ExchangeRateCharge' 	: 0.881057269,  
		'ExchangeMargin' 		: 0.95,
		'ExchangeMarginCH'		: 0.90,
		'MinAmount'		 		: 30, 
		'MaxAmount' 			: 1800,
		'Express'		: true,
		'ratefile' 		: '/var/exchangerates/today/eur.json',
		'ifwScript' 	: '/floor/app',
		'csScript'		: '/cgi/ifw?server=utstrx&lang=en',
		'onClose'		: Class.empty,
		'onEnter'		: Class.empty,
		'calling_class' : '',
		'build'			: false,
		'lbl_sendbtn'	: 'Update',
		'language' 		: {	'title': 'Calculator',
							'sent': 'Sent',
							'fees': 'Fees',
							'pay': 'You pay',
							'pay_in': '~ in',
							'delivered': 'Delivered',
							'rate': 'Rate EUR/CUC',
							'clear': 'c',
							'mode': 'mode',
							'sendbtn': 'Update',
							'init_amount': '--'
							},
		'title'			: 'title_calc'
 	},

    /*
	Constructor: initialize
		Constructor
	
		call rates and add event to enter amount or change trx type
	*/
	initialize : function(options) {
		this.setOptions(options);
		
		if (this.options.build) {
			if (typeof(CalcLanguage) != 'undefined') this.options.language = CalcLanguage;
			this._build();	
			this.calculator.injectInside($('center'));
		} else {
			this.calculator = this.options.target;
		
			this.form = $E('form',this.calculator);
			this.input = $E('.amount',this.calculator);
		}
		
		if (this.options.draggable) { this._makeDraggable(); }
		
		this._getConfig();
		this._getCountry();
		this._initKeyboard();
		this._initTouchScreen();
		
		//this.setMode(this.options.mode);
		
		this.calculator.onkeydown = function(event){
			var event = new Event(event);
			if (event.key == 'up') { this.nextMode(this.mode); }
			if (event.key == 'down') { this.previousMode(this.mode); }
		}.bind(this);
		
		
		// try to prevent selection of calculator except input.amout
		//this.calculator.addEvent('onselectstart' = function(event){
		//	var event = new Event(event);
		//	event.preventDefault();
		//}.bind(this);
		
				
		this.input.addEvent('keyup', function(e){
			this._calculateAmount();
		}.bind(this))
			
		this.input.addEvent('click', function(e){
			this.input.select();
		}.bind(this));
		
	},	

	/*
	Function: build
		Set amount
		
		Parameters:
			-
	*/
	
	_build : function() {
		this.calculator = new Element('div', {'class' : 'calc'});
		
		var form = new Element('form', {'autocomplete' : 'off'}).injectInside(this.calculator);
	
		this.input = new Element('input', {
			'name' : 'product_properties_amount',
			'class' : 'amount txt validate[\'required\',\'digit[30,1800]\']',
			'value' : ''	
		}).injectInside(form);
		
		var calc_close = new Element('span', {'class' : 'close'}).injectInside(form);
			new Element('img', {
				'alt' : 'close',
				'src' : '/img/calc/cl.png'
			}).injectInside(calc_close);
			
		var calc_title = new Element('h3', {'id' : 'title_calc'}).setHTML(this.options.language.title).injectInside(form);
		new Element('br').injectInside(calc_title);

		var screen = new Element('div', {'class' : 'screen'}).injectInside(form);

		var table = new Element('table').injectInside(screen);
			var tbody = new Element('tbody').injectInside(table);
				var tr1 = new Element('tr', {'class' : 'r2'}).injectInside(tbody);
					new Element('td', {'class' : 'c1'}).setHTML(this.options.language.sent).injectInside(tr1);
					new Element('td', {'class' : 'c2 eur'}).injectInside(tr1);
					new Element('td', {'class' : 'c3 send'}).setHTML(this.options.language.init_amount).injectInside(tr1);
					
				var tr2 = new Element('tr', {'class' : 'r3'}).injectInside(tbody);
					new Element('td', {'class' : 'c1'}).setHTML(this.options.language.fees).injectInside(tr2);
					new Element('td', {'class' : 'c2 eur'}).injectInside(tr2);
					new Element('td', {'class' : 'c2 fees'}).setHTML(this.options.language.init_amount).injectInside(tr2);

				var tr3 = new Element('tr', {'class' : 'r4'}).injectInside(tbody);
					new Element('td', {'class' : 'c1'}).setHTML(this.options.language.pay).injectInside(tr3);
					new Element('td', {'class' : 'c2 eur'}).injectInside(tr3);
					new Element('td', {'class' : 'c3 topay'}).setHTML(this.options.language.init_amount).injectInside(tr3);
					
				var tr4 = new Element('tr', {'class' : 'r5'}).injectInside(tbody);
					new Element('td', {'class' : 'c1 locallbl'}).setHTML(this.options.language.pay_in).injectInside(tr4);
					new Element('td', {'class' : 'c2 localcur'}).injectInside(tr4);
					new Element('td', {'class' : 'c3 local'}).setHTML(this.options.language.init_amount).injectInside(tr4);
				
				var tr5 = new Element('tr', {'class' : 'r1'}).injectInside(tbody);
					new Element('td', {'class' : 'c1'}).setHTML(this.options.language.delivered).injectInside(tr5);
					new Element('td', {'class' : 'c2 cuc'}).injectInside(tr5);
					new Element('td', {'class' : 'c3 deliver'}).setHTML(this.options.language.init_amount).injectInside(tr5);

		var info = new Element('div', {'class' : 'info'}).setHTML(this.options.language.rate).injectInside(screen);
			new Element('div', {'class' : 'rate'}).injectInside(info)
					
		var keyboard = new Element('div', {'class' : 'keyboard'}).injectInside(form);
			new Element('span').setHTML('7').injectInside(keyboard);
			new Element('span').setHTML('8').injectInside(keyboard);
			new Element('span').setHTML('9').injectInside(keyboard);
			
			new Element('span', {'class' : 'clr'}).setHTML(this.options.language.clear).injectInside(keyboard);
			
			new Element('span').setHTML('4').injectInside(keyboard);
			new Element('span').setHTML('5').injectInside(keyboard);
			new Element('span').setHTML('6').injectInside(keyboard);
			
			var kb_del = new Element('span', {'class' : 'del'});
			new Element('img', {
				'alt' : 'delete',
				'src' : '/img/calc/c.png'
			}).injectInside(kb_del);
			kb_del.injectInside(keyboard);
			
			new Element('span').setHTML('1').injectInside(keyboard);
			new Element('span').setHTML('2').injectInside(keyboard);
			new Element('span').setHTML('3').injectInside(keyboard);
			
			new Element('span', {'class' : 'mod'}).setHTML(this.options.language.mode).injectInside(keyboard);
			
			new Element('span').setHTML('0').injectInside(keyboard);
			new Element('span').setHTML('.').injectInside(keyboard);
			new Element('span', {'class' : 'send'}).setHTML(this.options.language.sendbtn).injectInside(keyboard);
			new Element('span', {'class' : 'ruler'}).injectInside(keyboard);
			new Element('span', {'class' : 'express'+((this.options.Express) ? ' selected' : '')}).setHTML(((this.options.Express) ? 'Express' : 'Standard')).injectInside(keyboard);
			//new Element('span', {'class' : 'eurusd'}).setHTML('EUR / USD').injectInside(keyboard);
			new Element('div', {'class' : 'clear'}).injectInside(keyboard);
		
		// add event for close-btn
		calc_close.addEvent('click', function(ev) {
			this.fireEvent('onClose');
		}.bind(this));
	},
	
	/*
	Function: setAmount
		Set amount
		
		Parameters:
			-
	*/
	
	setAmount : function(amount) {
		this.input.value = amount;
	},

	/*
	Function: _initNumericPad
		Internal method
		
		Add events to numeric touches
		
		Parameters:
			-
	*/
	_initKeyboard : function() {
		this.keyboard = $E('.keyboard',this.calculator);
		
		this.keyboard.getChildren().each( function(touch){
			touch.addEvent('click', function(ev) { 				
				if (touch.hasClass('del')) { 
					this.input.value=this.input.value.substr(0,this.input.value.length -1);
				}
				else if (touch.hasClass('clr')) { 
					this.input.value='';
					this.clearScreen();	
				}
				else if (touch.hasClass('mod')) { 
					this.nextMode();
				}
				else if (touch.hasClass('send')) { 
					this.fireEvent('onEnter');
				}
				else if (touch.hasClass('express')) { 
					this.toggleExpress(touch);
				}
				/*else if (touch.hasClass('eurusd')) { 
					this.toggleCurrency(touch);
				}*/
				else {
					this.input.value = this.input.value + touch.getText();
				}
				this._calculateAmount();
			}.bind(this));
		},this)
		
		if (!this.options.draggable) {
			this._disableSelection(this.calculator);
		}
	},
	
	/*
	Function: _initNumericPad
		Internal method
		
		Add events to numeric touches
		
		Parameters:
			-
	*/
	
	_initTouchScreen : function() {
		
		/*
		this.scrEen = $E('.screen',this.calculator);
		
		this.scrEen.addEvent('mouseleave', function(e) {	
			this.input.setStyle('display','none');
		}.bind(this));	
		
		this.scrEen.addEvent('mouseenter', function(e) {	
			this.input.setStyle('display','block');
		}.bind(this));	
			*/	
		
		
		$E('.topay',this.calculator).setStyle('cursor','pointer').addEvent('click', function(ev) { 
			this.setMode(1);
			this.input.select();
		}.bind(this));
		
		$E('.send',this.calculator).setStyle('cursor','pointer').addEvent('click', function(ev) { 												   
			this.setMode(2);
			this.input.select();
		}.bind(this));
		
		$E('.deliver',this.calculator).setStyle('cursor','pointer').addEvent('click', function(ev) { 
			this.setMode(3);
			this.input.select();
		}.bind(this));
		
		//$E('.local',this.calculator).addEvent('click', function(ev) { 
		//	this.setMode(3);
		//}.bind(this));
	},

	/*
	Function: setMode
		Internal method
		
		Set Mode
		
		Parameters:
			mode
	*/
	
	setMode :function(mode) {
		// .log('setMode:'+mode);
		
		switch(mode) {
			case 1: 
				this._setInput($E('.topay',this.calculator).getCoordinates());
				this.mode = 1;
				this.currency = 'EUR';
				this._calculateAmount();
				break; 
			case 2: 
				this._setInput($E('.send',this.calculator).getCoordinates());
				this.mode = 2;
				this.currency = 'EUR';
				this._calculateAmount();	
				break; 
			case 3: 
				this._setInput($E('.deliver',this.calculator).getCoordinates());
				this.mode = 3;
				this.currency = 'CUC';
				this._calculateAmount();
				break; 
			/*case 4: 
				this._setInput($E('.local',this.calculator).getCoordinates());
				this.mode = 4;
				this.currency = this.country;
				this._calculateAmount();
				break;*/ 
		}

	},
	
	/*
	Function: _nextMode
		Internal method
		
		calculate and set Mode
		
		Parameters:
			mode
	*/
	
	nextMode :function() {
		var mode = this.mode;

		(mode < 3 ) ? mode++ : mode = 1;
		
		this.setMode(mode);
	},
	
	/*
	Function: _previousMode
		Internal method
		
		calculate and set Mode
		
		Parameters:
			mode
	*/
	
	previousMode :function() {
		var mode = this.mode;

		(mode > 1 ) ? mode-- : mode = 3;
		
		this.setMode(mode);
	},
	
	/*
	Function: toggleExpress
		public method
		
		toggle express-mode
		
		Parameters:
			the btn-el
	*/
	toggleExpress : function(el)	{
		if (this.options.Express){
			this.options.Express = false;
			el.removeClass('selected');
			el.setHTML('Standard');
		}
		else	{
			this.options.Express = true;
			el.addClass('selected');
			el.setHTML('Express');
		}
		if (this.form)
			this.form.product_properties_express.value = (this.options.Express) ? 1 : 0;
	},
	
	/*
	Function: toggleCurrency
		public method
		
		toggle currency (eur / usd)
		
		Parameters:
			the btn-el
	*/
	toggleCurrency : function(el)	{
		if (this.options.Currency == 'EUR'){
			this.options.Currency = 'USD';
		}
		else	{
			this.options.Currency = 'EUR';
		}
		this._setCurrency(this.options.Currency);
		if (this.form)
			this.form.basket_currency.value = this.options.Currency;
	},
	
	_setCurrency : function(cur)	{
		
	},
	
	/*
	Function: _setInput
		Internal method
		
		Place input field where it should be
		
		Parameters:
			-
	*/
	
	_setInput :function(coord) {
		var offset_y = 0;
		var offset_x = 0;
		
		if (this.calculator.getStyle('position') == 'absolute') {
			var calccoord = this.calculator.getCoordinates();
			offset_y= calccoord.top;
			offset_x= calccoord.left;	
		}
		
		this.input.setStyles( {
			'display': 'block',
			'top' : coord.top-offset_y-1,
			'left' : coord.left-offset_x+4,
			'width' : coord.width-15
			
		});	
		
		//this.input.select();
		
	},

	/*
	Function: _calculateAmount
		Internal method
		
		Calculate amount
		
		Parameters:
			-
	*/
	_calculateAmount : function() {	
		if (!this.mode) { this.mode = this.options.mode; }
		if (!this.currency) { this.currency = 'EUR'; }		
		this.amount = this.input.value.replace(/[^\d.]/g,"");
		if (!this.amount) { this.amount = "0"; }
		this.floatamount = this.amount.toFloat();
		
		if ($E('.product_mode',this.calculator)) {
			$E('.product_mode',this.calculator).setProperty('value',this.mode);
		}
		if ($E('.currency',this.calculator)) {
			$E('.currency',this.calculator).setProperty('value',this.currency);			
		}		
		
		if (this._checkAmount(this.floatamount)) {
			this.input.removeClass('error_calc');
			this.currency="EUR";
		
			switch (this.mode) { 
			case 1:
				this._getTax();
				this.fees = (this.floatamount * this.tax);
				this.delivered = (this.floatamount - this.fees) * this.cubrate;
				this.topay = this.floatamount;
				break;
			case 2: 
				this._getTax();
				this.fees = (this.floatamount / (1 - this.tax)  * this.tax);
				this.delivered = (this.floatamount) * this.cubrate;
				this.topay = this.floatamount + this.fees;
				break;
			case 3:
				this.currency="CUC";
				this.floatamount = this.floatamount / this.cubrate;
				this._getTax();
				this.fees = (this.floatamount / (1 - this.tax)  * this.tax);
				this.delivered = this.floatamount * this.cubrate;
				this.topay = this.floatamount + this.fees;
				break;
			/*case 4:
				this.currency="EUR";
				this._getTax();
				this.fees = (this.floatamount * this.tax).round(2);
				this.delivered = (this.floatamount - this.fees) * this.cubrate;
				this.topay = this.floatamount;
				break;*/
			}
			this.fees = this.fees.round(2);
			
			this.topaylocal = (this.localrate) ? this.topay * this.localrate : '--';
			
			this.updateScreen();
		} else {
			this.clearScreen();
		}
	},
	
	/*
	Function: _updateScreen
		Internal method
		
		Update Screen of the calculator
		
		Parameters:
			-
	*/
	updateScreen : function() {
		if (this.amount == 0)	{ this.amount = ''; }
				
		this.input.value = this.input.value.replace(/[^\d.,]/g,"");
		
		$E('.fees',this.calculator).setHTML(this.fees.toFixed(2));
		$E('.deliver',this.calculator).setHTML(this.delivered.toFixed(2));	
		$E('.topay',this.calculator).setHTML(this.topay.toFixed(2));						
		$E('.send',this.calculator).setHTML((this.topay - this.fees).toFixed(2));
	
		$E('.localcur',this.calculator).setStyle('background','url(\'/img/currency/'+this.country+'.gif\') center no-repeat');
		$E('.local',this.calculator).setHTML((this.topaylocal == '--') ? this.topaylocal : this.topaylocal.toFixed(2));
	},

	/*
	Function: _getTax
		Internal method
		
		-
		
		Parameters:
			-
	*/
	_getTax : function() {
		for (var i=0; i<this.options.Taxes.length; i++)	{
			switch(this.mode) {
			
			case 1: 
				if (this.options.Taxes[i][0] <= this.floatamount) {
					this.tax = this.options.Taxes[i][1];
				};
				break;
				
			case 2: 
				var topay  = this.options.Taxes[i][0] * (1 - this.options.Taxes[i][1]); 
				if (topay <= this.floatamount) {
					this.tax = this.options.Taxes[i][1];
				}
				break;
			case 3: 
				var topay  = this.options.Taxes[i][0] * (1 - this.options.Taxes[i][1]);
			
				if (topay <= this.floatamount) {
					this.tax = this.options.Taxes[i][1];
				}
				break;
			/*case 4: 
				var topay  = this.options.Taxes[i][0] * (1 - this.options.Taxes[i][1]);
			
				if (topay <= this.floatamount) {
					this.tax = this.options.Taxes[i][1];
				}
				break;*/
			}
		}
		if (this.options.Express)
			this.tax = parseFloat(this.tax) + parseFloat(this.options.ExpressCharge);
	},

	/*
	Function: _calculateAmount
		Internal method
		
		Calculate amount
		
		Parameters:
			-
	*/
	_checkAmount : function(amount) {				
		if (amount < this.options.MinAmount || amount > this.options.MaxAmount) { return false } 
		 else { return true }		
	},
	/*
	Function: _calculateAmount
		Internal method
		
		Clear calculator interface
		
		Parameters:
			-
	*/
	clearScreen : function() {
		this.input.addClass('error_calc');
		
		$E('.fees',this.calculator).setHTML('--');
		$E('.send',this.calculator).setHTML('--');
		$E('.deliver',this.calculator).setHTML('--');
		$E('.topay',this.calculator).setHTML('--');
		$E('.local',this.calculator).setHTML('--');
	},
	/*
	Function: _getRates
		Internal method
		
		Get Json exchangerate file and get usd, and chf rate
		
		Parameters:
			-
	*/
	_getRates : function(rates) {
		rates.each(function(rate,currency){
			if (currency==this.country) { this.localrate = rate; }
			if (currency=="USD") { this.usdrate = rate; }
		},this);
		if (!this.country)
			this.country = '';
		var cubround = this.options.ExchangeMargin;
		if (this.country && this.options['ExchangeMargin'+this.country.substr(0,2)]) {
			cubround = this.options['ExchangeMargin'+this.country.substr(0,2)];
		}
		this.cubrate = (this.usdrate * this.options.ExchangeRateCharge * cubround);
		
		this.setAmount(this.options.amount);
		this.setMode(this.options.mode);
				
		$E('.rate',this.calculator).setHTML(this.cubrate.toFixed(4));			
	},
	
	/*
	Function: _getCountry
		Internal method
		
		Parameters:
			-
	*/
	_getCountry: function(){
		url = this.options.ifwScript + "?m=Whois&currency=1";
			
			new Ajax(url, {
				method: 'get',
				onComplete: function(e){
					if (e.test(/^.{3}$/)) {
						this.country = e;
					}
					var rate = new Rates({
						'onFinish': function(){
							this.options.calling_class._getRates(this.cookie_rate);
						},
						'calling_class'	: this
					});
				}.bind(this)
			}).request();
	},
	
	/*
	Function: _getConfig
		Internal method
		
		Parameters:
			-
	*/
	_getConfig : function(){
		var url = this.options.csScript + "&action=getCalcConfig&ajaxrequest=1";
			
			new Ajax(url, {
				method: 'get',
				onComplete: function(e){
					this._setConfig(e);
				}.bind(this)
			}).request();
	},
	
	/*
	Function: _setConfig
		Internal method
		
		Parameters:
			-
	*/
	_setConfig : function(conf)	{
		var c = conf.split("\n");
		var tax = new Array();
		for (var i=0; i<c.length; i++)	{
			if (c[i].match(/^Tax/))	{
				c[i] = c[i].replace(/Tax\:/,'');
				var t = c[i].split('=');
				tax.push(t);
			}
			else	{
				var t = c[i].split('=');
				this.options[t[0]] = t[1];
			}
		}
		if (tax.length > 0)
			this.options.Taxes = tax;
	},

	/*
	Function: _makeDraggable
		Internal method
		
		Parameters:
			-
	*/
	_makeDraggable:function(n) {
				
		this.calculator.makeDraggable({
			'handle': this.options.title,
			'onStart' : function() {
				// code
			}.bind(this),
			'onComplete': function() {
				// code
			}.bind(this)
		});		
	},
	
	_disableSelection : function (target){
		if (typeof target.onselectstart!="undefined") //IE route
			target.onselectstart=function(){return false}
		else if (typeof target.style.MozUserSelect!="undefined") //Firefox route
			target.style.MozUserSelect="none"
		else //All other route (ie: Opera)
			target.onmousedown=function(){return false}
		target.style.cursor = "default"
	},	
	
	/*
	Function: setPosition
		change calculator position
		
		Parameters:
			-
	*/
	setPosition : function(x,y) {
		this.calculator.setStyles( {
			'display': 'block',
			'top' :	y,
			'left' : x
		});	
	}
});

Calc.implement(new Options, new Events);
/*
	Class: 
		
		
	Usage:
		
		
	Parameters:
		
		
	Exemple:
	
	About:
		Profil.js v.1.0 for mootools v1.1 05 / 2007
		
		by Floor SA (http://www.floor.ch) MIT-style license
		
		last modified by Denis Schneiter 
*/
var Profil = new Class({
	options : {
		'input_profil' : 'init_profil'
	},

    /*
	Constructor: initialize
		Constructor
	
		-
	*/
	initialize : function(options) {
		this.setOptions(options)
		
		this._initProfil();
		this._updateNewsletter();
		this._changeNewPwd();
		this._changeNewEmail();
	},
	/*
	Function: _
		Internal method
		
		Parameters:
			
	*/
	_initProfil : function() {
		$$('.' + this.options.input_profil).each(function(el){
			
			var field_name = el.getProperty('name').replace(/^profil_/g,'');
			var contact_field_name = 'contact_' + field_name;
			
			if ($(contact_field_name)) {
				
				if ($(contact_field_name).getTag() == 'select') {
					this._initSelect($(contact_field_name),el.getProperty('value'));
				} else {
					this._initInput($(contact_field_name),el.getProperty('value'));
				}
			}				
		}, this);
		
		this._initCountry();
	},
	
	_initSelect : function(el,val) {
		
		$ES('option', el).each(function(el){
			
			if (el.getProperty('value') == val) {

				el.setProperty('selected','selected');	
			}
				
		}, this);

		if(el.getProperty('id') == 'contact_state') {
			address_book._getCity($('contact_state'));
		}
	},
	
	_initInput : function(el,val) {
		if (el.getProperty('type') == 'checkbox' && val == '1') {
			el.setProperty('checked','checked');
			$('hidden_newsletter').setProperty('value','1');
		}
		
		if (el.getProperty('type') == 'radio') {
			var radio_name = el.getProperty('name');
			$$('input').each(function(el_input){
				if (el_input.getProperty('type') == 'radio' && 
					el_input.getProperty('name') == radio_name && 
					el_input.getProperty('value') == val) {
					
						el_input.setProperty('checked','checked');
					}	
			}, this);
		}
	},
	
	_initCountry : function() {
		if ($('contact_country') && $('country_chooser')) {
			tokens.each(function(token){
  				if (token[1] == $('contact_country').getProperty('value')) {
					$('country_chooser').setProperty('value',token[0]);
				}
			},this);
		}
	},
	
	_updateNewsletter : function() {
		if ($('contact_news')) {
			$('contact_news').addEvent('click', function(){
				
				if ($('hidden_newsletter').getProperty('value') == '1') {
					$('hidden_newsletter').setProperty('value', '0');
				}
				else {
					$('hidden_newsletter').setProperty('value', '1');
				}
			}.bind(this));
		}
	},
	
	_changeNewPwd : function() {
		
		if ($('user_password')) {
			$('user_password').setProperty('value','');
			$('user_password').addEvent('keyup', function(){
				$('user_newpassword').setProperty('value', $('user_password').getProperty('value'));
			}.bind(this));
		}
	},
	
	_changeNewEmail : function() {
		if ($('user_newemail')) {
			$('contact_email').addEvent('keyup', function(){
				$('user_newemail').setProperty('value', $('contact_email').getProperty('value'));
			}.bind(this));
		}
	}	
});

Profil.implement(new Options, new Events);/*
	Class: Rates
		
	Usage:
		Use to manage UTS rate calculatore
		
	Parameters:
		- 
		
	Exemple:
	
	About:
		Rates.js v.1.0 for mootools v1.1 05 / 2007
		
		by Floor SA (http://www.floor.ch) MIT-style license
		
		last modified by Denis Schneiter 22.10.2007
*/
var Rates = new Class({
	options : {
		'rates_file' 	: '/var/exchangerates/today/eur.json',
		'useCookie'		: false,
		'onFinish'		: Class.empty,
		'calling_class'	: ''
 	},
    /*
	Constructor: initialize
		Constructor
	
		call rates and add event to enter amount or change trx type
	*/
	initialize : function(options) {
		this.setOptions(options)
		
		this.getRates();
	},
	/*
	Function: getRates
		Internal method
		
		Parameters:
			-
	*/
	getRates : function() {	
		this.cookie_rate = new Hash.Cookie('utstrxRate', {duration: 0});
		
		
		if (this.cookie_rate.get('USD') && this.options.use_cookie) {
			this.fireEvent('onFinish');
		}
		else {	
			new Json.Remote(this.options.rates_file, {
				method: 'get',
				onComplete: function(e){
					var rates = e.gesmes$Envelope.Cube.Cube.Cube;

					rates.each(function(rate){
						this.cookie_rate.set(rate.currency, rate.rate);
					}, this);
					this.cookie_rate.save();
					
					this.fireEvent('onFinish');
					}.bind(this)
			}).send();
		}	
	}
	
});

Rates.implement(new Options, new Events);/*
	Class: RateList
		
	Usage:
		Use to manage UTS rate calculatore
		
	Parameters:
		- 
		
	Exemple:
	
	About:
		Rates.js v.1.0 for mootools v1.1 05 / 2007
		
		by Floor SA (http://www.floor.ch) MIT-style license
		
		last modified by Denis Schneiter 22.10.2007
*/
var RateList = new Class({
	options : {
		'calling_class' : ''
 	},

    /*
	Constructor: initialize
		Constructor
	
		call rates and add event to enter amount or change trx type
	*/
	initialize : function(options) {
		this.setOptions(options)
		
		//this._getRates();
		
		if ($('lst_rates')) { 
			var rate = new Rates({
				'onFinish': function(){
					this.options.calling_class._listRate(this.cookie_rate);	
				},
				'calling_class'	: this
			});
		}		
	},
	/*
	Function: _getRates
		Internal method
		
		Get Json exchangerate file and get usd, and chf rate
		
		Parameters:
			-
	*/
	_listRate : function(rates) {
		
		var tbl_rate = '<ul id="rateslist">';
		var max_decimal = this._checkDecimal(rates);
		
		var j = 0;
		
		rates.each(function(rate,currency){
			var zebra = '';
			if (j%2 != 0) { zebra = 'class="zebra"'; }
			
		 	tbl_rate = tbl_rate + '<li '+ zebra +'><span class="currency">' + currency + '</span>';
			
			var tbl_ratedetail = rate.split(/\./);
			
			tbl_rate = tbl_rate + '<span class="rate">' + tbl_ratedetail[0] + '.</span>';
			
			var add_null = '';
			
			var i = tbl_ratedetail[1].length;
			
			while(i < max_decimal)
			{
				add_null = add_null + '0';
			  	i++;
			}
			
			tbl_rate = tbl_rate + '<span class="dec">' + tbl_ratedetail[1] + add_null + '</span></li>';
		 	j++;
		},this);
		
		tbl_rate = tbl_rate + "</ul>";
		
		$('lst_rates').innerHTML = tbl_rate;
		
		var vert = new Ticker('rateslist',{speed:1000,delay:2000,direction:'vertical'});					
	},		
	/*
	Function: _checkDecimal
		Internal method
		
		Parameters:
			-
	*/
	_checkDecimal : function(lst_rate) {
		
		var max_decimal = 0;
		
			
		lst_rate.each(function(currency,rate){
			var tbl_ratedetail = currency.split(/\./);
			
			if (tbl_ratedetail[1].length > max_decimal) max_decimal = tbl_ratedetail[1].length
		},this);
		
		return max_decimal;
	}		
});

RateList.implement(new Options, new Events);/*
	Class: 
		
		
	Usage:
		
		
	Parameters:
		
		
	Exemple:
	
	About:
		Upload.js v.1.0 for mootools v1.1 05 / 2007
		
		by Floor SA (http://www.floor.ch) MIT-style license
		
		last modified by Denis Schneiter 
*/
var Upload = new Class({
	options : {
		'input_profil' : 'init_profil',
		'ifwScript' : '/ifw/index.cgi'
	},

    /*
	Constructor: initialize
		Constructor
	
		-
	*/
	initialize : function(options) {
		this.setOptions(options)
		
		if ($('upload_legalfile')) {
			this._initFileList();
		}
	},
	/*
	Function: _initFileList
		Internal method
		
		Parameters:
			
	*/
	_initFileList : function() {
		
		//url = this.options.ifwScript + "?m=Upload&a=listFiles&sid=" + $('session').getProperty('value');
		url = this.options.ifwScript + "?m=Upload&a=checkFile&filename=identity&sid=" + $('session').getProperty('value');
		
		new Ajax(url, {
			method: 'get',
			update: $('file_list')
		}).request();		
	}
});

Upload.implement(new Options, new Events);/**
 * Observer - Observe formelements for changes
 *
 * @version		1.0rc1
 *
 * @license		MIT-style license
 * @author		Harald Kirschner <mail [at] digitarald.de>
 * @copyright	Author
 */
var Observer = new Class({

	options: {
		periodical: false,
		delay: 1000
	},

	initialize: function(el, onFired, options){
		this.setOptions(options);
		this.addEvent('onFired', onFired);
		this.element = $(el);
		this.listener = this.fired.bind(this);
		this.value = this.element.getValue();
		if (this.options.periodical) this.timer = this.listener.periodical(this.options.periodical);
		else this.element.addEvent('keyup', this.listener);
	},

	fired: function() {
		var value = this.element.getValue();
		if (this.value == value) return;
		this.clear();
		this.value = value;
		this.timeout = this.fireEvent.delay(this.options.delay, this, ['onFired', [value]]);
	},

	clear: function() {
		$clear(this.timeout);
		return this;
	}
});

Observer.implement(new Options);
Observer.implement(new Events);/**
 * Autocompleter
 *
 * @version		1.0rc4
 *
 * @license		MIT-style license
 * @author		Harald Kirschner <mail [at] digitarald.de>
 * @copyright	Author
 */
var Autocompleter = {};

Autocompleter.Base = new Class({

	options: {
		minLength: 1,
		useSelection: false,
		markQuery: false,
		inheritWidth: true,
		maxChoices: 10,
		injectChoice: null,
		onSelect: Class.empty,
		onShow: Class.empty,
		onHide: Class.empty,
		customTarget: null,
		className: 'autocompleter-choices',
		zIndex: 42,
		observerOptions: {},
		fxOptions: {},
		overflown: []
	},

	initialize: function(el, options) {
		this.setOptions(options);
		this.element = $(el);
		this.build();
		this.observer = new Observer(this.element, this.prefetch.bind(this), $merge({
			delay: 400
		}, this.options.observerOptions));
		this.value = this.observer.value;
		this.queryValue = null;
	},

	/**
	 * build - Initialize DOM
	 *
	 * Builds the html structure for choices and appends the events to the element.
	 * Override this function to modify the html generation.
	 */
	build: function() {
		if ($(this.options.customTarget)) this.choices = this.options.customTarget;
		else {
			this.choices = new Element('ul', {
				'class': this.options.className,
				styles: {zIndex: this.options.zIndex}
			}).injectInside(document.body);
			this.fix = new OverlayFix(this.choices);
		}
		this.fx = this.choices.effect('opacity', $merge({
			wait: false,
			duration: 200
		}, this.options.fxOptions))
			.addEvent('onStart', function() {
				if (this.fx.now) return;
				this.choices.setStyle('display', '');
				this.fix.show();
			}.bind(this))
			.addEvent('onComplete', function() {
				if (this.fx.now) return;
				this.choices.setStyle('display', 'none');
				this.fix.hide();
			}.bind(this)).set(0);
		this.element.setProperty('autocomplete', 'off')
			.addEvent(window.ie ? 'keydown' : 'keypress', this.onCommand.bindWithEvent(this))
			.addEvent('mousedown', this.onCommand.bindWithEvent(this, [true]))
			.addEvent('focus', this.toggleFocus.bind(this, [true]))
			.addEvent('blur', this.toggleFocus.bind(this, [false]))
			.addEvent('trash', this.destroy.bind(this));
	},

	destroy: function() {
		this.choices.remove();
	},

	toggleFocus: function(state) {
		this.focussed = state;
		if (!state) this.hideChoices();
	},

	onCommand: function(e, mouse) {
		if (mouse && this.focussed) this.prefetch();
		if (e.key && !e.shift) switch (e.key) {
			case 'enter':
				if (this.selected && this.visible) {
					this.choiceSelect(this.selected);
					e.stop();
				} return;
			case 'up': case 'down':
				if (this.observer.value != (this.value || this.queryValue)) this.prefetch();
				else if (this.queryValue === null) break;
				else if (!this.visible) this.showChoices();
				else {
					this.choiceOver((e.key == 'up')
						? this.selected.getPrevious() || this.choices.getLast()
						: this.selected.getNext() || this.choices.getFirst() );
					this.setSelection();
				}
				e.stop(); return;
			case 'esc': this.hideChoices(); return;
		}
		this.value = false;
	},

	setSelection: function() {
		if (!this.options.useSelection) return;
		var startLength = this.queryValue.length;
		if (this.element.value.indexOf(this.queryValue) != 0) return;
		var insert = this.selected.inputValue.substr(startLength);
		if (document.getSelection) {
			this.element.value = this.queryValue + insert;
			this.element.selectionStart = startLength;
			this.element.selectionEnd = this.element.value.length;
		} else if (document.selection) {
			var sel = document.selection.createRange();
			sel.text = insert;
			sel.move("character", - insert.length);
			sel.findText(insert);
			sel.select();
		}
		this.value = this.observer.value = this.element.value;
	},

	hideChoices: function() {
		if (!this.visible) return;
		this.visible = this.value = false;
		this.observer.clear();
		this.fx.start(0);
		this.fireEvent('onHide', [this.element, this.choices]);
	},

	showChoices: function() {
		if (this.visible || !this.choices.getFirst()) return;
		this.visible = true;
		var pos = this.element.getCoordinates(this.options.overflown);
		this.choices.setStyles({
			left: pos.left,
			top: pos.bottom+2
		});
		pos.width = pos.width -4;
		
		if (this.options.inheritWidth) this.choices.setStyle('width', pos.width);
		this.fx.start(1);
		this.choiceOver(this.choices.getFirst());
		this.fireEvent('onShow', [this.element, this.choices]);
	},

	prefetch: function() {
		if (this.element.value.length < this.options.minLength) this.hideChoices();
		else if (this.element.value == this.queryValue) this.showChoices();
		else this.query();
	},

	updateChoices: function(choices) {
		this.choices.empty();
		this.selected = null;
		if (!choices || !choices.length) return;
		if (this.options.maxChoices < choices.length) choices.length = this.options.maxChoices;
		choices.each(this.options.injectChoice || function(choice, i){
			var el = new Element('li').setHTML(this.markQueryValue(choice));
			el.inputValue = choice;
			this.addChoiceEvents(el).injectInside(this.choices);
		}, this);
		this.showChoices();
	},

	choiceOver: function(el) {
		if (this.selected) this.selected.removeClass('autocompleter-selected');
		this.selected = el.addClass('autocompleter-selected');
	},

	choiceSelect: function(el) {
		this.observer.value = this.element.value = el.inputValue;
		if (el.getProperty('alt')) {
			this.ISOCountryCode = el.getProperty('alt');
		}
		this.hideChoices();
		this.fireEvent('onSelect', [this.element], 20);
	},

	/**
	 * markQueryValue
	 *
	 * Marks the queried word in the given string with <span class="autocompleter-queried">*</span>
	 * Call this i.e. from your custom parseChoices, same for addChoiceEvents
	 *
	 * @param		{String} Text
	 * @return		{String} Text
	 */
	markQueryValue: function(txt) {
		return (this.options.markQuery && this.queryValue) ? txt.replace(new RegExp('^(' + this.queryValue.escapeRegExp() + ')', 'i'), '<span class="autocompleter-queried">$1</span>') : txt;
	},

	/**
	 * addChoiceEvents
	 *
	 * Appends the needed event handlers for a choice-entry to the given element.
	 *
	 * @param		{Element} Choice entry
	 * @return		{Element} Choice entry
	 */
	addChoiceEvents: function(el) {
		return el.addEvents({
			mouseover: this.choiceOver.bind(this, [el]),
			mousedown: this.choiceSelect.bind(this, [el])
		});
	}
});

Autocompleter.Base.implement(new Events);
Autocompleter.Base.implement(new Options);

Autocompleter.Local = Autocompleter.Base.extend({

	options: {
		minLength: 0,
		filterTokens : null
	},

	initialize: function(el, tokens, options) {
		this.parent(el, options);
		this.tokens = tokens;
		if (this.options.filterTokens) this.filterTokens = this.options.filterTokens.bind(this);
	},

	query: function() {
		this.hideChoices();
		this.queryValue = this.element.value;
		this.updateChoices(this.filterTokens());
	},

	filterTokens: function(token) {
		var regex = new RegExp('^' + this.queryValue.escapeRegExp(), 'i');
		return this.tokens.filter(function(token) {
			return regex.test(token);
		});
	}

});

Autocompleter.Ajax = {};

Autocompleter.Ajax.Base = Autocompleter.Base.extend({

	options: {
		postVar: 'value',
		postData: {},
		ajaxOptions: {},
		onRequest: Class.empty,
		onComplete: Class.empty
	},

	initialize: function(el, url, options) {
		this.parent(el, options);
		this.ajax = new Ajax(url, $merge({
			autoCancel: true
		}, this.options.ajaxOptions));
		this.ajax.addEvent('onComplete', this.queryResponse.bind(this));
		this.ajax.addEvent('onFailure', this.queryResponse.bind(this, [false]));
	},

	query: function(){
		var data = $extend({}, this.options.postData);
		data[this.options.postVar] = this.element.value;
		this.fireEvent('onRequest', [this.element, this.ajax]);
		this.ajax.request(data);
	},

	/**
	 * queryResponse - abstract
	 *
	 * Inherated classes have to extend this function and use this.parent(resp)
	 *
	 * @param		{String} Response
	 */
	queryResponse: function(resp) {
		this.value = this.queryValue = this.element.value;
		this.selected = false;
		this.hideChoices();
		this.fireEvent(resp ? 'onComplete' : 'onFailure', [this.element, this.ajax], 20);
	}

});

Autocompleter.Ajax.Json = Autocompleter.Ajax.Base.extend({

	queryResponse: function(resp) {
		this.parent(resp);
		var choices = Json.evaluate(resp || false);
		if (!choices || !choices.length) return;
		this.updateChoices(choices);
	}

});

Autocompleter.Ajax.Xhtml = Autocompleter.Ajax.Base.extend({

	options: {
		parseChoices: null
	},

	queryResponse: function(resp) {
		this.parent(resp);
		if (!resp) return;
		this.choices.setHTML(resp).getChildren().each(this.options.parseChoices || this.parseChoices, this);
		this.showChoices();
	},

	parseChoices: function(el) {
		var value = el.innerHTML;
		el.inputValue = value;
		el.setHTML(this.markQueryValue(value));
	}

});

var OverlayFix = new Class({
	initialize: function(el) {
		this.element = $(el);
		if (window.ie){
			this.element.addEvent('trash', this.destroy.bind(this));
			this.fix = new Element('iframe', {
				properties: {
					frameborder: '0',
					scrolling: 'no',
					src: 'javascript:false;'
				},
				styles: {
					position: 'absolute',
					border: 'none',
					display: 'none',
					filter: 'progid:DXImageTransform.Microsoft.Alpha(opacity=0)'
				}
			}).injectAfter(this.element);
		}
	},

	show: function() {
		if (this.fix) this.fix.setStyles($extend(
			this.element.getCoordinates(), {
				display: '',
				zIndex: (this.element.getStyle('zIndex') || 1) - 1
			}));
		return this;
	},

	hide: function() {
		if (this.fix) this.fix.setStyle('display', 'none');
		return this;
	},

	destroy: function() {
		this.fix.remove();
	}

});var Register = new Class({
	options : {
		'input_profil' : 'init_profil',
		'ifwScript' : '/ifw/index.cgi'
	},

    /*
	Constructor: initialize
		Constructor
	
		-
	*/
	initialize : function(options) {
		this.setOptions(options)
		
		if ($('country_chooser')) {	
			this._getCountry();
			this._initAutoCompleter();
		}
	},
	/*
	Function: _
		Internal method
		
		Parameters:
			
	*/
	_initAutoCompleter : function() {
	
		var completer1 = new Autocompleter.Local($('country_chooser'), tokens, {
			'delay': 100,
			'filterTokens': function() {
				var regex = new RegExp('^' + this.queryValue.escapeRegExp(), 'i');
				return this.tokens.filter(function(token){
					return (regex.test(token[0]) || regex.test(token[1]));
				});
			},
			'injectChoice': function(choice) {
				var el = new Element('li')
					.setHTML(this.markQueryValue(choice[0]))
					.adopt(new Element('span', {'class': 'example-info'}));
				el.inputValue = choice[0];
				el.setProperty('alt',choice[1]);
				
				this.addChoiceEvents(el).injectInside(this.choices);
				
			},
			'onSelect': function(el){
				$('contact_country').setProperty('value',this.ISOCountryCode);
			}
		});
		
		if ($('contact_country').value)
			completer1.ISOCountryCode = $('contact_country').value;
		
	/*	$('country_chooser').addEvent('keyup', function(event){
			event = new Event(event);
			if (event.key != "enter" && !completer1.ISOCountryCode) {
				$('contact_country').setProperty('value', $('country_chooser').value);
			}
		}.bind(this));	*/
	},
	/*
	Function: _
		Internal method
		
		Parameters:
			
	*/
	_getCountry : function() {
		if ($('session')) {
			var url = this.options.ifwScript + "?m=Whois";
		
			new Ajax(url, {
				method: 'get',
				onComplete : function(e) {			
					tokens.each(function(token){
		  				if (token[1] == e) {
							$('country_chooser').setProperty('value',token[0]);
							$('contact_country').setProperty('value',token[1]);
						}
					},this);
				}.bind(this)
			}).request();		
		}
	}
});

Register.implement(new Options, new Events);/*
	Class: AddressBook
		-
		
	Usage:
		-
		
	Parameters:
		- 
		
	Exemple:
	
	About:
		receiver.js v.1.0 for mootools v1.1 05 / 2007
		
		by Floor SA (http://www.floor.ch) MIT-style license
		
		last modified by Denis Schneiter 22.10.2007
*/
var AddressBook = new Class({
	options : {
		'radio_name' : 'product_properties_AddressBookID',
		'form_name' : 'adress_book',
		'target_receiver' : 'receiver',		
		'target_city' : 'reccity',		
		'category_id' : '27',		
		'overview_name' : 'checkout',
		'notamount_ident' : 'defineamount',
		'CS2Script'		: '/cgi/ifw'
	},

    /*
	Constructor: initialize
		Constructor
	
		-
	*/
	initialize : function(options) {
		this.setOptions(options)			
	},
	
	initClass : function() {
		this.els = $$('.' + this.options.target_receiver);
			this.els.each(function(el){
				this._checkCity(el);
				this._bindEditBtn(el);
				this._getGeneralVar();	
			}, this);
		this._changeSubact();
		this.checkifAmount();
		this.initAdressBookID();			
	},	
	
		
	/*
	Function: _getGeneralVar
		Internal method
		
		-
		
		Parameters:
			-
	*/
	_getGeneralVar : function() {
		if ($('session')) {this.session = $('session').value;}
		if ($('server')) {this.server = $('server').value;}
		if ($('lang')) {this.lang = $('lang').value;}
		
		this.url = this.options.CS2Script + '?server='+this.server+'&session='+this.session+'&lang='+this.lang+'&';
	},
	
	/*
	Function: _add
		Internal method
		
		-
		
		Parameters:
			-
	*/
	
	_add: function(action) {
		
		if ($('productID')) { action = action + "&product_ID=" + $('productID').getProperty('value'); }		
		if ($('amount')) { action = action + "&product_properties_amount=" + $('amount').getProperty('value'); }
		if ($('currency')) { action = action + "&product_properties_currency=" + $('currency').getProperty('value'); }
		if ($('mode')) { action = action + "&product_properties_mode=" + $('mode').getProperty('value'); }
			
		this._exec(this.url+"category_ident=" + action);
	},
	/*
	Function: _edit
		Internal method
		'address_book'
		-
		
		Parameters:
			-
	*/
	
	_edit: function() {
		if(this._getSelected()) {
			this._exec(this.url+"item_categoryID="+this.options.category_id+"&item_ID="+this.item_id+"&datatype=contact&template=process");
		} else {
			this._error('please select a contact!');
		}
	},
	/*
	Function: _edit
		Internal method
		
		-
		
		Parameters:
			-
	*/
	
	_del: function() {
		if(this._getSelected()) {
			if (confirm("Are you sure ?")) {
					this._exec(this.url+"subact=deleteuseritem&item_categoryID="+this.options.category_id+"&delete_item_ID="+this.item_id+"&deletemodule=contact&ifokgoto=myaddressbook&ifnotokgoto=myaddressbook");	
			}
		} else {
			this._error('please select a contact!');
		}
	},
	/*
	Function: _exec
		Internal method
		
		-
		
		Parameters:
			-
	*/
	_error : function(error_msg) {
		alert(error_msg);
	},	
	/*
	Function: _exec
		Internal method
		
		-
		
		Parameters:
			-
	*/
	_exec : function(url,method) {
		document.location = url;
	},
	
	_getSelected : function() {
		
		this.els = $ES("input", $$('.'+this.options.form_name));
		this.els.each(function(el){
			if (el.type == "radio" && el.getProperty('checked')==true) { this.item_id = el.value; }
		}.bind(this));
		
		return this.item_id;	
	},
	/*
	Function: _bindEditbtn
		Internal method
		
		-
		
		Parameters:
			-
	*/
	_bindEditBtn : function() {
		//my receiver add
		$ES('.add',$(this.options.form_name)).each(function(el) {
			el.addEvent('click', function(e){
				this._add('addreceiver');
			}.bind(this))
		},this);
		
		//payment process add
		$ES('.add2',$(this.options.form_name)).each(function(el) {
			el.addEvent('click', function(e){
				this._add('addreceiver2');
			}.bind(this))
		},this);
		
		$ES('.edit',$(this.options.form_name)).each(function(el) {
			el.addEvent('click', function(e){
				this._edit();
			}.bind(this))
		},this);
		
		$ES('.del',$(this.options.form_name)).each(function(el) {
			el.addEvent('click', function(e){
				this._del();
			}.bind(this))
		},this);
	},
	/*
	Function: _checkCity
		Internal method
		
		-
		
		Parameters:
			-
	*/
	_checkCity : function(rec) {
		this.els = $ES('.' + this.options.target_city, rec);
			this.els.each(function(el){			
				el.addEvent('change', function(e){
					this._getCity(el);
				}.bind(this))
			}, this);	
	},
	/*
	Function: _getCity
		Internal method
		
		-
		
		Parameters:
			-
	*/
	_getCity : function(el) {
		var city = cities[el.value];
		var content = '<option>Please Choose</option>';

		$('contact_city').innerHTML = "";
		
		if (city) {

			var element = new Element('option', {'value' : ''}).setHTML('Please Choose');
			$('contact_city').appendChild(element)
			
			city.each(function(value,i){
				//$('contact_city').options[i + 1] = new Option(value[1], value[0], false, false);
				
				element = new Element('option', {'value' : value[0]}).setHTML(value[1]);
				$('contact_city').appendChild(element)
			});
		} else {
			var element = new Element('option', {'value' : ''}).setHTML('Please Choose');
			$('contact_city').appendChild(element)
		}
	},
	/*
	Function: _changeSubact
		Internal method
		
		-
		
		Parameters:
			-
	*/	
	_changeSubact: function() {
		if ($('subact') && $('subact').alt) {
			$('subact').value = $('subact').alt;
			$('category_ident').value = this.options.overview_name;
		}
	},
	/*
	Function: initAdressBookID
		Internal method
		
		-
		
		Parameters:
			-
	*/	
	initAdressBookID: function() {
		if ($('AddressBookID')) {
			$$(".contactlist input").each( function(el) {
				if (el.getProperty('value') == $('AddressBookID').getProperty('value')){ 
					el.setProperty('checked','checked');
				}
			}.bind(this));
		}
	},
	/*
	Function: checkifAmount
		Internal method
		
		-
		
		Parameters:
			-
	*/	
	checkifAmount: function() {
		if ($('address_book')) {
			if($('amount') && $('amount').getProperty('value') == '') {
				if ($('subact')) { $('subact').setProperty('value',''); }
				if ($('category_ident')) { $('category_ident').setProperty('value', this.options.notamount_ident); }
			}
		}
	}
});

AddressBook.implement(new Options, new Events);

var address_book = new AddressBook();

window.addEvent('domready',function() {
	address_book.initClass();
});/*
	Class: FormCheck
		Performs different tests on forms and indicates errors.
		
	Usage:
		Works with these types of fields :
		- input (text, radio, checkbox)
		- textarea
		- select
		
		You just need to add a specific class to each fields you want to check. 
		For example, if you add the class
			(code)
			validate['required','length[4, -1]','differs[email]','digit']
			(end code)
		the value's field must be set (required) with a minimum length of four chars (4, -1), 
		must differs of the input named email (differs[email]), and must be digit. 
		You can perform check during the datas entry or on the submit action, shows errors as tips or as div after the field, 
		show errors one by one or all together, show a list of all errors at the top of the form, localize error messages, add new regex check, ...
		The layout is design only with css. It can also works with multiple forms on a single html page.
		The class supports now internationalization. To use it, simply specify a new <script> element in your html page, like this : <script type="text/javascript" src="formcheck/lang/fr.js"></script>. N.B. : you must load this script before the formcheck and this method overpass the old way. You can create new languages following existing ones. You can otherwise still specifiy the alerts' strings when you initialize the Class, with options.
	
	Test type:
		You can perform various test on fields by addind them to the validate class. Be careful to *not use space chars*. Here is the list of them.
			
		required - The field becomes required. This is a regex, you can change it with class options.
		alpha - The value is restricted to alphabetic chars. This is a regex, you can change it with class options.
		alphanum - The value is restricted to alphanumeric characters only. This is a regex, you can change it with class options.
		nodigit - The field doesn't accept digit chars. This is a regex, you can change it with class options.
		digit - The value is restricted to digit (no floating point number) chars, you can pass two arguments (f.e. digit[21,65]) to limit the number between them. Use -1 as second argument to not set a maximum.
		number - The value is restricted to number, including floating point number. This is a regex, you can change it with class options.
		email - The value is restricted to valid email. This is a regex, you can change it with class options.
		phone - The value is restricted to phone chars. This is a regex, you can change it with class options.
		url: - The value is restricted to url. This is a regex, you can change it with class options.
		confirm - The value has to be the same as the one passed in argument. f.e. confirm[password].
		differs - The value has to be diferent as the one passed in argument. f.e. differs[user].
		length - The value length is restricted by argument (f.e. length[6,10]). Use -1 as second argument to not set a maximum.
		
	Parameters:
		When you initialize the class with addEvent, you can set some options. If you want to modify regex, you must do it in a hash, like for display or alert. You can also add new regex check method by adding the regex and an alert with the same name.
		
		form_id - The id of the formular. This is required.
		
		tips_class - The class to apply to tipboxes' errors. By default it is 'tipsbox'.
		error_class - The class to apply to fields with error. By default it is 'error_f'.
		display - This is a hash of display settings. in here you can modify :
		showErrors - 0 : onSubmit, 1 : onSubmit & onBlur, by default it is 1.
		errorsLocation - 1 : tips, 2 : before, 3 : after, by default it is 1.
		indicateErrors - 0 : none, 1 : one by one, 2 : all, by default it is 1.
		tipsOffsetX - Horizontal position of the tips box (margin-left), , by default it is 100 (px).
		tipsOffsetY - Vertical position of the tips box (margin-bottom), , by default it is -10 (px).
		listErrorsAtTop - List all errors at the top of the form, , by default it is false.
		scrollToFirst - Smooth scroll the page to first error and focus on it, by default it is true.
		fadeDuration - Transition duration (in ms), by default it is 300.
		
		alerts  - This is a hash of alerts settings. in here you can modify strings to localize or wathever else. %0 and %1 represent the argument.
		
			required: "This field is required.",
			alpha: "This field accepts alphabetic characters only.",
			alphanum: "This field accepts alphanumeric characters only.",
			nodigit: "No digits are accepted.",
			digit: "Please enter a valid integer.",
			digitmin: "The number must be at least %0",
			digitltd: "The value must be between %0 and %1",
			number: "Please enter a valid number.",
			email: "Please enter a valid email.",
			phone: "Please enter a valid phone.",
			url: "Please enter a valid url.",
			confirm: "This field is different from %0",
			differs: "This value must be different of %0",
			length_str: "The length is incorrect, it must be between %0 and %1",
			lengthmax: "The length is incorrect, it must be at max %0",
			lengthmin: "The length is incorrect, it must be at least %0",
			checkbox: "Please check the box",
			radios: "Please select a radio",
			select: "Please choose a value"
		
	Example:
		You can initialize a formcheck (no scroll, custom classes and alert) by adding for example this in your html head this code :
		
		(code)
		<script type="text/javascript">
			window.addEvent('domready', function() {
				var myCheck = new FormCheck('form_id', {
					tips_class : 'tips_box',
					error_class : 'error_field',
					display : {
						scrollToFirst : false
					},
					alerts : {
						required : 'This field is ablolutely required! Please enter a value'
					}
				})
			});
		</script>
		(end code)
	
	About:
		formcheck2.js v.1.2 for mootools v1.1 - 09 / 2007
		
		by Floor SA (http://www.floor.ch) MIT-style license
		
		Created by Luca Pillonel and David Mignot, last modified by Luca Pillonel 09.19.07
	
*/

var FormCheck = new Class({
	options : {
		
		tips_class: 'tipsbox',			//tips error class
		error_class: 'error_f',			//div error class
		
		ccbox_id	: 'cc_form',			// box credit card infos
		cctype_name	: 'orderlist_cctype',// element(s) name use to choose the type of credit card
		iso_countrycode : 'contact_country',
		
		display : {
			showErrors : 1,				//0 : onSubmit, 1 : onSubmit & onBlur
			errorsLocation : 2,			//1 : tips, 2 : before, 3 : after
			indicateErrors : 0,			//0 :  none, 1 : one, 2 : all
			tipsOffsetX : -38,			//Left position of the tips box (margin-left)
			tipsOffsetY : 4,			//Top position of the tips box (margin-bottom)
			tipsPosition : 'relative',	//If you want to set the tips position with relative or absolute value (page not centered)
			tipsContainer : 'undef',	//Container of fields, to get right positions.
			listErrorsAtTop : false,	//list all errors at the top of the form
			scrollToFirst : true,		//Smooth scroll the page to first error
			fadeDuration : 500			//Transition duration
		},
				
		alerts : {
			required: "This field is required.",
			alpha: "This field accepts alphabetic characters only.",
			alphanum: "This field accepts alphanumeric characters only.",
			nodigit: "No digits are accepted.",
			digit: "Please enter a valid integer.",
			digitmin: "The number must be at least %0",
			digitltd: "The value must be between %0 and %1",
			number: "Please enter a valid number.",
			email: "Please enter a valid email.",
			phone: "Please enter a valid phone.",
			url: "Please enter a valid url.",
			cc_number: "Please enter a valid credit card number.",

			confirm: "This field is different from %0",
			differs: "This value must be different of %0",
			length_str: "The length is incorrect, it must be between %0 and %1",
			lengthmax: "The length is incorrect, it must be at max %0",
			lengthmin: "The length is incorrect, it must be at least %0",
			checkbox: "Please check the box",
			radios: "Please select a radio",
			select: "Please choose a value"
		},
				
		regexp : {
			required : /[^.*]/,
			alpha : /^[a-z ._-]+$/i,
			alphanum : /^[a-z0-9 ._-]+$/i,
			digit : /^[-+]?[0-9\.]+$/,
			nodigit : /^[^0-9]+$/,
			number : /^[-+]?\d*\.?\d+$/,
			email : /^[a-z0-9._%-]+@[a-z0-9.-]+\.[a-z]{2,4}$/i,
			phone : /^[\d\s\+\.\/\- ().-]+$/,
			birthdate : /^[0-9]{2}(\.|-|\/)[0-9]{2}(\.|-|\/)[0-9]{4}$/,
			url : /^(http|https|ftp)\:\/\/[a-z0-9\-\.]+\.[a-z]{2,3}(:[a-z0-9]*)?\/?([a-z0-9\-\._\?\,\'\/\\\+&amp;%\$#\=~])*$/i
		},
		
		cc_check : {
			ECA : /^5[1-5]\d{2}-?\d{4}-?\d{4}-?\d{4}$/,			// Mastercard: length 16, prefix 51-55, dashes optional.
			VIS : /^4\d{3}-?\d{4}-?\d{4}-?\d{4}$/,				// Visa: length 16, prefix 4, dashes optional.
			Amex : /^3[4,7]\d{13}$/,							// American Express: length 15, prefix 34 or 37.
			DISC : /^6011-?\d{4}-?\d{4}-?\d{4}$/,				// Discover: length 16, prefix 6011, dashes optional.
			DIN : /^3[0,6,8]\d{12}$/ 							// Diners: length 14, prefix 30, 36, or 38.
		}	
	},
	
	/*
	Constructor: initialize
		Constructor
	
		Add event on formular and perform some stuff, you now, like settings, ...
	*/
	
	initialize : function(form, options) {
		if (this.form = $(form)) {
			this.form.isValid = true;
			this.regex = ['length'];
			this.setOptions(options);
			
			//internalization
			if (typeof(formcheckLanguage) != 'undefined') this.options.alerts = formcheckLanguage;
			
			this.validations = [];
			this.alreadyIndicated = false;
			this.firstError = false;
			
			var regex = new Hash(this.options.regexp);
			regex.each(function(el, key) {
				this.regex.push(key);
			}, this)
	
			this.form.getElements("*[class*=validate]").each(function(el) {
				el.validation = [];
				var classes = el.getProperty("class").split(' ');
				classes.each(function(classX) {
					if(classX.match(/^validate(\[.+\])$/)) {
						var validators = eval(classX.match(/^validate(\[.+\])$/)[1]);
						for(var i = 0; i < validators.length; i++) {
							el.validation.push(validators[i]);
						}
						this._register(el);
					}
				}, this);
			}, this);
			
			this.form.addEvents({
				"submit": this._onSubmit.bind(this)
			});
		}
	},
	
	/*
	Function: _register
		Private method
		
		Add listener on fields
	*/
	_register : function(el) {
		this.validations.push(el);
		el.errors = [];
		if (this._isChildType(el) == false && this.options.display.showErrors == 1) el.addEvent('blur', function() {
			this._manageError(el, 'blur');
		}.bind(this));
	},
	
	/*
	Function: _validate
		Private method
		
		Dispatch check to other methods
	*/
	_validate : function(el) {
			
		el.errors = [];
		el.isOk = true;
		
		//On valide l'element qui n'est pas un radio ni checkbox
		el.validation.each(function(rule) {
			if(this._isChildType(el)) {
				if (this._validateGroup(el) == false) {
					el.isOk = false;
				}
			} else {
				var ruleArgs = [];
				if(rule.match(/^.+\[/)) {
					var ruleMethod = rule.split('[')[0];
					var ruleArgs = eval(rule.match(/^.+(\[.+\])$/)[1].replace(/([A-Z_]+)/i, "'$1'"));
				} else var ruleMethod = rule;
				
				if (this.regex.contains(ruleMethod)) {
					if (this._validateRegex(el, ruleMethod, ruleArgs) == false) {
						el.isOk = false;
					}
				}
				if (ruleMethod == 'confirm') {
					if (this._validateConfirm(el, ruleArgs) == false) {
						el.isOk = false;
					}
				}
				if (ruleMethod == 'differs') {
					if (this._validateDiffers(el, ruleArgs) == false) {
						el.isOk = false;
					}
				}
				if (el.getTag() == "select" || el.type == "checkbox") {
					if (this._simpleValidate(el) == false) {
						el.isOk = false;
					}
				}
				//New methode
				if (ruleMethod == 'ccnumber') {
					if (this._validateCcNumber(el, ruleArgs) == false) {
						el.isOk = false;
					}
				}
				//New methode
				if (ruleMethod == 'country') {
					if (this._validateCountry(el, ruleArgs) == false) {
						el.isOk = false;
					}
				}				
			}				
		}, this);
		
		if (el.isOk) return true;
		else return false;
	},
	
	/*
	Function: _simpleValidate
		Private method
		
		Perform simple check for select fields and checkboxes
	*/
	_simpleValidate : function(el) {
		if (el.getTag() == 'select' && (el.value == el.options[0].value)) {
			el.errors.push(this.options.alerts.select);
			return false;
		} else if (el.type == "checkbox" && el.checked == false) {
			el.errors.push(this.options.alerts.checkbox);
			return false;
		}
		return true;
	},
	
	/*
	Function: _validateRegex
		Private method
		
		Perform regex validations
	*/
	_validateRegex : function(el, ruleMethod, ruleArgs) {
		var msg = "";
		if (ruleArgs[1] && ruleMethod == 'length') {
			if (ruleArgs[1] == -1) {
				this.options.regexp.length = new RegExp("^.{"+ ruleArgs[0] +",}$");
				msg = this.options.alerts.lengthmin.replace("%0",ruleArgs[0]);
			} else {
				this.options.regexp.length = new RegExp("^.{"+ ruleArgs[0] +","+ ruleArgs[1] +"}$");
				msg = this.options.alerts.length_str.replace("%0",ruleArgs[0]).replace("%1",ruleArgs[1]);
			}
		} else if (ruleArgs[0]) {
			this.options.regexp.length = new RegExp("^.{0,"+ ruleArgs[0] +"}$");
			msg = this.options.alerts.lengthmax.replace("%0",ruleArgs[0]);
		} else {
			msg = this.options.alerts[ruleMethod];
		}
		if (ruleArgs[1] && ruleMethod == 'digit') {
			var regres = true;
			if (!this.options.regexp.digit.test(el.value)) {
				el.errors.push(this.options.alerts[ruleMethod]);
				regres = false;
			}
			if (ruleArgs[1] == -1) {
				if (el.value >= ruleArgs[0]) var valueres = true; else var valueres = false;
				msg = this.options.alerts.digitmin.replace("%0",ruleArgs[0]);
			} else {
				if (el.value >= ruleArgs[0] && el.value <= ruleArgs[1]) var valueres = true; else var valueres = false;
				msg = this.options.alerts.digitltd.replace("%0",ruleArgs[0]).replace("%1",ruleArgs[1]);
			}
			if (regres == false || valueres == false) {
				el.errors.push(msg);
				return false;
			}
		} else if (this.options.regexp[ruleMethod].test(el.value) == false)  { 
			el.errors.push(msg);
			return false;
		}
		return true;
	},
	
	/*
	Function: _validateConfirm
		Private method
		
		Perform confirm validations
	*/
	_validateConfirm: function(el,ruleArgs) {
		if (el.validation.contains('required') == false) {
			//el.validation.push('required');
		}
		var confirm = ruleArgs[0];
		if(el.value != this.form[confirm].value){
			msg = this.options.alerts.confirm.replace("%0",ruleArgs[0]);
			el.errors.push(msg);
			return false;
		}
		return true;
	},
	
	/*
	Function: _validateDiffers
		Private method
		
		Perform differs validations
	*/
	_validateDiffers: function(el,ruleArgs) {
		var confirm = ruleArgs[0];
		if(el.value == this.form[confirm].value){
			msg = this.options.alerts.differs.replace("%0",ruleArgs[0]);
			el.errors.push(msg);
			return false;
		}
		return true;
	},
	
	/*
	Function: _isChildType
		Private method
		
		Determine if the field is a group of radio or not.
	*/
	_isChildType: function(el) {
		var elType = el.type.toLowerCase();
		if((elType == "radio")) return true;
		return false;
	},
	
	/*
	Function: _validateGroup
		Private method
		
		Perform radios validations
	*/
	_validateGroup : function(el) {

		el.errors = [];
		var cbCheckeds = false;
		var nlButtonGroup = this.form[el.getProperty("name")];
		
		if (!nlButtonGroup.length) {
			if (el.checked) {
				cbCheckeds = true;
			}
		}
		else {
			el.group = nlButtonGroup;
			
			for (var i = 0; i < nlButtonGroup.length; i++) {
			
				if (nlButtonGroup[i].checked) {
					cbCheckeds = true;
				}
			}
		}
		
		if(cbCheckeds == false) {
			el.errors.push(this.options.alerts.radios);
			return false;
		} else {
			return true;	
		}
	},
	
	/*
	Method: validateCcNumber
		Internal method
		
		Use to validate a credit card number
		This script has been translated for mootools since :
		http://www.breakingpar.com/bkp/home.nsf/0/87256B280015193F87256CC70060A01B
		
	Parameters:
		el - html element
	*/
	_validateCcNumber: function(el){
		var cc_number = el.value;
				
		// if no cc type return and alert user
		if (!this._getCCType()) {
			el.errors.push(this.options.alerts.cc_type);
			return false;	
		}
			
		// check if the cc number is valid (check the correspondant regexp)	
		if (this.options.cc_check[this.cc_type].test(el.value) == false) {
			el.errors.push(this.options.alerts.cc_number);
			return false;
		} else {
			// Remove all dashes for the checksum checks to eliminate negative numbers
			cc_number = cc_number.replace(/\s/g,"");
			
			// Checksum ("Mod 10")
			// Add even digits in even length strings or odd digits in odd length strings.
			var checksum = 0;

			for (var i=(2-(cc_number.length % 2)); i<=cc_number.length; i+=2) {
				checksum += parseInt(cc_number.charAt(i-1));
			}

			// Analyze odd digits in even length strings or even digits in odd length strings.
			for (var i=(cc_number.length % 2) + 1; i<cc_number.length; i+=2) {
				var digit = parseInt(cc_number.charAt(i-1)) * 2;
				if (digit < 10) { checksum += digit; } else { checksum += (digit-9); }
			}
			if ((checksum % 10) != 0) {
				el.errors.push(this.options.alerts.cc_number);
				return false;
			}
			else {
				return true;
			}					
		}		
	},
	/*
	Function: _getCCType
		Private method
		
		check if user has choosed a credit card type
		
	*/
	_getCCType : function() {
		// if type is choosed by radio button
		$ES('input', $(this.options.ccbox_id)).each(function(el_type){
			if (el_type.getProperty('type') == 'radio' && el_type.getProperty('name') == this.options.cctype_name && el_type.checked) {
				this.cc_type = el_type.getProperty('value');
			}
		}, this);
		
		// if type is choosed by a dropdown element
		$ES('select', $(this.options.ccbox_id)).each(function(el_type){
			if (el_type.getProperty('name') == this.options.cctype_name && el_type.getProperty('value') != '') {
				this.cc_type = el_type.getProperty('value');
			}
		}, this);
		if (this.cc_type) return true; else return false;
	},
	
	/*
	Method: _validateCountry
		Internal method
		
		
	Parameters:
		el - html element
	*/
	_validateCountry: function(el){
		if ($(this.options.iso_countrycode).getProperty('value') != "") {
			return true;
		}
		else {
			el.errors.push(this.options.alerts.country);
			return false;
		} 
	},
	
	/*
	Function: _listErrorsAtTop
		Private method
		
		Display errors
	*/
	_listErrorsAtTop : function(obj) {
		if(!this.form.element) {
			 this.form.element = new Element('div', {'id' : 'errorlist', 'class' : this.options.error_class}).injectTop(this.form);
		}
		if ($type(obj) == 'collection') {
			new Element('p').setHTML("<span>" + obj[0].name + " : </span>" + obj[0].errors[0]).injectInside(this.form.element);
		} else {
			if ((obj.validation.contains('required') && obj.errors.length > 0) || (obj.errors.length > 0 && obj.value && obj.validation.contains('required') == false)) {
				obj.errors.each(function(error) {
					new Element('p').setHTML("<span>" + obj.name + " : </span>" + error).injectInside(this.form.element);
				}, this);
			}
		}
	},
	
	/*
	Function: _manageError
		Private method
		
		Manage display of errors boxes
	*/
	_manageError : function(el, method) {
		var isValid = this._validate(el);
		if (((!isValid && el.validation.contains('required')) || (!el.validation.contains('required') && el.value && !isValid))) {
			if(this.options.display.listErrorsAtTop == true && method == 'submit')
				this._listErrorsAtTop(el, method);
			if (this.options.display.indicateErrors == 2 ||this.alreadyIndicated == false || el.name == this.alreadyIndicated.name)
				{
					this._addError(el);
					return false;
				}
		} else if ((isValid || (!el.validation.contains('required') && !el.value)) && el.element) {
			this._removeError(el);
			return true;
		}
		return true;
	},
	
	/*
	Function: _addError
		Private method
		
		Add error message
	*/
	_addError : function(obj) {
		this.alreadyIndicated = obj;
		if(!this.firstError) this.firstError = obj;
		if(!obj.element) {
			if (this.options.display.errorsLocation == 1) {
				if (this.options.display.tipsPosition == 'relative') {
					var marginLeft = this.options.display.tipsOffsetX;
					if (this.options.display.tipsContainer = 'undef')
						var displacement = this.form.getCoordinates().left;
					else
						var displacement = $(this.options.display.tipsContainer).getCoordinates().left;
					var options = {
						'opacity' : 0,
						'position' : 'absolute',
						'margin-left' : obj.getCoordinates().right - displacement + this.options.display.tipsOffsetX
					}
				} else if (this.options.display.tipsPosition == 'absolute') {
					var options = {
						'opacity' : 0,
						'position' : 'absolute',
						'margin-left' : this.options.display.tipsOffsetX,
						'left' : obj.getCoordinates().right,
						'bottom' : obj.getCoordinates().top
					}
				}
					obj.element = new Element('div', {'id' : 'diverror' + obj.name, 'class' : this.options.tips_class, 'styles' : options});
					obj.element.injectInside(this.form);
				
			} else if (this.options.display.errorsLocation == 2){
				obj.element = new Element('div', {'id' : 'diverror' + obj.name, 'class' : this.options.error_class, 'styles' : {'opacity' : 0}});
				obj.element.injectBefore(obj);
			} else if (this.options.display.errorsLocation == 3){
				obj.element = new Element('div', {'id' : 'diverror' + obj.name, 'class' : this.options.error_class, 'styles' : {'opacity' : 0}});
				
				if ($type(obj.group) == 'object' || $type(obj.group) == 'collection')
					obj.element.injectAfter(obj.group[obj.group.length-1]);
				else
					obj.element.injectAfter(obj);
			}
		}						
		if (obj.element) {
			obj.element.empty();
			if (this.options.display.errorsLocation == 1) {
				var errors = [];
				obj.errors.each(function(error) {
					errors.push(new Element('p').setHTML(error));
				});
				var tips = this._makeTips(errors).injectInside(obj.element);
				obj.element.setStyle('top', obj.getCoordinates().top - tips.getCoordinates().height - this.options.display.tipsOffsetY);
			} else {
				obj.errors.each(function(error) {
					new Element('p').setHTML(error).injectInside(obj.element);
				});
			}
			
			if (!window.ie7 && obj.element.getStyle('opacity') == 0)
				new Fx.Styles(obj.element, {'duration' : this.options.display.fadeDuration}).start({'opacity':[1]});
			else
				obj.element.setStyle('opacity', 1);
		}
	},
	
	/*
	Function: _removeError
		Private method
		
		Remove the error display
	*/
	_removeError : function(obj) {
		this.firstError = false;
		this.alreadyIndicated = false;
		obj.errors = [];
		obj.isOK = true;
		if (this.options.display.errorsLocation == 2)
			new Fx.Styles(obj.element, {'duration' : this.options.display.fadeDuration}).start({ 'height':[0] });
		if (!window.ie7) {
			new Fx.Styles(obj.element, {
				'duration' : this.options.display.fadeDuration,
				'onComplete' : function() {
					if (obj.element) {
						obj.element.remove();
						obj.element = false;
					}
				}.bind(this)
			}).start({ 'opacity':[1,0] });
		} else {
			obj.element.remove();
			obj.element = false;
		}
	},
	
	/*
	Function: _focusOnError
		Private method
		
		Create set the focus to the first field with an error if needed
	*/
	_focusOnError : function (obj) {
		if (this.options.display.scrollToFirst && !this.alreadyFocused && this.alreadyIndicated.element && !this.isScrolling) {
			if (this.options.display.errorsLocation == 1) new Fx.Scroll(window, {onComplete : function() {this.isScrolling = false;}.bind(this)}).scrollTo(0,obj.element.getCoordinates().top);
			else if (this.options.display.errorsLocation == 2) new Fx.Scroll(window, {onComplete : function() {this.isScrolling = false;}.bind(this)}).scrollTo(0,obj.getCoordinates().top-30);
			this.isScrolling = true;
			obj.focus();
			this.alreadyFocused = true;
		} else if (this.options.display.scrollToFirst && !this.isScrolling) {
			new Fx.Scroll(window, {onComplete : function() {this.isScrolling = false;}.bind(this)}).scrollTo(0,obj.getCoordinates().top-30);
			this.isScrolling = true;
			obj.focus();
			this.alreadyFocused = true;
		}
	},
	
	/*
	Function: _makeTips
		Private method
		
		Create tips boxes
	*/
	_makeTips : function(txt) {
		var table = new Element('table', {'class' : 'tipsbox'});
			table.cellPadding ='0';
			table.cellSpacing ='0';
			table.border ='0';
			
			var tbody = new Element('tbody').injectInside(table);
				var tr1 = new Element('tr').injectInside(tbody);
					new Element('td', {'class' : 'tipsbox_top_left png'}).injectInside(tr1);
					new Element('td', {'class' : 'tipsbox_top png'}).injectInside(tr1);
					new Element('td', {'class' : 'tipsbox_top_right png'}).injectInside(tr1);
				var tr2 = new Element('tr').injectInside(tbody);
					new Element('td', {'class' : 'tipsbox_left png'}).injectInside(tr2);
					var errors = new Element('td', {'class' : 'tipsbox_inner png'}).injectInside(tr2);
					txt.each(function(error) {
						error.injectInside(errors);
					});
					new Element('td', {'class' : 'tipsbox_right png'}).injectInside(tr2);
				var tr3 = new Element('tr').injectInside(tbody);
					new Element('td', {'class' : 'tipsbox_bottom_left png'}).injectInside(tr3);
					new Element('td', {'class' : 'tipsbox_mark png'}).injectInside(tr3);
					new Element('td', {'class' : 'tipsbox_bottom_right png'}).injectInside(tr3);		
		return table;
	},
	
	/*
	Function: _reinitialize
		Private method		
		
		Reinitialize form before submit check
	*/
	_reinitialize: function() {
		this.validations.each(function(el) {
			if (el.element) {
				el.errors = [];
				el.isOK = true;
				el.element.remove();
				el.element = false;
			}
		});
		if (this.form.element) this.form.element.empty();
		this.alreadyFocused = false;
		this.firstError = false;
		this.alreadyIndicated = false;
		this.form.isValid = true;
	},
	
	/*
	Function: _onSubmit
		Private method		
		
		Perform check on submit action
	*/
	_onSubmit: function(event) {
		this._reinitialize();

		this.validations.each(function(el) {
		
			if(!this._manageError(el,'submit')) this.form.isValid = false;
		}, this);
		if(!this.form.isValid) { 
			new Event(event).stop();
			if (this.firstError) this._focusOnError(this.firstError);
		}
	},
	/*
	Function: validateForm
		Public method		
		
		return true if form is validated
	*/
	validateForm : function()	{
		this._reinitialize();

		this.validations.each(function(el) {
			if (!this._manageError(el, 'submit')) {
				this.form.isValid = false;
				return false;
			}
		}, this);
		return this.form.isValid;
	}
});

FormCheck.implement(new Options());/*
	Class: Checkout
		
	Usage:
		
		
	Parameters:
		- 
		
	Exemple:
	
	About:
		Popup.js v.1.0 for mootools v1.1 05 / 2007
		
		by Floor SA (http://www.floor.ch) MIT-style license
		
		last modified by Denis Schneiter 22.10.2007
*/
var Checkout = new Class({
	options : {
		'calc'		: 'calc-uts',
		'CS2Script'	: '/cgi/ifw',
		'ajax_template' : 'basketdetail',
		'pid'	: '1',
		'update_subact' : 'updatetransactionprice'
 	},

    /*
	Constructor: initialize
		Constructor
	
		
	*/
	initialize : function(options) {
		this.setOptions(options)
		this._initCheckout();
		this._initPopup();
	},	
	/*
	Function: _calculateAmount
		Internal method
		
		Parameters:
			-
	*/
	_initCheckout : function() {
		$$('.changeamount').each(function(el){
				el.addEvent('click', function(e){
					new Event(e).stop();
					this._changeAmount(el);
				}.bind(this))
		}, this);	
	},	
	/*
	Function: _changeAmount
		Internal method
		
		Parameters:
			-
	*/
	_changeAmount : function(el) {			
			this.hash_params = new Hash();
			var params = el.getProperty('href').split(/&/);
			
			params.each(function(e) {
				var param = e.split(/=/);
				this.hash_params.set(param[0], param[1]);
			},this);
			
			var elcoord = el.getCoordinates();
			if (!this.calc) {
				this.calc = new Calc({
					'draggable': true,
					'build': true,
					'amount': this.hash_params.get('product_properties_amount'),
					'mode': this.hash_params.get('product_properties_mode').toInt(),
					'Express': (this.hash_params.get('product_properties_express') == '1') ? true : false,
					'onEnter': function(){
						var amount = this.input.getProperty('value');
						this.options.calling_class.update(amount, this.mode, this.currency, this.calculator, this.options.Express);
					},
					'onClose': function()	{
						this.options.calling_class.close(this.calculator);
					},
					'calling_class': this
				});
				
				this.calc.setPosition(elcoord.left + 20, elcoord.top - 20);
				this.calc.setAmount(this.hash_params.get('product_properties_amount'));
				this.calc.setMode(this.hash_params.get('product_properties_mode').toInt());
			}	
	},
	
	close : function(calc)	{
		calc.remove();
		delete this.calc;
	},
	
	update : function(amount, mode, currency, calc, express) {
		var url = this.options.CS2Script +"?template=" + this.options.ajax_template + "&product_properties_amount=" + amount;
		url = url + "&product_ID=" + this.options.pid;
		url = url + "&category_ident=checkout";
		url = url + "&product_properties_currency=" + currency;
		url = url + "&product_properties_mode=" + mode;
		url = url + "&required=product_properties_amount";
		url = url + "&subact=" + this.options.update_subact;
		url = url + "&session=" + $('session').getProperty('value');
		url = url + "&server=" + $('server').getProperty('value');
		url = url + "&lang=" + $('lang').getProperty('value');
		url = url + "&basketdetailID=" + this.hash_params.get('basketdetailID');
		url = url + "&product_properties_AddressBookID=" + this.hash_params.get('product_properties_AddressBookID');
		url = url + "&product_properties_express=" + ((express) ? '1' : '0');
		
		new Ajax(url, {
			method: 'get',
			onComplete : function(e) {
				$('basket_content').innerHTML = e;
				calc.remove();
				delete this.calc;
				this._initCheckout();
			}.bind(this)
		}).request();
						
	},
	/*
	Function: _initPopup
		Internal method
		
		Parameters:
			-
	*/
	_initPopup : function() {
		if($('payment')) { 
			$('payment').addEvent('submit', function(e){
				new Event(e).stop();
							
				var popup = new Popup();
				popup.openPost($('payment'));
			}.bind(this));
		}
	}
});

Checkout.implement(new Options, new Events);/*
	Class: Popup
		
	Usage:
		
		
	Parameters:
		- 
		
	Exemple:
	
	About:
		Popup.js v.1.0 for mootools v1.1 05 / 2007
		
		by Floor SA (http://www.floor.ch) MIT-style license
		
		last modified by Denis Schneiter 22.10.2007
*/
var Popup = new Class({
	options : {
		'target'	: 'popup',
		'dependent' 	: 'no',
		'height' 	: 700,
		'width' 	: 500,
		'location' 	: 'no',
		'menubar' 	: 'no',
		'resizable' : 'yes',
		'status' 	: 'no',
		'toolbar' 	: 'no',
		'scrollbars' : 'yes'
 	},

    /*
	Constructor: initialize
		Constructor
	
		
	*/
	initialize : function(options) {
		this.setOptions(options)
		
	},
	/*
	Function: _calculateAmount
		Internal method
		
		Parameters:
			-
	*/
	open : function(url) {	
		var popup = window.open(url, this.options.target, "dependent="+this.options.dependent+",height="+this.options.height+",width="+this.options.width+",location="+this.options.location+",menubar="+this.options.menubar+",resizable="+this.options.resizable+",scrollbars="+this.options.scrollbars+",status="+this.options.status+",toolbar="+this.options.toolbar);
	},	
	/*
	Function: _openPost
		Internal method
		Open a popup and inject the form with post method
		
		Parameters:
			-
	*/
	openPost : function(el) {
		var form = eval(el);
    	
		var popup = window.open("", this.options.target, "dependent="+this.options.dependent+",height="+this.options.height+",width="+this.options.width+",location="+this.options.location+",menubar="+this.options.menubar+",resizable="+this.options.resizable+",scrollbars="+this.options.scrollbars+",status="+this.options.status+",toolbar="+this.options.toolbar);
		popup.focus();
		
		form.target = this.options.target;
		form.submit();
	}
});

Popup.implement(new Options, new Events);