/**
 * dxCombobox 1.2 (2008-04-22)
 *
 * Copyright (c) 2008 Dipesh Nyachhyon (http://dmashups.com)
 * Dual licensed under the MIT (MIT-LICENSE.txt)
 * and GPL (GPL-LICENSE.txt) licenses.
 *
 * Built upon jQuery 1.2.3 (http://jquery.com)
 * 
 * Syntax:
 * $(element).dxCombobox([options])
 * 
 * Parameters:
 * - plugin specific options
 * 
 * Options:
 * - int maxlength: maximum length to allow in editable text box, default is 35 characters
 */
(function($){$.fn.dxCombobox=function(options){var defaults={maxlength:35};var xClass='dxComboboxClass';var options=$.extend(defaults,options);var strSelId=$(this).attr('id');var strBoxId='txt_'+strSelId;var objSel=$(this);return $(this).bind('keydown',function(e){var intKey=$.dxCombobox.event(e);switch(intKey){case 8:case 9:case 13:case 16:case 17:case 18:case 27:case 33:case 34:case 35:case 36:case 37:case 38:case 39:case 40:case 45:case 46:break;default:objSel.children(':selected').removeAttr('selected');objSel.hide();if(document.getElementById(strBoxId)==null){var objBox=document.createElement('input');$(objBox).width(objSel.width()).attr('type','text').attr('id',strBoxId).attr('autocomplete','off').attr('maxlength',defaults.maxlength).addClass(objSel.attr('class'));objSel.after(objBox);objBox.focus();if($.browser.msie){if($.dxCombobox.ieVersion()<7){var range=document.selection.createRange();range.moveStart('character',1);$(objBox).val(String.fromCharCode(intKey));}}$(objBox).bind('keydown',function(elt){var txtKey=$.dxCombobox.event(elt);if(txtKey==13){$(objBox).trigger('blur');objSel.focus().focus().next().focus();}if(txtKey==27){$(objBox).val('').trigger('blur');objSel.focus().focus().next().focus();}});}$.dxCombobox.autoFill(strBoxId,objSel);break;}$('#'+strBoxId).bind('blur',function(){var bolCreateOption=true;objSel.children().each(function(){if(!$(this).hasClass(xClass)){if($(this).text().toLowerCase()==$('#'+strBoxId).val().toLowerCase()){$(this).attr('selected','selected');bolCreateOption=false;}}});if(!objSel.children().hasClass(xClass)&&bolCreateOption){objSel.prepend("<option class=\""+xClass+"\" selected></option>");}if(bolCreateOption){if($(this).val()!=''){objSel.children('option.'+xClass).text($(this).val()).val($(this).val()).attr('selected','selected');}else{objSel.children('option.'+xClass).remove();}}else{objSel.children('option.'+xClass).remove();}objSel.show();var objNode=document.getElementById(strBoxId);objNode.parentNode.removeChild(objNode);});});}})(jQuery);(
function($){$.dxCombobox={event:function(e){var intKey=0;if(!e)var e=window.event;if(e.keyCode)intKey=e.keyCode;else{if(e.which)intKey=e.which;}return intKey;},autoFill:function(strBoxId,objSel){var objTextBox=$('#'+strBoxId);objTextBox.bind('keyup',function(e){var strKeyword=objTextBox.val().toLowerCase();var intKey=$.dxCombobox.event(e);switch(intKey){case 8:case 9:case 33:case 34:case 35:case 36:case 37:case 38:case 39:case 40:case 45:case 46:case 27:case 13:break;default:objSel.children().each(function(){var strOption=$(this).text();var intPos=strOption.toLowerCase().indexOf(strKeyword);if(intPos==0){var intStart=strKeyword.length;var intEnd=strOption.length;objTextBox.val(strOption);if($.browser.msie){var range=document.getElementById(strBoxId).createTextRange();range.moveStart('character',intStart);range.select();}else{if(intStart==0)intStart=intStart+1;document.getElementById(strBoxId).setSelectionRange(intStart,intEnd);}return false;}});break;}});},ieVersion:function(){var objUa=navigator.userAgent;var intIEOffset=objUa.indexOf("MSIE ");if(intIEOffset==-1)return 0;else return parseFloat(objUa.substring(intIEOffset+5,objUa.indexOf(";",intIEOffset)));}}})(jQuery);
