var expandedComboboxHovered=false;function InitializeComboBox(target){$(target).find('div.gui-select-arrow').click(function(event){if(IsContentLayerOpen($(this))) {CloseContentLayer($(this),event);} else{OpenContentLayer($(this),event);$(this).closest('.gui-select').find('.gui-select-input').filter(function(){return $(this).css('display')!='none7';}).focus();} event.stopImmediatePropagation();return false;});$(target).find('a.gui-select-input').click(function(event){if(IsContentLayerOpen($(this))) {CloseContentLayer($(this),event);} else{OpenContentLayer($(this),event);$(this).closest('.gui-select').find('.gui-select-input').filter(function(){return $(this).css('display')!='none';}).focus();} event.stopImmediatePropagation();return false;});$(target).find('input.gui-select-input').keydown(function(event){var code;if(event.keyCode) code=event.keyCode;else code=event.charCode;if(code==9){CloseContentLayer(this,event);} if((code==38&&event.altKey)||(code==40&&event.altKey)){OpenContentLayer(this,event);return;} if(code==13||code==27){CloseContentLayer(this,event);} if(code==40){if(IsContentLayerOpen($(this))){var nextLink=$(this).closest('.gui-select').find('.gui-select_optionList a.selected-option').nextAll('a').eq(0);ChangeSelection(nextLink,false);} else{var nextLink=$(this).closest('.gui-select').find('.gui-select_optionList a.selected-option').nextAll('a').eq(0);ChangeSelection(nextLink);}} if(code==38){if(IsContentLayerOpen($(this))){var prevLink=$(this).closest('.gui-select').find('.gui-select_optionList a.selected-option').prevAll('a').eq(0);ChangeSelection(prevLink,false);} else{var prevLink=$(this).closest('.gui-select').find('.gui-select_optionList a.selected-option').prevAll('a').eq(0);ChangeSelection(prevLink);}}});$(target).find('input.gui-select-input').keyup(function(event){SetTooltip(this,$(this).val());$(this).closest('.gui-select').find('input.gui-select-input-value').val($(this).val());});$(target).focusout(function(event){DoFocusOutOperation(event,$(this));});$(target).find('input.gui-select-input').blur(function(event){$(this).closest('.gui-select').trigger('loseFocus');});$(target).find('a.gui-select-input').focus(function(event){$(this).css('outline','dotted 1px');});$(target).find('a.gui-select-input').keydown(function(event){var code;if(event.keyCode) code=event.keyCode;else code=event.charCode;if(code==9){CloseContentLayer(this,event);return;} if((code==38&&event.altKey)||(code==40&&event.altKey)){OpenContentLayer(this,event);return;} if(code==13||code==27){CloseContentLayer(this,event);return;} if(code==40){if(IsContentLayerOpen($(this))){var nextLink=$(this).closest('.gui-select').find('.gui-select_optionList a.selected-option').nextAll('a').eq(0);ChangeSelection(nextLink,false);} else{var nextLink=$(this).closest('.gui-select').find('.gui-select_optionList a.selected-option').nextAll('a').eq(0);ChangeSelection(nextLink);} return;} if(code==38){if(IsContentLayerOpen($(this))){var prevLink=$(this).closest('.gui-select').find('.gui-select_optionList a.selected-option').prevAll('a').eq(0);ChangeSelection(prevLink,false);} else{var prevLink=$(this).closest('.gui-select').find('.gui-select_optionList a.selected-option').prevAll('a').eq(0);ChangeSelection(prevLink);} return;} if(code>=48&&code<=90){var ch=String.fromCharCode(code);var match=$(this).closest('.gui-select').find('.gui-select_optionList a').filter(function(index){return $(this).text().toUpperCase().charAt(0)==ch;});if(match.size()>0){var matchIndex=$(this).closest('.gui-select').find('.gui-select_optionList a').index(match[0]);SetOptionListPosition($(this).closest('.gui-select'),matchIndex);} return;}});$(target).find('a.gui-select-input').blur(function(event){$(this).css('outline','none');});$(target).hover(function(event,element){if($(event.currentTarget).find('.gui-select-content-hidden').length==0) expandedComboboxHovered=true;},function(event,element){if($(event.currentTarget).find('.gui-select-content-hidden').length==0) expandedComboboxHovered=false;});$(target).find('.gui-select_optionList').children('a').mouseenter(function(event){$(this).css('background-color','#999999');});$(target).find('.gui-select_optionList').children('a').mouseleave(function(event){$(this).css('background-color','#FFFFFF');});$(target).find('.gui-select_optionList').children('a').bind('click',function(){ChangeSelection($(this));return false;});if($(target).find('a.selected-option').length>0){$(target).find('a.selected-option').each(function(){ChangeSelection($(this));});} $(target).filter('.gui-select').each(function(){if($(this).attr('inputName')){$(this).find('input.gui-select-input').attr('name',$(this).attr('inputName'));$(this).find('input.gui-select-input-value').attr('name',$(this).attr('inputName'));$(this).find('input.gui-select-input').attr('id',$(this).attr('inputName'));}});$(target).filter('.gui-select').each(function(){if($(this).attr('maxlength')){$(this).find('input.gui-select-input').attr('maxlength',$(this).attr('maxlength'));}});$(target).filter('.gui-select').each(function(){ResizeComboBox(this);$(this).resize(function(){ResizeComboBox($(this));});});} function DoFocusOutOperation(event,element){var relatedTarget;if(expandedComboboxHovered)return;if(IsContentLayerOpen($(element))){CloseContentLayer($(element),event);}} function ChangeSelection(link,closeContentLayer,suppressChangedEvent){$(link).closest('.gui-select').find('input.gui-select-input').val($(link).text());$(link).closest('.gui-select').find('a.gui-select-input').html($(link).html());$(link).closest('.gui-select').find('div.gui-select-input').html($(link).html());$(link).closest('.gui-select').find('input.gui-select-input-value').val($(link).next('.option-value').text());SetTooltip(link,$(link).text());if(closeContentLayer!=false){$(link).closest('.gui-select-content').removeClass('gui-select-content-hidden').addClass('gui-select-content-hidden');} var selectedItem=$(link).closest('.gui-select_optionList').find('a.selected-option');var selectedItemIndex=$(link).closest('.gui-select_optionList').find('a').index(selectedItem);var linkIndex=$(link).closest('.gui-select_optionList').find('a').index(link);if(selectedItemIndex!=linkIndex){$(link).closest('.gui-select_optionList').children('a').removeClass('selected-option');$(link).addClass('selected-option');if(suppressChangedEvent==undefined||!suppressChangedEvent) $(link).closest('.gui-select').trigger('selectionChanged');}} function SetTooltip(target,tooltipText){$(target).closest('.gui-select').find('a.gui-select-input').attr('title',tooltipText);$(target).closest('.gui-select').find('input.gui-select-input').attr('title',tooltipText);$(target).closest('.gui-select').find('div.gui-select-input').attr('title',tooltipText);} function ResizeComboBox(target,width){if($(target).hasClass('gui-select')){if(width==null){width=$(target).width();if(width==0){width=$(target).attr('comboboxWidth');}} if(width!=null){$(target).width(width);$(target).find('.gui-select-input').width(width-23);} $(target).find('.slider_wrapper').hide();$(target).find('.gui-select_optionList').css('margin-right','0px');$(target).find('.gui-select-content').css('height','');var maxOptionCount=$(target).attr('maxOptionCount');if(maxOptionCount){if($(target).find('.gui-select_optionList').children('a').size()>maxOptionCount){$(target).find('.gui-select_optionList').css('margin-right','17px');$(target).find('.slider_wrapper').show();$(target).find('.gui-select-content').css('height',(maxOptionCount*optionHeight));var contentHeight=(maxOptionCount*optionHeight)-4;$(target).find('.slider_wrapper').css('height',contentHeight);$(target).find('.slider').css('height',contentHeight-2*(sliderArrowHeight+sliderArrowMargin));$(target).find('.arrow-down').css('top',contentHeight-sliderArrowHeight);AttachSliderEvents($(target));}}}} var sliderArrowHeight=14;var sliderArrowMargin=2;var optionHeight=16;function AttachSliderEvents(target){var $this=$(target).find('.slider_wrapper');var $pane=$(target).find('.gui-select_optionList');var $drag=$(target).find('.handle');var $container=$(target).find('.gui-select-content');var $track=$(target).find('.slider');var $upArrow=$(target).find('.arrow-up');var $downArrow=$(target).find('.arrow-down') var maxOptionCount=$(target).attr('maxOptionCount');var contentHeight=(maxOptionCount*optionHeight)-4;var trackHeight=contentHeight-2*(sliderArrowHeight+sliderArrowMargin);var paneHeight=$pane.children('a').size()*optionHeight;var percentInView=paneHeight/contentHeight;var currentOffset;var maxY;var dragPosition=0;var dragMiddle=percentInView*paneHeight/2;var minTrackHeight=Math.min(trackHeight-20,25);var dragH=Math.max(Math.min(trackHeight/percentInView,trackHeight-15),minTrackHeight);var getPos=function(event,c){var p=c=='X'?'Left':'Top';return event['page'+c]||(event['client'+c]+(document.documentElement['scroll'+p]||document.body['scroll'+p]))||0;};var ignoreNativeDrag=function(){return false;};var initDrag=function(){currentOffset=$drag.offset(false);currentOffset.top-=dragPosition;maxY=trackHeight-dragH;};var onStartDrag=function(event){initDrag();dragMiddle=getPos(event,'Y')-dragPosition-currentOffset.top;$('html').bind('mouseup',onStopDrag).bind('mousemove',updateScroll).bind('mouseleave',onStopDrag) if($.browser.msie){$('html').bind('dragstart',ignoreNativeDrag).bind('selectstart',ignoreNativeDrag);} return false;};var onStopDrag=function(){$('html').unbind('mouseup',onStopDrag).unbind('mousemove',updateScroll);if($.browser.msie){$('html').unbind('dragstart',ignoreNativeDrag).unbind('selectstart',ignoreNativeDrag);}};var positionDrag=function(destY){$container.scrollTop(0);destY=destY<0?0:(destY>maxY?maxY:destY);dragPosition=destY;$drag.css({'top':destY+'px'});var p=destY/maxY;$pane.css({'top':((paneHeight-contentHeight)*-p)+'px'});$pane.trigger('scroll');};var updateScroll=function(e){positionDrag(getPos(e,'Y')-currentOffset.top-dragMiddle);};$drag.unbind('mousedown');$drag.css({'height':dragH+'px'}).bind('mousedown',onStartDrag);initDrag();var currentArrowDirection;var currentArrowInc;var currentArrowStep=maxY/($pane.children('a').size()-maxOptionCount);var currentArrowInterval;var rf=function(){return false;};var whileArrowButtonDown=function(){if(currentArrowInc>4||currentArrowInc%4==0){positionDrag(dragPosition+currentArrowDirection);} currentArrowInc++;};var onArrowMouseUp=function(event){$('html').unbind('mouseup',onArrowMouseUp);clearInterval(currentArrowInterval);};var onArrowMouseDown=function(){$('html').bind('mouseup',onArrowMouseUp);initDrag();currentArrowInc=0;whileArrowButtonDown();currentArrowInterval=setInterval(whileArrowButtonDown,100);};$upArrow.unbind('mousedown');$upArrow.bind('mousedown',function(){currentArrowDirection=-currentArrowStep;onArrowMouseDown();return false;}).bind('click',rf);$downArrow.unbind('mousedown');$downArrow.bind('mousedown',function(){currentArrowDirection=currentArrowStep;onArrowMouseDown();return false;}).bind('click',rf) $pane.unbind('forcescroll');$pane.bind('forcescroll',function(event){positionDrag(maxY*event.scrollstep/($pane.children('a').size()-maxOptionCount));});var trackScrollInterval;var trackScrollInc;var trackScrollMousePos;var doTrackScroll=function(){if(trackScrollInc>8||trackScrollInc%4==0){positionDrag((dragPosition-((dragPosition-trackScrollMousePos)/2)));} trackScrollInc++;};var onStopTrackClick=function(){clearInterval(trackScrollInterval);$('html').unbind('mouseup',onStopTrackClick).unbind('mousemove',onTrackMouseMove);};var onTrackMouseMove=function(event){trackScrollMousePos=getPos(event,'Y')-currentOffset.top-dragMiddle;};var onTrackClick=function(event){initDrag();onTrackMouseMove(event);trackScrollInc=0;$('html').bind('mouseup',onStopTrackClick).bind('mousemove',onTrackMouseMove);trackScrollInterval=setInterval(doTrackScroll,100);doTrackScroll();return false;};$track.unbind('mousedown');$track.bind('mousedown',onTrackClick);} function SetOptionListPosition(target,scrollStep){$(target).find('.gui-select_optionList').trigger({type:"forcescroll",scrollstep:scrollStep});} function CloseContentLayer(target,event){$(target).closest('.gui-select').find('.gui-select-content').removeClass('gui-select-content-hidden').addClass('gui-select-content-hidden');event.stopPropagation();} function OpenContentLayer(target,event){expandedComboboxHovered=true;$(target).closest('.gui-select').find('.gui-select-content').removeClass('gui-select-content-hidden');event.stopPropagation();} function IsContentLayerOpen(target){return $(target).closest('.gui-select').find('.gui-select-content').hasClass('gui-select-content-hidden')==false;} function SetComboBoxOptions(target,callerSettings){if($(target).hasClass('gui-select')){var settings=$.extend({readonly:true,disabled:false},callerSettings||{});if(settings.readonly){if(settings.disabled){$(target).removeClass().addClass('gui-select readonly-inactive-select');} else{$(target).removeClass().addClass('gui-select readonly-active-select');}} else{if(settings.disabled){$(target).removeClass().addClass('gui-select editable-inactive-select');$(target).find('input.gui-select-input').attr('disabled',true);} else{$(target).removeClass().addClass('gui-select editable-active-select');$(target).find('input.gui-select-input').attr('disabled',false);}}}} function AddComboBoxItem(target,item){if($(target).hasClass('gui-select')){var item=$.extend({text:"",value:"",imagePath:"",selected:false},item||{});var itemHtml="";if(item.imagePath!=""){itemHtml+="";} itemHtml+=item.text+"";itemHtml+=""+item.value+"";$(target).find('.gui-select_optionList a:last').removeClass('last-option');$(target).find('.gui-select_optionList').append(itemHtml);$(target).find('.gui-select_optionList').children('a').mouseenter(function(event){$(this).css('background-color','#999999');});$(target).find('.gui-select_optionList').children('a').mouseleave(function(event){$(this).css('background-color','#FFFFFF');});$(target).find('.gui-select_optionList a:last').bind('click',function(){ChangeSelection($(this));return false;});if(item.selected){$(target).find('.gui-select_optionList a.selected-option').removeClass('selected-option');$(target).find('.gui-select_optionList a:last').addClass('selected-option');}}} function GetComboBoxSelectedValue(target){if($(target).hasClass('gui-select')){if($(target).hasClass('editable-active-select')||$(target).hasClass('editable-inactive-select')){return $(target).find('input.gui-select-input').val();} else{return $(target).find('input.gui-select-input-value').val();}}} function GetComboBoxSelectedText(target){if($(target).hasClass('gui-select')){if($(target).hasClass('editable-active-select')||$(target).hasClass('editable-inactive-select')){return $(target).find('input.gui-select-input').attr('title');} else{return $(target).find('input.gui-select-input').attr('title');}}} function GetComboboxInputObject(target){if($(target).hasClass('gui-select')){if($(target).hasClass('editable-active-select')||$(target).hasClass('editable-inactive-select')){return $(target).find('input.gui-select-input').attr('id');} else{return $(target).find('input.gui-select-input-value').attr('id');}}} function GetComboBoxSelectedItemIndex(target){if($(target).hasClass('gui-select')){var selectedItem=$(target).find('.gui-select_optionList a.selected-option');var index=$(target).find('.gui-select_optionList a').index(selectedItem);return index;} return-1;} function GetComboBoxItemIndexByValue(target,value){if($(target).hasClass('gui-select')){var idx;var counter;counter=-1;var selectedItem=$(target).find('.gui-select_optionList .option-value').each(function(){counter++;if($(this).text()==value)idx=counter;});return idx;} return-1;} function GetComboBoxItemIndexByTitle(target,value){if($(target).hasClass('gui-select')){var idx;var counter;counter=-1;var selectedItem=$(target).find('.gui-select_optionList a').each(function(){counter++;if($(this).text()==value)idx=counter;});return idx;} return-1;} function GetComboBoxItemAttributeValue(target,index,attrName){if($(target).hasClass('gui-select')){return index=$(target).find('.gui-select_optionList a').eq(index).attr(attrName);} return"";} function SetComboBoxSelectedItemIndex(target,index,suppressChangedEvent){if($(target).hasClass('gui-select')){ChangeSelection($(target).find('.gui-select_optionList a').eq(index),null,suppressChangedEvent);}} function GetComboBoxItems(target,index){if(index==null){var items=new Array();$(target).find('.gui-select_optionList a').each(function(){items.push($(this).text());});return items;} else{return $(target).find('.gui-select_optionList a').eq(index).text();}} function GetComboBoxItemObjects(target){function Item(text,selected){this.Value=text;this.IsSelected=selected;} var items=new Array();$(target).find('.gui-select_optionList a').each(function(){if($(this).hasClass('selected-option')) items.push(new Item($(this).text(),true));else items.push(new Item($(this).text(),false));});return items;} function RemoveComboBoxItem(target,index){$(target).find('.gui-select_optionList a').eq(index).remove();$(target).find('.gui-select_optionList span').eq(index).remove();} function AnimateComboBoxWithCss(target){$(target).find(".gui-select-input").each(function(){$(this).removeClass("animate").addClass("animate");});} function AnimateComboBox(target,colorBack,colorFore){$(target).find(".gui-select-input, .gui-select-arrow,.gui-select-title").each(function(){AnimateBackColor($(this),null,colorBack,colorFore);});var $combobox;if($(target).hasClass('gui-select')){$combobox=$(target);} else{$combobox=$(target).find(".gui-select");} $combobox.each(function(){AnimateBorderColor($(this));});} function AnimateBackColor(target,endAnimation,colorBack,colorFore){if(!colorBack){colorBack="#cce0e7";} if(!colorFore){colorFore="#006487";} console.log(target);$(target).animate({borderWidth:"1px"},200,function(){$(this).css("background-color",colorBack);$(this).css("color",colorFore);$(this).css("font-weight","bold");$(this).animate({borderWidth:"1px"},300,function(){$(this).css("background-color","#FFF");$(this).css("color","#333");$(this).css("font-weight","normal");$(this).animate({borderWidth:"1px"},200,function(){$(this).css("background-color",colorBack);$(this).css("color",colorFore);$(this).css("font-weight","bold");$(this).animate({borderWidth:"1px"},300,function(){$(this).css("background-color","#FFF");$(this).css("color","#333");$(this).css("font-weight","normal");$(this).animate({borderWidth:"1px"},200,function(){$(this).css("background-color",colorBack);$(this).css("color",colorFore);$(this).css("font-weight","bold");$(this).animate({borderWidth:"1px"},300,function(){$(this).css("background-color","#FFF");$(this).css("color",colorFore);$(this).css("font-weight","normal");if(endAnimation!=true){AnimateBackColor($(this),true,colorBack,colorFore);}});});});});});});} function AnimateBorderColor(target,endAnimation){$(target).animate({"borderLeftWidth":"1px","borderRightWidth":"1px","borderTopWidth":"1px","borderBottomWidth":"1px","marginLeft":"0px","marginTop":"0px","marginRight":"0px","marginBottom":"0px"},200,function(){$(this).css("border-color","#006487");$(this).animate({"borderLeftWidth":"1px","borderRightWidth":"1px","borderTopWidth":"1px","borderBottomWidth":"1px","marginLeft":"0px","marginTop":"0px","marginRight":"0px","marginBottom":"0px"},300,function(){$(this).css("border-color","#666666");$(this).animate({"borderLeftWidth":"1px","borderRightWidth":"1px","borderTopWidth":"1px","borderBottomWidth":"1px","marginLeft":"0px","marginTop":"0px","marginRight":"0px","marginBottom":"0px"},200,function(){$(this).css("border-color","#006487");$(this).animate({"borderLeftWidth":"1px","borderRightWidth":"1px","borderTopWidth":"1px","borderBottomWidth":"1px","marginLeft":"0px","marginTop":"0px","marginRight":"0px","marginBottom":"0px"},300,function(){$(this).css("border-color","#666666");$(this).animate({"borderLeftWidth":"1px","borderRightWidth":"1px","borderTopWidth":"1px","borderBottomWidth":"1px","marginLeft":"0px","marginTop":"0px","marginRight":"0px","marginBottom":"0px"},200,function(){$(this).css("border-color","#006487");$(this).animate({"borderLeftWidth":"1px","borderRightWidth":"1px","borderTopWidth":"1px","borderBottomWidth":"1px","marginLeft":"0px","marginTop":"0px","marginRight":"0px","marginBottom":"0px"},300,function(){$(this).css("border-color","#666666");if(endAnimation!=true){AnimateBorderColor($(this),true);}});});});});});});} function ClearComboBoxSelection(target){$(target).find('.gui-select_optionList a.selected-option').removeClass('selected-option');} function SetComboBoxSelectedItemByValue(target,value){var index=GetComboBoxItemIndexByValue(target,value);SetComboBoxSelectedItemIndex(target,index);} function GetComboBoxSelectedItemAttributeValue(target,attrName){var index=GetComboBoxSelectedItemIndex(target);return GetComboBoxItemAttributeValue(target,index,attrName);}