//Skeenable Forms Management
var skeenableForms = new Class({
	initialize: function(poOptions){
		this.options = $extend({
			selector:		"form.skeenable"
		}, poOptions || {});
		var laForms = $(document.body).getElements(this.options.selector);
		this.forms = new Hash();
		$each(laForms, function(poFrm){ 
			this.forms.set(poFrm.getProperty("id") || poFrm.getProperty("name")
							, new skeenableForm(poFrm));}.bind(this));
	}
});
//Skeenable Form
var skeenableForm = new Class({
	initialize: function(poForm){
		
		this.form = poForm;
		
		//initialize all select
		var laSelect = this.form.getElements("select.skeenableSelect");
		this.selects = new Hash();
		this.selectGroups = new Hash();
		$each(laSelect, function(poSel, pnIdx){
			//detect select group
			var lsGroup = poSel.getProperty("groupName");
			var loSel = null;
			if(lsGroup){
				//include in a select group
				var loGroup = this.selectGroups.get(lsGroup);
				if(!loGroup){
					loGroup = new Array();
					this.selectGroups.set(lsGroup, loGroup);
				}
				loSel = new skeenableSelect(poSel, this, pnIdx, loGroup.length);
				loGroup.push(loSel);
			}else{
				//alone
				loSel = new skeenableSelect(poSel, this, pnIdx, null);
			}
			
			this.selects.set( poSel.getProperty("id") || poSel.getProperty("name"), loSel);
			
			}.bind(this)
		);
		
		//initialize all checkboxes
		var laCheckBoxes = this.form.getElements("input[type='checkbox'].skeenableRadio");
		this.checkboxes = new Hash();
		$each(laCheckBoxes, function(poCheck){
			var lsKey = poCheck.getProperty("id") || poCheck.getProperty("name");
			var laGoupBoxes = this.checkboxes.get(lsKey);  
			if(!laGoupBoxes){
				laGoupBoxes = new Array();
				this.checkboxes.set( lsKey, laGoupBoxes);
			}
			laGoupBoxes.push(new skeenableCheckbox(poCheck, this));
			
		}.bind(this));
		
		//initialize all riaos
		var laRadios = this.form.getElements("input[type='radio'].skeenableRadio");
		this.radios = new Hash();
		$each(laRadios, function(poRadio){
			var lsKey = poRadio.getProperty("name");
			var laGoupRadios = this.radios.get(lsKey);  
			if(!laGoupRadios){
				laGoupRadios = new Array();
				this.radios.set( lsKey, laGoupRadios);
			}
			laGoupRadios.push(new skeenableRadio(poRadio, this));
			
		}.bind(this));
		
		//initialize all input
		var laTexts = this.form.getElements("input[type='text'].skeenableInput");
		this.texts = new Hash();
		$each(laTexts, function(poText){
			var lsKey = poText.getProperty("id") || poText.getProperty("name");
			this.texts.set(lsKey, new skeenableInput(poText, this, false));
			
		}.bind(this));
		
		//initialize all input
		var laTags = this.form.getElements("input[type='submit'].skeenableBtn");
		this.submits = new Hash();
		$each(laTags, function(poText){
			var lsKey = poText.getProperty("id") || poText.getProperty("name");
			this.submits.set(lsKey, new skeenableInput(poText, this, true));
			
		}.bind(this));
		
		//initialize all input
		laTags = this.form.getElements("input[type='reset'].skeenableBtn");
		this.resets = new Hash();
		$each(laTags, function(poText){
			var lsKey = poText.getProperty("id") || poText.getProperty("name");
			this.resets.set(lsKey, new skeenableInput(poText, this, true));
			
		}.bind(this));
	},

	//get the label element associated with the argument element 
	getLabel : function(poElm){
		return this.form.getElement("label[for="+ poElm.getProperty("id") +"]");
	},
	
	//close all select in the form except the argument element
	closeAllSelect : function(poElm){
		$each(this.selects, function(poSel){
			if(poSel != poElm){
				poSel.display(false);
			}
		});
	},
	
	//reinit all select
	reinitSelects : function (){
		$each(this.selects, function(poSel){ poSel.reinit();});
	},
	
	//close all select after the select argument in its groups
	reinitSelectGroup : function(poSel){
		var lsGroupName = poSel.select.getProperty("groupName");
		if(lsGroupName){
			var laGroup = this.selectGroups.get(lsGroupName);
			for(var lnI= poSel.groupIndex + 1,lnL = laGroup.length ;lnI < lnL ; lnI++){
				laGroup[lnI].disable();
				laGroup[lnI].cleanList();
				laGroup[lnI].select.setProperty('disabled', 'disabled');
				//laGroup[lnI].select.setProperty('selectedIndex' , 0 );
				laGroup[lnI].display(false);
			}
		}
	}
});

// Skeenable checkbox
var skeenableCheckbox = new Class({

	//initialization
	initialize: function(poCheckBox, poForm){
	this.form = poForm;
	
		this.elm = poCheckBox;
		this.elm.defaultChecked = this.elm.checked;
		this.elm.addEvent('click', function(){ this.checkChecked();}.bind(this));
		
		this.ctn = new Element("a",{
			'href'		: "#",
			'class'		: this.elm.className,
			'events'	: { 'click' : function(){
											this.elm.checked = !this.elm.checked;
											this.checkChecked();
											return false;
											}.bind(this)
							}
			}
		);
		
		this.elm.getParent().insertBefore(this.ctn, this.elm);
		this.checkChecked();
	},

	checkChecked : function (){
		this.curStyle = this.ctn.getStyle("background-positionX");
		
		if(this.elm.checked){
			this.ctn.addClass('selected');
		}else{
			this.ctn.removeClass('selected');
		}
	},
	
	reset : function (){
		this.elm.checked = this.elm.defaultChecked;
		this.checkChecked();
	}
});

//Skeenable Select
var skeenableSelect = new Class({

	//initialization
	initialize: function(poSelect, poForm, poElementIndex, poGroupIndex){
		//init select properties from parameters
		this.select = poSelect;	
		this.form = poForm;
		this.index = poElementIndex;
		this.groupIndex = poGroupIndex;
		this.opts = poSelect.options;
		
		//init default values for properties
		this.open = false;
		this.fromTheMouse = false;
		this.selectedIndex = this.select.selectedIndex;
		this.setSelectionValue();
		this.fromKeyboard = true;
		this.focusByScript = true;	
		
		//get behavior from class definition
		this.onTop = this.select.hasClass("skeenableSelect_top");
		this.withImg = this.select.hasClass("skeenableSelect_img");
		this.selectSize = this.select.hasClass("skeenableSelect-size");
		this.bodyChild = this.select.hasClass("skeenable_overflow");
		
		//height is defined by classname skeenableSelect_HEIGHT
		this.maxHeight = this.select.className.match(/\bskeenableSelect_[0-9]*\b/);
		if(this.maxHeight) this.maxHeight = this.maxHeight[0].split("_")[1];
		//id link with the select specify by class name skeenableId_IDLINK
		this.$tmp = this.select.className.match(/\bskeenableId_[a-zA-Z]*\b/);
		this.childOf = null;
		if(this.$tmp)  {
			this.childOf = this.$tmp[0].split('_')[1];
		}		
		
		//get label for select
		this.label = this.form.getLabel(this.select);
		if(this.label) this.label.setStyle("display" , "none");
		this.defaultText = this.label ? this.label.innerHTML : this.opts[0].innerHTML;
		
		//remove actual onChange event
		this.select.oldOnChange = this.select.onchange;
		if(typeof this.select.oldOnChange == "function"){
			this.select.removeEvent("change", this.select.oldOnChange);
		}
		//build alternative html code for the select
		this.build();	
		
		//define select events
		this.select.addEvents({
			'click' : function() {return false;},
			'focus' : function() {return false;},
			'change': function(){
									if(this.focusByScript){
										this.update(this.as[this.select.selectedIndex]);
										this.a.focus();
									}
									if(typeof this.select.oldOnChange == "function") { this.select.oldOnChange()};
									this.focusByScript = true;
									return false;
								}.bind(this)
		});		
		
		//display alternative presentation
		if(this.opts.length < 2 || this.select.getAttribute('disabled')) this.disable();
		else {
			this.update(this.as[this.selectedIndex]);
			this.display(false);
		}
	},
	
	setSelectionValue : function(){
		if(this.select.selectedIndex > -1){
			if (this.select.selectedIndex == 0) {
				this.selectedValue = this.defaultText;
				this.selectedText = "";
			} else {
				this.selectedValue = this.select.options[this.select.selectedIndex].value;
				this.selectedText = this.select.options[this.select.selectedIndex].text;
			}
		}
	},
	
	//build alternative HTML
	build: function(){		
		//link creation (drop down)
		this.a = new Element("a",{
			'class' :	this.select.getProperty("class"),
			'style'	:	"position : absolute",
			'href'	:	"javascript:;",
			'events'	: {
		        'click'	: function (){
							this.display(!this.open);
							this.fromKeyboard = false;
							return false;
							}.bind(this),
				'focus'	: function (){
							this.selectedIndex = this.select.selectedIndex;
							this.setSelectionValue();
							this.giveKeyEvent(true);
							return false;
							}.bind(this),
				'blur'	: function (){
							if(!this.overUL) {
								this.display(false);
							}
							this.giveKeyEvent(false);
							return false;
							}.bind(this)	
			}
		});
		
		this.span = new Element("span",{'html'	:	this.defaultText});
		this.a.appendChild(this.span);
		
		//list creation
		this.ul = new Element("ul",{
			'class' :	this.select.getProperty("class"),
			'style'	:	"visibility : hidden",
			'events'	: {
				'mouseover'	: function (){
							this.overUL = true;
							this.giveKeyEvent(true);
							return false;
							}.bind(this),
				'mouseout'	: function (){
							this.overUL = false;
							this.giveKeyEvent(false);
							return false;
							}.bind(this)
			}
		});
		
		this.buildItems();
		
		// insert into DOM
		if(this.bodyChild || this.childOf){
			this.div = new Element("div",{
				'class' : this.form.form.getProperty("id") || this.form.form.getProperty("name")
			});	
		}
		var loSelectParent = this.select.getParent();
		if (this.bodyChild){	
			this.div.setProperty("class" , loSelectParent.getProperty("class"));
			$(document.body).appendChild(this.div);
			this.div.appendChild(this.a);
			this.div.appendChild(this.ul);
			this.a.setStyle("width" , loSelectParent.offsetWidth - parseInt(this.a.getStyle("padding-left"))); // hackable en CSS avec un !important
		}
		else if(!this.bodyChild && !this.childOf){
			loSelectParent.insertBefore(this.a, this.select);
			loSelectParent.insertBefore(this.ul, this.select);
			this.a.setStyle("width" , loSelectParent.offsetWidth - parseInt(this.a.getStyle("padding-left"))); // hackable en CSS avec un !important
		}
		else if(this.childOf){
			this.$tmp = $(this.childOf.toString());
			loSelectParent.insertBefore(this.a, this.select);
			this.div.appendChild(this.ul)
			this.$tmp.appendChild(this.div)
			this.a.setStyle("width" , loSelectParent.offsetWidth - parseInt(this.a.getStyle("padding-left"))); // hackable en CSS avec un !important
		}
		
		if (this.selectSize){
			this.a.setStyle("width" , loSelectParent.offsetWidth - parseInt(this.a.getStyle("padding-left"))); // hackable en CSS avec un !important
		}
	},
	
	buildItems : function(){
		//item creation
		this.lis = new Array();
		this.as = new Array();
		
		for(var lnI = 0, lnL = this.opts.length ; lnI < lnL ; lnI++){
			var loLi = new Element("li");

			if(lnI == 0) loLi.setProperty("class", "first");
			if(lnI == lnL - 1) loLi.setProperty("class", "last");
			var loA = new Element("a",{
				'href'		: "#"+this.opts[lnI].value,
				'index'		: lnI,
				'html'		: this.opts[lnI].innerHTML || this.opts[lnI].text,
				'class'		: this.withImg ? this.opts[lnI].value : null,
				'events'	: {
						        
						        'mouseover' : function(pnIndex){
						        	this.manageFocusOnLiA(pnIndex);
						        }.bind(this, lnI)
				}
			});
			
			loA.addEvent("click" , function(poA){
											this.update(poA);
											this.display(false);
											return false;
								        }.bind(this,loA));
			
			this.lis.push(loLi);
			this.as.push(loA);
			
			loLi.appendChild(loA);
			this.ul.appendChild(loLi);
		};
	},
	
	//update select
	update : function (loA){
		if(!loA) return;
		this.span.setProperty("html", loA.getProperty("html"));
		// I.E. fix
		try {
			this.a.focus();
		} catch (err) {
			// Element not focusable
		}
		this.select.selectedIndex =  loA.getProperty('index');
		this.oldIndex = this.select.selectedIndex;
		this.selectedIndex = this.select.selectedIndex;
		if (this.selectedIndex > 0) {
			this.span.addClass("selected");
		}
		this.setSelectionValue();
		// if image needs
		if(this.withImg) {
			this.span.setProperty("html", "<img src='/eshop/css/skin/misc/"+this.opts[this.oldIndex].value+".png' />");
		}
		
		if(typeof this.select.onchange == "function") {
			this.focusByScript = false;
			this.select.fireEvent('change');
		}
	},
	
	//disable select alternative display
	disable: function (){
		this.a.addClass("inactive");
		this.select.selectedIndex = 0;
		this.selectedIndex = 0;
		this.selectedValue = "";
		this.selectedText = "";
		this.span.setProperty("html" , this.defaultText);
		this.span.removeClass("selected");
		
		this.form.reinitSelectGroup(this);

		this.cleanList();
	},
	
	//display selection element
	display: function (pbOpen){
		if(this.opts.length < 2 || this.select.getProperty('disabled')) {
			this.disable();
			return;
		}else{
			this.a.removeClass("inactive");
		}

		if (pbOpen){
			this.form.closeAllSelect(this);
			this.positionate();
			this.ul.setStyle("display" , "block");
			this.span.setProperty("html" , this.defaultText);
			this.span.removeClass("selected");
			this.ul.addClass("open");
			this.a.addClass("skeenableSelected");
			this.a.fireEvent("focus");
		}
		else {
			this.ul.setStyle("display" , "none");
			this.ul.removeClass("open");
			this.a.removeClass("skeenableSelected");
			if (this.span.getProperty("html") == this.defaultText) this.update(this.as[this.oldIndex]);
		}
		this.open = pbOpen;
	},
	
	//positionate the drop downlist
	positionate: function (){
		this.ul.setStyles({
			visibility : "hidden" ,
			display : "block"});
		
		//calcul pour le select auto
		this.width2apply = this.a.offsetWidth - parseInt(this.ul.getStyle('border-left-width')) - parseInt(this.ul.getStyle('border-right-width'));
		
		this.ul.setStyle("width" , this.width2apply);
		if(this.maxHeight && this.ul.scrollHeight > this.maxHeight) {
			this.ul.setStyles({
				"height" : this.maxHeight+"px",
				"overflowY" : "auto",
				"overflowX" : "hidden"
			});
		}
		if(!this.bodyChild && !this.childOf){
			// if you check footerDownLeft  184 = margin-right + max-width
			// so this is a workaround to fix the IE flag displaying
			
			if(this.a.hasClass("skeenableSelect_img")) {
				this.ul.setStyle("left", this.a.offsetLeft - 184);
			} else {
				this.ul.setStyle("left", this.a.offsetLeft);
			}
			this.ul.setStyle("margin-top", this.a.offsetHeight - 5);
		}
		else if (this.bodyChild){
			var loCoor = this.select.getPosition();
			this.a.setStyles({top : loCoor.y+"px", left : loCoor.x+"px"});
			this.ul.setStyles({top :  (loCoor.y + this.a.offsetHeight - 5)+"px", left : loCoor.x+"px"});
		}
		else {
			var loCoor = this.a.getPosition();
			var loCoor2 = $(this.childOf.toString()).getPosition();
			
			if(!loCoor || !loCoor2) return;
			this.ul.setStyles({top :  (loCoor.y - loCoor2.y + this.a.offsetHeight - 5) + "px", left : (loCoor.x - loCoor2.x)+"px"});
		}
		if (this.onTop){
			//log(this.ul.offsetHeight)
			this.ul.setStyle("margin-top", this.ul.offsetHeight-5);
		}
		this.ul.setStyles({ display : "none", visibility : "visible"});

	},
	
	//append search method on key pressed
	giveKeyEvent: function (pbGiveEvent){ // boolean
		var lnOne2select = 0;
		if(pbGiveEvent){
			if(!this.onKeyDownMethod){
				this.onKeyDownMethod = function(poEvent){
					//If alphanum char
					if(
						poEvent.code >= 48 && poEvent.code <= 57 ||  //0 - 1 
						poEvent.code >= 65 && poEvent.code <= 90 || //A - Z 
						poEvent.code >= 97 && poEvent.code <= 122 //a - z
						
						){
						this.searchLetter(poEvent.key.toLowerCase());
						poEvent.stopPropagation();
						return true;
					}else if(poEvent.code == 13 || poEvent.code == 27){//If enter or esc
						if(this.ul.getStyle("display") != 'none'){
							this.display(false);
							return false;
						}
						return true;
					}else if(poEvent.code == 40){//Arrow down
						this.seek();
						poEvent.stopPropagation();
						poEvent.preventDefault();
					}else if(poEvent.code == 38){//Arrow up
						this.seek(true);
						poEvent.stopPropagation();
						poEvent.preventDefault();
					}
					return true;}.bindWithEvent(this);
			}
			$(document).removeEvent("keydown", this.onKeyDownMethod);
			$(document).addEvent("keydown" , this.onKeyDownMethod);
		}else{
			$(document).removeEvent("keydown", this.onKeyDownMethod);
		}
	},
	
	//focus on the first element with selected key	
	searchLetter: function(psKey){
		var lnCurrentIndex = parseInt(this.selectedIndex);
		var lnFoundIdx = -1;
		for(var lnI = lnCurrentIndex + 1, lnL = this.opts.length; lnI < lnL && lnFoundIdx < 0; lnI++){
			if(this.opts[lnI].text.toLowerCase().substr(0,1) == psKey) {
				lnFoundIdx = lnI;
			}
		}
		
		for(var lnI = 0, lnL = lnCurrentIndex; lnI < lnL && lnFoundIdx < 0 ; lnI++){
			if(this.opts[lnI].text.toLowerCase().substr(0,1) == psKey) {
				lnFoundIdx = lnI;
			}
		}
		
		if(lnFoundIdx > -1 && lnFoundIdx != lnCurrentIndex){
			this.update(this.as[lnFoundIdx]);
			this.fromKeyboard = true;
			this.manageFocusOnLiA(lnFoundIdx);
			// scroll to display the selected item
			this.ul.scrollTop = lnFoundIdx*this.ul.scrollHeight/this.opts.length ;
		}
	},
	
	seek:function(seekUp){
		var lnCurrentIndex = parseInt(this.selectedIndex),
		newIndex;
		if(seekUp){
			lnCurrentIndex > 0 ? newIndex = lnCurrentIndex - 1 : newIndex = this.opts.length - 1;
		}else{
			lnCurrentIndex < this.opts.length - 1 ? newIndex = lnCurrentIndex + 1 : newIndex = 0;
		}

		this.update(this.as[newIndex]);
		this.fromKeyboard = true;
		this.manageFocusOnLiA(newIndex);
		// scroll to display the selected item
		this.ul.scrollTop = newIndex*this.ul.scrollHeight/this.opts.length ;
	},
	
	//focus on a specific item
	manageFocusOnLiA: function(pnIndex){
		if(pnIndex == this.hoveredIndex) return;
		if(this.as[this.hoveredIndex]) this.as[this.hoveredIndex].removeClass("hover");
		this.hoveredIndex = pnIndex;
		this.as[this.hoveredIndex].addClass("hover");
		//if(this.fromKeyboard) this.update(this.as[this.selectedIndex]);
		if(!this.fromKeyboard) this.a.fireEvent("focus");			
	},
	
	//reinitialize the select
	reinit: function(poOptList, pnSelectedIndex){
		this.form.reinitSelectGroup(this);
		var loOldOnChange = this.select.onchange;
		if(typeof loOldOnChange == "function"){
			this.select.onchange = null;
		}
		this.select.setProperty("html", "");
		
		if(typeof poOptList == "string"){
			this.select.setProperty("html", poOptList);
		}
		else{
			var loFrag = document.createDocumentFragment();
			for(var lnI = 0, lnL = poOptList.length; lnI < lnL; lnI++){
				var loLi = new Element("option",{
					'value' : poOptList[lnI].value || poOptList[lnI][0],
					'html' : poOptList[lnI].text || poOptList[lnI][1]
				});
				loFrag.appendChild(loLi);
				
			}
			this.select.appendChild(loFrag);
		}
		
		this.select.selectedIndex = 0;
		this.oldIndex = pnSelectedIndex;
		this.selectedIndex = 0;
		this.selectedValue = "";
		this.selectedText = "";
		this.select.removeProperty("disabled");
		this.span.setProperty("html" , this.defaultText);
		this.span.removeClass("selected");
		if(this.open) this.fromTheMouse = false;
		this.totalRefresh();
		this.display(false);
		
		if(typeof loOldOnChange == 'function') 
			this.select.onchange = loOldOnChange;
		
		if(pnSelectedIndex != null && pnSelectedIndex != -1) {
			//this.select.fireEvent("change");
			this.update(this.as[pnSelectedIndex]);
			this.fromKeyboard = true;
			this.manageFocusOnLiA(pnSelectedIndex);
		}	
	},
	
	//refresh the select
	totalRefresh : function (){
		//empty ul
		for(var loCn = this.ul.childNodes, lnI = loCn.length - 1 ; lnI > 0 ; lnI--){
			loCn[lnI].parentNode.removeChild(loCn[lnI]);
		}
		this.ul.setProperty("html" , "");
		
		//reinit opt
		this.opts = this.select.options;
		this.buildItems();
	},
	
	cleanList : function(){
		for(var loCn = this.ul.childNodes, lnI = loCn.length - 1 ; lnI > 0 ; lnI--){
			loCn[lnI].parentNode.removeChild(loCn[lnI]);
		}
		this.selectedIndex = 0;
		this.selectedValue = "";
		this.selectedText = "";
		this.select.selectedIndex = 0;
		this.oldIndex = 0;

		this.ul.setProperty("html" , "");
	}
});

// Skeenable radios
var skeenableRadio = new Class({

	//initialization
	initialize: function(poRadio, poForm){
		this.form = poForm;
		this.elm = poRadio;
		this.elm.addEvent("click", function(){ this.ctn.focus(); this.checkAll(); return false;}.bind(this));
		//this.elm.addEvent("focus", function(){ this.ctn.focus(); this.checkAll(); return false;}.bind(this));
		
		this.ctn = new Element("a",{
			'href'		: "#",
			'class'		: this.elm.className,
			'events'	: { 'click' : function(){
											this.elm.checked = true;
											this.checkChecked();
											this.checkAll();
											return false;
											}.bind(this)
							}
			}
		);
		this.ctn.inject( this.elm, 'before');
	},
	
	//check all radio button of the same group
	checkAll : function(){
		var radioGroup = this.form.radios.get(this.elm.getProperty("name"))
		radioGroup.each(function(poRadio){ poRadio.checkChecked();});
	},
		
	//display graphicly the raiod state
	checkChecked : function (){
			if(this.elm.checked){
				this.ctn.addClass('selected');
			}else{
				this.ctn.removeClass('selected');
			}
	}
		
});

//Skeenable radios
var skeenableInput = new Class({

	//initialization
	initialize: function(poText, poForm, pbNotResize){
		this.form = poForm;
		this.elm = poText;
		this.originalWidth = this.elm.getParent().offsetWidth;
		
		this.ctn1 = new Element("span",{
			'class'		: this.elm.className
		});
		
		this.ctn2 = new Element("span");
			
		this.ctn2.inject(this.ctn1);
		this.ctn1.inject( this.elm, 'before');
		
		this.frag = document.createDocumentFragment();
		this.frag.appendChild(this.elm);
		this.ctn2.appendChild(this.frag);
		
		if(!pbNotResize){
			this.ctn2.setStyle("width", this.originalWidth - this.ctn1.getStyle("padding-left").toInt() - this.ctn2.getStyle("padding-right").toInt());
		}
		
		if(this.elm.hasClass("labelInside") ){
			this.label = this.form.getLabel(this.elm);
			if(this.label) {
				var lsLabel = this.label.getProperty("html");
				this.form.form.elements[this.elm.getProperty("id") || this.elm.getProperty("name")].value = lsLabel;
				this.labelValue = lsLabel;
				this.label.setProperty("html", "");
				this.label.setStyle("display" ,"none");
			}
			else if(this.elm.getProperty('label')){
				this.form.form.elements[this.elm.getProperty("id") || this.elm.getProperty("name")].value = this.elm.getProperty('label');
				this.labelValue = this.elm.getProperty('label');
			}		
		}
	}
});