PageSourceSearch

https://misericordiadibadia.it/wp-content/plugins/bt_cost_calculator/jquery.dd.js?ver=7.0.2

js misericordiadibadia.it collected 2026-09-25 09:04:53 UTC 51,627 bytes, 1,490 lines download raw bytes

1// MSDropDown - jquery.dd.js
2// author: Marghoob Suleman - http://www.marghoobsuleman.com/
3// Date: 10 Nov, 2012
4// Version: 3.2
5// Revision: 21
6// web: www.marghoobsuleman.com
7/*
8// msDropDown is free jQuery Plugin: you can redistribute it and/or modify
9// it under the terms of the either the MIT License or the Gnu General Public License (GPL) Version 2
10*/
11var msBeautify = msBeautify || {};
12(function ($) {
13msBeautify = {
14	version: {msDropdown:'3.2'},
15	author: "Marghoob Suleman",
16	counter: 20,
17	debug: function (v) {
18		if (v !== false) {
19			$(".ddOutOfVision").css({height: 'auto', position: 'relative'});
20		} else {
21			//$(".ddOutOfVision").css({height: '0px', position: 'absolute'});
22			$(".ddOutOfVision").css({height: '0px', position: 'relative'});
23		}
24	},
25	oldDiv: '',
26	create: function (id, settings, type) {
27		type = type || "dropdown";
28		var data;
29		switch (type.toLowerCase()) {
30		case "dropdown":
31		case "select":
32			data = $(id).msDropdown(settings).data("dd");
33			break;
34		}
35		return data;
36	}
37};
38
39$.msDropDown = {};
40$.msDropdown = {};
41$.extend(true, $.msDropDown, msBeautify);
42$.extend(true, $.msDropdown, msBeautify);
43// make compatibiliy with old and new jquery
44if ($.fn.prop === undefined) {$.fn.prop = $.fn.attr;}
45if ($.fn.on === undefined) {$.fn.on = $.fn.bind;$.fn.off = $.fn.unbind;}
46if (typeof $.expr.createPseudo === 'function') {
47	//jQuery 1.8  or greater
48	$.expr[':'].Contains = $.expr.createPseudo(function (arg) {return function (elem) { return $(elem).text().toUpperCase().indexOf(arg.toUpperCase()) >= 0; }; });
49} else {
50	//lower version
51	$.expr[':'].Contains = function (a, i, m) {return $(a).text().toUpperCase().indexOf(m[3].toUpperCase()) >= 0; };
52}
53//dropdown class
54function dd(element, settings) {
55	var _settings = $.extend(true,{byJson: {data: null, selectedIndex: 0, name: null, size: 0, multiple: false, width: 250},
56		mainCSS: 'dd',
57		height: 120, //not using currently
58		visibleRows: 7,
59		rowHeight: 0,
60		showIcon: true,
61		zIndex: 9999,
62		useSprite: false,
63		animStyle: '',
64		event:'click',
65		openDirection: 'auto', //auto || alwaysUp
66		jsonTitle: false,
67		style: '',
68		disabledOpacity: 0.7,
69		disabledOptionEvents: true,
70		childWidth:0,
71		enableCheckbox:false, //this needs to multiple or it will set element to multiple
72		checkboxNameSuffix:'_mscheck',
73		append:'',
74		prepend:'',
75		on: {create: null,open: null,close: null,add: null,remove: null,change: null,blur: null,click: null,dblclick: null,mousemove: null,mouseover: null,mouseout: null,focus: null,mousedown: null,mouseup: null}
76		}, settings);								  
77	var _this = this; //this class	 
78	var _holderId = {postElementHolder: '_msddHolder', postID: '_msdd', postTitleID: '_title',postTitleTextID: '_titleText', postChildID: '_child'};
79	var _styles = {dd:_settings.mainCSS, ddTitle: 'ddTitle', arrow: 'arrow arrowoff', ddChild: 'ddChild', ddTitleText: 'ddTitleText',disabled: 'disabled', enabled: 'enabled', ddOutOfVision: 'ddOutOfVision', borderTop: 'borderTop', noBorderTop: 'noBorderTop', selected: 'selected', divider: 'divider', optgroup: "optgroup", optgroupTitle: "optgroupTitle", description: "description", label: "ddlabel",hover: 'hover',disabledAll: 'disabledAll'};
80	var _styles_i = {li: '_msddli_',borderRadiusTp: 'borderRadiusTp',ddChildMore: 'border shadow',fnone: "fnone"};
81	var _isList = false, _isMultiple=false,_isDisabled=false, _cacheElement = {}, _element, _orginial, _isOpen=false;
82	var DOWN_ARROW = 40, UP_ARROW = 38, LEFT_ARROW=37, RIGHT_ARROW=39, ESCAPE = 27, ENTER = 13, ALPHABETS_START = 47, SHIFT=16 , CONTROL = 17;
83	var _shiftHolded=false, _controlHolded=false,_lastTarget=null,_forcedTrigger=false, _oldSelected, _isCreated = false;
84	var _doc = document;
85	
86	var _checkDataSetting = function() {
87		_settings.mainCSS = $("#"+_element).data("maincss") || _settings.mainCSS;
88		_settings.visibleRows = $("#"+_element).data("visiblerows") || _settings.visibleRows;
89		if($("#"+_element).data("showicon")==false) {_settings.showIcon = $("#"+_element).data("showicon");};
90		_settings.useSprite = $("#"+_element).data("usesprite") || _settings.useSprite;
91		_settings.animStyle = $("#"+_element).data("animstyle") || _settings.animStyle;
92		_settings.event = $("#"+_element).data("event") || _settings.event;
93		_settings.openDirection = $("#"+_element).data("opendirection") || _settings.openDirection;
94		_settings.jsonTitle = $("#"+_element).data("jsontitle") || _settings.jsonTitle;
95		_settings.disabledOpacity = $("#"+_element).data("disabledopacity") || _settings.disabledOpacity;
96		_settings.childWidth = $("#"+_element).data("childwidth") || _settings.childWidth;
97		_settings.enableCheckbox = $("#"+_element).data("enablecheckbox") || _settings.enableCheckbox;
98		_settings.checkboxNameSuffix = $("#"+_element).data("checkboxnamesuffix") || _settings.checkboxNameSuffix;
99		_settings.append = $("#"+_element).data("append") || _settings.append;
100		_settings.prepend = $("#"+_element).data("prepend") || _settings.prepend;		
101	};	
102	var getElement = function(ele) {
103		if (_cacheElement[ele] === undefined) {
104			_cacheElement[ele] = _doc.getElementById(ele);
105		}
106		return _cacheElement[ele];
107	}; 	
108	var _getIndex = function(opt) {
109		var childid = _getPostID("postChildID"); 
110		return $("#"+childid + " li."+_styles_i.li).index(opt);
111	};
112	var _createByJson = function() {
113		if (_settings.byJson.data) {
114				var validData = ["description","image",  "title"];
115				try {
116					if (!element.id) {
117						element.id = "dropdown"+msBeautify.counter;
118					};
119					_settings.byJson.data = eval(_settings.byJson.data);
120					//change element
121					var id = "msdropdown"+(msBeautify.counter++);
122					var obj = {};
123					obj.id = id;
124					obj.name = _settings.byJson.name || element.id; //its name
125					if (_settings.byJson.size>0) {
126						obj.size = _settings.byJson.size;
127					};
128					obj.multiple = _settings.byJson.multiple;					
129					var oSelect = _createElement("select", obj);
130					for(var i=0;i<_settings.byJson.data.length;i++) {
131						var current = _settings.byJson.data[i];
132						var opt = new Option(current.text, current.value);
133						for(var p in current) { 
134							if (p.toLowerCase() != 'text') { 
135								var key = ($.inArray(p.toLowerCase(), validData)!=-1) ? "data-" : "";
136								opt.setAttribute(key+p, current[p]);
137							};
138						};
139						oSelect.options[i] = opt;
140					};
141					getElement(element.id).appendChild(oSelect);
142					oSelect.selectedIndex = _settings.byJson.selectedIndex;
143					$(oSelect).css({width: _settings.byJson.width+'px'});
144					//now change element for access other things
145					element = oSelect;
146				} catch(e) {
147					throw "There is an error in json data.";
148				};
149		};			
150	};
151	var _construct = function() {		
152		 //set properties
153		 _createByJson();
154		if (!element.id) {
155			element.id = "msdrpdd"+(msBeautify.counter++);
156		};						
157		_element = element.id;
158		_this._element = _element;
159		_checkDataSetting();		
160		_isDisabled = getElement(_element).disabled;
161		var useCheckbox = _settings.enableCheckbox;
162		if(Boolean(useCheckbox)===true) {
163			getElement(_element).multiple = true;
164			_settings.enableCheckbox = true;
165		};
166		_isList = (getElement(_element).size>1 || getElement(_element).multiple==true) ? true : false;
167		//trace("_isList "+_isList);
168		if (_isList) {_isMultiple = getElement(_element).multiple;};			
169		_mergeAllProp();		
170		//create layout
171		_createLayout();
172		//set ui prop
173		_updateProp("uiData", _getDataAndUI());
174		_updateProp("selectedOptions", $("#"+_element +" option:selected"));				
175	 };	
176	 /********************************************************************************************/	
177	var _getPostID = function (id) {
178		return _element+_holderId[id];
179	};
180	var _getInternalStyle = function(ele) {		 
181		 var s = (ele.style === undefined) ? "" : ele.style.cssText;
182		 return s;
183	};
184	var _parseOption = function(opt) {
185		var imagePath = '', title ='', description='', value=-1, text='', className='', imagecss = '';
186		if (opt !== undefined) {
187			var attrTitle = opt.title || "";
188			//data-title
189			if (attrTitle!="") {
190				var reg = /^\{.*\}$/;
191				var isJson = reg.test(attrTitle);
192				if (isJson && _settings.jsonTitle) {
193					var obj =  eval("["+attrTitle+"]");	
194				};				 
195				title = (isJson && _settings.jsonTitle) ? obj[0].title : title;
196				description = (isJson && _settings.jsonTitle) ? obj[0].description : description;
197				imagePath = (isJson && _settings.jsonTitle) ? obj[0].image : attrTitle;
198				imagecss = (isJson && _settings.jsonTitle) ? obj[0].imagecss : imagecss;
199			};
200
201			text = opt.text || '';
202			value = opt.value || '';
203			className = opt.className || "";
204			//ignore title attribute if playing with data tags			
205			title = $(opt).prop("data-title") || $(opt).data("title") || (title || "");
206			description = $(opt).prop("data-description") || $(opt).data("description") || (description || "");
207			imagePath = $(opt).prop("data-image") || $(opt).data("image") || (imagePath || "");
208			imagecss = $(opt).prop("data-imagecss") || $(opt).data("imagecss") || (imagecss || "");
209			
210		};
211		var o = {image: imagePath, title: title, description: description, value: value, text: text, className: className, imagecss:imagecss};
212		return o;
213	};	 
214	var _createElement = function(nm, attr, html) {
215		var tag = _doc.createElement(nm);
216		if (attr) {
217		 for(var i in attr) {
218			 switch(i) {
219				 case "style":
220					tag.style.cssText  = attr[i];
221				 break;
222				 default:
223					tag[i]  = attr[i];
224				 break;
225			 };	
226		 };
227		};
228		if (html) {
229		 tag.innerHTML = html;
230		};
231		return tag;
232	};
233	 /********************************************************************************************/
234	  /*********************** <layout> *************************************/
235	var _hideOriginal = function() {
236		var hidid = _getPostID("postElementHolder");
237		if ($("#"+hidid).length==0) {			 
238			//var obj = {style: 'height: 0px;overflow: hidden;position: absolute;',className: _styles.ddOutOfVision};	
239			var obj = {style: 'height: 0px;overflow: hidden;position: relative;',className: _styles.ddOutOfVision};	
240			obj.id = hidid;
241			var oDiv = _createElement("div", obj);	
242			$("#"+_element).after(oDiv);
243			$("#"+_element).appendTo($("#"+hidid));
244		} else {
245			//$("#"+hidid).css({height: 0,overflow: 'hidden',position: 'absolute'});
246			$("#"+hidid).css({height: 0,overflow: 'hidden',position: 'relative'});
247		};
248	};
249	var _createWrapper = function () {
250		var obj = {
251			className: _styles.dd + " ddcommon borderRadius"
252		};
253		var styles = _getInternalStyle(getElement(_element));
254		var w = $("#" + _element).outerWidth();
255		//obj.style = "width: " + w + "px;";
256		if (styles.length > 0) {
257			obj.style = obj.style + "" + styles;
258		};
259		obj.id = _getPostID("postID");
260		var oDiv = _createElement("div", obj);
261		return oDiv;
262	};
263	var _createTitle = function () {
264		var selectedOption;
265		if(getElement(_element).selectedIndex>=0) {
266			selectedOption = getElement(_element).options[getElement(_element).selectedIndex];
267		} else {
268			selectedOption = {value:'', text:''};
269		}
270		var spriteClass = "", selectedClass = "";
271		//check sprite
272		var useSprite = $("#"+_element).data("usesprite");
273		if(useSprite) { _settings.useSprite = useSprite; };
274		if (_settings.useSprite != false) {
275			spriteClass = " " + _settings.useSprite;
276			selectedClass = " " + selectedOption.className;
277		};
278		var oTitle = _createElement("div", {className: _styles.ddTitle + spriteClass + " " + _styles_i.borderRadiusTp});
279		//divider
280		var oDivider = _createElement("span", {className: _styles.divider});
281		//arrow
282		var oArrow = _createElement("span", {className: _styles.arrow});
283		//title Text
284		var titleid = _getPostID("postTitleID");
285		var oTitleText = _createElement("span", {className: _styles.ddTitleText + selectedClass, id: titleid});
286	
287		var parsed = _parseOption(selectedOption);
288		var arrowPath = parsed.image;
289		var sText = parsed.text || "";		
290		if (arrowPath != "" && _settings.showIcon) {
291			var oIcon = _createElement("img");
292			var oIconParent = _createElement("span", {className: "ddImage"});
293			oIcon.src = arrowPath;
294			if(parsed.imagecss!="") {
295				oIcon.className = parsed.imagecss+" ";
296			};
297		};
298		var oTitleText_in = _createElement("span", {className: _styles.label}, sText);
299		oTitle.appendChild(oDivider);
300		oTitle.appendChild(oArrow);
301		if (oIcon) {
302			oIconParent.appendChild(oIcon);
303			oTitleText.appendChild(oIconParent);
304		};
305		oTitleText.appendChild(oTitleText_in);
306		oTitle.appendChild(oTitleText);
307		var oDescription = _createElement("span", {className: _styles.description}, parsed.description);
308
309		oTitleText_in.appendChild(oDescription);
310
311		return oTitle;
312	};
313	var _createFilterBox = function () {
314		var tid = _getPostID("postTitleTextID");
315		var sText = _createElement("input", {id: tid, type: 'text', value: '', autocomplete: 'off', className: 'text shadow borderRadius', style: 'display: none'});
316		return sText;
317	};
318	var _createChild = function (opt) {
319		var obj = {};
320		var styles = _getInternalStyle(opt);
321		if (styles.length > 0) {obj.style = styles; };
322		var css = (opt.disabled) ? _styles.disabled : _styles.enabled;
323		css = (opt.selected) ? (css + " " + _styles.selected) : css;
324		css = css + " " + _styles_i.li;
325		obj.className = css;
326		if (_settings.useSprite != false) {
327			obj.className = css + " " + opt.className;
328		};
329		var li = _createElement("li", obj);
330		var parsed = _parseOption(opt);
331		if (parsed.title != "") {
332			li.title = parsed.title;
333		};
334		var arrowPath = parsed.image;
335		if (arrowPath != "" && _settings.showIcon) {
336			var oIcon = _createElement("img");
337			oIcon.src = arrowPath;
338			var oIconParent = _createElement("span", {className: "ddImage"});
339			if(parsed.imagecss!="") {
340				oIcon.className = parsed.imagecss+" ";
341			};
342		};
343		if (parsed.description != "") {
344			var oDescription = _createElement("span", {
345				className: _styles.description
346			}, parsed.description);
347		};
348		var sText = opt.text || "";
349		var oTitleText = _createElement("span", {
350			className: _styles.label
351		}, sText);
352		//checkbox
353		if(_settings.enableCheckbox===true) {
354			var chkbox = _createElement("input", {
355			type: 'checkbox', name:_element+_settings.checkboxNameSuffix+'[]', value:opt.value||""}); //this can be used for future
356			li.appendChild(chkbox);
357			if(_settings.enableCheckbox===true) {
358				chkbox.checked = (opt.selected) ? true : false;
359			};
360		};
361		if (oIcon) {
362			oIconParent.appendChild(oIcon);
363			li.appendChild(oIconParent);
364		};
365		li.appendChild(oTitleText);
366		if (oDescription) {
367			oTitleText.appendChild(oDescription);
368		} else {
369			if (oIcon) {
370				oIcon.className = oIcon.className+_styles_i.fnone;
371			};
372		};
373		var oClear = _createElement("div", {className: 'clear'});
374		li.appendChild(oClear);
375		return li;
376	};
377	var _createChildren = function () {
378		var childid = _getPostID("postChildID");
379		var obj = {className: _styles.ddChild + " ddchild_ " + _styles_i.ddChildMore, id: childid};
380		if (_isList == false) {
381			obj.style = "z-index: " + _settings.zIndex;
382		} else {
383			obj.style = "z-index:1";
384		};
385		var childWidth = $("#"+_element).data("childwidth") || _settings.childWidth;
386		if(childWidth) {
387			obj.style =  (obj.style || "") + ";width:"+childWidth;
388		};		
389		var oDiv = _createElement("div", obj);
390		var ul = _createElement("ul");
391		if (_settings.useSprite != false) {
392			ul.className = _settings.useSprite;
393		};
394		var allOptions = getElement(_element).children;
395		for (var i = 0; i < allOptions.length; i++) {
396			var current = allOptions[i];
397			var li;
398			if (current.nodeName.toLowerCase() == "optgroup") {
399				//create ul
400				li = _createElement("li", {className: _styles.optgroup});
401				var span = _createElement("span", {className: _styles.optgroupTitle}, current.label);
402				li.appendChild(span);
403				var optChildren = current.children;
404				var optul = _createElement("ul");
405				for (var j = 0; j < optChildren.length; j++) {
406					var opt_li = _createChild(optChildren[j]);
407					optul.appendChild(opt_li);
408				};
409				li.appendChild(optul);
410			} else {
411				li = _createChild(current);
412			};
413			ul.appendChild(li);
414		};
415		oDiv.appendChild(ul);		
416		return oDiv;
417	};
418	var _childHeight = function (val) {
419		var childid = _getPostID("postChildID");
420		if (val) {
421			if (val == -1) { //auto
422				$("#"+childid).css({height: "auto", overflow: "auto"});
423			} else {				
424				$("#"+childid).css("height", val+"px");
425			};
426			return false;
427		};
428		//else return height
429		var iHeight;
430		if (getElement(_element).options.length > _settings.visibleRows) {
431			var margin = parseInt($("#" + childid + " li:first").css("padding-bottom")) + parseInt($("#" + childid + " li:first").css("padding-top"));
432			if(_settings.rowHeight===0) {
433				$("#" + childid).css({visibility:'hidden',display:'block'}); //hack for first child
434				_settings.rowHeight = Math.round($("#" + childid + " li:first").height());
435				$("#" + childid).css({visibility:'visible'});
436				if(!_isList || _settings.enableCheckbox===true) {
437					$("#" + childid).css({display:'none'});
438				};
439			};
440			iHeight = ((_settings.rowHeight + margin) * _settings.visibleRows);
441		} else if (_isList) {
442			iHeight = $("#" + _element).height(); //get height from original element
443		};		
444		return iHeight;
445	};
446	var _applyChildEvents = function () {
447		var childid = _getPostID("postChildID");
448		$("#" + childid).on("click", function (e) {
449			if (_isDisabled === true) return false;
450			//prevent body click
451			e.preventDefault();
452			e.stopPropagation();
453			if (_isList) {
454				_bind_on_events();
455			};
456		});
457		$("#" + childid + " li." + _styles.enabled).on("click", function (e) {
458			if(e.target.nodeName.toLowerCase() !== "input") {
459				_close(this);
460			};
461		});
462		$("#" + childid + " li." + _styles.enabled).on("mousedown", function (e) {
463			if (_isDisabled === true) return false;
464			_oldSelected = $("#" + childid + " li." + _styles.selected);
465			_lastTarget = this;
466			e.preventDefault();
467			e.stopPropagation();
468			//select current input
469			if(_settings.enableCheckbox===true) {
470				if(e.target.nodeName.toLowerCase() === "input") {
471					_controlHolded = true;
472				};	
473			};
474			if (_isList === true) {
475				if (_isMultiple) {					
476					if (_shiftHolded === true) {
477						$(this).addClass(_styles.selected);
478						var selected = $("#" + childid + " li." + _styles.selected);
479						var lastIndex = _getIndex(this);
480						if (selected.length > 1) {
481							var items = $("#" + childid + " li." + _styles_i.li);
482							var ind1 = _getIndex(selected[0]);
483							var ind2 = _getIndex(selected[1]);
484							if (lastIndex > ind2) {
485								ind1 = (lastIndex);
486								ind2 = ind2 + 1;
487							};
488							for (var i = Math.min(ind1, ind2); i <= Math.max(ind1, ind2); i++) {
489								var current = items[i];
490								if ($(current).hasClass(_styles.enabled)) {
491									$(current).addClass(_styles.selected);
492								};
493							};
494						};
495					} else if (_controlHolded === true) {
496						$(this).toggleClass(_styles.selected); //toggle
497						if(_settings.enableCheckbox===true) {
498							var checkbox = this.childNodes[0];
499							checkbox.checked = !checkbox.checked; //toggle
500						};
501					} else {
502						$("#" + childid + " li." + _styles.selected).removeClass(_styles.selected);
503						$("#" + childid + " input:checkbox").prop("checked", false);
504						$(this).addClass(_styles.selected);
505						if(_settings.enableCheckbox===true) {
506							this.childNodes[0].checked = true;
507						};
508					};					
509				} else {
510					$("#" + childid + " li." + _styles.selected).removeClass(_styles.selected);
511					$(this).addClass(_styles.selected);
512				};
513				//fire event on mouseup
514			} else {
515				$("#" + childid + " li." + _styles.selected).removeClass(_styles.selected);
516				$(this).addClass(_styles.selected);
517			};		
518		});
519		$("#" + childid + " li." + _styles.enabled).on("mouseenter", function (e) {
520			if (_isDisabled === true) return false;
521			e.preventDefault();
522			e.stopPropagation();
523			if (_lastTarget != null) {
524				if (_isMultiple) {
525					$(this).addClass(_styles.selected);
526					if(_settings.enableCheckbox===true) {
527						this.childNodes[0].checked = true;
528					};
529				};
530			};
531		});
532	
533		$("#" + childid + " li." + _styles.enabled).on("mouseover", function (e) {
534			if (_isDisabled === true) return false;
535			$(this).addClass(_styles.hover);
536		});
537		$("#" + childid + " li." + _styles.enabled).on("mouseout", function (e) {
538			if (_isDisabled === true) return false;
539			$("#" + childid + " li." + _styles.hover).removeClass(_styles.hover);
540		});
541	
542		$("#" + childid + " li." + _styles.enabled).on("mouseup", function (e) {
543			if (_isDisabled === true) return false;
544			e.preventDefault();
545			e.stopPropagation();
546			if(_settings.enableCheckbox===true) {
547				_controlHolded = false;
548			};
549			var selected = $("#" + childid + " li." + _styles.selected).length;			
550			_forcedTrigger = (_oldSelected.length != selected || selected == 0) ? true : false;	
551			_fireAfterItemClicked();
552			_unbind_on_events(); //remove old one
553			_bind_on_events();
554			_lastTarget = null;
555		});
556	
557		/* options events */
558		if (_settings.disabledOptionEvents == false) {
559			$("#" + childid + " li." + _styles_i.li).on("click", function (e) {
560				if (_isDisabled === true) return false;
561				fireOptionEventIfExist(this, "click");
562			});
563			$("#" + childid + " li." + _styles_i.li).on("mouseenter", function (e) {
564				if (_isDisabled === true) return false;
565				fireOptionEventIfExist(this, "mouseenter");
566			});
567			$("#" + child
567id + " li." + _styles_i.li).on("mouseover", function (e) {
568				if (_isDisabled === true) return false;
569				fireOptionEventIfExist(this, "mouseover");
570			});
571			$("#" + childid + " li." + _styles_i.li).on("mouseout", function (e) {
572				if (_isDisabled === true) return false;
573				fireOptionEventIfExist(this, "mouseout");
574			});
575			$("#" + childid + " li." + _styles_i.li).on("mousedown", function (e) {
576				if (_isDisabled === true) return false;
577				fireOptionEventIfExist(this, "mousedown");
578			});
579			$("#" + childid + " li." + _styles_i.li).on("mouseup", function (e) {
580				if (_isDisabled === true) return false;
581				fireOptionEventIfExist(this, "mouseup");
582			});
583		};
584	};
585	var _removeChildEvents = function () {
586		var childid = _getPostID("postChildID");
587		$("#" + childid).off("click");
588		$("#" + childid + " li." + _styles.enabled).off("mouseenter");
589		$("#" + childid + " li." + _styles.enabled).off("click");
590		$("#" + childid + " li." + _styles.enabled).off("mouseover");
591		$("#" + childid + " li." + _styles.enabled).off("mouseout");
592		$("#" + childid + " li." + _styles.enabled).off("mousedown");
593		$("#" + childid + " li." + _styles.enabled).off("mouseup");
594	};
595	var _applyEvents = function () {
596		var id = _getPostID("postID");
597		var childid = _getPostID("postChildID");		
598		$("#" + id).on(_settings.event, function (e) {			
599			if (_isDisabled === true) return false;
600			fireEventIfExist("click");
601			//prevent body click
602			e.preventDefault();
603			e.stopPropagation();
604			_open(e);
605		});
606		_applyChildEvents();		
607		$("#" + id).on("dblclick", on_dblclick);
608		$("#" + id).on("mousemove", on_mousemove);
609		$("#" + id).on("mouseenter", on_mouseover);
610		$("#" + id).on("mouseleave", on_mouseout);
611		$("#" + id).on("mousedown", on_mousedown);
612		$("#" + id).on("mouseup", on_mouseup);
613	};
614	//after create
615	var _fixedForList = function () {
616		var id = _getPostID("postID");
617		var childid = _getPostID("postChildID");		
618		if (_isList === true && _settings.enableCheckbox===false) {
619			$("#" + id + " ." + _styles.ddTitle).hide();
620			$("#" + childid).css({display: 'block', position: 'relative'});	
621			//_open();
622		} else {
623			if(_settings.enableCheckbox===false) {
624				_isMultiple = false; //set multiple off if this is not a list
625			};
626			$("#" + id + " ." + _styles.ddTitle).show();
627			//$("#" + childid).css({display: 'none', position: 'absolute'});
628			$("#" + childid).css({display: 'none', position: 'relative'});
629			//set value
630			var first = $("#" + childid + " li." + _styles.selected)[0];
631			$("#" + childid + " li." + _styles.selected).removeClass(_styles.selected);
632			var index = _getIndex($(first).addClass(_styles.selected));
633			_setValue(index);
634		};
635		_childHeight(_childHeight()); //get and set height 
636	};
637	var _fixedForDisabled = function () {
638		var id = _getPostID("postID");
639		var opc = (_isDisabled == true) ? _settings.disabledOpacity : 1;
640		if (_isDisabled === true) {
641			$("#" + id).addClass(_styles.disabledAll);
642		} else {
643			$("#" + id).removeClass(_styles.disabledAll);
644		};
645	};
646	var _fixedSomeUI = function () {
647		//auto filter
648		var tid = _getPostID("postTitleTextID");
649		$("#" + tid).on("keyup", _applyFilters);
650		//if is list
651		_fixedForList();
652		_fixedForDisabled();
653	};
654	var _createLayout = function () {		
655		var oDiv = _createWrapper();
656		var oTitle = _createTitle();
657		oDiv.appendChild(oTitle);
658		//auto filter box
659		var oFilterBox = _createFilterBox();
660		oDiv.appendChild(oFilterBox);
661	
662		var oChildren = _createChildren();
663		oDiv.appendChild(oChildren);
664		$("#" + _element).after(oDiv);
665		_hideOriginal(); //hideOriginal
666		_fixedSomeUI();
667		_applyEvents();
668		
669		var childid = _getPostID("postChildID");
670		//append
671		if(_settings.append!='') {
672			$("#" + childid).append(_settings.append);
673		};
674		//prepend
675		if(_settings.prepend!='') {
676			$("#" + childid).prepend(_settings.prepend);
677		};		
678		if (typeof _settings.on.create == "function") {
679			_settings.on.create.apply(_this, arguments);
680		};
681	};
682	var _selectMutipleOptions = function (bySelected) {
683		var childid = _getPostID("postChildID");
684		var selected = bySelected || $("#" + childid + " li." + _styles.selected); //bySelected or by argument
685		for (var i = 0; i < selected.length; i++) {
686			var ind = _getIndex(selected[i]);
687			getElement(_element).options[ind].selected = "selected";
688		};
689		_setValue(selected);
690	};
691	var _fireAfterItemClicked = function () {
692		//console.log("_fireAfterItemClicked")
693		var childid = _getPostID("postChildID");
694		var selected = $("#" + childid + " li." + _styles.selected);		
695		if (_isMultiple && (_shiftHolded || _controlHolded) || _forcedTrigger) {
696			getElement(_element).selectedIndex = -1; //reset old
697		};
698		var index;
699		if (selected.length == 0) {
700			index = -1;
701		} else if (selected.length > 1) {
702			//selected multiple
703			_selectMutipleOptions(selected);
704			//index = $("#" + childid + " li." + _styles.selected);
705			
706		} else {
707			//if one selected
708			index = _getIndex($("#" + childid + " li." + _styles.selected));
709		};		
710		if ((getElement(_element).selectedIndex != index || _forcedTrigger) && selected.length<=1) {			
711			_forcedTrigger = false;			
712			var evt = has_handler("change");
713			getElement(_element).selectedIndex = index;	
714			_setValue(index);
715			//local
716			if (typeof _settings.on.change == "function") {
717				var d = _getDataAndUI();
718				_settings.on.change(d.data, d.ui);
719			};			
720			$("#" + _element).trigger("change");			
721		};
722	};
723	var _setValue = function (index, byvalue) {
724		if (index !== undefined) {
725			var selectedIndex, value, selectedText;
726			if (index == -1) {
727				selectedIndex = -1;
728				value = "";
729				selectedText = "";
730				_updateTitleUI(-1);
731			} else {
732				//by index or byvalue
733				if (typeof index != "object") {
734					var opt = getElement(_element).options[index];
735					getElement(_element).selectedIndex = index;
736					selectedIndex = index;
737					value = _parseOption(opt);
738					selectedText = (index >= 0) ? getElement(_element).options[index].text : "";
739					_updateTitleUI(undefined, value);
740					value = value.value; //for bottom
741				} else {
742					//this is multiple or by option					
743					selectedIndex = (byvalue && byvalue.index) || getElement(_element).selectedIndex;
744					value = (byvalue && byvalue.value) || getElement(_element).value;
745					selectedText = (byvalue && byvalue.text) || getElement(_element).options[getElement(_element).selectedIndex].text || "";
746					_updateTitleUI(selectedIndex);
747				};
748			};
749			_updateProp("selectedIndex", selectedIndex);
750			_updateProp("value", value);
751			_updateProp("selectedText", selectedText);
752			_updateProp("children", getElement(_element).children);
753			_updateProp("uiData", _getDataAndUI());
754			_updateProp("selectedOptions", $("#" + _element + " option:selected"));
755		};
756	};
757	var has_handler = function (name) {
758		//True if a handler has been added in the html.
759		var evt = {byElement: false, byJQuery: false, hasEvent: false};
760		var obj = $("#" + _element);
761		//console.log(name)
762		try {
763			//console.log(obj.prop("on" + name) + " "+name);
764			if (obj.prop("on" + name) !== null) {
765				evt.hasEvent = true;
766				evt.byElement = true;
767			};
768		} catch(e) {
769			//console.log(e.message);
770		}
771		// True if a handler has been added using jQuery.
772		var evs;
773		if (typeof $._data == "function") { //1.8
774			evs = $._data(obj[0], "events");
775		} else {
776			evs = obj.data("events");
777		};
778		if (evs && evs[name]) {
779			evt.hasEvent = true;
780			evt.byJQuery = true;
781		};
782		return evt;
783	};
784	var _bind_on_events = function () {
785		_unbind_on_events();
786		$("body").on("click", _close);
787		//bind more events		 
788		$(document).on("keydown", on_keydown);
789		$(document).on("keyup", on_keyup);
790		//focus will work on this	 		 
791	};
792	var _unbind_on_events = function () {
793		$("body").off("click", _close);
794		//bind more events
795		$(document).off("keydown", on_keydown);
796		$(document).off("keyup", on_keyup);
797	};
798	var _applyFilters = function () {
799		var childid = _getPostID("postChildID");
800		var tid = _getPostID("postTitleTextID");
801		var sText = getElement(tid).value;
802		if (sText.length == 0) {
803			$("#" + childid + " li:hidden").show(); //show if hidden
804			_childHeight(_childHeight());
805		} else {
806			$("#" + childid + " li").hide();
807			$("#" + childid + " li:Contains('" + sText + "')").show();	
808			if ($("#" + childid + " li:visible").length <= _settings.visibleRows) {
809				_childHeight(-1); //set autoheight
810			};
811		};		
812	};
813	var _showFilterBox = function () {
814		var tid = _getPostID("postTitleTextID");
815		if ($("#" + tid + ":hidden").length > 0 && _controlHolded == false) {
816			$("#" + tid + ":hidden").show().val("");
817			getElement(tid).focus();
818		};
819	};
820	var _hideFilterBox = function () {
821		var tid = _getPostID("postTitleTextID");
822		if ($("#" + tid + ":visible").length > 0) {
823			$("#" + tid + ":visible").hide();
824			getElement(tid).blur();
825		};
826	};
827	var on_keydown = function (evt) {
828		var tid = _getPostID("postTitleTextID");
829		switch (evt.keyCode) {
830			case DOWN_ARROW:
831			case RIGHT_ARROW:
832				evt.preventDefault();
833				evt.stopPropagation();
834				//_hideFilterBox();
835				_next();				
836				break;
837			case UP_ARROW:
838			case LEFT_ARROW:
839				evt.preventDefault();
840				evt.stopPropagation();
841				//_hideFilterBox();
842				_previous();
843				break;
844			case ESCAPE:
845			case ENTER:
846				evt.preventDefault();
847				evt.stopPropagation();
848				_close();				
849				break;
850			case SHIFT:
851				_shiftHolded = true;
852				break;
853			case CONTROL:
854				_controlHolded = true;
855				break;
856			default:
857				if (evt.keyCode >= ALPHABETS_START && _isList === false) {
858					//_showFilterBox();
859				};
860				break;
861		};
862		if (_isDisabled === true) return false;
863		fireEventIfExist("keydown");
864	};
865	var on_keyup = function (evt) {
866		switch (evt.keyCode) {
867			case SHIFT:
868				_shiftHolded = false;
869				break;
870			case CONTROL:
871				_controlHolded = false;
872				break;
873		};
874		if (_isDisabled === true) return false;
875		fireEventIfExist("keyup");
876	};
877	var on_dblclick = function (evt) {
878		if (_isDisabled === true) return false;
879		fireEventIfExist("dblclick");
880	};
881	var on_mousemove = function (evt) {
882		if (_isDisabled === true) return false;
883		fireEventIfExist("mousemove");
884	};
885	
886	var on_mouseover = function (evt) {
887		if (_isDisabled === true) return false;
888		evt.preventDefault();
889		fireEventIfExist("mouseover");
890	};
891	var on_mouseout = function (evt) {
892		if (_isDisabled === true) return false;
893		evt.preventDefault();
894		fireEventIfExist("mouseout");
895	};
896	var on_mousedown = function (evt) {
897		if (_isDisabled === true) return false;
898		fireEventIfExist("mousedown");
899	};
900	var on_mouseup = function (evt) {
901		if (_isDisabled === true) return false;
902		fireEventIfExist("mouseup");
903	};
904	var option_has_handler = function (opt, name) {
905		//True if a handler has been added in the html.
906		var evt = {byElement: false, byJQuery: false, hasEvent: false};
907		if ($(opt).prop("on" + name) != undefined) {
908			evt.hasEvent = true;
909			evt.byElement = true;
910		};
911		// True if a handler has been added using jQuery.
912		var evs = $(opt).data("events");
913		if (evs && evs[name]) {
914			evt.hasEvent = true;
915			evt.byJQuery = true;
916		};
917		return evt;
918	};
919	var fireOptionEventIfExist = function (li, evt_n) {
920		if (_settings.disabledOptionEvents == false) {
921			var opt = getElement(_element).options[_getIndex(li)];
922			//check if original has some
923			if (option_has_handler(opt, evt_n).hasEvent === true) {
924				if (option_has_handler(opt, evt_n).byElement === true) {
925					opt["on" + evt_n]();
926				};
927				if (option_has_handler(opt, evt_n).byJQuery === true) {
928					switch (evt_n) {
929						case "keydown":
930						case "keyup":
931							//key down/up will check later
932							break;
933						default:
934							$(opt).trigger(evt_n);
935							break;
936					};
937				};
938				return false;
939			};
940		};
941	};
942	var fireEventIfExist = function (evt_n) {
943		//local
944		if (typeof _settings.on[evt_n] == "function") {
945			_settings.on[evt_n].apply(this, arguments);
946		};
947		//check if original has some
948		if (has_handler(evt_n).hasEvent === true) {
949			if (has_handler(evt_n).byElement === true) {
950				getElement(_element)["on" + evt_n]();
951			};
952			if (has_handler(evt_n).byJQuery === true) {
953				switch (evt_n) {
954					case "keydown":
955					case "keyup":
956						//key down/up will check later
957						break;
958					default:
959						$("#" + _element).trigger(evt_n);
960						break;
961				};
962			};
963			return false;
964		};
965	};
966	/******************************* navigation **********************************************/
967	var _scrollToIfNeeded = function (opt) {
968		var childid = _getPostID("postChildID");
969		//if scroll is needed
970		opt = (opt !== undefined) ? opt : $("#" + childid + " li." + _styles.selected);
971		if (opt.length > 0) {
972			var pos = parseInt(($(opt).position().top));
973			var ch = parseInt($("#" + childid).height());
974			if (pos > ch) {
975				var top = pos + $("#" + childid).scrollTop() - (ch/2);
976				$("#" + childid);
977			};
978		};
979	};
980	var _next = function () {
981		var childid = _getPostID("postChildID");
982		var items = $("#" + childid + " li:visible." + _styles_i.li);
983		var selected = $("#" + childid + " li:visible." + _styles.selected);
984		selected = (selected.length==0) ? items[0] : selected;
985		var index = $("#" + childid + " li:visible." + _styles_i.li).index(selected);
986		if ((index < items.length - 1)) {
987			index = getNext(index);
988			if (index < items.length) { //check again - hack for last disabled 
989				if (!_shiftHolded || !_isList || !_isMultiple) {
990					$("#" + childid + " ." + _styles.selected).removeClass(_styles.selected);
991				};
992				$(items[index]).addClass(_styles.selected);
993				_updateTitleUI(index);
994				if (_isList == true) {
995					_fireAfterItemClicked();
996				};
997				_scrollToIfNeeded($(items[index]));
998			};
999			if (!_isList) {
1000				_adjustOpen();
1001			};
1002		};	
1003		function getNext(ind) {
1004			ind = ind + 1;
1005			if (ind > items.length) {
1006				return ind;
1007			};
1008			if ($(items[ind]).hasClass(_styles.enabled) === true) {
1009				return ind;
1010			};
1011			return ind = getNext(ind);
1012		};
1013	};
1014	var _previous = function () {
1015		var childid = _getPostID("postChildID");
1016		var selected = $("#" + childid + " li:visible." + _styles.selected);
1017		var items = $("#" + childid + " li:visible." + _styles_i.li);
1018		var index = $("#" + childid + " li:visible." + _styles_i.li).index(selected[0]);
1019		if (index >= 0) {
1020			index = getPrev(index);
1021			if (index >= 0) { //check again - hack for disabled 
1022				if (!_shiftHolded || !_isList || !_isMultiple) {
1023					$("#" + childid + " ." + _styles.selected).removeClass(_styles.selected);
1024				};
1025				$(items[index]).addClass(_styles.selected);
1026				_updateTitleUI(index);
1027				if (_isList == true) {
1028					_fireAfterItemClicked();
1029				};
1030				if (parseInt(($(items[index]).position().top + $(items[index]).height())) <= 0) {
1031					var top = ($("#" + childid).scrollTop() - $("#" + childid).height()) - $(items[index]).height();
1032					$("#" + childid);
1033				};
1034			};
1035			if (!_isList) {
1036				_adjustOpen();
1037			};
1038		};
1039	
1040		function getPrev(ind) {
1041			ind = ind - 1;
1042			if (ind < 0) {
1043				return ind;
1044			};
1045			if ($(items[ind]).hasClass(_styles.enabled) === true) {
1046				return ind;
1047			};
1048			return ind = getPrev(ind);
1049		};
1050	};
1051	var _adjustOpen = function () {
1052		var id = _getPostID("postID");
1053		var childid = _getPostID("postChildID");
1054		var pos = $("#" + id).offset();
1055		var mH = $("#" + id).height();
1056		var wH = $(window).height();
1057		var st = $(window).scrollTop();
1058		var cH = $("#" + childid).height();
1059		var top = $("#" + id).height(); //this close so its title height
1060		
1061		var contBottom = $("#" + id).closest('.btQuoteBooking').offset().top + $("#" + id).closest('.btQuoteBooking').height();
1062	
1063		if (contBottom < Math.floor(cH + mH + pos.top) || _settings.openDirection.toLowerCase() == 'alwaysup') {
1064			top = cH;
1065			$("#" + childid).css({top: "-" + top + "px", display: 'block', zIndex: _settings.zIndex});
1066			$("#" + id).removeClass("borderRadius borderRadiusTp").addClass("borderRadiusBtm");
1067			var top = $("#" + childid).offset().top;
1068			if (top < -10) {
1069				$("#" + childid).css({top: (parseInt($("#" + childid).css("top")) - top + 20 + st) + "px", zIndex: _settings.zIndex});
1070				$("#" + id).removeClass("borderRadiusBtm borderRadiusTp").addClass("borderRadius");
1071			};
1072		} else {
1073			$("#" + childid).css({top: top + "px", zIndex: _settings.zIndex});
1074			$("#" + id).removeClass("borderRadius borderRadiusBtm").addClass("borderRadiusTp");
1075		};
1076		//hack for ie zindex
1077		//i hate ie :D
1078		/*if($.browser.msie) {
1079			if(parseInt($.browser.version)<=7) {
1080				$('div.ddcommon').css("zIndex", _settings.zIndex-10);
1081				$("#" + id).css("zIndex", _settings.zIndex+5);
1082			};
1083		};*/	
1084	};
1085	var _open = function (e) {
1086		if (_isDisabled === true) return false;
1087		var id = _getPostID("postID");
1088		var childid = _getPostID("postChildID");
1089		if (!_isOpen) {
1090			_isOpen = true;
1091			if (msBeautify.oldDiv != '') {
1092				$("#" + msBeautify.oldDiv).css({display: "none"}); //hide all 
1093			};
1094			msBeautify.oldDiv = childid;
1095			$("#" + childid + " li:hidden").show(); //show if hidden
1096			_adjustOpen();
1097			var animStyle = _settings.animStyle;
1098			if(animStyle=="" || animStyle=="none") {
1099				$("#" + childid).css({display:"block"});
1100				_scrollToIfNeeded();
1101				if (typeof _settings.on.open == "function") {
1102					var d = _getDataAndUI();
1103					_settings.on.open(d.data, d.ui);
1104				};
1105			} else {				
1106				$("#" + childid)[animStyle]("fast", function () {
1107					_scrollToIfNeeded();
1108					if (typeof _settings.on.open == "function") {
1109						var d = _getDataAndUI();
1110						_settings.on.open(d.data, d.ui);
1111					};
1112				});
1113			};
1114			_bind_on_events();
1115		} else {
1116			if(_settings.event!=='mouseover') {
1117				_close();
1118			};
1119		};
1120	};
1121	var _close = function (e) {
1122		_isOpen = false;
1123		var id = _getPostID("postID");
1124		var childid = _getPostID("postChildID");
1125		if (_isList === false || _settings.enableCheckbox===true) {
1126			$("#" + childid).css({display: "none"});
1127			$("#" + id).removeClass("borderRadiusTp borderRadiusBtm").addClass("borderRadius");			
1128		};
1129		_unbind_on_events();
1130		if (typeof _settings.on.close == "function") {
1131			var d = _getDataAndUI();
1132			_settings.on.close(d.data, d.ui);
1133		};
1134		//rest some old stuff
1135		_hideFilterBox();
1136		_childHeight(_childHeight()); //its needed after filter applied
1137		$("#" + childid).css({zIndex:1})		
1138	};
1139	/*********************** </layout> *************************************/	
1140	var _mergeAllProp = function () {
1141		_orginial = $.extend(true, {}, getElement(_element));
1142		for (var i in _orginial) {
1143			if (typeof _orginial[i] != "function") {
1144				_this[i] = _orginial[i]; //properties
1145			};
1146		};
1147		_this.selectedText = (_orginial.selectedIndex >= 0) ? _orginial.options[_orginial.selectedIndex].text : "";
1148		_this.version = msBeautify.version.msDropdown;
1149		_this.author = msBeautify.author;
1150	};
1151	var _getDataAndUIByOption = function (opt) {
1152		if (opt != null && typeof opt != "undefined") {
1153			var childid = _getPostID("postChildID");
1154			var data = _parseOption(opt);
1155			var ui = $("#" + childid + " li." + _styles_i.li + ":eq(" + (opt.index) + ")");
1156			return {data: data, ui: ui, option: opt, index: opt.index};
1157		};
1158		return null;
1159	};
1160	var _getDataAndUI = function () {
1161		var childid = _getPostID("postChildID");
1162		var ele = getElement(_element);
1163		var data, ui, option, index;
1164		if (ele.selectedIndex == -1) {
1165			data = null;
1166			ui = null;
1167			option = null;
1168			index = -1;
1169		} else {
1170			ui = $("#" + childid + " li." + _styles.selected);
1171			if (ui.length > 1) {
1172				var d = [], op = [], ind = [];
1173				for (var i = 0; i < ui.length; i++) {
1174					var pd = _getIndex(ui[i]);
1175					d.push(pd);
1176					op.push(ele.options[pd]);
1177				};
1178				data = d;
1179				option = op;
1180				index = d;
1181			} else {
1182				option = ele.options[ele.selectedIndex];
1183				data = _parseOption(option);
1184				index = ele.selectedIndex;
1185			};
1186		};
1187		return {data: data, ui: ui, index: index, option: option};
1188	};
1189	var _updateTitleUI = function (index, byvalue) {
1190		var titleid = _getPostID("postTitleID");
1191		var value = {};
1192		if (index == -1) {
1193			value.text = "&nbsp;";
1194			value.className = "";
1195			value.description = "";
1196			value.image = "";
1197		} else if (typeof index != "undefined") {
1198			var opt = getElement(_element).options[index];
1199			value = _parseOption(opt);
1200		} else {
1201			value = byvalue;
1202		};
1203
1204		//update title and current
1205		$("#" + titleid).find("." + _styles.label).html(value.text);
1206		var textnode = document.createTextNode( value.description );
1207		var desc = _createElement("span", {className: _styles.description});
1208		desc.appendChild( textnode );
1209		$("#" + titleid).find("." + _styles.description).remove();
1210		$("#" + titleid).find("." + _styles.label).append( desc );
1211		getElement(titleid).className = _styles.ddTitleText + " " + value.className;
1212		
1213		$("#" + titleid).removeClass( 'btNotSelected' );
1214		$("#" + titleid).closest( '.btContactField' ).removeClass( 'btNotSelected' );
1215		if ( value.value == '' ) {
1216			$("#" + titleid).addClass( 'btNotSelected' );
1217			$("#" + titleid).closest( '.btContactField' ).addClass( 'btNotSelected' );
1218		}
1219		
1220		//update desction		 
1221		if (value.description != "") {
1222			$("#" + titleid).find("." + _styles.description).html(value.description).show();
1223		} else {
1224			$("#" + titleid).find("." + _styles.description).html("").hide();
1225		};
1226		//update icon
1227		var img = $("#" + titleid).find("img");
1228		if (img.length > 0) {
1229			$(img).parent().remove();
1230		};
1231		if (value.image != "" && _settings.showIcon) {
1232			img = _createElement("img", {src: value.image});
1233			var imgParent = _createElement("span", {className: "ddImage"});
1234			imgParent.appendChild(img);
1235			$("#" + titleid).prepend(imgParent);
1236			if(value.imagecss!="") {
1237				img.className = value.imagecss+" ";
1238			};
1239			if (value.description == "") {
1240				img.className = img.className+_styles_i.fnone;
1241			};
1242		};
1243	};
1244	var _updateProp = function (p, v) {
1245		_this[p] = v;
1246	};
1247	var _updateUI = function (a, opt, i) { //action, index, opt
1248		var childid = _getPostID("postChildID");
1249		var wasSelected = false;
1250		switch (a) {
1251			case "add":
1252				var li = _createChild(opt || getElement(_element).options[i]);				
1253				var index;
1254				if (arguments.length == 3) {
1255					index = i;
1256				} else {
1257					index = $("#" + childid + " li." + _styles_i.li).length - 1;
1258				};				
1259				if (index < 0 || !index) {
1260					$("#" + childid + " ul").append(li);
1261				} else {
1262					var at = $("#" + childid + " li." + _styles_i.li)[index];
1263					$(at).before(li);
1264				};
1265				_removeChildEvents();
1266				_applyChildEvents();
1267				if (_settings.on.add != null) {
1268					_settings.on.add.apply(this, arguments);
1269				};
1270				break;
1271			case "remove":
1272				wasSelected = $($("#" + childid + " li." + _styles_i.li)[i]).hasClass(_styles.selected);
1273				$("#" + childid + " li." + _styles_i.li + ":eq(" + i + ")").remove();
1274				var items = $("#" + childid + " li." + _styles.enabled);
1275				if (wasSelected == true) {
1276					if (items.length > 0) {
1277						$(items[0]).addClass(_styles.selected);
1278						var ind = $("#" + childid + " li." + _styles_i.li).index(items[0]);
1279						_setValue(ind);
1280					};
1281				};
1282				if (items.length == 0) {
1283					_setValue(-1);
1284				};
1285				if ($("#" + childid + " li." + _styles_i.li).length < _settings.visibleRows && !_isList) {
1286					_childHeight(-1); //set autoheight
1287				};
1288				if (_settings.on.remove != null) {
1289					_settings.on.remove.apply(this, arguments);
1290				};
1291				break;
1292		};	
1293	};
1294	/************************** public methods/events **********************/
1295	this.act = function () {
1296		var action = arguments[0];
1297		Array.prototype.shift.call(arguments);
1298		switch (action) {
1299			case "add":
1300				_this.add.apply(this, arguments);
1301				break;
1302			case "remove":
1303				_this.remove.apply(this, arguments);
1304				break;
1305			default:
1306				try {
1307					getElement(_element)[action].apply(getElement(_element), arguments);
1308				} catch (e) {
1309					//there is some error.
1310				};
1311				break;
1312		};
1313	};
1314	
1315	this.add = function () {
1316		var text, value, title, image, description;
1317		var obj = arguments[0];		
1318		if (typeof obj == "string") {
1319			text = obj;
1320			value = text;
1321			opt = new Option(text, value);
1322		} else {
1323			text = obj.text || '';
1324			value = obj.value || text;
1325			title = obj.title || '';
1326			image = obj.image || '';
1327			description = obj.description || '';
1328			//image:imagePath, title:title, description:description, value:opt.value, text:opt.text, className:opt.className||""
1329			opt = new Option(text, value);
1330			$(opt).data("description", description);
1331			$(opt).data("image", image);
1332			$(opt).data("title", title);
1333		};
1334		arguments[0] = opt; //this option
1335		getElement(_element).add.apply(getElement(_element), arguments);
1336		_updateProp("children", getElement(_element)["children"]);
1337		_updateProp("length", getElement(_element).length);
1338		_updateUI("add", opt, arguments[1]);
1339	};
1340	this.remove = function (i) {
1341		getElement(_element).remove(i);
1342		_updateProp("children", getElement(_element)["children"]);
1343		_updateProp("length", getElement(_element).length);
1344		_updateUI("remove", undefined, i);
1345	};
1346	this.set = function (prop, val) {
1347		if (typeof prop == "undefined" || typeof val == "undefined") return false;
1348		prop = prop.toString();
1349		try {
1350			_updateProp(prop, val);
1351		} catch (e) {/*this is ready only */};
1352		
1353		switch (prop) {
1354			case "size":
1355				getElement(_element)[prop] = val;
1356				if (val == 0) {
1357					getElement(_element).multiple = false; //if size is zero multiple should be false
1358				};
1359				_isList = (getElement(_element).size > 1 || getElement(_element).multiple == true) ? true : false;
1360				_fixedForList();
1361				break;
1362			case "multiple":
1363				getElement(_element)[prop] = val;
1364				_isList = (getElement(_element).size > 1 || getElement(_element).multiple == true) ? true : false;
1365				_isMultiple = getElement(_element).multiple;
1366				_fixedForList();
1367				_updateProp(prop, val);
1368				break;
1369			case "disabled":
1370				getElement(_element)[prop] = val;
1371				_isDisabled = val;
1372				_fixedForDisabled();
1373				break;
1374			case "selectedIndex":
1375			case "value":
1376				getElement(_element)[prop] = val;
1377				var childid = _getPostID("postChildID");
1378				$("#" + childid + " li." + _styles_i.li).removeClass(_styles.selected);
1379				$($("#" + childid + " li." + _styles_i.li)[getElement(_element).selectedIndex]).addClass(_styles.selected);
1380				_setValue(getElement(_element).selectedIndex);
1381				break;
1382			case "length":
1383				var childid = _getPostID("postChildID");
1384				if (val < getElement(_element).length) {
1385					getElement(_element)[prop] = val;
1386					if (val == 0) {
1387						$("#" + childid + " li." + _styles_i.li).remove();
1388						_setValue(-1);
1389					} else {
1390						$("#" + childid + " li." + _styles_i.li + ":gt(" + (val - 1) + ")").remove();
1391						if ($("#" + childid + " li." + _styles.selected).length == 0) {
1392							$("#" + childid + " li." + _styles.enabled + ":eq(0)").addClass(_styles.selected);
1393						};
1394					};
1395					_updateProp(prop, val);
1396					_updateProp("children", getElement(_element)["children"]);
1397				};
1398				break;
1399			case "id":
1400				//please i need this. so preventing to change it. will work on this later
1401				break;
1402			default:
1403				//check if this is not a readonly properties
1404				try {
1405					getElement(_element)[prop] = val;
1406					_updateProp(prop, val);
1407				} catch (e) {
1408					//silent
1409				};
1410				break;
1411		}
1412	};
1413	this.get = function (prop) {
1414		return _this[prop] || getElement(_element)[prop]; //return if local else from original
1415	};
1416	this.visible = function (val) {
1417		var id = _getPostID("postID");		
1418		if (val === true) {
1419			$("#" + id).show();
1420		} else if (val === false) {
1421			$("#" + id).hide();
1422		} else {
1423			return ($("#" + id).css("display")=="none") ? false : true;
1424		};
1425	};
1426	this.debug = function (v) {
1427		msBeautify.debug(v);
1428	};
1429	this.close = function () {
1430		_close();
1431	};
1432	this.open = function () {		
1433		_open();
1434	};
1435	this.showRows = function (r) {
1436		if (typeof r == "undefined" || r == 0) {
1437			return false;
1438		};
1439		_settings.visibleRows = r;
1440		_childHeight(_childHeight());
1441	};
1442	this.visibleRows = this.showRows;
1443	this.on = function (type, fn) {
1444		$("#" + _element).on(type, fn);
1445	};
1446	this.off = function (type, fn) {
1447		$("#" + _element).off(type, fn);
1448	};
1449	this.addMyEvent = this.on;
1450	this.getData = function () {
1451		return _getDataAndUI()
1452	};
1453	this.namedItem = function () {
1454		var opt = getElement(_element).namedItem.apply(getElement(_element), arguments);
1455		return _getDataAndUIByOption(opt);
1456	};
1457	this.item = function () {
1458		var opt = getElement(_element).item.apply(getElement(_element), arguments);
1459		return _getDataAndUIByOption(opt);
1460	};	
1461	//v 3.2
1462	this.setIndexByValue = function(val) {
1463		this.set("value", val);
1464	};
1465	this.destory = function () {
1466		var hidid = _getPostID("postElementHolder");
1467		var id = _getPostID("postID");
1468		$("#" + id + ", #" + id + " *").off();
1469		$("#" + id).remove();
1470		$("#" + _element).parent().replaceWith($("#" + _element));		
1471		$("#" + _element).data("dd", null);
1472	};
1473	//Create msDropDown		
1474	_construct();
1475};
1476//bind in jquery
1477$.fn.extend({
1478			msDropDown: function(settings)
1479			{
1480				return this.each(function()
1481				{
1482					if (!$(this).data('dd')){
1483						var mydropdown = new dd(this, settings);
1484						$(this).data('dd', mydropdown);
1485					};
1486				});
1487			}
1488});
1489$.fn.msDropdown = $.fn.msDropDown; //make a copy
1490})(jQuery);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.