
DestroyableItems={items:[],add:function(inItem)
{this.items.push(inItem);},destroyAll:function()
{var items=DestroyableItems.items;for(var i=0;i<items.length;i++){var item=items[i];if(!item){continue;}
if(item.destroy){item.destroy();}else{DestroyableItems.clearObjectReferences(item);}}
DestroyableItems.items.length=0;DestroyableItems.add=null;DestroyableItems.clearObjectReferences=null;},clearObjectReferences:function(inItem)
{if(inItem.element&&typeof inItem.element=="object"){inItem.element.instance=null;}
for(var attribute in inItem){try{if(typeof inItem[attribute]=="object"||typeof inItem[attribute]=="function"){inItem[attribute]=null;}}catch(exception){}}}};function formatHMSFromSeconds(inSeconds)
{var durationString="";var hours=Math.floor(inSeconds/3600);var minutes=Math.floor((inSeconds%3600)/60);var seconds=(inSeconds%60);if(hours){durationString=hours+":"+(minutes+100).toString().slice(1)+":";}else{durationString=minutes+":";}
durationString+=(seconds+100).toString().slice(1);return durationString;}
function createXmlDom(){var xmlDom=null;if(!createXmlDom.progID){var progIDs=["Msxml2.DOMDocument.5.0","Msxml2.DOMDocument.4.0","Msxml2.DOMDocument.3.0","MSXML2.DOMDocument.2.6","MSXML2.DOMDocument","MSXML.DOMDocument","Microsoft.XMLDOM"];for(var i=0;i<progIDs.length;i++){try{xmlDom=new ActiveXObject(progIDs[i]);createXmlDom.progID=progIDs[i];break;}catch(exception){}}}
if(!createXmlDom.progID){return null;}
if(!xmlDom){xmlDom=new ActiveXObject(createXmlDom.progID);}
return xmlDom;}
function clipToRange(inStart,inValue,inEnd)
{return Math.min(Math.max(inStart,inValue),inEnd);}
function isDefined(inIdentifier)
{return(typeof inIdentifier!="undefined");}
function isUndefined(inIdentifier)
{return(typeof inIdentifier=="undefined");}
function addClass(inElement,inClass)
{if(!inElement||typeof inElement.className=="undefined"||!inClass){return;}
if(inElement.className.indexOf(inClass)>-1){return;}
inElement.className+=" "+inClass;}
function removeClass(inElement,inClass)
{if(!inElement||typeof inElement.className=="undefined"||!inClass){return;}
inElement.className=inElement.className.replace(new RegExp("( "+inClass+")|("+inClass+" ?)","g"),"");}
function show(inElement,inDisplayType)
{if(typeof inElement=="string"){inElement=document.getElementById(inElement);}
if(inElement&&inElement.style){inElement.style.display=inDisplayType||"block";}}
function hide(inElement)
{if(typeof inElement=="string"){inElement=document.getElementById(inElement);}
if(inElement&&inElement.style){inElement.style.display="none";}}
function dispatchInstanceEvents(inEvent)
{inEvent=inEvent||this.document.parentWindow.event;if(this.instance&&this.instance[inEvent.type]){return this.instance[inEvent.type](inEvent);}}
String.prototype.trim=function(inTrimCharacters)
{return this.replace(new RegExp("["+inTrimCharacters+"]+$"),"");};String.prototype.replaceTokens=function()
{var tokenCount=arguments.length;var s=this;for(var i=0;i<tokenCount;i++){s=s.replace(new RegExp("(^|[^%])%"+(i+1),"g"),"$1"+arguments[i]);}
s=s.replace(/%%/g,"%");return s;};if(typeof Array.prototype.push!="function"){Array.prototype.push=function()
{for(var i=0;i<arguments.length;i++){this[this.length]=arguments[i];}};}
if(typeof Array.prototype.splice!="function"){Array.prototype.splice=function(start,deleteCount){var a=start>0?this.slice(0,start):[];a=a.concat(Array.from(arguments).slice(2),this.slice(start+deleteCount));var self=this,deleted=this.slice(start,start+deleteCount);a.foreach(function(v,i){self[i]=v;});this.length=a.length;return deleted;};}
Array.prototype.getIndexByValue=function(inValue)
{for(var i=0;i<this.length;i++){if(this[i]==inValue){return i;}}
return-1;};Array.prototype.exists=function(inValue)
{return this.getIndexByValue(inValue)!=-1;};Array.prototype.contains=Array.prototype.exists;Array.prototype.getIndexesByAttribute=function(inAttributes)
{var indexes=[];nextItem:for(var i=0;i<this.length;i++){var item=this[i];if(typeof item=="object"||typeof item=="function"){for(var attribute in inAttributes){var itemValue=item[attribute];var requiredValue=inAttributes[attribute];if(requiredValue instanceof Array){if(requiredValue.length){var itemMatched=false;for(var valueIndex=0;valueIndex<requiredValue.length;valueIndex++){if(item[attribute]==requiredValue[valueIndex]){itemMatched=true;break;}}
if(!itemMatched){continue nextItem;}}}else if(typeof requiredValue=="function"){if(!requiredValue(attribute,item[attribute])){continue nextItem;}}else if(itemValue!=requiredValue){continue nextItem;}}
indexes.push(i);}}
return indexes;};Array.prototype.getItemsByAttribute=function(inAttributes)
{var matches=this.getIndexesByAttribute(inAttributes);for(var i=0;i<matches.length;i++){matches[i]=this[matches[i]];}
return matches;};Array.prototype.sortByAttribute=function(inSortAttribute,inReverseSort)
{this.sort(function(inA,inB)
{var attributeA=inA[inSortAttribute];var attributeB=inB[inSortAttribute];var typeA=typeof attributeA;var typeB=typeof attributeB;attributeA=(typeA=="string")?attributeA.toLowerCase():attributeA;attributeB=(typeB=="string")?attributeB.toLowerCase():attributeB;if(typeA!="number"&&(attributeA==" "||attributeA==""||attributeA==null)){return 1;}else if(typeB!="number"&&(attributeB==" "||attributeB==""||attributeB==null)){return-1;}
if(attributeA==attributeB){return 0;}else if(attributeA<attributeB){return-1;}else{return 1;}});if(inReverseSort){this.reverse();}
return this;};Array.prototype.sortCaseInsensitive=function(inReverseSort)
{this.sort(function(inA,inB)
{var a=(typeof inA=="string")?inA.toLowerCase():inA;var b=(typeof inB=="string")?inB.toLowerCase():inB;if(a==b){return 0;}else if(a<b){return-1;}else{return 1;}});if(inReverseSort){this.reverse();}
return this;};Array.prototype.removeItem=function(inIndex)
{if(typeof(inIndex)=="string"){inIndex=parseInt(inIndex);}
this.splice(inIndex,1);};Array.prototype.removeItemByValue=function(inValue)
{for(var i=0;i<this.length;i++){if(this[i]==inValue){this.removeItem(i);return;}}};if(typeof Function.prototype.apply!="function"){Function.prototype.apply=function(obj,args){var s,tmp;if(obj){tmp="__tmp__";switch(typeof(obj)){case"string":s="'"+obj.replace(Function.prototype.apply.re,"\\'")+"'";String.prototype[tmp]=this;break;case"number":s="("+obj+")";Number.prototype[tmp]=this;break;default:s="obj";obj[tmp]=this;break;}
s="var r = "+s+"."+tmp+"(";}
else
s="var r = this(";for(var i=0;i<args.length;++i)
s+="args["+i+"],";s=(args.length?s.slice(0,-1):s)+");";eval(s);return r;};Function.prototype.apply.re=/\'/g;Function.prototype.call=function(obj){var args=[];for(var i=1;i<arguments.length;i++){args.push(arguments[i]);}
return this.apply(obj,args);};}
function alertObject(inObject)
{var attributes=[];for(var attribute in inObject){if(typeof inObject[attribute]=="function"){attributes.push(attribute+": function");}else{attributes.push(attribute+": "+inObject[attribute]);}}
attributes.sort();alert(attributes.join(", "));}
function getScreenX(inObject)
{var doc=inObject.ownerDocument||inObject.document;var window=doc.parentWindow;return window.screenLeft+doc.body.clientLeft+
inObject.getBoundingClientRect().left;}
function getScreenY(inObject)
{var doc=inObject.ownerDocument||inObject.document;var window=doc.parentWindow;return window.screenTop+doc.body.clientTop+
inObject.getBoundingClientRect().top;}
function getPageX(inObject)
{if(inObject.pageX){return inObject.pageX;}else{var pageX=inObject.offsetLeft;var currentObject=inObject.offsetParent;while(currentObject){pageX+=currentObject.offsetLeft;currentObject=currentObject.offsetParent;}
return pageX;}}
function getPageY(inObject)
{if(inObject.pageY){return inObject.pageY;}else{var pageY=inObject.offsetTop;var currentObject=inObject.offsetParent;while(currentObject){pageY+=currentObject.offsetTop;currentObject=currentObject.offsetParent;}
return pageY;}}
function getParent(inElement,inAttributes,inReturnElementIfMatch,inMatchAnyAttribute)
{if(inElement==null){return null;}
if(inAttributes){var startingElement=inReturnElementIfMatch?inElement:inElement.parentNode;nextParent:for(var parent=startingElement;parent!=null;parent=parent.parentNode){for(var name in inAttributes){if(name=="className"){if(!inMatchAnyAttribute&&(!parent[name]||parent[name].indexOf(inAttributes[name])<0)){continue nextParent;}}else if(typeof inAttributes[name]=="function"){if(!inAttributes[name](parent[name])&&!inMatchAnyAttribute){continue nextParent;}}else if(inAttributes[name]instanceof Array){var values=inAttributes[name];var parentValue=parent[name];var foundMatch=false;for(var i=0;i<values.length;i++){if(parentValue==values[i]){foundMatch=true;break;}}
if(!foundMatch&&!inMatchAnyAttribute){continue nextParent;}}else if(parent[name]!=inAttributes[name]&&!inMatchAnyAttribute){continue nextParent;}
if(inMatchAnyAttribute){break;}}
return parent;}
return null;}else{return inElement.parentNode;}}
YMStringResource.k={};YMStringResource.k.number_singular="singular";YMStringResource.k.number_plural="plural";YMStringResource.k.pluralSuffix="Plural";function YMStringResource(inAttributes)
{if(typeof inAttributes=="object"){for(var attribute in inAttributes){this[attribute]=inAttributes[attribute];}}
if(this.xmlPath){this.loadXML(this.xmlPath);}}
YMStringResource.prototype.get=function(inID)
{if(!this.xml){return"";}
var stringNode=this.xml.nodeFromID(inID);if(!stringNode){return"";}
var string=stringNode.text;if(arguments.length>1){var values=[];for(var i=1;i<arguments.length;i++){values.push(arguments[i]);}
if(stringNode.getAttribute("number")==YMStringResource.k.number_singular&&values[0]>1){var pluralStringNode=this.xml.nodeFromID(inID+YMStringResource.k.pluralSuffix);if(pluralStringNode){string=pluralStringNode.text;}}
string=string.replaceTokens(values);}
return string;}
YMStringResource.prototype.document=document;YMStringResource.prototype.xml=null;YMStringResource.prototype.xmlPath="";YMStringResource.prototype.loadXML=function(inXMLPath)
{this.xmlPath=inXMLPath;this.xml=createXmlDom();this.xml.async=false;this.xml.load(inXMLPath);}
YMGroupListItem.k={};YMGroupListItem.k.class_container="YMGroupListItem";YMGroupListItem.k.class_selected="YMGroupListItem_Selected";YMGroupListItem.k.class_highlighted="YMGroupListItem_Highlighted";function YMGroupListItem(inAttributes)
{if(typeof inAttributes=="object"){for(var attribute in inAttributes){this[attribute]=inAttributes[attribute];}}
DestroyableItems.add(this);}
YMGroupListItem.prototype.getElement=function()
{if(this.element==null){this.createElement();}
return this.element;}
YMGroupListItem.prototype.setSelected=function(inSelected)
{this.selected=inSelected;if(this.element){if(this.selected){addClass(this.element,this.class_selected);}else{removeClass(this.element,this.class_selected);}}
this.onSelectionChanged();}
YMGroupListItem.prototype.onAddedToGroup=function(inGroup,inIndex)
{this.group=inGroup;this.index=inIndex;this.list=this.group.list;}
YMGroupListItem.prototype.onAddedToList=function(inList,inIndex)
{this.list=inList;this.index=inIndex;}
YMGroupListItem.prototype.show=function()
{if(this.element){this.element.style.display="block";}}
YMGroupListItem.prototype.hide=function()
{if(this.element){this.element.style.display="none";}}
YMGroupListItem.prototype.document=document;YMGroupListItem.prototype.element=null;YMGroupListItem.prototype.group=null;YMGroupListItem.prototype.list=null;YMGroupListItem.prototype.index=0;YMGroupListItem.prototype.selected=false;YMGroupListItem.prototype.tagName="DIV";YMGroupListItem.prototype.handledEvents=[];YMGroupListItem.prototype.class_container=YMGroupListItem.k.class_container;YMGroupListItem.prototype.class_selected=YMGroupListItem.k.class_selected;YMGroupListItem.prototype.createElement=function()
{if(this.document==null){return;}
this.element=this.document.createElement(this.tagName);this.element.instance=this;this.element.selectable=true;this.element.className=this.class_container;this.element.innerHTML=this.getHTML();this.finishElement();this.updateView();}
YMGroupListItem.prototype.getHTML=function()
{return'Item';}
YMGroupListItem.prototype.finishElement=function()
{}
YMGroupListItem.prototype.updateView=function()
{}
YMGroupListItem.prototype.attachEventHandlers=function()
{}
YMGroupListItem.prototype.onSelectionChanged=function()
{}
YMGroupListItem.handleEvent=function(inEvent)
{inEvent=inEvent||this.document.parentWindow.event;if(this.instance[inEvent.type]){return this.instance[inEvent.type](inEvent);}}
YMGroupList.k={};YMGroupList.k.class_container="YMGroupList";function YMGroupList(inAttributes)
{if(typeof inAttributes=="object"){for(var attribute in inAttributes){this[attribute]=inAttributes[attribute];}}
this.items=[];this.selectedItems=[];this.groups=[];this.createElement();DestroyableItems.add(this);}
YMGroupList.prototype.getElement=function()
{if(this.element==null){this.createElement();}
return this.element;}
YMGroupList.prototype.show=function()
{this.visible=true;if(this.element){this.element.style.display="block";}}
YMGroupList.prototype.hide=function()
{this.visible=false;if(this.element){this.element.style.display="none";}}
YMGroupList.prototype.addGroup=function(inGroup)
{if(!inGroup){return;}
inGroup.index=this.groups.length;this.groups.push(inGroup);inGroup.list=this;this.itemContainer.appendChild(inGroup.getElement());}
YMGroupList.prototype.addItem=function(inItem,inGroup,inIndex)
{if(!inItem){return;}
if(typeof inIndex!="undefined"){this.items.splice(inIndex,0,inItem);}else{this.items.push(inItem);}
var group=null;if(inGroup){if(typeof inGroup=="string"){if(this.groupsByID[inGroup]){group=this.groupsByID[inGroup];}}else{group=inGroup;}}
if(group){group.addItem(inItem,inIndex);}else{inItem.onAddedToList(this,this.items.length-1);if(this.itemContainer.children.length==0||typeof inIndex=="undefined"||inIndex>=this.itemContainer.children.length){this.itemContainer.appendChild(inItem.getElement());}else{this.itemContainer.insertBefore(inItem.getElement(),this.itemContainer.children[inIndex]);}}}
YMGroupList.prototype.getItem=function(inIndex)
{if(inIndex>=0&&inIndex<this.items.length){return this.items[inIndex];}else{return null;}}
YMGroupList.prototype.selectItem=function(inItem,inMultiSelect)
{if(!inItem){return;}
if(this.selectedItems.length>0&&!inMultiSelect){this.unselectAll();}
if(inItem.selected){return;}
this.selectedItems.push(inItem);inItem.setSelected(true);this.onSelectionChanged(this.selectedItems);}
YMGroupList.prototype.selectItemByIndex=function(inItemIndex,inMultiSelect)
{inItemIndex=clipToRange(0,inItemIndex,this.items.length-1);this.selectItem(this.items[inItemIndex]);}
YMGroupList.prototype.unselectItem=function(inItem)
{if(!inItem){return;}
inItem.setSelected(false);this.selectedItems.removeItemByValue(inItem);this.onSelectionChanged(this.selectedItems);}
YMGroupList.prototype.selectAll=function()
{for(var i=0;i<this.items.length;i++){if(!this.items[i].selected){this.selectedItems.push(this.items[i]);this.items[i].setSelected(true);}}
this.onSelectionChanged(this.selectedItems);}
YMGroupList.prototype.unselectAll=function()
{for(var i=this.selectedItems.length-1;i>=0;i--){this.selectedItems[i].setSelected(false);}
this.selectedItems.length=0;this.onSelectionChanged(this.selectedItems);}
YMGroupList.prototype.getSelectedItems=function()
{return[].concat(this.selectedItems);}
YMGroupList.prototype.removeItem=function(inItem)
{if(inItem.selected){this.unselectItem(inItem);}
this.items.removeItemByValue(inItem);if(this.lastClickedItem==inItem){this.lastClickedItem=null;}
var itemElement=inItem.getElement();DestroyableItems.clearObjectReferences(inItem);itemElement.removeNode(true);}
YMGroupList.prototype.removeItems=function(inItems)
{for(var i=0;i<inItems.length;i++){this.removeItem(inItems[i]);}}
YMGroupList.prototype.removeAllItems=function()
{for(var i=this.items.length-1;i>=0;i--){this.removeItem(this.items[i]);}
this.lastClickedItem=null;}
YMGroupList.prototype.getItemIndex=function(inItem)
{return this.items.getIndexByValue(inItem);}
YMGroupList.prototype.scrollToItem=function(inItem)
{if(typeof inItem=="number"){inItem=this.items[clipToRange(0,inItem,this.items.length-1)];}
if(inItem){inItem.getElement().scrollIntoView(false);}}
YMGroupList.prototype.refreshItemViews=function()
{for(var i=0;i<this.items.length;i++){this.items[i].updateView();}}
YMGroupList.prototype.getGroupByID=function(inGroupID)
{return this.groups.getItemsByAttribute({id:inGroupID})[0];}
YMGroupList.prototype.document=document;YMGroupList.prototype.element=null;YMGroupList.prototype.itemContainer=null;YMGroupList.prototype.visible=true;YMGroupList.prototype.items=null;YMGroupList.prototype.selectedItems=null;YMGroupList.prototype.lastClickedItem=null;YMGroupList.prototype.groups=null;YMGroupList.prototype.tagName="DIV";YMGroupList.prototype.class_container=YMGroupList.k.class_container;YMGroupList.prototype.createElement=function()
{this.element=this.document.createElement(this.tagName);this.element.instance=this;this.element.className=this.class_container;this.element.innerHTML=this.getHTML();if(this.element.all.ItemContainer){this.itemContainer=this.element.all.ItemContainer;}else{this.itemContainer=this.element;}
this.element.onmousedown=dispatchInstanceEvents;this.element.ondblclick=dispatchInstanceEvents;this.element.oncontextmenu=dispatchInstanceEvents;this.finishElement();if(!this.visible){this.hide();}}
YMGroupList.prototype.getHTML=function()
{var html='';return html;}
YMGroupList.prototype.finishElement=function()
{}
YMGroupList.prototype.onSelectionChanged=function(inSelectedItems)
{}
YMGroupList.prototype.onItemDblClick=function(inItem)
{}
YMGroupList.prototype.onItemContextMenu=function(inItem)
{}
YMGroupList.prototype.mousedown=function(inEvent)
{if(this.items.length==0){return;}
var itemElement=getParent(inEvent.srcElement,{selectable:true},true);if(itemElement==null){if(!inEvent.ctrlKey&&!inEvent.shiftKey){this.unselectAll();}
return true;}
itemElement=getParent(itemElement,{instance:function(inInstance){return inInstance!=null;}},true);var item=itemElement.instance;if(inEvent.shiftKey){if(!this.lastClickedItem){this.lastClickedItem=this.items[0];}
this.unselectAll();var lastClickedIndex=this.getItemIndex(this.lastClickedItem);var newClickedIndex=this.getItemIndex(item);var range=lastClickedIndex<newClickedIndex?[lastClickedIndex,newClickedIndex]:[newClickedIndex,lastClickedIndex];for(var i=range[0];i<=range[1];i++){this.selectItem(this.items[i],true);}}else{if(item.selected){if(inEvent.ctrlKey){this.unselectItem(item);}else{this.selectItem(item);}}else{this.selectItem(item,inEvent.ctrlKey);}
this.lastClickedItem=item;}
inEvent.cancelBubble=true;return true;}
YMGroupList.prototype.dblclick=function(inEvent)
{var itemElement=getParent(inEvent.srcElement,{selectable:true},true);if(itemElement==null){return true;}
itemElement=getParent(itemElement,{instance:function(inInstance){return inInstance!=null;}},true);if(itemElement){this.onItemDblClick(itemElement.instance);}}
YMGroupList.prototype.contextmenu=function(inEvent)
{var itemElement=getParent(inEvent.srcElement,{selectable:true},true);itemElement=getParent(itemElement,{instance:function(inInstance){return inInstance!=null;}},true);if(itemElement){this.onItemContextMenu(itemElement.instance);}}
YMListBox.k={};YMListBox.k.class_container="YMListBox";YMListBox.k.keyCodeScrollMappings=[];YMListBox.k.keyCodeScrollMappings[33]="scrollbarPageUp";YMListBox.k.keyCodeScrollMappings[34]="scrollbarPageDown";YMListBox.k.keyCodeScrollMappings[36]="scrollbarHome";YMListBox.k.keyCodeScrollMappings[35]="scrollbarEnd";YMListBox.k.scrollDelay=50;function YMListBox(inAttributes)
{if(typeof inAttributes=="object"){for(var attribute in inAttributes){this[attribute]=inAttributes[attribute];}}
this.rows=[];this.selectedItems={};this.updateRowTimers=[];this.setData(this.data);var listBox=this;this.scrollTimerHandler=function(){listBox.scroll({clientX:listBox.lastClientX,clientY:listBox.lastClientY});};DestroyableItems.add(this);}
YMListBox.prototype.destroy=function()
{try{this.scrollbar.instance=null;this.scrollbar.onscroll=null;this.scrollbar=null;}catch(exception){}
DestroyableItems.clearObjectReferences(this);}
YMListBox.prototype.getElement=function()
{if(this.element==null){this.createElement();}
return this.element;}
YMListBox.prototype.addTo=function(inParentElement)
{if(!this.element){this.createElement(inParentElement);}else{inParentElement.appendChild(this.element);}}
YMListBox.prototype.show=function()
{this.visible=true;if(this.element){show(this.element);}}
YMListBox.prototype.hide=function()
{this.visible=false;if(this.element){hide(this.element);}}
YMListBox.prototype.setData=function(inDataSet)
{if(this.data){this.data.removeListener(this,"handleDataEvents");}
this.data=inDataSet;if(!this.data){this.data=new YMDataSet();}
this.data.addListener(this,"handleDataEvents");this.handleDataEvents({type:"NewDataSet",source:this.data});}
YMListBox.prototype.getItem=function(inIndex)
{if(this.data){return this.data.getItem(inIndex);}else{return null;}}
YMListBox.prototype.selectItem=function(inItemIndex,inMultiSelect)
{if(inItemIndex<0||inItemIndex>=this.data.getLength()){return;}
if(this.selectedItemsCount>0&&!inMultiSelect){this.unselectAll(true);}
if(!this.selectedItems[inItemIndex]){this.selectedItems[inItemIndex]=true;this.selectedItemsCount++;}
this.setRowSelectionByItemIndex(inItemIndex,true);this.onSelectionChanged(this.selectedItemsCount);}
YMListBox.prototype.unselectItem=function(inItemIndex)
{delete this.selectedItems[inItemIndex];this.selectedItemsCount--;this.setRowSelectionByItemIndex(inItemIndex,false);this.onSelectionChanged(this.selectedItemsCount);}
YMListBox.prototype.selectAll=function()
{var itemCount=this.data.getLength();var rowsToSelect=Math.min(this.rows.length,itemCount);for(var i=0;i<rowsToSelect;i++){if(this.rows[i].element.selectable){this.rows[i].setSelected(true);}}
for(var i=0;i<itemCount;i++){this.selectedItems[i]=true;}
this.selectedItemsCount=itemCount;this.onSelectionChanged(this.selectedItemsCount);}
YMListBox.prototype.unselectAll=function(inDontNotifyListeners)
{for(var i=0;i<this.rows.length;i++){this.rows[i].setSelected(false);}
this.selectedItems={};this.selectedItemsCount=0;if(!inDontNotifyListeners){this.onSelectionChanged(this.selectedItemsCount);}}
YMListBox.prototype.selectRange=function(inStartIndex,inEndIndex,inMultiSelect)
{if(!inMultiSelect){this.unselectAll(true);}
if(inStartIndex>inEndIndex){var newStartIndex=inEndIndex;inEndIndex=inStartIndex;inStartIndex=newStartIndex;}
for(var i=inStartIndex;i<=inEndIndex;i++){if(!this.selectedItems[i]){this.selectedItems[i]=true;this.selectedItemsCount++;}}
this.updateRowSelection();this.onSelectionChanged(this.selectedItemsCount);}
YMListBox.prototype.getSelectedIndexes=function()
{var selectedIndexes=[];for(var i in this.selectedItems){if(this.selectedItems[i]){selectedIndexes.push(parseInt(i));}}
return selectedIndexes;}
YMListBox.prototype.scrollToItem=function(inItemIndex)
{if(!this.element){return;}
var itemScrollOffsetTop=inItemIndex*this.rowHeight;var itemScrollOffsetBottom=itemScrollOffsetTop+this.rowHeight;var visibleAreaHeight=this.element.clientHeight;var visibleAreaTop=this.getScrollTop();var visibleAreaBottom=visibleAreaTop+visibleAreaHeight;if(itemScrollOffsetTop>=visibleAreaTop){if(itemScrollOffsetBottom>=visibleAreaBottom){this.scrollToPixel(itemScrollOffsetTop-visibleAreaHeight+2*this.rowHeight,true);}}else{this.scrollToPixel(itemScrollOffsetTop,true);}}
YMListBox.prototype.doScrollEvent=function(inScrollEvent)
{if(!this.element){return;}
switch(inScrollEvent){case"scrollbarHome":this.scrollToPixel(0,true);this.selectItem(0);break;case"scrollbarEnd":this.scrollToPixel(this.getScrollHeight(),true);this.selectItem(this.getLastSelectableVisibleItemIndex());break;case"scrollbarPageUp":var topItem=this.getFirstVisibleItemIndex();if(this.selectedItems[topItem]){this.scrollbar.doScroll(inScrollEvent);this.selectItem(this.getFirstVisibleItemIndex());}else{this.selectItem(topItem);}
break;case"scrollbarPageDown":var bottomItem=this.getLastSelectableVisibleItemIndex();if(this.selectedItems[bottomItem]){this.scrollbar.doScroll(inScrollEvent);this.selectItem(this.getLastSelectableVisibleItemIndex());}else{this.selectItem(bottomItem);}
break;default:this.scrollbar.doScroll(inScrollEvent);break;}}
YMListBox.prototype.document=document;YMListBox.prototype.element=null;YMListBox.prototype.rowContainer=null;YMListBox.prototype.scrollbar=null;YMListBox.prototype.scrollbarWidth=16;YMListBox.prototype.ignoreNextScrollEvent=false;YMListBox.prototype.visible=true;YMListBox.prototype.data=null;YMListBox.prototype.selectedItems=null;YMListBox.prototype.selectedItemsCount=0;YMListBox.prototype.lastClickedItem=0;YMListBox.prototype.lastScrollTop=0;YMListBox.prototype.lastMouseDownScrollTop=0;YMListBox.prototype.lastTopItemIndex=0;YMListBox.prototype.lastClickedScrollbarComponent="";YMListBox.prototype.lastClientHeight=-1;YMListBox.prototype.lastClientX=0;YMListBox.prototype.lastClientY=0;YMListBox.prototype.scrollTimer=null;YMListBox.prototype.scrollTimerHandler=null;YMListBox.prototype.updateRowTimers=null;YMListBox.prototype.rows=null;YMListBox.prototype.rowHeight=1;YMListBox.prototype.rowConstructor=YMListBoxRow;YMListBox.prototype.tagName="DIV";YMListBox.prototype.class_container=YMListBox.k.class_container;YMListBox.prototype.createElement=function(inParentElement)
{this.element=this.document.createElement(this.tagName);if(inParentElement){inParentElement.style.overflow="hidden";inParentElement.appendChild(this.element);}
this.element.instance=this;var style=this.element.style;style.width="100%";style.height="100%";style.overflow="hidden";this.element.className=this.class_container;this.element.innerHTML=this.getHTML();if(this.element.all.RowContainer){this.rowContainer=this.element.all.RowContainer;}else{this.rowContainer=this.element;}
this.createScrollbar();this.element.onresize=dispatchInstanceEvents;this.element.onmousedown=dispatchInstanceEvents;this.element.onclick=dispatchInstanceEvents;this.element.ondblclick=dispatchInstanceEvents;this.element.oncontextmenu=dispatchInstanceEvents;this.element.onselectstart=dispatchInstanceEvents;this.element.onkeydown=dispatchInstanceEvents;this.element.onmouseup=dispatchInstanceEvents;this.element.onmousewheel=dispatchInstanceEvents;this.finishElement();this.updateRowHeight();this.resize({srcElement:this.element});if(!this.visible){this.hide();}}
YMListBox.prototype.createScrollbar=function()
{if(!this.element){return;}
this.scrollbar=this.document.createElement("DIV");this.document.body.appendChild(this.scrollbar);this.scrollbar.className="FakeScrollbar";var style=this.scrollbar.style;style.width="100px";style.height="100%";style.position="absolute";style.top="0";style.right="0";style.overflowX="hidden";style.overflowY="scroll";this.scrollbarWidth=this.scrollbar.offsetWidth-this.scrollbar.clientWidth;style.overflowY="auto";this.scrollbar.innerHTML='<div id="ContentProxy"></div>';this.scrollbar.all.ContentProxy.style.height="1px";this.scrollbar.all.ContentProxy.style.width="1px";this.scrollbar.instance=this;this.scrollbar.onscroll=dispatchInstanceEvents;this.element.appendChild(this.scrollbar);return this.scrollbar;}
YMListBox.prototype.getHTML=function()
{var html='<div id="RowContainer"></div>';return html;}
YMListBox.prototype.finishElement=function()
{}
YMListBox.prototype.updateView=function()
{if(!this.element){return;}
this.lastTopItemIndex=this.getFirstVisibleItemIndex();this.lastScrollTop=this.getScrollTop();var rowCount=this.rows.length;var itemIndex=this.lastTopItemIndex;for(var i=0;i<rowCount;i++){this.updateRow(i,itemIndex+i);}}
YMListBox.prototype.updateRowSelection=function()
{if(!this.element){return;}
var rows=this.rows;for(var i=0,row;row=rows[i];i++){row.setSelected(this.selectedItems[row.getItemIndex()]);}}
YMListBox.prototype.updateScrollHeight=function()
{var contentHeight=this.data.getLength()*this.rowHeight;if(contentHeight>this.element.clientHeight){contentHeight+=this.rowHeight;}
this.scrollbar.all.ContentProxy.style.pixelHeight=contentHeight;}
YMListBox.prototype.updateRow=function(inRowIndex,inItemIndex,inItemData)
{if(inRowIndex<0||inRowIndex>=this.rows.length){return;}
inItemData=inItemData||this.data.getItem(inItemIndex);var row=this.rows[inRowIndex];row.setItemData(inItemData,inItemIndex);row.setSelected(this.selectedItems[inItemIndex]);}
YMListBox.prototype.updateRowHeight=function()
{if(!this.rowContainer){return;}
if(this.rows.length>0){this.rowHeight=this.rows[0].getElement().offsetHeight||1;}else{this.addRow();this.updateRow(0,null);this.rowHeight=this.rows[0].getElement().offsetHeight||1;this.rows[0].getElement().removeNode(true);this.rows.length=0;}
this.updateScrollHeight();}
YMListBox.prototype.addRow=function()
{if(!this.element){return;}
var newRow=new this.rowConstructor({listBox:this,rowIndex:this.rows.length});this.rows.push(newRow);this.rowContainer.appendChild(newRow.getElement());}
YMListBox.prototype.scrollToPixel=function(inPixel,inDontIgnoreNextScrollEvent)
{this.ignoreNextScrollEvent=false;inPixel=clipToRange(0,inPixel,this.getScrollHeight()-this.element.clientHeight);if(this.scrollbar.scrollTop!=inPixel){this.ignoreNextScrollEvent=!inDontIgnoreNextScrollEvent;this.lastMouseDownScrollTop=inPixel;this.scrollbar.scrollTop=inPixel;}}
YMListBox.prototype.getFirstVisibleItemIndex=function(inBias)
{return this.getItemIndexFromPixel(this.scrollbar.scrollTop,inBias);}
YMListBox.prototype.getLastVisibleItemIndex=function()
{var fullRowCount=Math.floor(this.element.clientHeight/this.rowHeight)-1;return this.getItemIndexFromPixel(this.getScrollTop()+fullRowCount*this.rowHeight,"up");}
YMListBox.prototype.getLastSelectableVisibleItemIndex=function()
{var fullRowCount=Math.floor(this.element.clientHeight/this.rowHeight)-1;var lastItem=this.getItemIndexFromPixel(this.getScrollTop()+fullRowCount*this.rowHeight,"up");var lastItemData=this.data.getItem(lastItem);while(lastItem>=0&&(!lastItemData||!lastItemData.selectable)){lastItemData=this.data.getItem(--lastItem);}
return lastItem;}
YMListBox.prototype.getItemIndexFromPixel=function(inPixel,inBias)
{if(inBias=="down"){return Math.ceil(inPixel/this.rowHeight);}else{return Math.floor(inPixel/this.rowHeight);}}
YMListBox.prototype.getScrollTop=function()
{return this.scrollbar.scrollTop;}
YMListBox.prototype.getScrollHeight=function()
{return this.scrollbar.all.ContentProxy.style.pixelHeight;}
YMListBox.prototype.getRowFromItemIndex=function(inItemIndex)
{return this.rows.getItemsByAttribute({itemIndex:inItemIndex})[0];}
YMListBox.prototype.setRowSelectionByItemIndex=function(inItemIndex,inSelected)
{var row=this.getRowFromItemIndex(inItemIndex);if(row){row.setSelected(inSelected);}}
YMListBox.prototype.handleDataEvents=function(inEvent)
{if(typeof this["on"+inEvent.type]=="function"){this["on"+inEvent.type](inEvent);}}
YMListBox.prototype.onNewDataSet=function(inEvent)
{if(!this.element){return;}
this.unselectAll();this.updateScrollHeight();this.updateView();}
YMListBox.prototype.onDataChanged=function(inEvent)
{if(!this.element){return;}
this.updateView();}
YMListBox.prototype.onSelectionChanged=function(inSelectedItemsCount)
{}
YMListBox.prototype.onItemClick=function(inItemIndex)
{}
YMListBox.prototype.onItemDblClick=function(inItemIndex)
{}
YMListBox.prototype.onItemContextMenu=function(inItemIndex)
{}
YMListBox.prototype.scroll=function(inEvent)
{inEvent=inEvent||window.event;if(this.ignoreNextScrollEvent){this.ignoreNextScrollEvent=false;this.lastScrollTop=this.getScrollTop();return true;}
var notScrollbarThumbClicked=(this.lastClickedScrollbarComponent.indexOf("Down")>-1||this.lastClickedScrollbarComponent.indexOf("Up")>-1);if(notScrollbarThumbClicked&&this.lastScrollTop!=this.getScrollTop()){window.clearTimeout(this.scrollTimer);this.scrollTimer=window.setTimeout(this.scrollTimerHandler,YMListBox.k.scrollDelay);this.lastClientX=inEvent.clientX;this.lastClientY=inEvent.clientY;this.lastScrollTop=this.getScrollTop();return true;}
window.clearTimeout(this.scrollTimer);var currentScrollbarComponent=this.scrollbar.componentFromPoint(inEvent.clientX,inEvent.clientY);if(currentScrollbarComponent.indexOf("Down")>-1||currentScrollbarComponent.indexOf("Up")>-1){this.lastClickedScrollbarComponent=currentScrollbarComponent;notScrollbarThumbClicked=true;this.lastScrollTop=this.lastMouseDownScrollTop;}
var scrollbarArrowClicked=(this.lastClickedScrollbarComponent=="scrollbarUp"||this.lastClickedScrollbarComponent=="scrollbarDown");var fixupScrollbar=true;var scrolledTop=this.getScrollTop();var currentTop=scrolledTop;var scrollChange=currentTop-this.lastScrollTop;var scrollDirection=(scrollChange<0?-1:1);var bias=scrollDirection==1?"up":"down";if(scrollbarArrowClicked&&scrollChange!=0){currentTop=(this.lastTopItemIndex+scrollDirection)*this.rowHeight;fixupScrollbar=false;scrollChange=currentTop-this.lastScrollTop;}
var distanceFromBottom=this.getScrollHeight()-this.element.clientHeight-currentTop;if(distanceFromBottom<this.rowHeight){if(scrollDirection==1){bias="down";fixupScrollbar=false;currentTop=this.getScrollHeight();}else{bias="up";}}else if(currentTop<this.rowHeight&&scrollDirection==-1){fixupScrollbar=false;currentTop=0;}
if(!notScrollbarThumbClicked){bias="up";}
var topItemIndex=this.getItemIndexFromPixel(currentTop,bias);if(fixupScrollbar&&notScrollbarThumbClicked){currentTop=topItemIndex*this.rowHeight;}
this.scrollToPixel(currentTop);this.lastScrollTop=this.getScrollTop();if(this.lastTopItemIndex!=topItemIndex){this.updateView();}
return true;}
YMListBox.prototype.mousewheel=function(inEvent)
{var scrollAmount=clipToRange(-this.element.clientHeight,-inEvent.wheelDelta,this.element.clientHeight);this.lastClickedScrollbarComponent="";this.scrollToPixel(this.getScrollTop()+scrollAmount,true);}
YMListBox.prototype.resize=function(inEvent)
{if(!this.element||this.lastClientHeight==this.element.clientHeight){return;}
this.lastClientHeight=this.element.clientHeight;var visibleRowCount=Math.ceil(this.element.clientHeight/this.rowHeight);var topItemIndex=this.getFirstVisibleItemIndex();var rowsToAddCount=0;if(this.rows.length<visibleRowCount){rowsToAddCount=visibleRowCount-this.rows.length;var firstNewRowIndex=this.rows.length;var firstNewRowItemIndex=topItemIndex+this.rows.length;for(var i=0;i<rowsToAddCount;i++){this.addRow();}}else{}
this.updateScrollHeight();if(this.lastTopItemIndex!=this.getFirstVisibleItemIndex()){for(var i=0;i<this.updateRowTimers.length;i++){window.clearTimeout(this.updateRowTimers[i]);}
this.updateRowTimers=[];this.updateView();}else{var listBox=this;this.updateRowTimers.push(window.setTimeout(function()
{for(var i=0;i<rowsToAddCount;i++){listBox.updateRow(firstNewRowIndex+i,firstNewRowItemIndex+i);}
listBox=null;},0));}}
YMListBox.prototype.mousedown=function(inEvent)
{if(this.rows.length==0){return false;}
if(inEvent.srcElement==this.scrollbar&&this.scrollbar.scrollHeight>this.element.clientHeight){this.lastClickedScrollbarComponent=this.scrollbar.componentFromPoint(inEvent.clientX,inEvent.clientY);this.ignoreNextScrollEvent=false;this.lastMouseDownScrollTop=this.getScrollTop();return false;}
this.lastClickedScrollbarComponent="";var rowElement=getParent(inEvent.srcElement,{selectable:true},true);if(rowElement==null){if(!inEvent.ctrlKey&&!inEvent.shiftKey){this.unselectAll();}
return true;}
rowElement=getParent(rowElement,{instance:function(inInstance){return inInstance!=null;}},true);var row=rowElement.instance;if(inEvent.shiftKey){this.selectRange(this.lastClickedItem,row.itemIndex,inEvent.ctrlKey);}else{if(row.selected){if(inEvent.ctrlKey){this.unselectItem(row.itemIndex);}else if(this.selectedItemsCount>1){this.selectItem(row.itemIndex);}}else{this.selectItem(row.itemIndex,inEvent.ctrlKey);}
this.lastClickedItem=row.itemIndex;}
inEvent.cancelBubble=true;return true;}
YMListBox.prototype.click=function(inEvent)
{var rowElement=getParent(inEvent.srcElement,{selectable:true},true);if(rowElement==null){return true;}
rowElement=getParent(rowElement,{instance:function(inInstance){return inInstance!=null;}},true);if(rowElement){this.onItemClick(rowElement.instance.itemIndex);}
return true;}
YMListBox.prototype.dblclick=function(inEvent)
{var rowElement=getParent(inEvent.srcElement,{selectable:true},true);if(rowElement==null){return true;}
rowElement=getParent(rowElement,{instance:function(inInstance){return inInstance!=null;}},true);if(rowElement){this.onItemDblClick(rowElement.instance.itemIndex);}
return true;}
YMListBox.prototype.contextmenu=function(inEvent)
{var rowElement=getParent(inEvent.srcElement,{selectable:true},true);rowElement=getParent(rowElement,{instance:function(inInstance){return inInstance!=null;}},true);if(rowElement){this.onItemContextMenu(rowElement.instance.itemIndex);}
return true;}
YMListBox.prototype.keydown=function(inEvent)
{var upArrow=false;this.lastClickedScrollbarComponent="";switch(inEvent.keyCode){case 38:upArrow=true;case 40:var nextItem=0;var nextItemData=null;if(upArrow){if(this.selectedItemsCount==0){nextItem=this.getLastSelectableVisibleItemIndex();}else{if(this.selectedItemsCount>1){nextItem=this.lastClickedItem-1;}else{nextItem=this.getSelectedIndexes()[0]-1;}}}else{if(this.selectedItemsCount==0){nextItem=this.getFirstVisibleItemIndex();}else{if(this.selectedItemsCount>1){nextItem=this.lastClickedItem+1;}else{nextItem=this.getSelectedIndexes()[0]+1;}}}
var nextItemData=this.data.getItem(nextItem);if(nextItemData&&nextItemData.selectable){this.lastClickedItem=nextItem;if((upArrow&&nextItem<this.getFirstVisibleItemIndex())||(!upArrow&&nextItem>this.getLastVisibleItemIndex())){this.selectedItems={};this.selectedItems[nextItem]=true;this.selectedItemsCount=1;this.scrollToItem(nextItem);this.onSelectionChanged(this.selectedItemsCount);}else{this.selectItem(nextItem);this.scrollToItem(nextItem);}}
break;case 33:case 34:case 36:case 35:this.doScrollEvent(YMListBox.k.keyCodeScrollMappings[inEvent.keyCode]);break;}}
YMListBox.prototype.selectstart=function(inEvent)
{inEvent.returnValue=false;inEvent.cancelBubble=true;return false;}
YMListBoxRow.k={};YMListBoxRow.k.class_container="YMListBoxRow";YMListBoxRow.k.class_selected="YMListBoxRow-Selected";YMListBoxRow.k.baseTabIndex=100;function YMListBoxRow(inAttributes)
{if(typeof inAttributes=="object"){for(var attribute in inAttributes){this[attribute]=inAttributes[attribute];}}
DestroyableItems.add(this);}
YMListBoxRow.prototype.getElement=function()
{if(this.element==null){this.createElement();}
return this.element;}
YMListBoxRow.prototype.setSelected=function(inSelected)
{if(this.selected==inSelected){return;}
this.selected=inSelected;if(this.element){if(this.selected&&this.element.selectable){addClass(this.element,this.class_selected);}else{removeClass(this.element,this.class_selected);}}}
YMListBoxRow.prototype.setItemData=function(inItemData,inItemIndex)
{this.itemData=inItemData;this.itemIndex=inItemIndex;if(this.element){}
this.updateView();}
YMListBoxRow.prototype.getItemData=function()
{return this.itemData;}
YMListBoxRow.prototype.getItemIndex=function()
{return this.itemIndex;}
YMListBoxRow.prototype.document=document;YMListBoxRow.prototype.element=null;YMListBoxRow.prototype.listBox=null;YMListBoxRow.prototype.itemIndex=0;YMListBoxRow.prototype.rowIndex=0;YMListBoxRow.prototype.selected=false;YMListBoxRow.prototype.tagName="DIV";YMListBoxRow.prototype.class_container=YMListBoxRow.k.class_container;YMListBoxRow.prototype.class_selected=YMListBoxRow.k.class_selected;YMListBoxRow.prototype.createElement=function()
{if(this.document==null){return;}
this.element=this.document.createElement(this.tagName);this.element.instance=this;this.element.selectable=true;this.element.className=this.class_container;this.element.innerHTML=this.getHTML();this.finishElement();this.updateView();}
YMListBoxRow.prototype.getHTML=function()
{return'&nbsp;';}
YMListBoxRow.prototype.finishElement=function()
{}
YMListBoxRow.prototype.updateView=function()
{if(!this.element){return;}
if(!this.itemData){this.element.innerHTML="&nbsp;";this.element.selectable=false;return;}
this.element.selectable=true;this.element.innerHTML=this.itemData;}
YMDataSet.k={};YMDataSet.k.event_NewDataSet="NewDataSet";YMDataSet.k.event_DataChanged="DataChanged";YMDataSet.k.eventTypes=[YMDataSet.k.event_NewDataSet,YMDataSet.k.event_DataChanged];function YMDataSet(inAttributes)
{this.items=[];if(typeof inAttributes=="object"){for(var attribute in inAttributes){this[attribute]=inAttributes[attribute];}}
this.listeners=[];DestroyableItems.add(this);}
YMDataSet.prototype.setItems=function(inItems)
{this.items=inItems;this.notifyNewDataSet();}
YMDataSet.prototype.getLength=function()
{return this.items.length;}
YMDataSet.prototype.getItem=function(inIndex)
{var item=this.items[inIndex];if(!item){item=null;}
return item;}
YMDataSet.prototype.getItemsByAttribute=function(inAttributes)
{if(this.items instanceof Array){return this.items.getItemsByAttribute(inAttributes);}else{return[];}}
YMDataSet.prototype.getIndexesByAttribute=function(inAttributes)
{if(this.items instanceof Array){return this.items.getIndexesByAttribute(inAttributes);}else{return[];}}
YMDataSet.prototype.notifyNewDataSet=function()
{this.notifyListeners({type:YMDataSet.k.event_NewDataSet,source:this});}
YMDataSet.prototype.notifyDataChanged=function()
{this.notifyListeners({type:YMDataSet.k.event_DataChanged,source:this});}
YMDataSet.prototype.addListener=function(inObject,inMethodName,inEventTypes)
{var newListener={object:inObject,methodName:inMethodName};if(inEventTypes&&!(inEventTypes instanceof Array)){inEventTypes=[inEventTypes];}
var eventTypes=inEventTypes||this.eventTypes;for(var i=0;i<eventTypes.length;i++){newListener[eventTypes[i]]=true;}
this.listeners.push(newListener);}
YMDataSet.prototype.removeListener=function(inObject,inMethodName)
{var matchingListeners=this.listeners.getIndexesByAttribute({object:inObject,methodName:inMethodName});for(var i=matchingListeners.length-1;i>=0;i--){this.listeners.removeItem(matchingListeners[i]);}}
YMDataSet.prototype.items=null;YMDataSet.prototype.listeners=null;YMDataSet.prototype.eventTypes=YMDataSet.k.eventTypes;YMDataSet.prototype.notifyListeners=function(inEvent)
{for(var i=0;i<this.listeners.length;i++){var listener=this.listeners[i];if(!listener[inEvent.type]){continue;}
var object=listener.object;var methodName=listener.methodName;if(object&&typeof object[methodName]=="function"){object[methodName](inEvent);}else if(typeof window[methodName]=="function"){window[methodName](inEvent);}}}
YMSlider.k={};YMSlider.k.class_container="YMSlider";YMSlider.k.class_thumb="YMSlider_Thumb";YMSlider.k.class_disabled="Disabled";function YMSlider(inAttributes)
{if(typeof inAttributes=="object"){for(var attribute in inAttributes){this[attribute]=inAttributes[attribute];}}
this.setHorizontal(this.isHorizontal);this.listeners=[];DestroyableItems.add(this);}
YMSlider.prototype.getElement=function()
{if(this.element==null){this.createElement();}
return this.element;}
YMSlider.prototype.addListener=function(inObject,inMethodName,inEventNames)
{var newListener={object:inObject,methodName:inMethodName};if(inEventNames){if(!(inEventNames instanceof Array)){inEventNames=[inEventNames];}
for(var i=0;i<inEventNames.length;i++){newListener[inEventNames[i]]=true;}}else{newListener.ValueChanged=true;newListener.Scroll=true;newListener.ScrollStart=true;newListener.ScrollEnd=true;}
this.listeners.push(newListener);}
YMSlider.prototype.removeListener=function(inObject,inMethodName)
{var matchingListeners=this.listeners.getIndexesByAttribute({object:inObject,methodName:inMethodName});for(var i=matchingListeners.length-1;i>=0;i--){this.listeners.removeItem(matchingListeners[i]);}}
YMSlider.prototype.setRange=function(inRangeStart,inRangeEnd,inNewValue)
{this.rangeStart=inRangeStart;this.rangeEnd=inRangeEnd;this.rangeSteps=this.rangeEnd-this.rangeStart;if(typeof inNewValue!="undefined"){this.setValue(inNewValue);}else{if(this.element&&this.element.parentNode){this.updateMeasurements();if(this.value>=this.rangeStart&&this.value<=this.rangeEnd){this.syncThumbToValue();}else{this.setValue((this.value<this.rangeStart)?this.rangeStart:this.rangeEnd);}}}}
YMSlider.prototype.setValue=function(inValue,inDontNotifyListeners)
{inValue=Math.min(Math.max(this.rangeStart,inValue),this.rangeEnd);if(inValue!=this.value){this.value=inValue;if(this.element&&this.element.parentNode){this.updateMeasurements();if(!inDontNotifyListeners){this.notifyListeners("ValueChanged");}}else{}}}
YMSlider.prototype.getValue=function()
{return this.value;}
YMSlider.prototype.setEnabled=function(inEnabled)
{this.enabled=inEnabled;if(this.enabled){removeClass(this.element,YMSlider.k.class_disabled);}else{addClass(this.element,YMSlider.k.class_disabled);}}
YMSlider.prototype.setHorizontal=function(inHorizontal)
{this.isHorizontal=inHorizontal;if(this.isHorizontal){this.getLocalPosition=this.getLocalX;this.getPagePosition=getPageX;this.stylePixelPosition="pixelLeft";this.styleSize="width";this.stylePosition="left";this.stylePaddingSide="paddingRight";this.offsetSize="offsetWidth";this.offsetPosition="offsetLeft";this.clientSize="clientWidth";}else{this.getLocalPosition=this.getLocalY;this.getPagePosition=getPageY;this.stylePixelPosition="pixelTop";this.styleSize="height";this.stylePosition="top";this.stylePaddingSide="paddingBottom";this.offsetSize="offsetHeight";this.offsetPosition="offsetTop";this.clientSize="clientHeight";}}
YMSlider.prototype.document=document;YMSlider.prototype.element=null;YMSlider.prototype.tagName="DIV";YMSlider.prototype.listeners=null;YMSlider.prototype.enabled=true;YMSlider.prototype.thumb=null;YMSlider.prototype.progressBar=null;YMSlider.prototype.maxThumbTravel=100;YMSlider.prototype.thumbSize=10;YMSlider.prototype.cursorOffset=0;YMSlider.prototype.trackClientPosition=0;YMSlider.prototype.isHorizontal=true;YMSlider.prototype.getPagePosition=getPageX;YMSlider.prototype.stylePixelPosition="pixelLeft";YMSlider.prototype.styleSize="width";YMSlider.prototype.stylePosition="left";YMSlider.prototype.stylePaddingSide="marginRight";YMSlider.prototype.offsetSize="offsetWidth";YMSlider.prototype.offsetPosition="offsetLeft";YMSlider.prototype.clientSize="clientWidth";YMSlider.prototype.value=1;YMSlider.prototype.rangeStart=1;YMSlider.prototype.rangeEnd=10;YMSlider.prototype.rangeSteps=9;YMSlider.prototype.rangeStepSize=1;YMSlider.prototype.class_container=YMSlider.k.class_container;YMSlider.current=null;YMSlider.prototype.createElement=function()
{if(this.document==null){return;}
this.element=this.document.createElement(this.tagName);this.element.instance=this;this.element.className=this.class_container;this.element.innerHTML=this.getHTML();this.thumb=this.element.all.Thumb;this.progressBar=this.element.all.ProgressBar;this.element.onmousedown=dispatchInstanceEvents;this.element.onmouseup=dispatchInstanceEvents;this.finishElement();this.updateView();this.updateMeasurements();}
YMSlider.prototype.getHTML=function()
{var html='<div id="ThumbContainer"><div id="Thumb"></div></div>';return html;}
YMSlider.prototype.finishElement=function()
{}
YMSlider.prototype.updateView=function()
{}
YMSlider.prototype.updateMeasurements=function()
{this.trackClientPosition=this.getPagePosition(this.element.all.ThumbContainer);this.thumbSize=this.thumb[this.offsetSize];this.rangeStepSize=this.maxThumbTravel/this.rangeSteps;this.element.all.ThumbContainer.parentNode.style[this.stylePaddingSide]=this.thumbSize+"px";this.maxThumbTravel=this.element.all.ThumbContainer[this.offsetSize]||1;this.syncThumbToValue();this.fractionalPosition=this.thumb.style[this.stylePixelPosition];}
YMSlider.prototype.getLocalX=function(inEvent)
{return inEvent.clientX-this.trackClientPosition;}
YMSlider.prototype.getLocalY=function(inEvent)
{return inEvent.clientY-this.trackClientPosition;}
YMSlider.prototype.getLocalPosition=YMSlider.prototype.getLocalX;YMSlider.prototype.incrementThumb=function(inFractionalStep)
{this.fractionalPosition+=inFractionalStep*this.rangeStepSize;this.moveThumbTo(this.fractionalPosition);}
YMSlider.prototype.syncThumbToValue=function()
{this.moveThumbTo(((this.value-this.rangeStart)/this.rangeSteps)*this.maxThumbTravel);}
YMSlider.prototype.moveThumbTo=function(inLocation)
{if(this.maxThumbTravel>0){var percentagePosition=Math.min(Math.max(0,inLocation/this.maxThumbTravel),1);}else{var percentagePosition=0;}
this.thumb.style[this.stylePosition]=percentagePosition*100+"%";if(this.progressBar){if(percentagePosition==0){hide(this.progressBar);}else{this.progressBar.style[this.styleSize]=percentagePosition*100+"%";show(this.progressBar);}}
var newValue=Math.round(percentagePosition*this.rangeSteps)+this.rangeStart;newValue=Math.min(Math.max(this.rangeStart,newValue),this.rangeEnd);if(newValue!=this.value){this.value=newValue;this.notifyListeners("Scroll");}}
YMSlider.prototype.startDrag=function(inEvent)
{this.updateMeasurements();var thumb=getParent(inEvent.srcElement,{id:"Thumb"},true);if(thumb==null){this.cursorOffset=(-this.thumb[this.offsetSize]/2);this.moveThumbTo(this.getLocalPosition(inEvent)+this.cursorOffset);}else{this.cursorOffset=this.thumb[this.offsetPosition]-this.getLocalPosition(inEvent);}
YMSlider.current=this;this.mousemove=this.doDrag;this.mouseup=this.stopDrag;this.element.attachEvent("onmousemove",YMSlider.handleDrag);this.element.attachEvent("onmouseup",YMSlider.handleDrag);this.element.setCapture(true);this.notifyListeners("ScrollStart");}
YMSlider.prototype.doDrag=function(inEvent)
{this.moveThumbTo(this.getLocalPosition(inEvent)+this.cursorOffset);this.fractionalPosition=this.thumb.style[this.stylePixelPosition];}
YMSlider.prototype.stopDrag=function(inEvent)
{this.mousemove=null;this.mouseup=null;this.element.detachEvent("onmousemove",YMSlider.handleDrag);this.element.detachEvent("onmouseup",YMSlider.handleDrag);this.element.releaseCapture();this.notifyListeners("ScrollEnd");}
YMSlider.handleDrag=function(inEvent)
{inEvent=inEvent||this.document.parentWindow.event;if(!YMSlider.current){return;}
switch(inEvent.type){case"mousemove":YMSlider.current.doDrag(inEvent);break;case"mouseup":YMSlider.current.stopDrag(inEvent);break;}}
YMSlider.handleEvent=function(inEvent)
{inEvent=inEvent||this.document.parentWindow.event;if(!this.instance.enabled){return true;}
if(this.instance[inEvent.type]){return this.instance[inEvent.type](inEvent);}}
YMSlider.prototype.mousedown=function(inEvent)
{if(!this.enabled){return;}
this.startDrag(inEvent);inEvent.cancelBubble=true;return true;}
YMSlider.prototype.notifyListeners=function(inEventName)
{for(var i=0;i<this.listeners.length;i++){var listener=this.listeners[i];if(!listener[inEventName]){continue;}
var object=listener.object;var methodName=listener.methodName;if(object&&typeof object[methodName]=="function"){object[methodName](this.value,this,inEventName);}else if(typeof window[methodName]=="function"){window[methodName](this.value,this,inEventName);}}}
YMTooltip.k={};YMTooltip.k.cssPath="YMTooltip.css";YMTooltip.k.offsetFromCursorX=0;YMTooltip.k.offsetFromCursorY=20;YMTooltip.k.preContent='<div id="Content">';YMTooltip.k.postContent='</div>';function YMTooltip(inAttributes)
{if(typeof inAttributes=="object"){for(var attribute in inAttributes){this[attribute]=inAttributes[attribute];}}
this.document=this.document||document;if(this.preCacheCSS){this.createPopup();this.show(this.document.body,this.defaultHTML,null,100,100);this.hide();}
DestroyableItems.add(this);}
YMTooltip.prototype.destroy=function()
{try{if(this.popup){this.popup.document.body.onload=null;this.popup.document.body.onunload=null;}}catch(exception){}
DestroyableItems.clearObjectReferences(this);}
YMTooltip.prototype.show=function(inElement,inHTML,inEvent,inWidth,inHeight)
{if(!this.popup){this.createPopup();}
if(this.popup.isOpen){}
var popupBody=this.popup.document.body;inHTML=inHTML||this.defaultHTML;if(inHTML){popupBody.innerHTML=this.preContent+inHTML+this.postContent;}
if(inWidth==0||inHeight==0){this.popup.show(0,0,inWidth,inHeight,inElement);inWidth=inWidth||this.popup.document.all.Content.offsetWidth;inHeight=inHeight||this.popup.document.all.Content.offsetHeight;}
var screenW=window.screen.width;var screenH=window.screen.height;var deltaX=0;var deltaY=0;if(inElement){var targetX=getScreenX(inElement)+this.offsetX;var targetY=getScreenY(inElement)+this.offsetY;var offsetX=this.offsetX;var offsetY=this.offsetY;if(targetX>screenW){deltaX=screenW-inWidth-targetX;}else if(targetX<0){offsetX=inElement.offsetWidth+10;}
this.popup.show(offsetX+deltaX,offsetY,inWidth,inHeight,inElement);}else{var targetX=inEvent.screenX+this.offsetX;var targetY=inEvent.screenY+this.offsetY;if(targetX+inWidth>screenW){deltaX=screenW-inWidth-targetX;}
if(targetY+inHeight>screenH){deltaY=screenH-inHeight-targetY;}
this.popup.show(targetX+deltaX,targetY+deltaY,inWidth,inHeight);}}
YMTooltip.prototype.hide=function()
{if(this.popup){this.popup.hide();}}
YMTooltip.prototype.isOpen=function()
{return(this.popup&&this.popup.isOpen);}
YMTooltip.prototype.document=null;YMTooltip.prototype.popup=null;YMTooltip.prototype.offsetX=YMTooltip.k.offsetFromCursorX;YMTooltip.prototype.offsetY=YMTooltip.k.offsetFromCursorY;YMTooltip.prototype.preContent=YMTooltip.k.preContent;YMTooltip.prototype.postContent=YMTooltip.k.postContent;YMTooltip.prototype.cssPath=YMTooltip.k.cssPath;YMTooltip.prototype.onPopupShown=null;YMTooltip.prototype.onPopupHidden=null;YMTooltip.prototype.preCacheCSS=false;YMTooltip.prototype.defaultHTML="&nbsp;";YMTooltip.prototype.createPopup=function()
{if(this.popup){return;}
this.popup=window.createPopup();this.popup.document.instance=this;var tooltip=this;this.popup.document.body.onload=function(){if(tooltip.onPopupShown){tooltip.onPopupShown();}};this.popup.document.body.onunload=function(){if(tooltip.onPopupHidden){tooltip.onPopupHidden();}};this.popup.document.createStyleSheet(this.cssPath);}
CLVMPlayer.k={};CLVMPlayer.k.class_container="CLVMPlayer";CLVMPlayer.k.class_selected="CLVMPlayer_Selected";CLVMPlayer.k.class_highlighted="CLVMPlayer_Highlighted";CLVMPlayer.k.class_disabled="Disabled";CLVMPlayer.k.class_buffering="Buffering";CLVMPlayer.k.skipAmount=7000;CLVMPlayer.k.listenedLength=6000;CLVMPlayer.k.bufferingDelay=400;CLVMPlayer.k.volumePopup_CSSPath="CLVolumePopupStyles.css";CLVMPlayer.k.volumePopup_HTML='<div id="VolumeSliderContainer"></div>';CLVMPlayer.k.volumePopup_width=35;CLVMPlayer.k.volumePopup_height=130;CLVMPlayer.k.maxVolume=100;CLVMPlayer.k.volumeStepSize=5;function CLVMPlayer(inAttributes)
{if(typeof inAttributes=="object"){for(var attribute in inAttributes){this[attribute]=inAttributes[attribute];}}
CLVMPlayer.currentPlayer=this;window.clOnVMActionDone=CLVMPlayer.handleVMActionDone;window.clOnGetVolume=CLVMPlayer.handleGetVolume;DestroyableItems.add(this);}
CLVMPlayer.prototype.destroy=function()
{this.setItemData(this.itemView,null);DestroyableItems.clearObjectReferences(this);}
CLVMPlayer.prototype.getElement=function()
{if(this.element==null){this.createElement();}
return this.element;}
CLVMPlayer.prototype.setItemData=function(inItemData)
{this.stop();this.itemData=inItemData;this.setEnabled(inItemData!=null);this.updateView();}
CLVMPlayer.prototype.play=function()
{if(!this.itemData||!this.enabled||this.isPlaying){return;}
this.startBufferingTimer();this.doVMAction("Play",this.slider.value);}
CLVMPlayer.prototype.pause=function()
{if(!this.itemData||!this.enabled||!this.isPlaying){return;}
this.doVMAction("Pause");}
CLVMPlayer.prototype.stop=function()
{if(!this.itemData||!this.enabled||!this.isPlaying){return;}
this.doVMAction("Stop");}
CLVMPlayer.prototype.togglePlayPause=function()
{if(!this.itemData||!this.enabled){return;}
if(this.isPlaying){this.pause();}else{this.play();}}
CLVMPlayer.prototype.skip=function(inSkipAmount)
{if(!this.itemData||!this.enabled){return;}
this.slider.setValue(this.slider.getValue()+inSkipAmount);this.setPlayPosition(this.slider.getValue());}
CLVMPlayer.prototype.setPlayPosition=function(inPosition)
{if(!this.itemData||!this.enabled){return;}
inPosition=clipToRange(0,inPosition,this.itemData.D);if(!this.isPlaying){this.startBufferingTimer();}
this.doVMAction("Play",inPosition);}
CLVMPlayer.prototype.setEnabled=function(inEnabled)
{if(inEnabled==this.enabled||!this.element){return;}
this.enabled=inEnabled;this.slider.setEnabled(this.enabled);this.element.all.PlayPauseButton.enabled=this.element.all.BackButton.enabled=this.element.all.ForwardButton.enabled=this.element.all.VolumeButton.enabled=this.enabled;if(this.enabled){removeClass(this.element,CLVMPlayer.k.class_disabled);}else{addClass(this.element,CLVMPlayer.k.class_disabled);this.isSliderScrolling=false;this.setIsPlaying(false);this.setIsBuffering(false);}}
CLVMPlayer.handleVMActionDone=function(inAction,inID,inValue,inStatus,inReason)
{if(CLVMPlayer.currentPlayer){CLVMPlayer.currentPlayer.onVMActionDone(inAction,inID,inValue,inStatus,inReason);}}
CLVMPlayer.handleBufferingTimer=function()
{if(CLVMPlayer.currentPlayer){CLVMPlayer.currentPlayer.setIsBuffering(true);}}
CLVMPlayer.handleGetVolume=function(inVolume)
{var player=CLVMPlayer.currentPlayer;if(player){player.updateVolumeButton(inVolume);if(player.volumeSlider){player.volumeSlider.setValue((CLVMPlayer.k.maxVolume-inVolume)/CLVMPlayer.k.volumeStepSize,true);}}}
CLVMPlayer.prototype.document=document;CLVMPlayer.prototype.element=null;CLVMPlayer.prototype.slider=null;CLVMPlayer.prototype.volumePopup=null;CLVMPlayer.prototype.volumeSlider=null;CLVMPlayer.prototype.itemView=null;CLVMPlayer.prototype.itemData=null;CLVMPlayer.prototype.enabled=false;CLVMPlayer.prototype.isPlaying=false;CLVMPlayer.prototype.isSliderScrolling=false;CLVMPlayer.prototype.isBuffering=false;CLVMPlayer.prototype.bufferingTimer=null;CLVMPlayer.prototype.strings=null;CLVMPlayer.prototype.data=null;CLVMPlayer.currentPlayer=null;CLVMPlayer.prototype.createElement=function()
{if(this.document==null){return;}
this.element=this.document.createElement("DIV");this.element.instance=this;this.element.className=CLVMPlayer.k.class_container;this.element.innerHTML=this.getHTML();this.slider=new YMSlider();this.slider.getHTML=function()
{var html='\
   <div id="ThumbTrack">\
    <div id="ThumbContainer">\
     <div id="ProgressBar"><div id="ProgressBarRightEdge"></div></div>\
     <div id="Thumb" class="SliderThumb"></div>\
    </div>\
   </div>\
   <img id="LeftEdge" src="images/vm-slider-left.gif">\
   <img id="RightEdge" src="images/vm-slider-right.gif">\
  ';return html;};var playButton=this.element.all.PlayPauseButton;playButton.playTooltip=this.strings.get("PlayButtonTooltip");playButton.pauseTooltip=this.strings.get("PauseButtonTooltip");playButton.title=playButton.playTooltip;this.element.all.BackButton.title=this.strings.get("BackButtonTooltip");this.element.all.ForwardButton.title=this.strings.get("ForwardButtonTooltip");this.element.all.VolumeButton.title=this.strings.get("VolumeButtonTooltip");this.element.all.SliderContainer.appendChild(this.slider.getElement());this.slider.element.title=this.strings.get("SliderTooltip");this.slider.addListener(this,"onSliderChanged",["ScrollStart","ScrollEnd","Scroll"]);this.volumePopup=new YMTooltip({cssPath:CLVMPlayer.k.volumePopup_CSSPath,offsetY:IMButton.offsetHeight,preCacheCSS:true,defaultHTML:CLVMPlayer.k.volumePopup_HTML});this.volumePopup.defaultHTML=null;this.volumePopup.popup.document.body.onselectstart=document.body.onselectstart;this.volumeSlider=new YMSlider({document:this.volumePopup.popup.document,isHorizontal:false,getHTML:function()
{var html='\
    <div id="ThumbTrack">\
     <div id="ThumbContainer">\
      <div id="Thumb" class="SliderThumb"></div>\
     </div>\
    </div>\
    <img id="LeftEdge" src="images/vol-slider-top.gif">\
   ';return html;}});this.volumeSlider.setRange(0,CLVMPlayer.k.maxVolume/CLVMPlayer.k.volumeStepSize);this.volumePopup.popup.document.all.VolumeSliderContainer.appendChild(this.volumeSlider.getElement());this.volumeSlider.addListener(this,"onVolumeSliderChanged",["ScrollEnd","Scroll"]);this.element.onclick=dispatchInstanceEvents;this.element.ondblclick=dispatchInstanceEvents;var enabled=this.enabled;this.enabled=null;this.setEnabled(enabled);this.updateView();}
CLVMPlayer.prototype.getHTML=function()
{var html='\
  <table cellspacing="0" cellpadding="0">\
   <tr>\
    <td id="Controls">\
     <nobr>\
     <span id="PlayPauseButton" class="PlayPauseButton" enabled="false"></span>\
     <span id="BackButton" class="SkipButton" enabled="false"></span>\
     <span id="ForwardButton" class="SkipButton" enabled="false"></span>\
     </nobr>\
    </td>\
    <td id="CurrentTime"></td>\
    <td id="SliderContainer"></td>\
    <td id="Duration"></td>\
    <td id="PlayerVolume">\
     <span id="VolumeButton" \
      class="ToolbarButton" \
      enabled="true"\
     ><img src="images/cl-tb-volume-0.gif"></span>\
    </td>\
   </tr>\
  </table>\
 ';return html;}
CLVMPlayer.prototype.updateView=function()
{if(!this.element){return;}
if(!this.itemData){this.element.all.CurrentTime.innerText="";this.element.all.Duration.innerText="";return;}
var duration=this.itemData.D;this.updateCurrentTime(0);this.element.all.Duration.innerText=formatHMSFromSeconds(Math.round(this.itemData.D/1000));this.slider.setRange(0,duration,0);}
CLVMPlayer.prototype.updateCurrentTime=function(inMilliseconds)
{this.element.all.CurrentTime.innerText=formatHMSFromSeconds(Math.round(inMilliseconds/1000));}
CLVMPlayer.prototype.setIsPlaying=function(inIsPlaying)
{if(this.isPlaying!=inIsPlaying){this.isPlaying=inIsPlaying;var playButton=this.element.all.PlayPauseButton;playButton.isPlaying=this.isPlaying;playButton.title=(this.isPlaying?playButton.pauseTooltip:playButton.playTooltip);if(this.isPlaying){this.setIsBuffering(false);}}}
CLVMPlayer.prototype.startBufferingTimer=function()
{this.stopBufferingTimer();this.bufferingTimer=window.setTimeout(CLVMPlayer.handleBufferingTimer,CLVMPlayer.k.bufferingDelay);}
CLVMPlayer.prototype.stopBufferingTimer=function()
{window.clearTimeout(this.bufferingTimer);this.bufferingTimer=null;}
CLVMPlayer.prototype.setIsBuffering=function(inIsBuffering)
{if(!this.element){return;}
this.isBuffering=inIsBuffering;if(this.isBuffering){addClass(this.slider.getElement(),CLVMPlayer.k.class_buffering);}else{this.stopBufferingTimer();removeClass(this.slider.getElement(),CLVMPlayer.k.class_buffering);}}
CLVMPlayer.prototype.onSliderChanged=function(inValue,inSlider,inEvent)
{if(!this.itemData){this.isSliderScrolling=false;return;}
switch(inEvent){case"ScrollStart":this.isSliderScrolling=true;break;case"Scroll":this.updateCurrentTime(inValue);break;case"ScrollEnd":this.isSliderScrolling=false;this.setPlayPosition(inValue);break;}}
CLVMPlayer.prototype.doVMAction=function(inAction,inParameter)
{inParameter=inParameter||0;if(gMessenger){gMessenger.clDoVMAction(this.itemData.id,inAction,inParameter);}}
CLVMPlayer.prototype.onVMActionDone=function(inID,inAction,inValue,inStatus,inReason)
{if(!this.itemData||inID!=this.itemData.id){}
if(!this.enabled){return;}
if(this["onVMAction"+inAction]){this["onVMAction"+inAction](inID,inValue,inStatus,inReason);}}
CLVMPlayer.prototype.clOnVMActionError=function(inID,inAction,inValue)
{alert(inAction+" error");}
CLVMPlayer.prototype.onVMActionPlay=function(inID,inValue,inStatus,inReason)
{this.setIsPlaying(true);if(!this.isSliderScrolling){this.slider.setValue(inValue);this.updateCurrentTime(inValue);}
if(this.itemData.id!=inID){return;}
if(this.itemData.L==0&&(inValue>CLVMPlayer.k.listenedLength||inValue>=this.itemData.D)){this.doVMAction("Update_Listen",1);}}
CLVMPlayer.prototype.onVMActionPause=function(inID,inValue,inStatus,inReason)
{this.setIsPlaying(false);this.isSliderScrolling=false;}
CLVMPlayer.prototype.onVMActionStop=function(inID,inValue,inStatus,inReason)
{this.setIsPlaying(false);this.isSliderScrolling=false;this.slider.setValue(0);this.updateCurrentTime(0);}
CLVMPlayer.prototype.onVMActionUpdate_Listen=function(inID,inValue,inStatus,inReason)
{if(inStatus=="Okay"){this.data.notifyDataChanged();if(this.itemData){this.itemData=this.data.getItem(this.itemData.index);}}}
CLVMPlayer.prototype.onVolumeSliderChanged=function(inValue,inSlider,inEvent)
{switch(inEvent){case"Scroll":case"ScrollEnd":if(gMessenger&&typeof gMessenger.clSetVolume!="undefined"){gMessenger.clSetVolume(CLVMPlayer.k.maxVolume-(inValue*CLVMPlayer.k.volumeStepSize));}
this.updateVolumeButton(CLVMPlayer.k.maxVolume-(inValue*CLVMPlayer.k.volumeStepSize));break;}}
CLVMPlayer.prototype.updateVolumeButton=function(inVolume)
{if(this.element){var icon=this.element.all.VolumeButton.firstChild;if(inVolume==0){icon.src="images/cl-tb-volume-0.gif";}else{icon.src="images/cl-tb-volume-"+(Math.floor(inVolume/52)+1)+".gif";}}}
CLVMPlayer.prototype.showVolumePopup=function()
{if(this.volumePopup){this.volumePopup.show(this.element.all.VolumeButton,null,null,CLVMPlayer.k.volumePopup_width,CLVMPlayer.k.volumePopup_height);this.volumeSlider.updateMeasurements();}}
CLVMPlayer.prototype.hideVolumePopup=function()
{if(this.volumePopup){this.volumePopup.hide();}}
CLVMPlayer.prototype.click=function(inEvent)
{if(!this.itemData||!this.enabled){return;}
var button=getParent(inEvent.srcElement,{tagName:"SPAN"},true);if(!button){return;}
switch(button.id){case"PlayPauseButton":this.togglePlayPause();break;case"ForwardButton":this.skip(CLVMPlayer.k.skipAmount);break;case"BackButton":this.skip(-CLVMPlayer.k.skipAmount);break;case"VolumeButton":if(gMessenger&&typeof gMessenger.clGetVolume!="undefined"){gMessenger.clGetVolume();}
this.showVolumePopup();break;}}
CLVMPlayer.prototype.dblclick=function(inEvent)
{if(!this.itemData||!this.enabled){return;}
switch(inEvent.srcElement.id){case"ForwardButton":this.skip(CLVMPlayer.k.skipAmount);break;case"BackButton":this.skip(-CLVMPlayer.k.skipAmount);break;}}
CLItemView.k={};CLItemView.k.class_container="CLItemView";CLItemView.k.class_selected="CLItemView_Selected";CLItemView.k.class_highlighted="CLItemView_Highlighted";CLItemView.k.class_unplayedVM="CLItemView_UnplayedVM";CLItemView.k.typeIconBaseName="images/cl-type-icon-";CLItemView.k.typeIconExt=".gif";function CLItemView()
{this.constructor.apply(this,arguments);}
CLItemView.prototype=new YMListBoxRow();CLItemView.prototype.itemData=null;CLItemView.prototype.class_container=CLItemView.k.class_container;CLItemView.prototype.class_selected=CLItemView.k.class_selected;CLItemView.prototype.createElement=function()
{if(this.document==null){return;}
this.element=this.document.createElement("TR");this.element.instance=this;this.element.selectable=true;this.element.className=this.class_container;var cell=this.document.createElement("TD");cell.id="TypeIconCell";cell.innerHTML='<img id="TypeIcon" src="">';this.element.appendChild(cell);cell=this.document.createElement("TD");cell.innerHTML='<nobr><span id="ContactName"></span><span id="PSTN"></span></nobr>';this.element.appendChild(cell);cell=this.document.createElement("TD");cell.id="Duration";this.element.appendChild(cell);cell=this.document.createElement("TD");cell.id="DateTime";this.element.appendChild(cell);this.finishElement();this.updateView();}
CLItemView.prototype.updateView=function()
{if(!this.element){return;}
if(!this.itemData||this.itemData.inlineMessage){this.element.all.TypeIcon.style.visibility="hidden";this.element.all.DateTime.innerHTML="";this.element.all.PSTN.innerHTML="";this.element.all.Duration.innerHTML="&nbsp;"
removeClass(this.element,CLItemView.k.class_unplayedVM);this.element.selectable=false;this.element.hideFocus=true;if(this.itemData&&this.itemData.inlineMessage){this.element.all.ContactName.innerHTML=this.itemData.inlineMessage;}else{this.element.all.ContactName.innerHTML="";}
return;}
this.element.selectable=true;if((this.isVM()&&!this.isPlayed())||this.itemData.missed){addClass(this.element,CLItemView.k.class_unplayedVM);}else{removeClass(this.element,CLItemView.k.class_unplayedVM);}
this.element.all.TypeIcon.src=CLItemView.k.typeIconBaseName+this.itemData.TE+
CLItemView.k.typeIconExt;this.element.all.TypeIcon.style.visibility="visible";this.element.all.TypeIcon.title=this.listBox.strings.get(this.itemData.TE+"Tooltip");this.element.all.ContactName.innerHTML=this.itemData.prettyName;var pstnString="";if(this.itemData.DID&&(this.itemData.PSTN||(this.itemData.PSTN==""&&this.itemData.YID==""))){this.element.all.ContactName.title=this.element.all.PSTN.title=this.listBox.strings.get("PSTNTooltip",this.itemData.DID);}else{this.element.all.ContactName.title=this.element.all.PSTN.title="";}
if(this.itemData.PSTN){if(this.itemData.PSTN!=this.itemData.prettyName){pstnString=this.itemData.ABTEL||this.itemData.PSTN;if(this.itemData.PSTNType){pstnString+=" "+this.listBox.strings.get("Type"+this.itemData.PSTNType);}}}
this.element.all.PSTN.innerHTML=pstnString;this.element.all.DateTime.innerHTML="<nobr>"+this.itemData.TD+"</nobr>";if(this.itemData.TE!="Missed"&&this.itemData.D){if(this.isVM()){this.element.all.Duration.innerHTML=formatHMSFromSeconds(Math.round(this.itemData.D/1000));}else{this.element.all.Duration.innerHTML=formatHMSFromSeconds(this.itemData.D);}}else{this.element.all.Duration.innerHTML="&nbsp;"}}
CLItemView.prototype.isVM=function()
{if(!this.itemData){return false;}
return(this.itemData.TE=="VoiceMail");}
CLItemView.prototype.isPlayed=function()
{if(!this.itemData){return true;}
return(this.itemData.L==1);}
CLItemList.k={};CLItemList.k.class_container="CLItemList";CLItemList.k.class_vmPlayer="CLVMPLayer";CLItemList.k.path_addIMIcon="images/cl-tb-add.gif";CLItemList.k.path_addPSTNIcon="images/cl-tb-add-pstn.gif";CLItemList.k.firstVMYID="ymessenger_with_voice";function CLItemList(inAttributes)
{this.constructor.apply(this,arguments);}
CLItemList.prototype=new YMListBox();CLItemList.prototype.setData=function(inDataSet)
{this.constructor.prototype.setData.apply(this,arguments);if(this.vmPlayer){this.vmPlayer.data=this.data;}}
CLItemList.prototype.showVMPlayer=function(inItemIndex)
{var itemData=this.data.getItem(inItemIndex);if(this.selectedItemsCount==1&&itemData&&itemData.TE=="VoiceMail"){this.vmPlayer.setItemData(itemData);}else{this.hideVMPlayer();}}
CLItemList.prototype.hideVMPlayer=function()
{this.vmPlayer.setItemData(null);}
CLItemList.prototype.selectItem=function(inItemIndex,inMultiSelect)
{if(inItemIndex<0||inItemIndex>=this.data.getLength()){return;}
var item=this.data.getItem(inItemIndex);if(!item||!item.selectable){this.unselectAll();return;}
this.constructor.prototype.selectItem.apply(this,arguments);}
CLItemList.prototype.selectAll=function()
{var itemCount=this.data.getLength();var rowsToSelect=Math.min(this.rows.length,itemCount);for(var i=0;i<rowsToSelect;i++){if(this.rows[i].element.selectable){this.rows[i].setSelected(true);}}
for(var i=0;i<itemCount;i++){if(this.data.getItem(i).selectable){this.selectedItems[i]=true;}}
this.selectedItemsCount=itemCount;this.onSelectionChanged(this.selectedItemsCount);}
CLItemList.prototype.doScrollEvent=function(inScrollEvent)
{if(!this.element){return;}
this.constructor.prototype.doScrollEvent.apply(this,arguments);if(this.getSelectedIndexes().length==0){this.selectItem(this.getLastVisibleItemIndex()-1);}}
CLItemList.prototype.class_container=CLItemList.k.class_container;CLItemList.prototype.vmPlayer=null;CLItemList.prototype.strings=null;CLItemList.prototype.rowConstructor=CLItemView;CLItemList.prototype.getHTML=function()
{var html='\
  <div id="TableContainer">\
   <table cellpadding="0" cellspacing="0"><tbody id="RowContainer"></tbody></table>\
  </div>\
  <div id="ShowWaitMsg"></div>\
 ';return html;}
CLItemList.prototype.finishElement=function()
{this.element.all.TableContainer.style.paddingRight=this.scrollbarWidth+"px";this.element.hideFocus=true;this.vmPlayer=new CLVMPlayer({strings:this.strings,data:this.data});var vmPlayerElement=this.vmPlayer.getElement();window.setTimeout(function(){VMPlayerContainer.appendChild(vmPlayerElement);},0);}
CLItemList.prototype.onSelectionChanged=function(inSelectedItemsCount)
{if(inSelectedItemsCount==1){DeleteButton.enabled=true;var itemIndex=this.getSelectedIndexes()[0];var itemData=this.data.getItem(itemIndex);if(itemData&&itemData.TE=="VoiceMail"){this.showVMPlayer(itemIndex);}else{this.hideVMPlayer(itemIndex);}
if(itemData.PSTN){CallButton.title=this.strings.get("CallPSTNButtonTooltip",itemData.ABTEL||itemData.PSTN);CallButton.enabled=true;IgnoreButton.title="";IgnoreButton.enabled=false;AddButton.firstChild.src=CLItemList.k.path_addPSTNIcon;if(itemData.DBID){AddButton.title="";AddButton.enabled=false;}else{AddButton.title=this.strings.get("SaveNumberButtonTooltip",itemData.PSTN);AddButton.enabled=true;}}else{CallButton.enabled=false;CallButton.title="";AddButton.title="";AddButton.enabled=false;}
if(itemData.YID&&itemData.YID!=CLItemList.k.firstVMYID){if(!itemData.PSTN){CallButton.title=this.strings.get("CallButtonTooltip",itemData.prettyName);}
CallButton.enabled=true;IMButton.title=this.strings.get("IMButtonTooltip",itemData.YID);IMButton.enabled=true;AddButton.firstChild.src=CLItemList.k.path_addIMIcon;if(isBuddy(itemData.YID)){AddButton.title="";AddButton.enabled=false;IgnoreButton.title="";IgnoreButton.enabled=false;}else{AddButton.title=this.strings.get("AddButtonTooltip",itemData.YID);AddButton.enabled=true;IgnoreButton.title=this.strings.get("IgnoreButtonTooltip",itemData.YID);IgnoreButton.enabled=true;}}else{IMButton.title="";IMButton.enabled=false;IgnoreButton.title="";IgnoreButton.enabled=false;if(itemData.PSTN&&itemData.DBID){AddButton.title="";AddButton.enabled=false;}}}else{if(inSelectedItemsCount==0){DeleteButton.enabled=false;}else{DeleteButton.enabled=true;}
CallButton.enabled=false;IMButton.enabled=false;AddButton.title="";AddButton.enabled=false;IgnoreButton.enabled=false;IgnoreButton.title="";this.hideVMPlayer(null,null);}}
CLItemList.prototype.onItemClick=function(inItemIndex)
{var itemData=this.data.getItem(inItemIndex);if(itemData&&itemData.TE=="VoiceMail"){if(this.vmPlayer.isPlaying){this.vmPlayer.pause();}else{this.vmPlayer.play();}}}
CLItemList.prototype.onItemDblClick=function(inItemIndex)
{var itemData=this.data.getItem(inItemIndex);if(itemData&&itemData.TE!="VoiceMail"){if(itemData.PSTN){callPSTN(itemData.PSTN,itemData.DID,itemData.DBID);}else{callID(itemData.YID);}}}
function CLDataSet(inAttributes)
{this.constructor.apply(this,arguments);this.cachedItems=[];this.showAllItem={inlineMessage:'<div class="ShowAllLink" onclick="showAllItems();">%1</div>'.replaceTokens(this.strings.get("ShowAllLink")),selectable:false};}
CLDataSet.prototype=new YMDataSet();CLDataSet.prototype.setItems=function(inItems)
{this.cachedItems=[];this.constructor.prototype.setItems.apply(this,arguments);}
CLDataSet.prototype.getItem=function(inIndex)
{if(inIndex<0){return null;}
if(this.cachedItems[inIndex]){return this.cachedItems[inIndex];}
var item=this.items[inIndex];if(!item){item=null;if(gFilters.length&&inIndex==this.items.length){item=this.showAllItem;}}else{var yid=item.getAttribute("OPID");var dbid=item.getAttribute("DBID");var pstn=item.getAttribute("PSTNRef");item={index:inIndex,id:item.getAttribute("id"),DBID:dbid,YID:yid,PSTN:pstn,DID:item.getAttribute("DIDRef"),TE:item.getAttribute("TE"),TD:item.getAttribute("TD"),TD2:item.getAttribute("TD2"),D:parseInt(item.getAttribute("D")),L:parseInt(item.getAttribute("L")),missed:parseInt(item.getAttribute(kMissedCallAttribute)),prettyName:yid,selectable:true};var caller=gCallers.getByItemData(item);if(caller){item.prettyName=caller.prettyName;if(pstn&&caller.phoneNumbers&&caller.phoneNumbers[pstn]){item.ABTEL=caller.phoneNumbers[pstn].ABTEL;item.PSTNType=caller.phoneNumbers[pstn].Type;item.YID=caller.YID;item.prettyName=item.prettyName||yid||item.ABTEL||pstn;}}else if(item.PSTN==""&&item.YID==""){item.prettyName=this.strings.get("FilterUnknownCaller");}}
this.cachedItems[inIndex]=item;return item;};CLDataSet.prototype.getLength=function()
{var length=this.items.length;if(gFilters.length){length++;}
return length;};CLDataSet.prototype.getDataLength=function()
{return this.items.length;};CLDataSet.prototype.getIndexesByAttribute=function(inAttributes)
{var itemArray=[];for(var i=0;i<this.items.length;i++){itemArray.push(this.getItem(i));}
return itemArray.getIndexesByAttribute(inAttributes);}
CLDataSet.prototype.notifyNewDataSet=function()
{this.cachedItems=[];this.constructor.prototype.notifyNewDataSet.apply(this,arguments);}
CLDataSet.prototype.notifyDataChanged=function()
{this.cachedItems=[];this.constructor.prototype.notifyDataChanged.apply(this,arguments);}
CLDataSet.prototype.strings=null;CLDataSet.prototype.showAllItem=null;CLDataSet.prototype.cachedItems=null;CLSelectList.k={};CLSelectList.k.class_container="CLSelectList";CLSelectList.k.minItemCount=6;function CLSelectList(inAttributes)
{this.constructor.apply(this,arguments);}
CLSelectList.prototype=new YMGroupList();CLSelectList.prototype.selectItem=function(inItem)
{this.constructor.prototype.selectItem.apply(this,[inItem,false]);}
CLSelectList.prototype.resetList=function()
{for(var i=this.items.length-1;i>=CLSelectList.k.minItemCount;i--){this.removeItem(this.items[i]);}
this.lastClickedItem=null;}
CLSelectList.prototype.class_container=CLSelectList.k.class_container;CLSelectList.prototype.lastSelectedItem=null;CLSelectList.prototype.onSelectionChanged=function(inSelectedItems)
{var item=inSelectedItems[0];if(item){if(item!=this.lastSelectedItem){this.lastSelectedItem=item;onFilterSelected(item.index,item.value,item.YID);}}else{this.lastSelectedItem=null;}}
CLSelectList.prototype.mousedown=function(inEvent)
{if(this.items.length==0){return;}
var itemElement=getParent(inEvent.srcElement,{selectable:true},true);if(itemElement){this.constructor.prototype.mousedown.apply(this,arguments);}}
CLSelectListItem.k={};CLSelectListItem.k.class_container="CLSelectListItem";CLSelectListItem.k.class_selected="CLSelectListItem_Selected";CLSelectListItem.k.class_highlighted="CLSelectListItem_Highlighted";function CLSelectListItem()
{this.constructor.apply(this,arguments);}
CLSelectListItem.prototype=new YMGroupListItem();CLSelectListItem.prototype.value="";CLSelectListItem.prototype.label="";CLSelectListItem.prototype.class_container=CLSelectListItem.k.class_container;CLSelectListItem.prototype.class_selected=CLSelectListItem.k.class_selected;CLSelectListItem.prototype.getHTML=function()
{var html='\
  <nobr id="Label"></nobr>\
 ';return html;}
CLSelectListItem.prototype.finishElement=function()
{this.element.all.Label.innerHTML=this.label;}
var kVMCountWarningTrigger=.75;var kStringXMLPath="CLStrings.xml";var kToolbarButtonIDs=["CallButton","IMButton","DeleteButton"];var kOpenedReason_Normal=0;var kOpenedReason_Missed=1;var kOpenedReason_ForContact=2;var kMissedCallAttribute="missed";var kLeftPanePadding=40;var kLeftPaneMaxWidth=220;log.enabled=false;LogWindow.dialogPath="../Log/";var gStrings=null;var gItemData=null;var gItemDataSet=null;var gCallerData=null;var gOpenedReason=kOpenedReason_Normal;var gLocalePNFlag=0;var gTotalVMCount=0;var gUnplayedVMCount=0;var gItemList=null;var gFilterList=null;var gFilters=[];var gDefaultOPID="";var gOnDataReadyDone=false;var gMessenger=gMessenger||window.external;gMissedItems={enabled:false,callCount:0,messageCount:0,setEnableCounting:function(inEnabled)
{this.enabled=inEnabled;},incrementCallCount:function()
{if(this.enabled){this.callCount++;updateMissedWarning();}},incrementMessageCount:function()
{if(this.enabled){this.messageCount++;updateMissedWarning();}},getCallCount:function()
{return this.callCount;},getMessageCount:function()
{return this.messageCount;}};gCallers={items:[],addItemData:function(inCallerData)
{var contact=this.getByItemData(inCallerData);var isNewContact=false;if(!contact){contact={phoneNumbers:{},DBID:inCallerData.DBID};this.items.push(contact);}
contact.prettyName=contact.prettyName||inCallerData.prettyName;contact.YID=contact.YID||inCallerData.YID;if(inCallerData.PSTN){contact.PSTN=inCallerData.PSTN;contact.phoneNumbers[inCallerData.PSTN]={Type:inCallerData.Type,ABTEL:inCallerData.ABTEL};}},sort:function()
{this.items.sort(this.compareItems);},compareItems:function(inA,inB)
{var prettyNameA=(inA.prettyName||"").toLowerCase();var prettyNameB=(inB.prettyName||"").toLowerCase();var pstnA=inA.ABTEL||inA.PSTN;var pstnB=inB.ABTEL||inB.PSTN;if(prettyNameA){if(prettyNameB){if(prettyNameA==prettyNameB){return 0;}else if(prettyNameA<prettyNameB){return-1;}else{return 1;}}else{return-1;}}else if(prettyNameB){return 1;}else if(pstnA){if(pstnB){if(pstnA==pstnB){return 0;}else if(pstnA<pstnB){return-1;}else{return 1;}}else{return prettyNameB?1:-1;}}else if(pstnB){return prettyNameA?-1:1;}},getByItemData:function(inItemData)
{if(inItemData.DBID){var indexes=this.items.getIndexesByAttribute({DBID:inItemData.DBID});if(indexes.length){return this.items[indexes[0]];}}
if(inItemData.YID){indexes=this.items.getIndexesByAttribute({YID:inItemData.YID});if(indexes.length){return this.items[indexes[0]];}}
if(inItemData.PSTN){indexes=this.items.getIndexesByAttribute({PSTN:inItemData.PSTN});return this.items[indexes[0]];}
return null;},getItems:function()
{return this.items;},removeAllItems:function()
{this.items=[];}};function initialize()
{gStrings=new YMStringResource({xmlPath:kStringXMLPath});for(var i=0;i<kToolbarButtonIDs.length;i++){var button=document.all[kToolbarButtonIDs[i]];if(button){button.title=gStrings.get(button.id+"Tooltip");}}
gItemDataSet=new CLDataSet({strings:gStrings});gItemDataSet.addListener(null,"updateVMCount");createItemList();createFilterList();gItemData=createXmlDom();gCallerData=createXmlDom();if(gMessenger&&typeof gMessenger.clInitData!="undefined"){gMessenger.clInitData(gItemData,gCallerData);}
window.setTimeout(function(){gItemList.getElement().focus();Toolbar.style.visibility="visible";},0);}
function createItemList()
{gItemList=new CLItemList({strings:gStrings,data:gItemDataSet});gItemList.addTo(ItemListContainer);gItemList.getElement().tabIndex=2;}
function createFilterList()
{gFilterList=new CLSelectList();LeftPane.appendChild(gFilterList.getElement());gFilterList.addItem(new CLSelectListItem({value:"All",label:'<img src="images/cl-type-icon-All.gif">'+gStrings.get("FilterAll")}));gFilterList.addItem(new CLSelectListItem({value:"VoiceMessages",label:'<img src="images/cl-type-icon-VoiceMail.gif"><span id="VMItem">'+gStrings.get("FilterVM")+' <span id="UnplayedVMCount"></span></span>'}));gFilterList.addItem(new CLSelectListItem({value:"Incoming",label:'<img src="images/cl-type-icon-Incoming.gif">'+gStrings.get("FilterIncoming")}));gFilterList.addItem(new CLSelectListItem({value:"Outgoing",label:'<img src="images/cl-type-icon-Outgoing.gif">'+gStrings.get("FilterOutgoing")}));gFilterList.addItem(new CLSelectListItem({value:"Missed",label:'<img src="images/cl-type-icon-Missed.gif">'+gStrings.get("FilterMissed")}));gFilterList.addItem(new CLSelectListItem({value:"",label:'<div>&nbsp;</div>',class_container:"CLSelectListSeparator",finishElement:function(){this.element.selectable=false;}}));}
function updateLeftPaneWidth()
{var widestLabel=0;for(var i=0;i<gFilterList.items.length;i++){var item=gFilterList.items[i];var labelWidth=item.element.all.Label.offsetWidth;widestLabel=(labelWidth>widestLabel)?labelWidth:widestLabel;}
if(widestLabel+kLeftPanePadding>LeftPane.clientWidth){LeftPane.style.width=Math.min(widestLabel+kLeftPanePadding,kLeftPaneMaxWidth)+"px";}}
function onUnload()
{if(gItemList&&gItemList.vmPlayer){gItemList.vmPlayer.setItemData(null,null);}
if(gMessenger&&typeof gMessenger.clReleaseData!="undefined"){gMessenger.clReleaseData();}
DestroyableItems.destroyAll();gMessenger=null;gStrings=null;gItemData=null;gItemDataSet=null;gCallerData=null;gItemDataSet=null;gItemList=null;gFilterList=null;gFilters=null;gCallers=null;}
window.attachEvent("onunload",onUnload);function removeSelectedItems()
{if(!gItemList){return;}
var selectedIndexes=gItemList.getSelectedIndexes();if(selectedIndexes.length==0){return;}
if(!confirm(gStrings.get("DeleteWarning",selectedIndexes.length))){return;}
if(selectedIndexes.length==gItemDataSet.getLength()&&gFilters.length==0){gMessenger.clDeleteAllItems();clOnDataReady();}else{var firstDeletedItemIndex=selectedIndexes[0];var allSelected=(selectedIndexes.length==gItemDataSet.getDataLength());if(typeof gMessenger.clDeleteItems!="undefined"){var ids=[];for(var i=0;i<selectedIndexes.length;i++){ids.push(gItemDataSet.getItem(selectedIndexes[i]).id);}
gMessenger.clDeleteItems(ids.join(","));}
if(allSelected){showAllItems();}else{gItemList.selectItem(firstDeletedItemIndex);gItemList.scrollToItem(firstDeletedItemIndex);}}}
function buildCallerPrettyNames()
{gCallers.removeAllItems();var callerNodes=gCallerData.selectNodes("//U | //Ph");for(var i=0;i<callerNodes.length;i++){var node=callerNodes[i];var yid=node.getAttribute("OPID");var firstName=node.getAttribute("FN");var lastName=node.getAttribute("LN");var prettyName="";if(lastName&&lastName.length>0){prettyName=lastName;}
if(firstName&&firstName.length>0){switch(gLocalePNFlag){case 0:prettyName=firstName+" "+lastName;break;case 1:prettyName=lastName+" "+firstName;break;case 2:prettyName=lastName+""+firstName;break;case 3:prettyName=lastName+", "+firstName;break;default:prettyName=firstName+" "+lastName;break;}
prettyName=prettyName.trim(", ");}
if(prettyName.length==0){prettyName=yid;}
gCallers.addItemData({YID:yid,prettyName:prettyName,DBID:node.getAttribute("DBID"),PSTN:node.getAttribute("PSTN"),Type:node.getAttribute("Type"),ABTEL:node.getAttribute("ABTEL")});}
gCallers.sort();var unknownCallers=gMessenger.clGetNodes('//I[@OPID = "" and @PSTNRef = ""]');if(unknownCallers.length){gCallers.addItemData({OPID:"",PSTN:""});}}
function buildFilterMenu()
{gFilterList.resetList();var callers=gCallers.getItems();for(var i=0;i<callers.length;i++){caller=callers[i];if(caller.YID){gFilterList.addItem(new CLSelectListItem({value:"OPID",DBID:caller.DBID,YID:caller.YID,label:caller.prettyName}));}else if(caller.PSTN){gFilterList.addItem(new CLSelectListItem({value:"PSTN",DBID:caller.DBID,PSTN:caller.PSTN,label:caller.prettyName||caller.ABTEL||caller.PSTN}));}else{gFilterList.addItem(new CLSelectListItem({value:"PSTN",DBID:"",PSTN:"",label:gStrings.get("FilterUnknownCaller")}));}}
updateLeftPaneWidth();}
function selectFilterItemByValue(inValue,inID)
{var item=gFilterList.items.getItemsByAttribute({value:"All"})[0];if(inValue=="OPID"){if(inID){item=gFilterList.items.getItemsByAttribute({YID:inID})[0]||item;}}else if(inValue=="PSTN"){if(inID){item=gFilterList.items.getItemsByAttribute({PSTN:inID})[0]||item;}}else{item=gFilterList.items.getItemsByAttribute({value:inValue})[0]||item;}
gFilterList.selectItem(item);gFilterList.scrollToItem(item);}
function onFilterSelected(inItemIndex,inItemValue,inYID)
{gFilters=[];var booleanOperator="and";switch(inItemValue){case"All":break;case"VoiceMessages":gFilters.push('@TE = "VoiceMail"');break;case"Missed":gFilters.push('@TE = "Missed"');break;case"Incoming":gFilters.push('@TE = "Incoming"');break;case"Outgoing":gFilters.push('@TE = "Outgoing"');break;case"OPID":var caller=gCallers.getByItemData({YID:inYID});if(caller){if(caller.DBID){gFilters.push('@DBID = "'+caller.DBID+'"');}else{gFilters.push('@OPID = "'+inYID+'"');for(var phoneNumber in caller.phoneNumbers){gFilters.push('@PSTNRef = "'+phoneNumber+'"');}
booleanOperator="or";}}else{gFilters.push('@OPID = "'+inYID+'"');}
break;case"PSTN":if(gFilterList.items[inItemIndex].DBID){gFilters.push('@DBID = "'+gFilterList.items[inItemIndex].DBID+'"');}else if(gFilterList.items[inItemIndex].PSTN){gFilters.push('@PSTNRef = "'+gFilterList.items[inItemIndex].PSTN+'"');}else{gFilters.push('@PSTNRef = ""');gFilters.push('@OPID = ""');}
break;}
filterItems(true,booleanOperator);}
function filterItems(inSelectFirstItem,inBooleanOperator)
{inBooleanOperator=inBooleanOperator||"and";var xpath="CL/I";if(gFilters.length){xpath+="["+gFilters.join(" "+inBooleanOperator+" ")+"]";}
var matchingNodes=gMessenger.clGetNodes(xpath);gItemDataSet.setItems(matchingNodes);if(inSelectFirstItem){if(document.nodeType){selectFirstItem();}else{window.setTimeout(selectFirstItem,0);}}}
function selectFirstItem()
{gItemList.selectItem(0);gItemList.scrollToItem(0);}
function showOnlyVM()
{gFilterList.unselectAll();selectFilterItemByValue("VoiceMessages");}
function showAllItems()
{selectFilterItemByValue("All");}
function updateLocalePNFlag()
{if(!gCallerData.documentElement){return;}
gLocalePNFlag=parseInt(gCallerData.documentElement.getAttribute("PNFlag"))||0;}
function updateVMCount()
{if(!gItemData.documentElement){return;}
gUnplayedVMCount=gMessenger.clGetNodes('CL/I[@TE = "VoiceMail" and @L = "0"]').length;gTotalVMCount=gItemData.documentElement.getAttribute("VMCount");var vmMax=gItemData.documentElement.getAttribute("VMMax")||1;if(gUnplayedVMCount>0){UnplayedVMCount.innerHTML="("+gUnplayedVMCount+")";addClass(VMItem,"UnplayedVMs");updateLeftPaneWidth();}else{UnplayedVMCount.innerHTML="";removeClass(VMItem,"UnplayedVMs");}
if(gTotalVMCount/vmMax>=kVMCountWarningTrigger){var remainingVMs=vmMax-gTotalVMCount;if(remainingVMs==0){addClass(VMWarning,"VMWarningStop");VMWarningText.innerHTML=gStrings.get("VMBoxFull");}else{removeClass(VMWarning,"VMWarningStop");VMWarningText.innerHTML=gStrings.get("VMBoxAlmostFull",remainingVMs);}
show(VMWarning);}else if(gTotalVMCount==-1){VMWarningText.innerHTML=gStrings.get("VMErrorGeneric");show(VMWarning);}else{hide(VMWarning);}}
function updateMissedWarning()
{if(gOpenedReason==kOpenedReason_Missed){var missedCalls=gMissedItems.getCallCount();var missedMessages=gMissedItems.getMessageCount();if(missedCalls||missedMessages){show(MissedWarning);if(missedCalls){MissedCallText.innerHTML=gStrings.get("MissedCallWarning",missedCalls);show(MissedCall);}else{hide(MissedCall);}
if(missedMessages){MissedVMText.innerHTML=gStrings.get("MissedVMWarning",missedMessages);show(MissedVM);}else{hide(MissedVM);}}}else{hide(MissedWarning);hide(MissedCall);hide(MissedVM);}}
function highlightMissedCall(inNode)
{if(inNode){inNode.setAttribute(kMissedCallAttribute,true);}}
function onToolbarButtonClick(inEvent)
{inEvent=inEvent||window.event;var button=getParent(inEvent.srcElement,{className:"ToolbarButton"},true);if(!button||!button.enabled){return;}
if(button.id=="DeleteButton"){removeSelectedItems();}else{var selectedIndexes=gItemList.getSelectedIndexes();if(selectedIndexes.length!=1){return;}
var selectedItem=gItemDataSet.getItem(selectedIndexes[0]);logAttribs(selectedItem);if(!selectedItem||(!selectedItem.YID&&!selectedItem.PSTN)){return;}
switch(button.id){case"CallButton":if(selectedItem.PSTN){callPSTN(selectedItem.PSTN,selectedItem.DID,selectedItem.DBID);}else{callID(selectedItem.YID);}
break;case"IMButton":imID(selectedItem.YID);break;case"AddButton":if(selectedItem.PSTN){if(gMessenger&&typeof gMessenger.clSavePhoneNumber!="undefined"){gMessenger.clSavePhoneNumber(selectedItem.PSTN);}}else if(selectedItem.YID){window.location="ymsgr:addfriend?"+selectedItem.YID;}
break;case"IgnoreButton":ignoreID(selectedItem.YID);break;}}}
function callID(inYID)
{if(inYID&&gMessenger&&typeof gMessenger.clCallID!="undefined"){gMessenger.clCallID(inYID);}}
function callPSTN(inNumber,inDID,inDBID)
{if(inNumber&&gMessenger&&typeof gMessenger.clCallPSTN!="undefined"){gMessenger.clCallPSTN(inNumber,inDID,inDBID);}}
function imID(inYID)
{if(inYID&&gMessenger&&typeof gMessenger.clIMID!="undefined"){gMessenger.clIMID(inYID);}}
function ignoreID(inYID)
{if(inYID&&gMessenger&&typeof gMessenger.clAddToIgnoreList!="undefined"){gMessenger.clAddToIgnoreList(inYID);}}
function isBuddy(inYID)
{if(inYID&&gMessenger&&typeof gMessenger.clIsBuddy!="undefined"){return gMessenger.clIsBuddy(inYID);}else{return false;}}
function clOnShowOPID(inID)
{if(gOnDataReadyDone){if(inID){selectFilterItemByValue("OPID",inID);}}else{gDefaultOPID=inID;}}
function clOnDataReady(inOpenedReason)
{gOnDataReadyDone=true;gOpenedReason=inOpenedReason;gItemData.validateOnParse=true;gFilterList.resetList();updateLocalePNFlag();clOnPrettyNameChanged();updateVMCount();if(gDefaultOPID!=""){selectFilterItemByValue("OPID",gDefaultOPID);gDefaultOPID="";}else if(gOpenedReason==kOpenedReason_Missed){var firstMissedCall=gMessenger.clGetNodes('CL/I[@TE = "Missed"]')[0];if(firstMissedCall){highlightMissedCall(firstMissedCall);}
gMissedItems.setEnableCounting(true);gMissedItems.incrementCallCount();showAllItems();}else{if(gTotalVMCount>0){showOnlyVM();}else{selectFilterItemByValue("OPID",gDefaultOPID);gDefaultOPID="";}}}
function clOnItemsAdded(inIDs,inAddedNodes)
{if(typeof inIDs!="string"){return;}
var ids=inIDs.split(",");var visibleDataHasChanged=false;for(var i=0;i<ids.length;i++){var newNode=gMessenger.clGetNodes('CL/I[@id = "'+ids[i]+'"]')[0];if(gOpenedReason==kOpenedReason_Missed&&newNode){if(newNode.getAttribute("TE")=="VoiceMail"){gMissedItems.incrementMessageCount();showAllItems();return;}else if(newNode.getAttribute("TE")=="Missed"){gMissedItems.incrementCallCount();highlightMissedCall(newNode);showAllItems();return;}}
if(newNode&&newNode.getAttribute("TE")=="VoiceMail"){showOnlyVM();return;}
var filtersWithID=['@id = "'+ids[i]+'"'].concat(gFilters);newNode=gMessenger.clGetNodes('CL/I['+filtersWithID.join(" and ")+']')[0];if(newNode){visibleDataHasChanged=true;break;}}
if(visibleDataHasChanged){filterItems(true);}}
function clOnItemsDeleted(inIDs)
{filterItems(false);}
function clOnErrorItemsDeleted()
{alert(gStrings.get("VMErrorDelete"));clOnDataReady();}
function clOnPlayVM(inID)
{if(typeof inID!="string"){return;}
showOnlyVM();var vmIndex=gItemDataSet.getIndexesByAttribute({id:inID})[0];if(isDefined(vmIndex)){gItemList.selectItem(vmIndex);gItemList.scrollToItem(vmIndex);gItemList.vmPlayer.play();}}
function clOnPrettyNameChanged()
{var currentSelection=gFilterList.getSelectedItems()[0];buildCallerPrettyNames();gItemDataSet.notifyDataChanged();buildFilterMenu();if(currentSelection){selectFilterItemByValue(currentSelection.value,(currentSelection.value=="OPID")?currentSelection.YID:currentSelection.PSTN);}else{showAllItems();}}
function clOnDataError(inType)
{alert(gStrings.get("VMErrorGeneric"));}
function onKeyDown()
{var itemListFocused=gItemList.getElement().contains(document.activeElement);switch(event.keyCode){case 46:case 8:removeSelectedItems();break;case"A".charCodeAt(0):if(event.ctrlKey){gItemList.selectAll();}
break;case 33:case 34:case 36:case 35:case 38:case 40:if(!itemListFocused){gItemList.keydown(event);}
break;case 27:if(gMessenger&&typeof gMessenger.clCloseWindow!="undefined"){gMessenger.clCloseWindow();}else{window.close();}
break;case 13:case" ".charCodeAt(0):if(gItemList.vmPlayer){gItemList.vmPlayer.togglePlayPause();}
break;case 37:if(gItemList.vmPlayer){gItemList.vmPlayer.skip(-CLVMPlayer.k.skipAmount);}
break;case 39:if(gItemList.vmPlayer){gItemList.vmPlayer.skip(CLVMPlayer.k.skipAmount);}
break;case"E".charCodeAt(0):if(event.ctrlKey&&event.altKey&&event.shiftKey){log.open();}
break;}
event.cancelBubble=true;return false;}
document.attachEvent("onkeydown",onKeyDown);