var vg=new Object();
vg.html=new Object();
vg.comp=new Object();
vg.util=new Object();
vg.smil=new Object();
vg.validation=new Object();
vg.button=new Object();
vg.expRow=new Object();
vg.resultsRow=new Object();
vg.string=new Object();
vg.ageBand=new Object();
vg.listGrid=new Object();
vg.cobrowse=new Object();
vg.cobrowse.capture=false;
vg.cobrowse.event="*";
vg.cobrowse.play=true;
vg.cobrowse.record=true;
vg.cobrowse.parameters=true;
vg.event=new Object();
vg.position=new Object();
vg.event.DOM_CHANGE="CBD_DOM_CHANGE";
vg.event.GEO_CHANGE="CBD_GEO_CHANGE";
vg.event.PAGE_READY="CBD_PAGE_READY";
vg.event.LAYER_REPOSITION="CBD_LAYER_REPOSITION";
vg.event.LAYER_OPEN="CBD_LAYER_OPEN";
vg.event.LAYER_CLOSE="CBD_LAYER_CLOSE";
vg.event.ELEMENT_DISABLED="CBD_ELEMENT_DISABLED";
vg.event.CUSTOM_EVENTS=new Array();
vg.delayedEvents=0;
vg.html.ELEMENT_NODE="1";
var CBD_GLOBAL_INFO_BOX='NON_BB_GLOBAL_INFO_BOX';
var CBD_DYNAMIC_CSS='dynmCSS';
if(!window._cbdLooseFuncs)
{
_cbdLooseFuncs={};
}
vg.QueryString=function(readOnLoad)
{
this.arg=new Array;
if(readOnLoad!=false)
{
this.read();
}
}
vg.QueryString.prototype=
{
get:function(sName)
{
return this.arg[sName];
},
read:function(sUrl)
{
var aArgsTemp, aTemp, sQuery;
if(sUrl)
{
sQuery=sUrl.substr(sUrl.lastIndexOf("?")+1, sUrl.length);
}
else
{
sQuery=window.location.search.substr(1, window.location.search.length);
}
if(sQuery.length < 1)
return;
aArgsTemp=sQuery.split("&");
for(var i=0;i < aArgsTemp.length;i++)
{
aTemp=aArgsTemp[i].split("=");
this.arg[aTemp[0]]=aTemp[1];
}
}
}
vg.position._ne=function(elem, target)
{
elem.viewNode.x=target.x+target.w;
elem.viewNode.y=target.y - elem.h;
elem.leaderId=null;
}
vg.position._se=function(elem, target)
{
elem.viewNode.x=target.x+target.w;
elem.viewNode.y=target.y+target.h;
elem.leaderId=null;
}
vg.position._sw=function(elem, target)
{
elem.viewNode.x=target.x - elem.w;
elem.viewNode.y=target.y+target.h;
elem.leaderId=null;
}
vg.position._nw=function(elem, target)
{
elem.viewNode.x=target.x - elem.w;
elem.viewNode.y=target.y - elem.h;
elem.leaderId=null;
}
vg.position._right=function(elem, target)
{
elem.viewNode.x=target.x+target.w;
elem.viewNode.y=target.y+target.h/2 - elem.h/2;
if(elem.hasLeader)
{
elem.ldrLoc="xLdrLft"
_cbdAddLeader(elem, target);
elem.ldrOffSetX=((ie)?10:11 );
}
}
vg.position._top=function(elem, target)
{
elem.viewNode.x=target.x+target.w/2 - elem.w/2+((ie6)?2:4);
var offsetBoxY=(ie6)?0:6;
elem.viewNode.y=target.y - elem.h+offsetBoxY;
if(elem.hasLeader)
{
elem.ldrLoc="xLdrBot";
_cbdAddLeader(elem, target);
elem.ldrOffSetY=-11;
}
}
vg.position._left=function(elem, target)
{
elem.viewNode.x=target.x - elem.w;
elem.viewNode.y=target.y+target.h/2 - elem.h/2;
if(elem.hasLeader)
{
elem.ldrLoc="xLdrRgt";
_cbdAddLeader(elem, target);
elem.ldrOffSetX=((ie)?-11:-12 );
}
}
vg.position._bottom=function(elem, target)
{
elem.viewNode.x=target.x+target.w/2 - elem.w/2+((ie6)?2:4);
elem.viewNode.y=target.y+target.h;
if(elem.hasLeader)
{
elem.ldrLoc="xLdrTop";
_cbdAddLeader(elem, target);
elem.ldrOffSetY=11;
}
}
vg.position._topLeft=function(elem, target)
{
elem.viewNode.x=target.x;
elem.viewNode.y=target.y - elem.h;
elem.x=elem.viewNode.x;
if(elem.hasLeader)
{
var ldrw=32;
var offsetBoxX=target.w <=ldrw?ldrw - .5*ldrw:0;
var offsetBoxY=(ie6)?0:6;
elem.viewNode.x=elem.viewNode.x - offsetBoxX;
elem.viewNode.y=elem.viewNode.y+offsetBoxY;
elem.x=elem.viewNode.x;
elem.y=elem.viewNode.y;
elem.ldrLoc="xLdrBot";
var ldrData=_cbdAddLeader(elem, target);
elem.ldrOffSetY=-11;
var leaderOffset=target.w <=ldrw?(target.w/2+13 - .25*ldrw):15;
ldrDiv=document.getElementById(elem.leaderId);
ldrDiv.style.left=elem.x+leaderOffset+"px";
ldrDiv.style.top=ldrData.elem.y+offsetBoxY+"px";
}
}
vg.position._topRight=function(elem, target)
{
elem.viewNode.x=target.x+target.w - elem.w;
elem.x=elem.viewNode.x;
elem.viewNode.y=target.y - elem.h;
if(elem.hasLeader)
{
var ldrw=32;
var offsetBoxX=target.w <=ldrw?ldrw - .25*ldrw:0;
var offsetBoxY=(ie6)?0:6;
elem.viewNode.x=elem.viewNode.x+offsetBoxX;
elem.viewNode.y=elem.viewNode.y+offsetBoxY;
elem.x=elem.viewNode.x;
elem.y=elem.viewNode.y;
elem.ldrLoc="xLdrBot";
var ldrData=_cbdAddLeader(elem, target);
elem.ldrOffSetY=-11;
var leaderOffset=target.w <=ldrw?1.2*(target.w/2+13 - .25*ldrw):15;
ldrDiv=document.getElementById(elem.leaderId);
ldrDiv.style.left=elem.x+elem.w - ldrData.elem.w - leaderOffset+"px";
ldrDiv.style.top=ldrData.elem.y+offsetBoxY+"px";
}
}
vg.position._fixedBottom=function(elem, target)
{
elem.x=target.x;
elem.y=target.y+target.h;
var offsetBox=(elem.x>=12?12:0);
var offsetLeader=(target.w/2);
elem.x=elem.x-offsetBox;
_cbdCreateLeader(elem.id, 'xLdrTop');
elem.ldrOffSetY=11;
elem.viewNode.x=elem.x;
elem.viewNode.y=elem.y;
ldrDiv=document.getElementById(elem.leaderId);
ldrDiv.style.left=elem.x+offsetLeader+"px";
ldrDiv.style.top=elem.y+"px";
}
vg.position._bottomLeft=function(elem, target)
{
elem.viewNode.x=target.x;
elem.viewNode.y=target.y+target.h;
elem.x=elem.viewNode.x;
if(elem.hasLeader)
{
var offsetBox=(elem.x>=12?12:0);
var offsetLeader=(offsetBox/2)+4;
elem.x=elem.x - offsetBox;
elem.ldrLoc="xLdrTop";
_cbdAddLeader(elem, target);
elem.ldrOffSetY=11;
ldrDiv=document.getElementById(elem.leaderId);
ldrDiv.style.left=elem.x+offsetLeader+"px";
elem.viewNode.x=elem.x;
}
}
vg.position._bottomRight=function(elem, target)
{
elem.viewNode.x=target.x+target.w - elem.w;
elem.viewNode.y=target.y+target.h;
if(elem.hasLeader)
{
var ldrw=32;
var offsetBox=target.w <=ldrw?ldrw - .25*ldrw:0;
elem.viewNode.x=elem.viewNode.x+offsetBox;
elem.x=elem.viewNode.x;
elem.ldrLoc="xLdrTop";
var ldrData=_cbdAddLeader(elem, target);
elem.ldrOffSetY=11;
var leaderOffset=target.w <=ldrw?(target.w/2+13 - .25*ldrw):15;
ldrDiv=document.getElementById(elem.leaderId);
ldrDiv.style.left=elem.x+elem.w - ldrData.elem.w - leaderOffset+"px";
}
}
cbdns._cbdAddLeader=function(elem, target)
{
_cbdCreateLeader(elem.id, elem.ldrLoc);
return vg.html.position({elementNode:elem.leaderId, targetNode:target.viewNode, dispLoc:elem.dispLoc, infobox:elem.infobox});
}
vg.position._auto=function(elem, horzPos, target, defaultTop)
{
var scrollTop=(ie)?document.body.scrollTop:window.pageYOffset;
var screenHeight=jsCBDgetScreenHeight()+scrollTop;
var spaceBelowTrigger=screenHeight -(target.y+target.h);
var spaceAboveTrigger=target.y - scrollTop;
var dispLoc;
var heightOfDisplayObj=elem.h;
elem.dispLoc=null;
if(elem.hasLeader)
{
heightOfDisplayObj=heightOfDisplayObj+26;
}
var positionBelow=(spaceBelowTrigger >=heightOfDisplayObj)
var positionAbove=(spaceAboveTrigger >=heightOfDisplayObj)
if((defaultTop&&(positionAbove||!positionBelow))||((positionAbove&&!positionBelow)) )
{
dispLoc='top';
}
else
{
dispLoc='bottom';
}
var scrollLeft=document.body.scrollLeft;
var screenWidth=jsCBDgetScreenWidth()+scrollLeft;
var centerOfTarget=target.x+target.w/2;
var spaceOnLeft=centerOfTarget >=elem.w;
var spaceOnRight=(screenWidth - centerOfTarget) > elem.w;
if(spaceOnLeft&&spaceOnRight&&horzPos!=null)
{
dispLoc=dispLoc+horzPos;
}
else if(spaceOnRight)
{
dispLoc=dispLoc+'left';
}
else if(spaceOnLeft)
{
dispLoc=dispLoc+'right';
}
elem.dispLoc=dispLoc;
return vg.html.position(elem.viewNode, target.viewNode, dispLoc, elem.infobox, elem.hasLeader);
}
vg.html.isElement=function(node)
{
return node.nodeType==vg.html.ELEMENT_NODE;
}
vg.html._setDimensions=function(obj)
{
var prop=vg.html.getObjSizePosition(obj.viewNode);
obj.x=prop.x;
obj.y=prop.y;
obj.h=prop.h;
obj.w=prop.w;
}
vg.html.getXMLNodeText=function(xmlNode)
{
var text="";
if(ie){
text=xmlNode.text;
}
else{
text=xmlNode.textContent;
}
return text;
}
vg.html.disableRightClickMenu=function(obj)
{
obj.oncontextmenu=function(){return false};
}
vg.html.position=function(elementNode, targetNode, dispLoc, infobox, leader, horzPos)
{
if(elementNode.elementNode!=null)
{
targetNode=elementNode.targetNode;
dispLoc=elementNode.dispLoc.toLowerCase();
infobox=elementNode.infobox;
leader=elementNode.leader;
horzPos=elementNode.horzPos;
elementNode=elementNode.elementNode;
}
if(typeof infobox=="undefined")
{
infobox=false;
}
if(infobox)
{
var globalInfoBox=vg.html.getElement(CBD_GLOBAL_INFO_BOX);
var parent=globalInfoBox.parentNode;
if(!parent.getAttribute(CBD_DYNAMIC_CSS))
{
var newDiv=document.createElement("div");
newDiv.setAttribute(CBD_DYNAMIC_CSS,'true');
parent.removeChild(globalInfoBox);
newDiv.appendChild(globalInfoBox);
parent.appendChild(newDiv);
parent=newDiv;
}
var cssContainer=vg.html._cbdGetCSSContainer(targetNode);
vg.html.setStyle(cssContainer.className, parent);
}
var target=new Object();
target.viewNode=vg.html.getElement(targetNode);
vg.html._setDimensions(target);
target.y -=_cbdGetTotalScroll(target.viewNode);
if(targetNode.inLayoutTopBorderTd&&(ie||safari))
{
target.y=target.y+10;
}
var elem=new Object();
elem.viewNode=vg.html.getElement(elementNode);
elem.id=elem.viewNode.getAttribute('id');
elem.dispLoc=dispLoc;
elem.hasLeader=leader;
elem.leaderId=null;
elem.infobox=infobox;
vg.html._setDimensions(elem);
elem.y -=_cbdGetTotalScroll(elem.viewNode);
if(elem.hasLeader)
{
elem.leaderId="ldr_"+elem.id;
elem.ldrOffSetY=0;
elem.ldrOffSetX=0;
}
var dpData=new Object();
dpData.elem=elem;
dpData.target=target;
switch(dispLoc)
{
case "top":
vg.position._top(elem, target);
break;
case "right":
vg.position._right(elem, target);
break;
case "left":
vg.position._left(elem, target);
break;
case "bottom":
vg.position._bottom(elem, target);
break;
case "topleft":
vg.position._topLeft(elem, target);
break;
case "topright":
vg.position._topRight(elem, target);
break;
case "bottomleft":
vg.position._bottomLeft(elem, target);
break;
case "fixedbottom":
vg.position._fixedBottom(elem, target);
break;
case "bottomright":
vg.position._bottomRight(elem, target);
break;
case "ne":
vg.position._ne(elem, target);
break;
case "se":
vg.position._se(elem, target);
break;
case "sw":
vg.position._sw(elem, target);
break;
case "nw":
vg.position._nw(elem, target);
break;
default:
dpData=vg.position._auto(elem, horzPos, target, infobox);
dispLoc=dpData.elem.dispLoc;
}
var ances=vg.html.findAncestor(target.viewNode,{tagName:null,attrName:null}, jsCBDCheckFixedStyle);
if((ances!=null)&&(!ie))
{
elem.viewNode.style.position="fixed";
}
else if(elem.viewNode.style.position!="absolute")
{
elem.viewNode.style.position="absolute";
}
elem.x=parseInt(elem.viewNode.x);
elem.y=parseInt(elem.viewNode.y);
elem.ldrOffSetX=dpData.elem.ldrOffSetX;
elem.ldrOffSetY=dpData.elem.ldrOffSetY;
if("fixedbottom"!=dispLoc.toLowerCase())
{
elem.viewNode.style.left=elem.x+"px";
elem.viewNode.style.top=elem.y+"px";
}
dpData.elem.dispLoc=dispLoc;
dpData.elem=elem;
dpData.target=target;
return dpData;
}
vg.html.getNodeText=function(node)
{
var ret='';
for(var i=0;i < node.childNodes.length;i++)
{
if(node.childNodes[i].nodeType==3)
{
ret+=node.childNodes[i].nodeValue+' ';
}
}
return ret;
}
vg.html.getFirstChild=function(node)
{
var chNode=(vg.html.getElement(node)!=null)?vg.html.getElement(node).firstChild:null;
while(chNode!=null&&(chNode.nodeType!=1||chNode.tagName.toLowerCase()=='script' ) )
{
chNode=chNode.nextSibling;
}
return chNode;
}
vg.html.getFormElements=function(form)
{
var formElements=new Array();
vg.util.concat(formElements, form.getElementsByTagName('input'));
vg.util.concat(formElements, form.getElementsByTagName('select'));
vg.util.concat(formElements, form.getElementsByTagName('textarea'));
return formElements;
}
vg.html.addEventListenerMethod=function(node, eventType, obj, method, listenerId)
{
vg.html.addEventListener(node, eventType,
function _callListenerMethod()
{
var args=Array.prototype.slice.call(arguments );
obj[method].apply(obj, args );
},
listenerId );
}
vg.html.addEventListener=function(node, eventType, func, listenerId)
{
node=vg.html.getElement(node );
if(node)
{
if(!node.eventCounter)
{
node.eventCounter={};
}
if(node.eventCounter[eventType])
{
node.eventCounter[eventType]++;
}
else
{
node.eventCounter[eventType]=1;
}
}
if(eventType.indexOf('CBD_') >=0)
{
vg.html._addCustomEventListener(node, eventType, func);
}
else
{
eventType=vg.html.getEventName(eventType);
if(listenerId!=null)
{
listenerId+='_listener';
if(node[listenerId]==true)
{
return;
}
}
if(ie)
{
node.attachEvent(eventType, func);
}
else
{
node.addEventListener(eventType, func, false);
}
if(listenerId!=null)
{
node[listenerId]=true;
}
}
}
vg.html.removeEventListener=function(node, eventType, func, listenerId)
{
eventType=vg.html.getEventName(eventType);
if(ie)
{
node.detachEvent(eventType, func);
}
else
{
node.removeEventListener(eventType, func, false);
}
if(listenerId!=null)
{
node[listenerId+'_listener']=false;
}
if(node.eventCounter&&node.eventCounter[eventType]> 0)
{
node.eventCounter[eventType]--;
}
}
vg.html.hasEventListeners=function(node, eventType)
{
return(node.eventCounter!=null&&
node.eventCounter[eventType]!=null&&
node.eventCounter[eventType]> 0);
}
vg.html.getEventName=function(eventName, omitOn)
{
if(eventName=='mouseenter'&&!ie)
{
eventName='mouseover';
}
else if(eventName=='mouseleave'&&!ie)
{
eventName='mouseout';
}
return ie&&!omitOn?'on'+eventName:eventName;
}
vg.html._addCustomEventListener=function(node, eventType, func)
{
var event=null;
var globalEvent=vg.event.CUSTOM_EVENTS[eventType];
if(globalEvent==null)
{
globalEvent=vg.html._createCustomEvent(eventType);
vg.event.CUSTOM_EVENTS[eventType]=globalEvent;
}
if(node&&node!=window )
{
vg.event.CUSTOM_EVENTS[eventType].hasNodeListeners=true;
if(!node.customEvents )
{
node.customEvents={};
}
event=node.customEvents[eventType];
if(event==null )
{
event=vg.html._createCustomEvent(eventType);
node.customEvents[eventType]=event;
}
}
else
{
event=globalEvent;
}
event.subscribe(func);
}
vg.html._createCustomEvent=function(eventType)
{
return new YAHOO.util.CustomEvent(eventType);
}
vg.html._fireCustomEvent=function(eventType, targetElement, eventData, skipGlobal )
{
targetElement=vg.html.getElement(targetElement );
var nodeEvent=null;
if(targetElement
&&targetElement.customEvents
&&targetElement.customEvents[eventType])
{
nodeEvent=targetElement.customEvents[eventType];
}
if(eventData==null)
{
eventData={};
}
eventData.targetElement=targetElement;
if(nodeEvent )
{
nodeEvent.fire(eventData);
}
var globalEvent=vg.event.CUSTOM_EVENTS[eventType];
if(targetElement&&targetElement!=window&&
globalEvent&&globalEvent.hasNodeListeners )
{
var parentContainer=vg.html.findAncestor(targetElement,{}, vg.comp._isContainer );
if(parentContainer )
{
vg.html._fireCustomEvent(eventType, parentContainer, eventData, true );
}
}
if(globalEvent&&!skipGlobal)
{
globalEvent.fire(eventData);
}
}
vg.html.setDisabledAttr=function(node, value)
{
(ie)?node.disabled=value:node.setAttribute('disabled', value);
}
vg.html.getDisabledAttr=function(node)
{
return String((ie)?node.disabled:node.getAttribute('disabled'));
}
vg.html.disableTextSelect=function(node)
{
(ie)?node.onselectstart=function(){return false;}:node.style.MozUserSelect="none";
}
vg.html.getReadOnlyAttr=function(elem)
{
elem=vg.html.getElement(elem);
return elem.getAttribute('readonly');
}
vg.html.setStyle=function(className, node )
{
node.className=className;
}
vg.html.addStyle=function(className, node)
{
jsCBDaddStyle(node, className);
}
vg.html.removeStyle=function(className, node)
{
jsCBDdeleteStyle(node, className);
}
vg.html.hasStyle=function(classname, node )
{
if(node.className)
{
var arr=node.className.split(" " );
for(var i=0;i < arr.length;i++)
{
if(arr[i]==classname )
{
return true;
}
}
}
return false;
}
vg.html.hasFocus=function(node)
{
return vg.html.hasStyle('focus', node);
}
vg.html.listStyles=function(node )
{
return node.className.split(" " );
}
vg.html.addOrRemoveStyle=function(className, node, add)
{
(add)?jsCBDaddStyle(node, className):jsCBDdeleteStyle(node, className);
}
vg.html.addOrRemoveStyleFromNodes=function(className, nodes, add)
{
for(var i=0;i < nodes.length;i++)
{
vg.html.addOrRemoveStyle(className, nodes[i], add);
}
}
vg.html.replaceClass=function(node, oldClass, newClass)
{
jsCBDdeleteStyle(node, oldClass);
jsCBDaddStyle(node, newClass);
}
vg.html.replaceClassOnNodes=function(nodes, oldClass, newClass)
{
for(var i=0;i < nodes.length;i++)
{
vg.html.replaceClass(nodes[i], oldClass, newClass);
}
}
vg.html.setCursorStyle=function(elem, style)
{
elem.style.cursor=style;
}
vg.html.setPadding=function(node, padding)
{
node.style.padding=padding;
}
vg.html.setHeight=function(node, height)
{
node.style.height=height;
}
vg.html.setWidth=function(node, width)
{
node.style.width=width;
}
vg.html.setLeft=function(node, left)
{
node.style.left=left+"px";;
}
vg.html.setOpacity=function(node, opacity, adjustZoom)
{
if(typeof adjustZoom=="undefined")
{
adjustZoom=false;
}
if(ie)
{
if(!node.currentStyle.hasLayout)
{
node.style.zoom="1";
}
if(adjustZoom){node.style.zoom="0.9999";}
opacity=parseFloat(opacity)*100;
node.style.filter='alpha(opacity='+opacity+')';
}
else
{
node.style.opacity=opacity;
}
}
vg.html.getObjPadding=function(obj)
{
var domElement=vg.html.getElement(obj );
var pad={};
pad.left=parseInt(jsCBDGetComputedStylePropertyValue(domElement, "padding-left"));
pad.right=parseInt(jsCBDGetComputedStylePropertyValue(domElement, "padding-right"));
pad.top=parseInt(jsCBDGetComputedStylePropertyValue(domElement, "padding-top"));
pad.bottom=parseInt(jsCBDGetComputedStylePropertyValue(domElement, "padding-bottom"));
return pad;
}
vg.html.getObjHeight=function(obj)
{
var obj2=vg.html.getElement(obj );
var isHidden=obj2.style.display=='none';
var ret=0;
if(isHidden)
{
obj2.style.display='inline';
ret=obj2.offsetHeight;
obj2.style.display='none';
}
else
{
ret=obj2.offsetHeight;
}
return ret;
}
vg.html.getHeightOfHiddenElem=function(obj)
{
var obj=vg.html.getElement(obj );
obj.style.position="relative";
vg.html.setObjTop(obj, -5000);
vg.html.setLeft(obj, -5000);
obj.style.display="block";
var contentH=obj.offsetHeight;
obj.style.display="";
obj.style.position="";
return contentH;
}
vg.html.getSpanObjHeight=function(obj)
{
var obj2=vg.html.getElement(obj );
var dispStyle=jsCBDGetComputedStylePropertyValue(obj2, 'display');
var ret=0;
obj2.style.display=ie?'inline':((firefox)?'block':'inline-block');
ret=obj2.offsetHeight;
obj2.style.display=dispStyle;
return ret;
}
vg.html.getObjWidth=function(obj)
{
var obj2=vg.html.getElement(obj );
var isHidden=obj2.style.display=='none';
var ret=0;
if(isHidden )
{
obj2.style.display='inline';
ret=obj2.offsetWidth;
obj2.style.display='none';
}
else
{
ret=obj2.offsetWidth;
}
return ret;
}
vg.html.getObjClientWidth=function(obj)
{
var obj2=vg.html.getElement(obj );
var isHidden=obj2.style.display=='none';
var ret=0;
if(isHidden )
{
obj2.style.display='inline';
ret=obj2.clientWidth;
obj2.style.display='none';
}
else
{
ret=obj2.clientWidth;
}
return ret;
}
vg.html.getObjSizePosition=function(obj )
{
var objData=new Array();
objData.x=vg.html.getObjX(obj);
objData.y=vg.html.getObjY(obj);
objData.h=(obj&&obj.tagName.toLowerCase()=="span")?vg.html.getSpanObjHeight(obj):vg.html.getObjHeight(obj);
objData.w=vg.html.getObjWidth(obj);
return objData;
}
vg.html.getObjX=function(obj )
{
var x=0;
while(obj!=null )
{
x+=obj.offsetLeft;
obj=obj.offsetParent;
}
return x;
}
vg.html.getObjY=function(obj )
{
var y=0;
while(obj!=null )
{
y+=obj.offsetTop;
obj=obj.offsetParent;
}
return y;
}
vg.html.setObjTop=function(obj, value )
{
obj.style.top=value+"px";
}
vg.html.scrollToPosition=function(node,posX,posY)
{
var el=vg.html.getElement(node);
if(posX!=null) el.scrollLeft=parseInt(posX.toString().replace("px",""));
if(posY!=null) el.scrollTop=parseInt(posY.toString().replace("px",""));
}
vg.html.scrollIntoView=function(container, elem, elemHeight, elemY, amimate, scrollspeed)
{
var containerStartY=vg.html.getObjY(container)+container.scrollTop;
var containerHeight=container.scrollHeight;
var containerViewHeight=vg.html.getObjHeight(container);
var containerEndY=containerStartY+containerViewHeight;
if(elemHeight==null)
{
elemHeight=vg.html.getObjHeight(elem);
}
if(elemY==null)
{
elemY=vg.html.getObjY(elem);
}
var newScrollTop=container.scrollTop;
if(containerEndY < elemY+elemHeight)
{
newScrollTop=container.scrollTop+elemY - containerEndY+elemHeight;
}
else if(containerStartY > elemY - elemHeight)
{
newScrollTop=container.scrollTop -(containerStartY - elemY);
}
if(amimate)
{
var distance=Math.abs(newScrollTop - container.scrollTop);
var duration=1000;
var attributes={scroll:{to:[0, newScrollTop]}};
if(!scrollspeed) scrollspeed=3;
if(distance > 0&&scrollspeed > 0)
{
duration=Math.round(distance/scrollspeed);
}
if(container.anim)
{
container.anim.stop();
}
container.anim=vg.smil.animateElement({target:container, attr:attributes, duration:duration, scrollAnimation:true});
}
else
{
container.scrollTop=newScrollTop;
}
}
vg.html._hasVerticalScrollBar=function(node)
{
return node.clientHeight < node.scrollHeight;
}
vg.html.getElement=function(target)
{
if(typeof(target)=="string")
{
return document.getElementById(target);
}
return target;
}
vg.html.findAncestor=function(node, oFilter, check)
{
return _cbdFindAncestor(node, oFilter, check);
}
vg.html.getSibling=function(node, oFilter, direction)
{
var siblingAccessor=(direction=="-"?'previousSibling':'nextSibling');
for(node=node[siblingAccessor];node!=null;node=node[siblingAccessor])
{
if(_cbdCheckNodeAttrs(node, oFilter))
{
return node;
}
}
return null;
}
vg.html.getSiblings=function(node, oFilter, direction)
{
var siblings=new Array();
var siblingAccessor=(direction=="-"?'previousSibling':'nextSibling');
for(node=node[siblingAccessor];node!=null;node=node[siblingAccessor])
{
if(_cbdCheckNodeAttrs(node, oFilter))
{
siblings.push(node);
}
}
return siblings;
}
vg.html.getElementsRec=function(ret, depth, context, oFilter, check )
{
if(!context||depth==0 )
{
return;
}
for(var i=0;i < context.childNodes.length;++i)
{
var node=context.childNodes[i];
if(!(node instanceof String ) )
{
var flag=true;
flag&=_cbdCheckNodeAttrs(node, oFilter );
if(flag&&check )
{
flag&=check(node );
}
if(flag )
{
ret.push(node );
}
vg.html.getElementsRec(ret, depth - 1, node, oFilter, check );
}
}
}
vg.html.getElements=function(context, oFilter, check )
{
var elements=new Array();
var tagName=oFilter.tagName;
if(!context )
{
return elements;
}
if(oFilter.maxDepth!==undefined&&oFilter.maxDepth > 0 )
{
var ret=[];
vg.html.getElementsRec(ret, oFilter.maxDepth, context, oFilter, check );
return ret;
}
var nodes=context.getElementsByTagName(tagName);
oFilter.tagName=null;
for(var i=0;i < nodes.length;++i)
{
var node=nodes[i];
var flag=true;
flag&=_cbdCheckNodeAttrs(node, oFilter );
if(flag&&check )
{
flag&=check(node );
}
if(flag )
{
elements.push(node );
}
}
return elements;
}
vg.html.findParentComponent=function(context, type )
{
var ret=null;
var search=true;
var node=vg.html.getElement(context );
while(!ret&&search )
{
if(node )
{
var matches=node.jsController!==undefined;
if(type )
{
matches=matches&&node.jsController instanceof type;
}
if(matches )
{
ret=node;
}
else
{
node=vg.html._getParentNode(node);
}
}
else
{
search=false;
}
}
return ret;
}
vg.html._getParentNode=function(node)
{
var assocParentId=node.getAttribute?node.getAttribute("associatedParentId"):null;
return assocParentId?document.getElementById(assocParentId):node.parentNode;
}
vg.html.openDisableDiv=function(coveredEl,opac,layerId,layerDelay,layerResize,waitCursor)
{
var CE=vg.html.getElement(coveredEl);
if(CE.hasCover)
{
CE=vg.comp.getController(CE);
CE.openDisableModalDiv(opac,layerId,layerDelay,layerResize,waitCursor);
}
else
{
new DisableModalDiv(coveredEl,opac,layerId,layerDelay,layerResize,waitCursor)
}
}
vg.html.closeDisableDiv=function(coveredEl)
{
var coveredEl=vg.html.getElement(coveredEl);
var disDivController=coveredEl.disDivController;
if(ie&&CBD_FLOATING_HEAD)
{
coveredEl.setAttribute('covered','false');
vg.html._fireCustomEvent(vg.event.ELEMENT_DISABLED, coveredEl );
}
disDivController.layerState=false;
clearTimeout(disDivController.t);
if(disDivController.layerId) jsCBDcloseLayer(disDivController.layerId);
disDivController.disDiv.style.cursor="pointer";
jsCBDtoggleElement(disDivController.disDiv, false);
}
vg.html.closeAllDisableDivs=function()
{
var disDivCont=document.getElementById(DISABLE_DIV_CONTAINER);
if(disDivCont==null)
{
return;
}
for(i=0;i < disDivCont.divArray.length;i++)
{
var el=vg.html.getElement(disDivCont.divArray[i].triggerEl);
vg.html.closeDisableDiv(el);
}
}
vg.html._resizeDisableDivs=function()
{
var disDivCont=document.getElementById(DISABLE_DIV_CONTAINER);
if(disDivCont==null) return;
for(i=0;i < disDivCont.childNodes.length;i++)
{
var el=vg.html.getElement(disDivCont.childNodes[i].triggerEl);
el=vg.comp.getController(el);
el.disDiv.pos=el.positionSizeDisableModalDiv(el.coveredEl);
if(el.layerState)
{
el.positionSizeDisableLayer(el.coveredEl);
}
}
}
vg.html.stopEventPropagation=function(event)
{
if(event.stopPropagation)
{
event.stopPropagation();
}
else if(ie)
{
event.cancelBubble=true;
}
}
vg.html.preventDefault=function(event)
{
if(ie)
{
event.returnValue=false;
}
else
{
event.preventDefault();
}
}
vg.html.disableCopyPaste=function(event)
{
var event=jsCBDgetEvent(event);
var keyCode=event.keyCode;
if(event.ctrlKey&&(keyCode==67||keyCode==65||keyCode==86||keyCode==88 )||event.shiftKey&&keyCode==45)
{
if(ie)
{
event.returnValue=false;
}
else
{
event.preventDefault();
}
}
}
vg.html.isElementInView=function(elem)
{
if(elem==null)
return false;
var yPos=vg.html.getObjSizePosition(elem).y;
var scrollTop=_cbdGetScrollTop();
var winHeight=jsCBDgetScreenHeight();
var yHeight=elem.offsetHeight;
return((scrollTop < yPos)&&(yPos+yHeight+30 < scrollTop+winHeight));
}
vg.html.getSelection=function(input)
{
var obj={start:null, end:null};
input=vg.html.getElement(input );
if(!input) return;
if(input.createTextRange)
{
try
{
input.focus();
}
catch(err)
{
return obj;
}
var range=document.selection.createRange().duplicate();
var s=0;var e=0;
while(range.moveStart("character", -1)!=0 ) s++;
while(range.moveEnd("character", -1)!=0 ) e++;
obj.start=s;
obj.end=e;
}
else if(input.setSelectionRange)
{
obj.start=input.selectionStart;
obj.end=input.selectionEnd;
}
return obj;
}
vg.html.setSelection=function(input, start, end)
{
input=vg.html.getElement(input );
if(!input||!start||!end) return;
if(input.createTextRange)
{
var range=input.createTextRange();
range.collapse(true);
range.moveEnd('character', end);
range.moveStart('character', start);
range.select();
}
else if(input.setSelectionRange)
{
input.setSelectionRange(start, end);
}
try
{
input.focus();
}
catch(err)
{
}
}
vg.html.getContainerInputs=function(context, ret)
{
if(context.childNodes.length  < 0)
{
return;
}
var name=context.nodeName;
if(vg.html.isInput(context))
{
ret.push(context );
}
else
{
for(var i=0;i < context.childNodes.length;++i)
{
if(vg.html.isInput(context))
{
ret.push(context );
return;
}
var node=context.childNodes[i];
vg.html.getContainerInputs(node, ret );
}
}
}
vg.html.isInput=function(context)
{
var name=context.nodeName;
if(context.type!='hidden'&&
!context.disabled&&
(name=='INPUT'||name=='SELECT'||name=='TEXTAREA'||name=='A' ))
{
return true;
}
return false;
}
vg.cobrowse.recordEvent=function(oEvent, target, eventName, value, stopEventPropagation)
{
if(vg.cobrowse.isCobrowseActive())
{
var isRiaEvent=!oEvent||(oEvent.isRiaEvent!=false);
if(eventName&&isRiaEvent)
{
eventName="ria_"+eventName;
}
cob.recordEventAndFlush(oEvent, target, eventName, value);
if(oEvent&&stopEventPropagation!=false)
{
vg.html.stopEventPropagation(oEvent );
}
}
}
vg.cobrowse.isInPlayBackMode=function(node)
{
var cobrowseEventAttr=node.getAttribute('cobrowseEvent');
return(cobrowseEventAttr=='true');
}
vg.cobrowse.allowPlayBackOnly=function(node)
{
return(node&&node.tagName&&node.getAttribute("intdisabledcobrowsable")=='true');
}
vg.cobrowse._setAllowPlaybackOnly=function(event)
{
var eNode=jsCBDgetEventNode(event);
if(eNode.getAttribute("intDisabledCobrowsable")==null)
{
eNode.setAttribute("intDisabledCobrowsable", true);
}
if(!vg.cobrowse.isInPlayBackMode(eNode))
{
vg.html.preventDefault(event);
}
}
vg.cobrowse.setAttention=function(target)
{
if(window.VG&&window.VG.conf.cobrowse)
{
VG.setAttention(vg.html.getElement(target));
}
}
vg.cobrowse.isCobrowseActive=function()
{
return(window.cob&&window.cob.conf.cobrowse);
}
vg.conf=function()
{
this.options={};
this.optionNames=[];
}
vg.conf.prototype.add=function(name, value )
{
if(!this.options[name])
{
this.optionNames.push(name );
}
this.options[name]=value;
return this;
}
vg.conf.prototype.setOptions=function(obj )
{
for(var i=0;i < this.optionNames.length;i++)
{
var name=this.optionNames[i];
obj[name]=this.options[name];
}
}
vg.util.getMousePos=function(e)
{
var mouse=new Array();
if(ie)
{
mouse.x=e.clientX+document.body.scrollLeft;
mouse.y=e.clientY+document.body.scrollTop;
}
else
{
mouse.x=e.clientX+window.pageXOffset;
mouse.y=e.clientY+window.pageYOffset;
}
return mouse;
}
vg.util.testNSFunc=function(){
_debug("log", "Hosting-App vg object");
}
vg.util.setTimeout=function(func, timeDelay){
vg.delayedEvents++;
return setTimeout(function(){vg.util.execFunc(func);vg.delayedEvents--;}, timeDelay);
}
vg.util.execFunc=function(func, args)
{
_cbdExecuteFunc(func, args);
}
vg.util.disableTextSelection=function(event)
{
var event=jsCBDgetEvent(event );
if(ie)
{
event.returnValue=false;
}
else
{
el.style['-moz-user-select']='none';
}
}
vg.util.getHTMLbodyHeight=function()
{
var wDiv=vg.html.getElement('wrapDiv');
if(wDiv!=null)
{
return(wDiv.clientHeight >=wDiv.scrollHeight)?wDiv.clientHeight+'px':wDiv.scrollHeight+'px';
}
var ieHeight=(document.body.clientHeight >=document.body.scrollHeight)?document.body.clientHeight:document.body.scrollHeight;
return(ie)?ieHeight+'px':document.documentElement.scrollHeight+'px';
}
vg.util.getHTMLbodyWidth=function()
{
if(vg.html.getElement('wrapDiv'))
{
return(ie)?document.body.scrollWidth - 16+'px':document.documentElement.scrollWidth - 16+'px';
}
return(ie)?document.body.scrollWidth+'px':document.documentElement.scrollWidth+'px';
}
vg.util.getHTMLbodyScrollTop=function()
{
var wDiv=vg.html.getElement('wrapDiv');
if(wDiv!=null)
{
return(wDiv.scrollTop);
}
return document.body.scrollTop;
}
vg.util.setHTMLbodyScrollTop=function(scrollTopPos)
{
var wDiv=vg.html.getElement('wrapDiv');
if(wDiv!=null)
{
wDiv.scrollTop=scrollTopPos;
}
else
{
document.body.scrollTop=scrollTopPos;
}
}
vg.util.removeTags=function(s)
{
return String(s).replace(/<\/?[^>]+>/gi, "");
}
vg.util.concat=function(array1, array2)
{
for(var i=0;i < array2.length;i++)
{
array1.push(array2[i])
}
}
vg.util.execOnPageReady=function(func)
{
if(RIA)
{
cbd.loader.addCallback(func);
cbd.loader.load();
}
else
{
if(_cbdNonRiaPageReady)
{
func();
}
else
{
vg.html.addEventListener(window, 'load', func);
}
}
}
vg.util.checkConditionsAndExecute=function(conditions, func, trials)
{
_cbdCheckConditionsAndExecute(conditions, func, trials)
}
vg.util.isDefined=function(variable)
{
return(typeof variable!='undefined');
}
vg.util.throwException=function(methodName, error)
{
throw("Method name:"+methodName+";Error:"+error);
}
vg.util.attachJsonOptions=function(obj, opts )
{
for(var i in opts )
{
var opt=opts[i];
obj[i]=opt;
}
}
vg.util.createNameValObj=function(name, value )
{
return{name:name, value:value};
}
vg.util.buildBooleanTable=function(data )
{
var table=[];
for(var i=0;i < data.length;i++)
{
var row=data[i];
var bools=row[0];
var val=row[1];
var arr=table;
for(var j=0;j < bools.length;j++)
{
var flag=bools[j];
var idx=(flag?1:0 );
if(arr[idx]==null )
{
if(j+1==bools.length )
{
arr[idx]=val;
}
else
{
arr[idx]=[];
}
}
arr=arr[idx];
}
}
return table;
}
vg.util.getBooleanTableValue=function(table, bools )
{
var ptr=table;
for(var i=0;i < bools.length;i++)
{
ptr=ptr[bools[i]?1:0];
}
return ptr;
}
vg.util._convertToString=function(obj)
{
var type=typeof(obj);
if(type=="string")
{
var delim=obj.indexOf("'") < 0?"'":'"';
//remove new lines
obj=obj.replace(/\n/g, ' ');
return delim+obj+delim;
}
else if(type!="object")
{
//other primitive types;return as is
return obj;
}
str="";
if(obj instanceof Array)
{
str="[";
for(var i=0;i < obj.length;++i)
{
if(i > 0)
{
str+=",";
}
str+=vg.util._convertToString(obj[i]);
}
str+="]";
}
else if(type=="object")
{
//JSON object
str="{";
var i=0;
for(var p in obj)
{
if(i++> 0)
{
str+=",";
}
//propName can't contain dots
var propName=p.replace(/\./g, '_');
str+=(propName+":");
str+=vg.util._convertToString(obj[p]);
}
str+="}";
}
return str;
}
//
//Check if a string starts with provided character
//PARAMS:
//string=string to check
//char=character to match
//
vg.string.startsWith=function(string, char)
{
return string.charAt(0)==char;
}
//
//Check if a string starts with provided character
//PARAMS:
//string=string to check
//Strubg=string to match
//
vg.string.startsWithStr=function(str, strToMatch)
{
return(str.match("^"+strToMatch)==strToMatch)
}
/*****************************************************************************
*
*Animation(SMIL) APIs
*
*****************************************************************************/
//
//Checks if the SMIL(animation) module has been loaded
//
vg.smil.isLoaded=function()
{
return window.YAHOO&&YAHOO.util&&YAHOO.util.Anim;
}
//
//Convert a given string with units into a number
//This function will stip the units portion out of the string
//It will work with a+or - sign in front of the number
//If the input is a time in seconds, it is converted into milliseconds
//
vg.smil.convertUnits=function(t )
{
var res=vg.smil.convertUnits.re.exec(t );
var ret=1;
if(res!=null )
{
//Check for a negative
if(res[1]=="-" )
{
ret=-1;
}
//grab the integer value
ret*=parseInt(res[2]);
//if seconds was passed in, then convert to milliseconds
if(res[3]=="s" )
{
ret*=1000;
}
}
return ret;
}
//regular expression to strip the units
vg.smil.convertUnits.re=new RegExp("([\\+\\-]?)(\\d+)(ms|s|\\%)?" );
vg.smil.EASE_IN="easeIn";
vg.smil.getEasing=function(easingStr)
{
return YAHOO.util.Easing[easingStr];
}
//
//General animation routine
//
//Parameters:
//target - id or DOM element
//attr - attribution to animage(e.g. opacity)
//duration - milliseconds
//beginTime - how long to wait to start animation. 0 is right away
//frompoint - beginning value(Optional - Must specify From, To, or By)
//topoint - ending value(Optional)
//bypoint -(Optional)
//easeIn -(Optional)[true/false]defaults to false, if true, the YAHOO.util.Easing.easeIn method will be added to the animation
//colorAnimation - used to animate color
//easing -(Optional) specifies which YAHOO.util.Easing method to add to the animation(overrides easeIn attribute, when specified)
//
vg.smil.Animation=function(target, attr, duration, beginTime, frompoint, topoint, bypoint, funcFinished, easeIn, colorAnimation, motionAnimation, scrollAnimation, easing)
{
if(target.target!=null)
{
var params=target;
target=params.target;
attr=params.attr;
duration=params.duration;
beginTime=params.beginTime;
frompoint=params.frompoint;
topoint=params.topoint;
bypoint=params.bypoint;
funcFinished=params.funcFinished;
easeIn=params.easeIn;
colorAnimation=params.colorAnimation;
motionAnimation=params.motionAnimation;
scrollAnimation=params.scrollAnimation;
easing=params.easing;
}
this.duration=duration;
this.beginTime=beginTime;
this.attributes={};
this.stopped=false;
this.ready=false;
this.colorAnimation=colorAnimation;
this.motionAnimation=motionAnimation;
this.scrollAnimation=scrollAnimation;
if(!easing&&easeIn)
{
//Convert boolean easeIn into easing string
easing=vg.smil.EASE_IN;
}
if(typeof(attr )=='string' )
{
//Default, no attributes
this.attributes[attr]={};
//Handle optional From, To, By attributes
if(frompoint!==undefined&&frompoint!=null ){this.attributes[attr].from=frompoint;}
if(topoint!==undefined&&topoint!=null ){this.attributes[attr].to=topoint;}
if(bypoint!==undefined&&bypoint!=null ){this.attributes[attr].by=bypoint;}
}
else
{
this.attributes=attr;
}
var THIS=this;
//make sure YUI animation is loaded
cbd.loader.loadAndExec('animation', function(){THIS.init(target, attr, funcFinished, easing );}, true );
}
//
//Initialize the YUI animation object
//
vg.smil.Animation.prototype.init=function(target, attr, funcFinished, easing )
{
if(this.motionAnimation)
{
this.anim=new YAHOO.util.Motion(target, this.attributes, this.duration/1000 );
}
//Check for color animation and call approprate Yahoo routine
else if(this.colorAnimation)
{
this.anim=new YAHOO.util.ColorAnim(target, this.attributes, this.duration/1000 );
}
else if(this.scrollAnimation)
{
this.anim=new YAHOO.util.Scroll(target, this.attributes, this.duration/1000);
}
else
{
this.anim=new YAHOO.util.Anim(target, this.attributes, this.duration/1000, easing );
}
if(!this.colorAnimation)
{
/*
*Fire the custom event vg.event.GEO_CHANGE during and after the animation.
*Minimally, pass in the targetElement to the custom event listeners
*/
var targetElement=vg.html.getElement(target );
this.duringAnimation(function smil_geo_change(){vg.html._fireCustomEvent(vg.event.GEO_CHANGE, targetElement )});
this.addOnFinish(function smil_geo_change(){vg.html._fireCustomEvent(vg.event.GEO_CHANGE, targetElement );});
}
//if a finished callback was specified
if(funcFinished )
{
this.addOnFinish(funcFinished );
}
this.ready=true;
this.anim.animate();
}
//
//Get the amount of time since the start of the animation
//
vg.smil.Animation.prototype.timeElapsed=function()
{
return new Date().getTime() - this.anim.getStartTime().getTime();
}
//
//Stop the animation
//
vg.smil.Animation.prototype.stop=function()
{
this.stopped=true;
this.anim.stop(false );
}
//
//Start the animation
//Note:this method is deprecated, since we now call animate() in the init() method of vg.smil.Animation
//
vg.smil.Animation.prototype.start=function()
{
var THIS=this;
setTimeout(
function vg_smil_start_timeout()
{
vg.util.checkConditionsAndExecute(
function vg_smil_check_anim_loaded()
{
return THIS.ready;
},
function vg_smil_start()
{
THIS.anim.animate();
}
);
}, THIS.beginTime );
}
//
//Add a callback that gets executed at every step of the animation
//
//PARAMS:
//func - function that will be executed
//
vg.smil.Animation.prototype.duringAnimation=function(func )
{
var THIS=this;
//uses YUI "onTween" method
this.anim.onTween.subscribe(function anim_onTween(){if(!THIS.stopped ){func();}});
}
//
//Add a callback that gets executed at the end of an animation
//
//PARAMS:
//func - function that will be executed
//
vg.smil.Animation.prototype.addOnFinish=function(func )
{
var THIS=this;
//uses YUI "onComplete" method
this.anim.onComplete.subscribe(
function anim_onComplete()
{
if(!THIS.stopped )
{
func();
}
}
);
}
//
//Set the easing method for smoother animations
//
//PARAMS:
//name - name of the easing function
//
vg.smil.Animation.prototype.setEase=function(name )
{
var easing=YAHOO.util.Easing[name];
if(easing )
{
this.anim.method=easing;
}
}
//
//Animate an element
//
//PARAMS:
//element - node that will be animated
//attr - attribute to be animated, or json config object
//duration - time in ms for the animation
//beginTime - time before the animation starts
//frompoint - start point
//topoint - end point
//bypoint - by point(only use topoint XOR bypoint )
//funcFinished - function that gets executed after the animation completes
//colorAnimation - used do animate colors.
//easing - adds easing to animation
//
vg.smil.animateElement=function(element, attr, duration, beginTime, frompoint, topoint, bypoint, funcFinished, easeIn, colorAnimation, motionAnimation, scrollAnimation, easing )
{
var anim=new vg.smil.Animation(element, attr, duration, beginTime, frompoint, topoint, bypoint, funcFinished, easeIn, colorAnimation, motionAnimation, scrollAnimation, easing );
return anim;
}
/*****************************************************************************
*
*Mouse Manager
*
*****************************************************************************/
//
//Create a Mouse Manager object to manage Enter and Leave events
//
//Parameters:
//config - json config object
//onMouseEnter - user function to call when entering container
//onMouseLeave - user function to call when leaving container
//element - HTML node to execute mouseEnter/Leave on
//
vg.MouseManager=function(config)
{
vg.util.attachJsonOptions(this, config);
this.inElement=false;
vg.html.addEventListenerMethod(this.element, 'mouseleave', this, 'mouseLeave' );
vg.html.addEventListenerMethod(this.element, 'mouseenter', this, 'mouseEnter' );
}
vg.MouseManager.prototype.mouseEnter=function(e)
{
this.inElement=true;
var controller=this;
var event=jsCBDgetEvent(e, true);
//Check for previous timeout. If one exists, cancel this one
if(this.mouseEnterTimer!=null)
{
/*
*Kill the previous timeout
*/
clearTimeout(this.mouseEnterTimer);
}
//Delay a little and check if we are still inside the box
this.mouseEnterTimer=setTimeout(function()
{
controller.checkMouseIn(event);
},
10);
}
vg.MouseManager.prototype.mouseLeave=function(e)
{
this.inElement=false;
var controller=this;
var event=jsCBDgetEvent(e, true);
//Check for previous timeout. If one exists, cancel this one
if(this.mouseLeaveTimer!=null)
{
/*
*Kill the previous timeout
*/
clearTimeout(this.mouseLeaveTimer);
}
//Delay a little and check if we have left the box
this.mouseLeaveTimer=setTimeout(function()
{
controller.checkMouseOut(event);
},
100);
}
vg.MouseManager.prototype.checkMouseIn=function(e)
{
//If in element, than call user function
if(this.inElement)
{
this.onMouseEnter(e);
}
}
vg.MouseManager.prototype.checkMouseOut=function(e)
{
//If in element, than call user function
if(!this.inElement)
{
this.onMouseLeave(e);
}
}
/*****************************************************************************
*
*Element Persistance APIs
*
*****************************************************************************/
//
//Create a persistance object
//
//Parameters:
//obj - json config object
//openFunc - function to call to open the attached container
//closeFunc - function to call to close the attached container
//gobalDiv - reference to the attached container ndoe
//
//
vg.ElementPersistance=function(obj )
{
vg.util.attachJsonOptions(this, obj );
this.onlink=false;
this.openflag=false;
this.pendingTimeouts=[];
this.count=0;
this.globalDiv.persistObj=this;
vg.html.addEventListenerMethod(this.globalDiv, 'mouseleave', this, 'globalOut' );
vg.html.addEventListenerMethod(this.globalDiv, 'mouseenter', this, 'globalIn' );
}
//
//Called when the user mouses over the link
//
//Parameters:
//id - id of the container
//link - reference to the link that is being moused over
//
vg.ElementPersistance.mouseLinkEnter=function(id, link )
{
var THIS=document.getElementById(id ).persistObj;
if(THIS.setTarget )
{
THIS.setTarget(link.getAttribute('id' ) );
}
THIS.linkIn();
}
//
//Called when the user mouses out of the link
//
//Parameters:
//id - id of the container
//
vg.ElementPersistance.mouseLinkLeave=function(id )
{
var THIS=document.getElementById(id ).persistObj;
THIS.linkOut();
}
//
//Add the event handlers to a link node
//
//Paramaeters:
//node - link node
//
vg.ElementPersistance.prototype.addLinkNode=function(node )
{
node=vg.html.getElement(node );
vg.html.addEventListenerMethod(node, 'mouseenter', this, 'linkIn' );
vg.html.addEventListenerMethod(node, 'mouseleave', this, 'linkOut' );
}
//
//Called the mouse moves into a link
//
//Parameters:
//e - event object
//
vg.ElementPersistance.prototype.linkIn=function(e )
{
this.onlink=true;
this.clearTimeouts();
if(this.openflag )
{
if(this.repositionFunc )
{
this.repositionFunc();
}
}
else
{
var THIS=this;
var event=e;
this.pendingTimeouts.push(setTimeout(function(){THIS.openflag=true;THIS.openFunc(event );}, 500 ) );
}
}
//
//Called when the mouse moves out of the link
//
//Parameters:
//e - event object
//
vg.ElementPersistance.prototype.linkOut=function(e )
{
this.onlink=false;
this.clearTimeouts();
this.delayThenClose();
}
//
//Delay, then try to close
//
vg.ElementPersistance.prototype.delayThenClose=function()
{
var THIS=this;
this.pendingTimeouts.push(setTimeout(function(){THIS.checkClose();}, 200 ) );
}
//
//Called when the mouse moves out of the container object
//
//Parameters:
//e - event object
//
vg.ElementPersistance.prototype.globalOut=function(e )
{
this.count--;
this.clearTimeouts();
this.delayThenClose();
}
//
//Called when the mouse moves into the container object
//
//Parameters:
//e - event object
//
vg.ElementPersistance.prototype.globalIn=function(e )
{
this.count++;
}
//
//Check to see if we should close the component
//
vg.ElementPersistance.prototype.checkClose=function()
{
if(!this.onlink&&this.count==0 )
{
this.openflag=false;
this.closeFunc();
}
}
//
//Stop all pending timeouts from executing
//
vg.ElementPersistance.prototype.clearTimeouts=function()
{
for(var i=0;i < this.pendingTimeouts.length;i++)
{
clearTimeout(this.pendingTimeouts[i]);
}
this.pendingTimeouts=[];
}
/*****************************************************************************
*
*Component APIs
*
*****************************************************************************/
//
//Check to see if the component is ready
//
//PARAMs:
//target - id of the component to check, or component itself
//
vg.comp._isCompReady=function(target)
{
return vg.comp._hasController(target);
}
//
//Check to see if a node has a controller of a given type
//
//PARAMS:
//node - Node to check for a controller
//type -(optional) type of controller to check for
//
vg.comp._hasController=function(node, type )
{
//was null passed in
if(!node )
{
return false;
}
//get the node if the id was passed in
node=vg.html.getElement(node );
//if an id of a node that doesn't exist is passed in, then node will
//be null, we o we have to do another check
if(!node )
{
return false;
}
var isDefined=typeof(node.jsController )!='undefined';
if(type )
{
return isDefined&&(node.jsController instanceof type);
}
return isDefined;
}
//
//Check to see if a node is a container
//
//PARAMS:
//node - Node to check
//
vg.comp._isContainer=function(node )
{
if(!node )
{
return false;
}
node=vg.html.getElement(node );
var isDefined=typeof(node.jsController )!='undefined';
if(!isDefined )
{
return false;
}
var isContainer=false;
isContainer=isContainer||(window.NavBox&&node.jsController instanceof NavBox );
isContainer=isContainer||(window.Layer&&node.jsController instanceof Layer );
isContainer=isContainer||(window.SideTab&&node.jsController instanceof SideTab );
isContainer=isContainer||(window.Deck&&node.jsController instanceof Deck );
isContainer=isContainer||(window.AccordionItem&&node.jsController instanceof AccordionItem );
return isContainer;
}
//
//Traverses the DOM tree upwards and returns first available controller.
//
vg.comp.findController=function(target, startFromParent)
{
var node=vg.html.getElement(target);
if(startFromParent)
{
node=node.parentNode;
}
var jsController;
do
{
jsController=vg.comp.getController(node);
if(jsController!=null)
{
return jsController;
}
node=vg.html._getParentNode(node);
}while(node!=null)
//vg.util.throwException('vg.comp.findController', 'controller not found');
}
//
//invokes the specified method on a controller.
//
//PARAMs:
//target - id of a viewNode or viewNode object
//methodName - method to call
//args - arguments to pass to the method
//
//<span class="attention">FOR INTERNAL CBD USE ONLY</span>
//
vg.comp.callMethod=function(target, methodName, args)
{
var controller=vg.comp.getController(target);
controller[methodName].call(controller, args);
}
//
//Replace "this" reference in attribute with the object and execute function
//PARAMS:
//attrValue - value of the event handler
//node - html node on which the handler is triggered
//
vg.comp._execEventHandler=function(attrValue, node)
{
var thisRef=node;
var pattern=/([\,\:\s\(]{1})this([\,\s\.\)]{1})/g;
attrValue=attrValue.replace(pattern,"$1thisRef$2");
attrValue=attrValue.replace(/return false;?$/g,'');
return eval(attrValue);
}
//
//Find all the nodes that have the bleeding and hidden problem
//
//<span class="attention">FOR INTERNAL CBD USE ONLY</span>
//
//PARAMs:
//base - root node to start searching from
//
vg.comp.findHiddenComponents=function(base )
{
var inputs=new Array;
var spans=base.getElementsByTagName('span' );
for(var i=0;i < spans.length;i++)
{
inputs.push(spans[i]);
}
var divs=base.getElementsByTagName('div' );
for(var i=0;i < divs.length;i++)
{
inputs.push(divs[i]);
}
return inputs;
}
//
//Repaint all the nodes that have the bleeding and hidden problem
//
//<span class="attention">FOR INTERNAL CBD USE ONLY</span>
//
//PARAMs:
//base - root node to start searching from
//
vg.comp.repaintSubComponents=function(base )
{
var inputs=vg.comp.findHiddenComponents(base );
for(var i=0;i < inputs.length;i++)
{
var node=inputs[i];
var height=node.style.height;
node.style.height='1px';
node.style.height=height;
}
}
//
//Returns controller
//
vg.comp.getController=function(target)
{
return vg.html.getElement(target).jsController;
}
//
//Returns content node
//
vg.comp.getContentNode=function(target)
{
return vg.comp.getController(target).contentNode;
}
//
//Changes display property on the viewNodes associated with items(controllers)
//
vg.comp._hideAllItems=function(items)
{
var length=items.length;
for(var i=0;i < length;i++)
{
/*
*items[i]is a controller
*/
jsCBDtoggleElement(items[i].viewNode, false);
}
}
//
//Array with which components are registered
//
vg.comp._registeredComps=new Array();
//
//Registers the component if it is present on the page
//PARAMS:
//compName=the name of the component to check
//
vg.comp._registerComponent=function(compName)
{
vg.comp._registeredComps[compName.toLowerCase()]=true;
}
//
//Checks to see if the component has been registered
//PARAMS:
//compName=the name of the component to check
//
vg.comp._isCompRegistered=function(compName)
{
return vg.comp._registeredComps[compName.toLowerCase()];
}
vg.comp._configureHiddenItems=function(node)
{
vg.comp._configureSlider(node);
}
vg.comp._configureSlider=function(node)
{
//Search for YUI slider
var oSliders=vg.html.getElements(node,{tagName:'div', attrName:'class', attrValue:'sliderBar'});
var sliderController;
for(var i=0;oSliders!=null&&i < oSliders.length;i++)
{
sliderController=vg.comp.getController(oSliders[i]);
if(sliderController!=null)
{
if(cbd.loader.isPageReady())
{
sliderController.show();
}
else
{
vg.util.execOnPageReady(function(){sliderController.show()});
}
}
}
}
//
//Check to see if a component has been loaded
//
vg.comp.isCompLoaded=function(name )
{
return window[name]!=null;
}
//
//Get the ancestor of type=button from the event node
//
vg.comp.getButtonFromNode=function(node)
{
var buttonNode=vg.html.findAncestor(node,{tagName:"span", attrName:"type", attrValue:"button"});
return buttonNode;
}
/*********Start of Controller(superclass of all component controllers)****************/
vg.Controller=function(viewNodeId, contentNode, jsTransient)
{
this.viewNode=vg.html.getElement(viewNodeId);
if(!this.viewNode )
{
//jsTransient - attribute in selectOneMenu tag
if(jsTransient)
{
//return if jsTransient is set to true
return;
}
else
{
//display an error if the viewNode is invalid
console.error('Invalid viewNode id='+viewNodeId );
}
}
this.contentNode=contentNode;
this.viewNode.jsController=this;
}
vg.Controller.prototype=
{
/*
*Returns the controller
*/
getController:function()
{
return this.jsController;
},
/*
*Returns the viewNode
*/
getViewNode:function()
{
return this.viewNode;
},
/*
*Set that state of the component based on the history state
*/
setStatusFromHistory:function(status )
{
}
}
/**********************End of Controller*****************************/
/**********************Start of Button*********************************/
var BUTTON_DEFAULT_STYLE="default";
var BUTTON_HIGHLIGHT_STYLE="hover";
var BUTTON_ACTIVE="press";
var BUTTON_INPUT_CLASS="btn";
//Get the span node
vg.button._getSpan=function(button)
{
return vg.html.getFirstChild(vg.html.getElement(button));
}
vg.button._mouseInOut=function(selected, button)
{
if(vg.button._isDisabled(button))
{
return false;
}
var span=vg.button._getSpan(button);
if(selected)
{
vg.html.replaceClass(span, BUTTON_DEFAULT_STYLE, BUTTON_HIGHLIGHT_STYLE)
}
else{
jsCBDdeleteStyle(span, BUTTON_ACTIVE);
vg.html.replaceClass(span, BUTTON_HIGHLIGHT_STYLE, BUTTON_DEFAULT_STYLE);
}
}
//
//Check if button disabled
//
vg.button._isDisabled=function(button)
{
var buttonChildren=vg.html.getElements(button,{tagName:'input', attrName:'class'}, function(input){return vg.html.hasStyle(BUTTON_INPUT_CLASS, input);});
var buttonInput=buttonChildren[0];
var disabled='false';
if(buttonInput)
{
disabled=buttonInput.getAttribute('disabledBtn');
}
return(disabled=='true'||disabled=='disabled');
}
//
//Sets required  styles
//
vg.button._select=function(selected, button, event)
{
var key=jsCBDgetKey(jsCBDgetEvent(event));
if(key==9||key==16 )
{
selected=false;
}
if(vg.button._isDisabled(button))
{
return false;
}
var span=vg.button._getSpan(button);
if(selected)
{
jsCBDaddStyle(span, BUTTON_ACTIVE);
vg.html.replaceClass(span, BUTTON_HIGHLIGHT_STYLE, BUTTON_DEFAULT_STYLE);
}
else
{
jsCBDdeleteStyle(span, BUTTON_ACTIVE);
}
}
//Focus event
vg.button._focus=function(button)
{
var span=vg.button._getSpan(button);
jsCBDaddStyle(span, BUTTON_FOCUS);
}
//Blur event
vg.button._blur=function(button)
{
var span=vg.button._getSpan(button);
jsCBDdeleteStyle(span, BUTTON_ACTIVE);
jsCBDdeleteStyle(span, BUTTON_FOCUS);
vg.html.addOrRemoveStyleFromNodes(BUTTON_ROW_HIGHLIGHT_STYLE, span.getElementsByTagName('tr'),  false);
}
//disables/enable a button
//
//PARAMS:
//controller - button controller
//state -- boolean takes on the following values:
//true -- to disable
//false -- to enable
//
vg.button._disable=function(button, state)
{
var disableValue=(state)?"disabled":"false";
var span=vg.button._getSpan(button);
(state)?jsCBDaddStyle(span, "disabled"):jsCBDdeleteStyle(span, "disabled");
var oldClass=null;
var newClass=null;
var buttonTd=vg.html.getFirstChild(vg.html.getFirstChild(span));
oldClass=(state)?'default':'disabled';
newClass=(state)?'disabled':'default';
vg.html.replaceClass(buttonTd, oldClass, newClass);
var buttonChildren=vg.html.getElements(button,{tagName:'input', attrName:'class'}, function(input){return vg.html.hasStyle(BUTTON_INPUT_CLASS, input);});
var buttonInput=buttonChildren[0];
(state)?buttonInput.setAttribute("disabledBtn", disableValue):buttonInput.removeAttribute("disabledBtn");
var inpId=button.getAttribute('id');
jsCBDcreateHiddenInput(inpId, state, inpId, button.parentNode);
}
//
//Handles onClick functionality
//
vg.button._handleClick=function(event,button)
{
if(vg.button._isDisabled(button))
{
return false;
}
//
//For intDisabledCobrowsable buttons, only allow the click action,
//when it's triggered by the cobrowse engine in the playback mode
//(vg.cobrowse.isInPlayBackMode() is true)
//
if(vg.cobrowse.allowPlayBackOnly(button)&&!vg.cobrowse.isInPlayBackMode(button))
{
return false;
}
event=jsCBDgetEvent(event );
//Record this event for cobrowse
vg.cobrowse.recordEvent(event, button, null );
var onClickAttr=button.getAttribute('clickJs');
var thisRef=button;
if(onClickAttr!=null)
{
vg.comp._execEventHandler(onClickAttr, thisRef);
}
if(!button.getAttribute('blockSubmit'))
{
vg.button._submit(button);
}
}
//
//Handles enter key
//
vg.button._keyPress=function(e, button)
{
button=vg.html.getElement(button);
e=jsCBDgetEvent(e);
var key=jsCBDgetKey(e);
if(key==9 )
{
var span=vg.html.getFirstChild(vg.button._getSpan(button));
jsCBDdeleteStyle(span, BUTTON_ACTIVE);
}
else if(key==13 )
{
vg.button._select(true, button);
}
}
//
//Sets focus on a button
//
vg.button.setFocus=function(button)
{
var button=vg.html.getElement(button);
var input=button.getElementsByTagName("input");
input[0].focus();
}
//
//Executes validation and submits the form
//
vg.button._submit=function(button)
{
var onSubmit=button.getAttribute('onSubmit');
var showMsg=button.getAttribute('showWaitMsgOnSubmit');
var immediate=button.getAttribute('immediate');
var disableWT=button.getAttribute('wtCallDisabled');
if(onSubmit==null||eval(onSubmit))
{
if(immediate)
{
vg.validation.submitParentForm(button, showMsg, disableWT)
}
else
{
vg.validation.validateAndSubmitParentForm(button, showMsg, disableWT)
}
}
}
//
//Handles click functionality
//
//PARAMs:
//target - id of a button object
//
vg.button.triggerClick=function(target )
{
var button=vg.html.getElement(target);
if(!vg.button._isDisabled(button))
{
jsCBDtriggerEventOnNode(target, 'click');
}
}
/**********************End of Button*********************************/
/**********************Start of Deck*********************************/
//
//Returns index of the selected deck card
//PARAMS:
//deckId=id of deck component
//
cbdns.jsCBDgetSelectedDeckCardIndex=function(deckId)
{
return vg.comp.getController(deckId).selectedIndex;
}
//
//Used to select a deck's card(includes PREV or NEXT capability)
//
//PARAMS:
//deckId - id of the deck
//cardIdx - index of deckCard that needs to be displayed(starts with 0)
//
//OPTIONAL:
//wrap -[true/false]Defaults to true;If true, the function will roll thru to the first or last card when the last or first card is reached, respectively
//
//RETURNS:
//args - the argument returned to the calling function, which is comprised of:
//1) args.curCard=current card index after this function has executed
//2) args.totalCards=total number of cards in the deck
//
//EXAMPLE(s):
//jsCBDselectDeckCard('myDeck',"2",null)
//jsCBDselectDeckCard('myDeck',PREV,false)
//jsCBDselectDeckCard('myDeck',NEXT,false)
//
var PREV=-1;
var NEXT=999;
cbdns.jsCBDselectDeckCard=function(deckId, cardIdx, wrap)
{
//if cardIdx is not equal to PREV or NEXT, then it must be a specific card index that the user wants selected
if(cardIdx!=PREV&&cardIdx!=NEXT )
{
vg.comp.callMethod(deckId, 'select',[cardIdx]);
return;
}
else
{
/*
*cardIdx must be PREV or NEXT so go to previous or next card accordingly
*/
wrap=(wrap==null)?true:wrap;
var deck=vg.comp.getController(deckId);
var args={};
args.totalCards=deck.items.length - 1;
cardIdx=(cardIdx==NEXT)?1:cardIdx;//if cardIdx=NEXT, then make cardIdx equal to+1(vs. -1 for PREV)
var toCard=deck.selectedIndex+cardIdx;
toCard=(toCard > args.totalCards||toCard < 0 )?deck.selectedIndex:toCard;//avoid setting toCard to a card that does not exist
/*
*if wrap is false, then goto prev or next card if the curIndex!=to the first or last card
*else(i.e., wrap is true),  then goto last card in deck if curIndex=0, or goto first card if curIndex=last card, or go to the prev or next card depending on value of dir
*/
if(!wrap&&(deck.selectedIndex!=args.totalCards||deck.selectedIndex!=0) )
{
deck.select(toCard );
}
else
{
if(deck.selectedIndex==0&&cardIdx < 0)
{
deck.select(deck.items.length -1);
}
else if(deck.selectedIndex==args.totalCards&&cardIdx > 0)
{
deck.select(0);
}
else
{
deck.select(toCard );
}
}
args.curCard=deck.selectedIndex;//pass back the now currently selected card index
}
//we need to confige selectonemenu when deck is open
vg.comp._configureHiddenItems(document.getElementById(deckId));
//pass back args, i.e., the currently selected card index and total cards to the calling function
if(args) return args;
}
//
//Used to load a card's content
//
//PARAMS:
//cardId - id of the deck card
//
//OPTIONAL:
//callback - user callback function passed without "()"
//
cbdns.jsCBDloadCardContent=function(cardId, callback)
{
cbd.Navigator.userCallback=callback;
vg.comp.getController(cardId).loadCardContent();
}
//
//sets content url on deckCard component
//PARAMS:
//deckId=id of deckCard component
//url - content url
//
cbdns.jsCBDsetDeckCardContentUrl=function(cardId, url)
{
var deckCard=document.getElementById(cardId);
deckCard.setAttribute("url", url);
}
Deck=function(id, adjustZoom, transDur)
{
this.base=vg.Controller;
this.base(id, null);
this.items=new Array();
this.id=id;
this.selectedIndex=this.viewNode.getAttribute('selectedcardidx');
this.transType=this.viewNode.getAttribute('transitiontype');
this.fadeInOut=this.transType=="NONE"||this.transType=="CBD_FADE_IN_OUT_DECK";
this.vertSlide=this.transType=="CBD_VERT_SLIDE";
this.horizSlide=this.transType=="CBD_HORIZ_SLIDE";
this.carouselType=(this.viewNode.getAttribute('carouselType')!=null)?true:false;
this.slider=vg.html.getFirstChild(this.viewNode);
this.height=this.viewNode.getAttribute('height');
this.isAnimated="true"==this.viewNode.getAttribute('transition');
this.afterInit=false;
this.isAdjustZoom=adjustZoom;
this.transDur=transDur;
this.easingStr=this.viewNode.getAttribute('easing');
if(this.selectedIndex!=null&&this.horizSlide)
{
var newPosition=-(this.selectedIndex*100);
this.slider.style.left=newPosition+"%";
}
var controller=this;
if(this.carouselType) vg.util.execOnPageReady(function(){controller._getCarouselControllers()});
if(this.easingStr)
{
//Set easing function
vg.util.execOnPageReady(function(){controller.easing=vg.smil.getEasing(controller.easingStr);});
}
}
Deck.prototype=
{
select:function(cardIdx)
{
if(this.selectedIndex==cardIdx)
{
return;
}
//unselected all deck cards
if(!this.horizSlide&&!this.vertSlide)
{
vg.comp._hideAllItems(this.items);
}
//select a card
var selectedCard=this.items[cardIdx];
var selectedNode=selectedCard.viewNode;
if(this.isAnimated&&this.fadeInOut)
{
vg.html.setOpacity(selectedNode, '0', this.isAdjustZoom);
}
jsCBDtoggleElement(selectedNode, true);
this.setSelectedCard(vg.comp.getController(selectedNode));
//send the selected card to the server
cbd.StateKeeper._setState(this.viewNode.getAttribute('id'), cardIdx, true);
//load data
selectedCard.loadCardContent();
//execute animation
selectedCard.animate();
},
_setHeight:function()
{
if(this.afterInit)
{
var curHeight=this.viewNode.style.height
this.viewNode.style.height="auto";
var toHeight=this.items[this.selectedIndex].viewNode.scrollHeight;
this.viewNode.style.height=curHeight;
var attributes={height:{to:toHeight}};
vg.smil.animateElement({target:this.viewNode, attr:attributes, duration:150, easeIn:false});
}
else
{
var setCardPosition=-(this.selectedIndex*100);
this.slider.style.top=setCardPosition+"%";
vg.html.setHeight(this.viewNode, this.items[this.selectedIndex].viewNode.scrollHeight+"px");
this.afterInit=true;
}
},
addItem:function(controller)
{
var length=this.items.length;
this.items[length]=controller;
controller.index=length;
},
setSelectedCard:function(controller)
{
this.selectedIndex=controller.index;
},
_getCarouselControllers:function()
{
var controller=this;
this._carContLft=document.getElementById(this.id+"_carLft");
this._carContRgt=document.getElementById(this.id+"_carRgt");
vg.html.addEventListener(this._carContLft, 'click', function(){controller._triggerCarousel('left')});
vg.html.addEventListener(this._carContRgt, 'click', function(){controller._triggerCarousel('right')});
this._configCarousel();
},
_triggerCarousel:function(dir)
{
jsCBDselectDeckCard(this.id,(dir=='left')?PREV:NEXT, false);
this._configCarousel();
},
_configCarousel:function()
{
vg.html.removeStyle("carDisabled", this._carContLft);
vg.html.removeStyle("carDisabled", this._carContRgt);
if(this.selectedIndex==0||this.items.length==1)
{
vg.html.addStyle("carDisabled", this._carContLft);
}
if(this.selectedIndex==this.items.length-1||this.items.length==1)
{
vg.html.addStyle("carDisabled", this._carContRgt);
}
},
_setTransDur:function(defaultTransDur)
{
//Is the user-supplied transition duration valid?
if(this.transDur==null||this.transDur==''||isNaN(this.transDur))
{
//Invalid, so set default value
this.transDur=defaultTransDur;
}
else
{
//Looks valid, save as floating point number
this.transDur=parseFloat(this.transDur);
}
//Convert supplied value to milliseconds
this.transDur=this.transDur*1000;
}
}
DeckItem=function(id, selected)
{
this.base=vg.Controller;
var contentNode=document.getElementById(id);
this.width=contentNode.getAttribute('width');
this.base(id, contentNode, true);
this.selected=selected;
this.id=id;
this.onTransCallback=null;
this.deckContr=vg.comp.findController(contentNode, true);
this.deckContr.addItem(this);
var contr=this;
//set width
contentNode.style.width=this.width;
//load data
if(this.selected)
{
if(this.deckContr.vertSlide)
{
this.deckContr._setTransDur(.3);
this.viewNode.style.overflow="auto";
}
else if(this.deckContr.horizSlide)
{
this.deckContr._setTransDur(.3);
}
else if(this.deckContr.fadeInOut)
{
this.deckContr._setTransDur(1.5);
}
else
{
//We should not get here, but if we do set a default of 1500 ms(1.5 seconds)
this.deckContr._setTransDur(1.5);
}
this.deckContr.setSelectedCard(this);
this.loadCardContent(true);
}
}
DeckItem.prototype=
{
setCardContHeight:function()
{
this.contHeight=this.viewNode.scrollHeight;
},
animate:function()
{
//get parent controller to see if transition is set to false on deck
var contentNode=this.contentNode;
if(this.deckContr.isAnimated)
{
if(this.deckContr.horizSlide)
{
this._horizSlide();
}
else if(this.deckContr.vertSlide)
{
this._vertSlide();
}
else
{
this._fadeInOut();
}
}
},
_vertSlide:function()
{
//
//To figure out what portion of slider div to display we need to multiply current item index by 100
//
var newPosition=-(this.deckContr.selectedIndex*100);
var currentPosition=parseInt(this.deckContr.slider.style.top);
if(!currentPosition)
{
currentPosition=0;
}
var attributes={top:{from:currentPosition, to:newPosition, unit:"%"}};
var THIS=this;
var afterAnim=function()
{
if(THIS.deckContr.height=="auto")
{
THIS.deckContr._setHeight();
}
else
{
THIS.deckContr.items[THIS.deckContr.selectedIndex].viewNode.style.overflow="auto";
}
if(THIS.deckContr.selectedIndex!=0)
{
THIS.deckContr.items[THIS.deckContr.selectedIndex-1].viewNode.style.visibility="hidden";
}
}
var numOfItems=this.deckContr.items.length;
for(var i=0;i < numOfItems;i++)
{
this.deckContr.items[i].viewNode.style.overflow="hidden";
this.deckContr.items[i].viewNode.style.visibility="visible";
}
vg.smil.animateElement({target:this.deckContr.slider, attr:attributes, duration:this.deckContr.transDur, funcFinished:afterAnim, easing:this.deckContr.easing});
},
_horizSlide:function()
{
var newPosition=-(this.deckContr.selectedIndex*100);
var currentPosition=parseInt(this.deckContr.slider.style.left);
if(!currentPosition)
{
currentPosition=0;
}
//YUI animation doesn't work on a mac
if(mac)
{
this.deckContr.slider.style.left=newPosition+'%';
}
else
{
var attributes={left:{from:currentPosition, to:newPosition, unit:"%"}};
vg.smil.animateElement({target:this.deckContr.slider, attr:attributes, duration:this.deckContr.transDur, easing:this.deckContr.easing});
}
},
_fadeInOut:function()
{
var bColor=this.viewNode.style.backgroundColor;
if(bColor==null||bColor=="")
{
this.viewNode.style.backgroundColor="#FFF";
}
vg.html.setOpacity(this.viewNode, '0', this.deckContr.isAdjustZoom);
vg.smil.animateElement(this.viewNode,'opacity',this.deckContr.transDur,0,0,1,null, this.onTransCallback);
},
loadCardContent:function(init)
{
var contentNode=this.contentNode;
var contentUrl=contentNode.getAttribute('url');
var contr=this;
var deckContr=this.deckContr;
//for horz and vert slide transitions, call animate() if after initial is false, otherwise let the deck.select() method call animate() for all subsequent card selections
var performAnimation=function(){
if(!deckContr.afterInit&&(deckContr.horizSlide||deckContr.vertSlide))
{
contr.animate();
}
};
if(contentUrl==null)
{
/*
*Don't execute the populator on page load(init==true),
*since it executes itself via its constructor
*/
if(init!=true)
{
Populator._execute(contentNode, performAnimation);
}
else
{
performAnimation();
}
}
else
{
if(contentUrl.indexOf('javascript:')==0)
{
var js=contentUrl.substring('javascript:'.length);
eval(js);
performAnimation();
}
else
{
//we need to set height of a deck after content is loaded.
jsCBDloadContent(contentUrl, this.id, 'replaceChildren', performAnimation);
}
}
//Configure embedded Slider, if necessary
vg.comp._configureSlider(contentNode);
//Peforms Select All for embedded SelectTable
this.handleSelectTable();
},
//Determine if we have an embedded SelectTable and handle it appropriately
handleSelectTable:function()
{
var nodes=vg.html.getElements(this.contentNode,{tagName:'TH',attrName:'class'});
if(nodes!=null)
{
//Search for the Select All node
for(var i=0;nodes!=null&&i < nodes.length;i++)
{
if(nodes[i].className!=null&&nodes[i].className.indexOf(SELECT_ALL_BEHAVIOR) >=0)
{
//Found it...send the show event, then exit loop
var controller=vg.comp.findController(nodes[i]);
if(controller)
{
controller.show();
}
break;
}
}
}
}
}
/**********************end of Deck***********************************/
/**********************start RollOverMenu****************************/
var ROLLOVER_HIGHLIGHT_STYLE2="roDeck-sel2";
var ROLLOVER_HIGHLIGHT_STYLE="roDeck-sel";
RollOverMenu=function(id, autoplay)
{
this.base=vg.Controller;
this.base(id, null);
this.items=new Array();
this.defaultCard;
var controller=this;
this.autoplay='false';
var defaultCardAttr=this.viewNode.getAttribute('defaultCard');
this.defaultCard=(defaultCardAttr==null)?null:parseInt(defaultCardAttr);
if(autoplay=='true')
{
this.autoplay='true';
setTimeout(function(){controller._autoplayRMDeck(1)}, 3000);
}
}
RollOverMenu.prototype=
{
addItem:function(controller)
{
var length=this.items.length;
this.items[length]=controller;
controller.index=length;
},
//
//Called by the RolloverMenuDeck, when autoplay is set to true.
//<span class="attention">FOR INTERNAL CBD USE ONLY</span>
//Will loop through(auto play) the menu items and the deck.
//
//PARAMS:
//menuId - id of the rollover menu
//
_autoplayRMDeck:function(count)
{
var controller=this;
//autoplay each item
if(count < controller.items.length&&controller.autoplay=='true')
{
var menuItem=this.items[count];
//select the deck specified in the mouse target
var mouseTarget=menuItem.viewNode.getAttribute('mouseTarget');
if(mouseTarget!=null){
RollOverMenuItem.cbdSelectRMItem(menuItem, mouseTarget);
}
var itemCount=++count;
setTimeout(function(){controller._autoplayRMDeck(itemCount)}, 3000);
//end rotation at the first item
if(itemCount==controller.items.length)
{
var menuItem=controller.items[0];
var mouseTarget=menuItem.viewNode.getAttribute('mouseTarget');
setTimeout(function(){RollOverMenuItem.cbdSelectRMItem(menuItem, mouseTarget)}, 3000);
}
}
}
}
RollOverMenuItem=function(id, deckChangeMode)
{
this.base=vg.Controller;
this.base(id, null);
this.deckChangeMode=deckChangeMode.toLowerCase();
this.isMouseEnter=null;
var parentController=vg.comp.findController(this.viewNode, true);
parentController.addItem(this);
var controller=this;
vg.html.addEventListener(this.viewNode, 'click', function(){controller.click()});
vg.html.addEventListener(this.viewNode, 'mouseenter', function(e){controller.highlight();controller.recordEvent(e, 'mouseenter');});
vg.html.addEventListener(this.viewNode, 'mouseleave', function(e){controller.mouseLeave();controller.recordEvent(e, 'mouseleave');});
}
RollOverMenuItem.prototype=
{
recordEvent:function(e, eventName)
{
e=jsCBDgetEvent(e);
/*
*Specify isRiaEvent property on event as false to
*prevent ria prefix from being appended to eventName.
*/
e.isRiaEvent=false;
vg.cobrowse.recordEvent(e, this.viewNode, eventName);
},
highlight:function()
{
var parentController=vg.comp.findController(this.viewNode, true);
if(this.deckChangeMode=="onmouseover")
{
parentController.autoplay='false';
}
this.isMouseEnter='true';
this.select();
},
click:function()
{
var id=this.viewNode.getAttribute('id');
var parentController=vg.comp.findController(this.viewNode, true);
parentController.selected=true;
if(this.deckChangeMode=="onclick"||this.deckChangeMode=="onclick_2" )
{
var menuItem=vg.comp.getController(id);
var parentController=vg.comp.findController(this.viewNode, true);
vg.html.addOrRemoveStyleFromNodes(ROLLOVER_HIGHLIGHT_STYLE2, parentController.items, false);
jsCBDaddStyle(menuItem, ROLLOVER_HIGHLIGHT_STYLE2);
var clickTarget=this.viewNode.getAttribute('clickTarget');
eval(clickTarget);
}
if(this.deckChangeMode=="onmouseover")
{
RollOverMenuItem.cbdDoRMonclick(id);
var mouseTarget=this.viewNode.getAttribute('mouseTarget');
eval(mouseTarget);
}
},
select:function()
{
var id=this.viewNode.getAttribute('id');
setTimeout("RollOverMenuItem.cbdDoRMmouseEnter('"+id+"')" , 150 );
},
mouseLeave:function()
{
this.isMouseEnter=false;
if(this.deckChangeMode=="onmouseover")
{
var id=this.viewNode.getAttribute('id');
setTimeout("RollOverMenuItem.cbdDoRMmouseLeave('"+id+"')" , 150 );
}
}
}
//
//Selects the given menuItem and the associated mouseTarget or clickTarget
//<span class="attention">FOR INTERNAL CBD USE ONLY</span>
//PARAMS:
//menuItemId - id of the rollover menu item
//jsTarget - mouseTarget or clickTarget
RollOverMenuItem.cbdSelectRMItem=function(menuItem, jsTarget)
{
var parentController=vg.comp.findController(menuItem.viewNode, true);
vg.html.addOrRemoveStyleFromNodes(ROLLOVER_HIGHLIGHT_STYLE, parentController.items, false);
jsCBDaddStyle(menuItem, ROLLOVER_HIGHLIGHT_STYLE);
if(jsTarget!=null)
{
eval(jsTarget);
}
}
//
//Called by the RolloverMenu on mouse enter - selects the current item and de-selects the others
//<span class="attention">FOR INTERNAL CBD USE ONLY</span>
//PARAMS:
//menuItemId - id of the rollover menu item
//
RollOverMenuItem.cbdDoRMmouseEnter=function(menuItemId)
{
var menuItem=vg.comp.getController(menuItemId);
var isMouseEnter=menuItem.isMouseEnter;
if(isMouseEnter=='true'||isMouseEnter=='autoPlay')//check  MouseEnter for autoplay
{
var mouseTarget=menuItem.viewNode.getAttribute('mouseTarget');
//we need to close all selectOneMenus before changing cards
_cbdClosePrevSelectOneMenu();
RollOverMenuItem.cbdSelectRMItem(menuItem, mouseTarget);
}
}
//
//Called by the RolloverMenu on mouse leave - if default card specified, selects the default card
//
//PARAMS:
//menuItemId - id of the rollover menu item
//
RollOverMenuItem.cbdDoRMmouseLeave=function(menuItemId)
{
var menuItem=vg.comp.getController(menuItemId);
var parentController=vg.comp.findController(menuItem.viewNode, true);
var menuItems=parentController.items;
var defaultCardAttr=parentController.defaultCard;
var size=menuItems.length;
//Check to see if the user entered an adjacent menuItem or if they left the rolloverMenu all together
var mouseState='false';
var mouseEnter=null;
for(var i=1;i < size;i++)
{
mouseEnter=menuItems[i].isMouseEnter;
if(mouseEnter=='true') mouseState='true';
}
if(!isEmpty(defaultCardAttr))
{
defaultCardAttr=parseInt(defaultCardAttr);
if(defaultCardAttr >=0&&defaultCardAttr < size&&mouseState=='false')
{
for(var i=1;i < size;i++)
{
if(menuItems[i].viewNode.getAttribute('idx')==defaultCardAttr)
defaultCardAttr=i;
}
var menuItem=menuItems[defaultCardAttr];
var mouseTarget=menuItem.viewNode.getAttribute('mouseTarget');
RollOverMenuItem.cbdSelectRMItem(menuItem, mouseTarget);
if(parentController.selected)
{
vg.html.addOrRemoveStyleFromNodes(ROLLOVER_HIGHLIGHT_STYLE2, parentController.items, false);
jsCBDaddStyle(menuItem, ROLLOVER_HIGHLIGHT_STYLE2);
}
}
}
}
//
//Called by the RolloverMenuItem onclick - sets the default card attribute on its parent(RolloverMenu)
//<span class="attention">FOR INTERNAL CBD USE ONLY</span>
//PARAMS:
//menuItemId - id of the rollover menu item
//
RollOverMenuItem.cbdDoRMonclick=function(menuItemId)
{
var menuItem=vg.comp.getController(menuItemId);
var menuItemNo=menuItem.viewNode.getAttribute('idx');
var parentController=vg.comp.findController(menuItem.viewNode, true);
var defaultCard=parentController.defaultCard;
if(!isEmpty(defaultCard))
{
parentController.defaultCard=menuItemNo;
}
vg.html.addOrRemoveStyleFromNodes(ROLLOVER_HIGHLIGHT_STYLE2, parentController.items, false);
jsCBDaddStyle(menuItem, ROLLOVER_HIGHLIGHT_STYLE2);
}
//
//Selects the RolloverMenu Item and the deck associated with it.
//
//PARAMS:
//menuItemId - id of the rollover menu item
//
cbdns.jsCBDselectRMItem=function(menuItemId)
{
var menuItem=vg.comp.getController(menuItemId);
var parentController=vg.comp.findController(menuItem.viewNode, true);
parentController.autoplay='false';
var menuItem=vg.comp.getController(menuItemId);
var jsTarget=menuItem.viewNode.getAttribute('mouseTarget');
if(jsTarget==null)
{
jsTarget=menuItem.viewNode.getAttribute('clickTarget');
}
RollOverMenuItem.cbdSelectRMItem(menuItem, jsTarget);
RollOverMenuItem.cbdDoRMonclick(menuItemId);
}
//
//Simulate mousing over the RolloverMenu Item
//
//PARAMS:
//menuItemId - id of the rollover menu item
//
cbdns.jsCBDmouseOverRMItem=function(menuItemId)
{
var menuItem=vg.comp.getController(menuItemId);
var parentController=vg.comp.findController(menuItem.viewNode, true);
parentController.autoplay='false';
var menuItem=vg.comp.getController(menuItemId);
var mouseTarget=menuItem.viewNode.getAttribute('mouseTarget');
RollOverMenuItem.cbdSelectRMItem(menuItem, mouseTarget);
}
/**********end RollOver*********************/
var MOUSE_OVER_HEAD_CSS='vg-AccHover';
//
//Constructor for accordion
//PARAMS:
//id=accordion id.
//
Accordion=function(id, numberOfItems, type, selectedIndex)
{
//we require animation, but don't need it before the object
//initializes, only after we click
cbd.loader.require('animation' );
this.id=id;
this.node=document.getElementById(id);
this.items=new Array();
this.node.jsController=this;
this.selectedIndex=selectedIndex;
this.numberOfItems=numberOfItems;
this.type=type;
}
//
//Constructor for accordion item
//PARAMS:
//id=accordion item id.
//selected=true/false
//
AccordionItem=function(clientId, id)
{
this.id=id;
this.clientId=clientId;
this.node=document.getElementById(clientId);
this.parent=this.node.parentNode;
this.node.jsController=this;
var parentController=this.parent.jsController;
this.index=parentController.items.length;
parentController.items[this.index]=this;
//set selected index on a accordion
if(parentController.selectedIndex==this.index)
{
this.selected=true;
}
/*
*IE and FireFox return different height value
*We need to adjust height style to get correct look
*/
var body=AccordionItem.getBody(this.node);
body.style.height=(ie)?"100%":"auto";
//add event Listener
vg.html.addEventListener(this.node, 'mouseover', AccordionItem.highlight);
vg.html.addEventListener(this.node, 'mouseout', AccordionItem.unhighlight);
vg.html.addEventListener(this.node, 'click', AccordionItem.changeSelection);
AccordionItem.select(this.node, this.selected, true);
}
//
//highlight accordion item header
//PARAMS:e=event
//
AccordionItem.highlight=function(e)
{
var eNode=jsCBDgetEventNode(e);
if(AccordionItem.insideTheHeader(eNode))
{
var item=AccordionItem.getItem(eNode);
if(!isEmpty(item))
{
var header=AccordionItem.getHeader(item);
jsCBDaddStyle(header, MOUSE_OVER_HEAD_CSS);
}
}
}
//
//Checks if event node is in the header
//
AccordionItem.insideTheHeader=function(node)
{
var headerNode;
while(node!=null)
{
if(node.className&&node.className=='vg-AccItemHead')
{
headerNode=node;
break;
}
node=node.parentNode;
}
return headerNode!=null;
}
//
//Unhighlight accordion item header
//PARAMS:e=event
//
AccordionItem.unhighlight=function(e)
{
var eNode=jsCBDgetEventNode(e);
if(AccordionItem.insideTheHeader(eNode))
{
var item=AccordionItem.getItem(eNode);
if(!isEmpty(item))
{
var header=AccordionItem.getHeader(item);
jsCBDdeleteStyle(header, MOUSE_OVER_HEAD_CSS);
}
}
}
//
//Returns accordion item header.
//PARAMS:
//item=accordion item
//
AccordionItem.getHeader=function(item)
{
return(item!=null)?vg.html.getFirstChild(vg.html.getFirstChild(item)):null;
}
//
//Returns accordion item header
//PARAMS:
//item=accordion item
//
AccordionItem.getBody=function(item)
{
return(item!=null)?item.childNodes[1]:null;
}
//
//Returns accordion item
//PARAMS:
//node=Dom node
//
AccordionItem.getItem=function(node)
{
return vg.html.findParentComponent(node, AccordionItem );
}
//
//Changes selected item. Used to change selection on click event.
//PARAMS:
//e=event
//
AccordionItem.changeSelection=function(e)
{
var item=AccordionItem.getItem(jsCBDgetEventNode(e));
if(!isEmpty(item))
{
var itemController=item.jsController;
var parentController=itemController.parent.jsController;
var items=parentController.items;
var selectedIndex=parentController.selectedIndex;
if(itemController.index!=selectedIndex)
{
AccordionItem.select(item, true);
AccordionItem.select(items[selectedIndex].node, false);
}
}
var webUsageJS=item.getAttribute('webUsageJs');
if(webUsageJS!=null)
{
eval(webUsageJS);
}
}
//
//Executes animation(Gradually changes height) on accordion item
//PARAMS:
//node=html node representing accordion item.
//controller=JavaScript object representing accordion item.
//parentController=JavaScript object representing accordion.
//
AccordionItem.animate=function(node, controller, parentController)
{
var body=AccordionItem.getBody(node);
var selectedIndex=parentController.selectedIndex;
var nodeIndex=controller.index;
var prevOpen=selectedIndex < nodeIndex;
var inAMiddle=nodeIndex < parentController.items.length;
var header=AccordionItem.getHeader(node);
var headerHeight=vg.html.getObjSizePosition(header).h;
if(parentController.type!='ACCORDION_FOUR')
{
headerHeight=headerHeight+4;
}
//we need to change dispaly on a body, to get correct height
body.style.display='block';
var itemHeight=vg.html.getObjSizePosition(body).h+headerHeight;
var animateProp={attributeName:"height", dur:'750ms'}
var selectedNode=parentController.items[selectedIndex].node;
var anim=null;
var nodes=[];
var openNode=null;
var animFinished=function()
{
if(openNode )
{
openNode.style.height='auto';
}
}
if(prevOpen)
{
//if item before this item selected, we need to use animation to reduce height of selected item
anim=vg.smil.animateElement(selectedNode, "height", 750, "0ms", itemHeight, headerHeight, null, animFinished );
}
else
{
openNode=node;
anim=vg.smil.animateElement(node, "height", 750, "0ms", headerHeight, itemHeight, null, animFinished );
}
var sameNode=selectedIndex==nodeIndex;
if(inAMiddle&&!sameNode)
{
openNode=node;
anim=vg.smil.animateElement(node, "height", 750, "0ms", headerHeight, itemHeight, null, animFinished);
vg.smil.animateElement(selectedNode, "height", 750, "1ms", itemHeight, headerHeight);
}
//this logic should be moved to animation callback when we move to yui animation
setTimeout(function(){node.style.height=(ie)?"100%":"auto";}, 1000);
}
//
//Selects accordion item
//PARAMS:
//node - html node representing accordion item.
//state - state of the accordion item.
//initLoad - flag to indicate if select was executed from the constructor
//
AccordionItem.select=function(node, state, initLoad)
{
var SELECTED_STYLE="vg-AccItemSelected";
var NOT_SELECTED_STYLE="vg-AccItemDeselected";
var HORIZ_RULE="horizRule";
if(node.nodeType=='1')
{
var controller=node.jsController;
var parentController=controller.parent.jsController;
if(state)
{
if(!initLoad)
{
cbd.StateKeeper._setState(parentController.id, controller.id);
}
if(vg.smil.isLoaded())
{
AccordionItem.animate(node, controller, parentController);
}
//set selectedIndex on a accordion
parentController.selectedIndex=controller.index;
//add horizRule to last item
if(parentController.numberOfItems - 1==controller.index)
{
jsCBDaddStyle(node, HORIZ_RULE);
}
jsCBDaddStyle(node, SELECTED_STYLE);
jsCBDdeleteStyle(node, NOT_SELECTED_STYLE);
}
else
{
if(parentController.numberOfItems - 1==controller.index)
{
jsCBDdeleteStyle(node, HORIZ_RULE);
}
jsCBDaddStyle(node, NOT_SELECTED_STYLE);
jsCBDdeleteStyle(node, SELECTED_STYLE);
}
}
}
//
//Constructor for infoBox
//PARAMS:
//id=infoBox id.
//position=position of a inforBox
//disableEventListener - used with inputs to disable mouseover, mouseout
//closeOnClick - an optional attribute that indicates the InfoBox will close when the triggerLabel is clicked
//targetRequired - prevent javascript error when target node not found
//
InfoBox=function(id, position, disableEventListener, targetNodeId, closeOnClick, targetRequired)
{
this.base=vg.Controller;
this.base(id, jsCBDgetElementsByAttr(document.getElementById(id), "span", "className", "content")[0]);
this.leaderId;
this.content=this.contentNode.innerHTML;
this.globalInfoBox=document.getElementById(CBD_GLOBAL_INFO_BOX);
this.position=position;
this.iBoxPersist=this.viewNode.getAttribute("iBoxPersist")=='true';
this.mouseIsOverLink=false;
var globalInfoBoxContentDiv=jsCBDgetElementsByAttr(this.globalInfoBox, "div", "className", "roundBoxCtnt");
var sizeHolder=this.contentNode.parentNode;
this.width=sizeHolder.getAttribute('infoBoxWidth');
//target Node where the infoBox needs to be set.
if(targetNodeId!=null)
{
//when targetNodeId passed, override the default target
var node=document.getElementById(targetNodeId);
this.targetNode=node;
this.viewNode=node;
//prevent javascript error when target node not found if suppressError attribute set to true
if(!targetRequired&&this.targetNode==null)
{
return;
}
//Add class to allow infoBox to cobrowse
vg.html.addStyle("iLayerLink", node);
}
else
{
this.targetNode=jsCBDgetElementsByAttr(document.getElementById(id), "a", "name", "iLayerAnchor")[0];
//for when type=inherit
if(this.targetNode==null)
{
this.targetNode=jsCBDgetElementsByAttr(document.getElementById(id), "span", "name", "iLayerAnchor")[0];
}
//for when a commandLink is placed inside of an infoBox
if(this.targetNode==null)
{
this.targetNode=jsCBDgetElementsByAttr(document.getElementById(id), "a")[0];
}
if(this.targetNode==null)
{
this.targetNode=this.viewNode;
}
}
//add event Listener
var controller=this;
if(disableEventListener==null||!disableEventListener)
{
//Verify that viewNode is not null.  This is different than the check above because we still want
//to execute the rest, but avoid the null.
if(this.viewNode!=null)
{
vg.html.addEventListener(this.viewNode, 'mouseover', function(e){controller.openWithDelay(e)});
vg.html.addEventListener(this.viewNode, 'mouseout', function(e){controller.close(e)});
vg.html.addEventListener(this.viewNode, 'keydown', function(e){controller._keyDown(e)});
vg.html.addEventListener(this.targetNode, 'blur', function(e){controller._blur(e)});
if(closeOnClick)
{
vg.html.addEventListener(this.viewNode, 'click', function(e){controller.close(e)});
}
}
}
vg.html.addEventListener(this.contentNode, 'contentLoaded', function(e){controller.contentLoaded(e)});
if(this.iBoxPersist&&!this.globalInfoBox.mouseListenerSet)
{
vg.html.addEventListener(this.globalInfoBox, 'mouseout', function(e){controller.mouseoutGlobalInfoBox(e)});
vg.html.addEventListener(this.globalInfoBox, 'mouseover', function(e){controller.mouseinGlobalInfoBox(e)});
this.globalInfoBox.mouseListenerSet=true;
}
}
InfoBox.close=function()
{
//hide the leader
var globalInfoBoxObj=vg.html.getElement(CBD_GLOBAL_INFO_BOX);
if(globalInfoBoxObj&&globalInfoBoxObj.leaderId)
{
jsCBDtoggleElement(document.getElementById(globalInfoBoxObj.leaderId), false);
}
if(globalInfoBoxObj)
{
jsCBDtoggleElement(globalInfoBoxObj, false);
}
}
InfoBox.prototype=
{
contentLoaded:function(e)
{
this.open(e)
},
openWithDelay:function(e)
{
this.mouseIsOverLink=true;
this.globalInfoBox.onlink=true;
var event=e;
var controller=this;
setTimeout(function(){if(controller.mouseIsOverLink){controller.open(event)}}, 500);
},
//
//Closes the infoBox on blur
//
_blur:function(e)
{
this.close();
},
//
//Handles spacebar Key through keydown event
//
_keyDown:function(e)
{
var key=jsCBDgetKey(jsCBDgetEvent(e));
if(key==32||key==13)
{
if(this.globalInfoBox.style.display=="none")
{
this.open();
}
else
{
this.close();
}
if(key==32)
{
vg.html.stopEventPropagation(e);
vg.html.preventDefault(e);
}
}
},
open:function(e)
{
var globalInfoBoxContentDiv=jsCBDgetElementsByAttr(this.globalInfoBox, "div", "className", "roundBoxCtnt");
if(Populator.exists(this.viewNode))
{
Populator._copy(this.viewNode, this.contentNode);
var controller=this;
Populator._execute(this.contentNode, function(){controller.contentLoaded()});
this.content=this.contentNode.innerHTML;
}
//If the infoBox is closed and leader is still open, then close it.
if(this.globalInfoBox.leader )
{
jsCBDtoggleElement(this.globalInfoBox.leader, false);
}
globalInfoBoxContentDiv[0].innerHTML=this.content;
this.globalInfoBox.onlink=true;
//calculate height and width based on screen
var widthInPx=null;
if(this.width.indexOf("%") > -1)
{
widthInPx=(jsCBDgetScreenWidth()*this.width.replace("%",""))/100;
}
else if(this.width.indexOf("px"))
{
widthInPx=this.width.replace("px","");
}
else
{
widthInPx=this.width;
}
//set width
vg.html.setWidth(this.globalInfoBox, widthInPx+"px");
//set height on infoBox
var h=jsCBDgetScreenHeight();
var max=(40*h)/100;
var scrollDiv=globalInfoBoxContentDiv[0].parentNode;
//toggle element temporarily to get the height
jsCBDtoggleElement(this.globalInfoBox, true);
var contentHeight=vg.html.getObjHeight(globalInfoBoxContentDiv[0]);
jsCBDtoggleElement(this.globalInfoBox, false);
vg.html.setHeight(scrollDiv,(contentHeight > max)?max+"px":"auto");
this.globalInfoBox.count=0;
//position leader
var leaderData=vg.html.position({elementNode:CBD_GLOBAL_INFO_BOX, targetNode:this.targetNode, dispLoc:this.position, infobox:true, leader:true});
//"ne, nw, se, sw" position doesn't have a leader
if(leaderData.elem.leaderId!=null)
{
//we need to save leaderId, so we can hide it onmouseout
this.globalInfoBox.leaderId=leaderData.elem.leaderId;
//pull infoBox and leader together
this.globalInfoBox.style.left=leaderData.elem.x+leaderData.elem.ldrOffSetX+"px";
if(leaderData.elem.dispLoc=="top"||leaderData.elem.dispLoc=="topright"||leaderData.elem.dispLoc=="topleft")
{
var topOffSet=11;
this.globalInfoBox.style.top=leaderData.elem.y - topOffSet+"px";
}
else if(leaderData.elem.dispLoc=="bottom"||leaderData.elem.dispLoc=="bottomright"||leaderData.elem.dispLoc=="bottomleft")
{
var bottomOffSet=11;
this.globalInfoBox.style.top=leaderData.elem.y+bottomOffSet+"px";
}
//show leader
jsCBDtoggleElement(document.getElementById(this.globalInfoBox.leaderId), true);
var controller=this;
this.globalInfoBox.leader=document.getElementById(this.globalInfoBox.leaderId);
vg.html.addEventListener(this.globalInfoBox.leader, 'mouseout', function(e){controller.mouseoutGlobalInfoBox(e)});
vg.html.addEventListener(this.globalInfoBox.leader, 'mouseover', function(e){controller.mouseinGlobalInfoBox(e)});
}
jsCBDtoggleElement(this.globalInfoBox, true);
},
close:function(e)
{
this.globalInfoBox.onlink=false;
this.mouseIsOverLink=false;
//when iBoxPersist set to true we need to keep infoBox open as long as mouse inside infoBox
if(this.iBoxPersist)
{
this.callCheckClose();
return;
}
InfoBox.close();
},
checkClose:function()
{
if(this.globalInfoBox.count!=0||this.globalInfoBox.onlink)
{
return;
}
InfoBox.close();
},
mouseoutGlobalInfoBox:function(e)
{
this.globalInfoBox.count--;
this.callCheckClose();
},
callCheckClose:function()
{
var controller=this;
setTimeout(function(e){controller.checkClose()}, 200);
},
mouseinGlobalInfoBox:function(e)
{
this.globalInfoBox.count++;
}
}
InfoBox.open=function(id)
{
var infoBox=document.getElementById(id);
vg.comp.getController(infoBox).open();
}
var HIGHLIGHT_STYLE="callout";
//Constructor for CheckBox object
CheckBox=function(id, row, cell)
{
this.base=vg.Controller;
this.id=id;
this.base(id, null);
this.highlightObj=vg.html.findAncestor(this.viewNode,{tagName:(row)?'TR':'TD'});
var controller=this;
vg.html.addEventListener(this.viewNode, 'click', function(){controller.select()});
this.select();
}
CheckBox.prototype=
{
select:function()
{
if(this.viewNode.checked)
{
this.highlight();
}
else
{
this.unhighlight();
}
},
highlight:function()
{
jsCBDaddStyle(this.highlightObj, HIGHLIGHT_STYLE);
},
unhighlight:function()
{
jsCBDdeleteStyle(this.highlightObj, HIGHLIGHT_STYLE);
}
}
//Constructor for RadioButton object
RadioButton=function(id, group, row, cell)
{
this.base=vg.Controller;
this.id=id;
this.group=group;
this.base(id, null);
this.highlightObj=vg.html.findAncestor(this.viewNode,{tagName:(row)?'TR':'TD'});
var controller=this;
vg.html.addEventListener(this.viewNode, 'click', function(){controller.select()});
this.select();
}
RadioButton.prototype=
{
select:function()
{
var results=vg.validation.getTargetInputs(this.group);
for(var i=0;i < results.length;i++)
{
if(results[i].jsController)
{
if(results[i].checked)
{
results[i].jsController.highlight();
}
else
{
results[i].jsController.unhighlight();
}
}
}
},
highlight:function()
{
jsCBDaddStyle(this.highlightObj, HIGHLIGHT_STYLE);
},
unhighlight:function()
{
jsCBDdeleteStyle(this.highlightObj, HIGHLIGHT_STYLE);
}
}
/**********************Start of NineBoxFilter*********************************/
//
//Constructor for NineBoxFilter
//PARAMS:
//id=NineBox id.
//
NineBoxFilter=function(id)
{
this.base=vg.Controller;
this.base(id, null);
this.id=this.viewNode.getAttribute('id');
this.nineBoxTable=vg.html.getElements(document.getElementById(this.id),{tagName:'table', attrName:'class', attrValue:'nineBoxSelector pad'});
this.items=vg.html.getElements(document.getElementById(this.id),{tagName:'div', attrName:'class', attrValue:'selected'});
this.headers=vg.html.getElements(document.getElementById(this.id),{tagName:'a', attrName:null, attrValue:null});
this.onClickJS=this.viewNode.getAttribute('clickjs');
this.hiddenInput=document.getElementById(this.id+"_hiddenInput");
this.selectedItems=this.hiddenInput.value;
this.overItem=false;
/*
*if "this.selectedItems" is null or an empty string, then the component has not
*specified specific elements to be selected upon page load.  Therefore, "this.allSelected" will, by
*default, be set to true.
*/
this.allSelected=(this.selectedItems=="1,2,3,4,5,6,7,8,9")?true:false;
this.selectItems(this.selectedItems,true);
var controller=this;
//create event listeners for item cells
for(var i=0;i < 9;i++)
{
vg.html.addEventListener(this.items[i], 'mousedown', function(e){controller.onItem(e)});
vg.html.addEventListener(this.items[i], 'mouseover', function(e){controller.onItem(e)});
vg.html.addEventListener(this.items[i], 'mouseout', function(e){controller.onItem(e)});
vg.html.addEventListener(this.items[i], 'click', function(e){controller.onItem(e)});
}
//create event listeners for the colHead and rowHead cells
for(var i=0;i < 6;i++)
{
vg.html.addEventListener(this.headers[i], 'mousedown', function(e){controller.onColRowHeader(e)});
vg.html.addEventListener(this.headers[i], 'mouseover', function(e){controller.onColRowHeader(e)});
vg.html.addEventListener(this.headers[i], 'mouseout', function(e){controller.onColRowHeader(e)});
vg.html.addEventListener(this.headers[i], 'click', function(e){controller.onColRowHeader(e)});
}
}
NineBoxFilter.prototype=
{
/*
*Changes the class state of the respective nineBoxFilter item upon
*mouseover/mouseout/mousedown events over the respective nineBoxFilter item
*/
onItem:function(e)
{
var eNode=jsCBDgetEventNode(e);
var state=e.type;
var itemNo=this.getItemNo(eNode)-1;
/*
*Because we need to treat the all items are selected differently, then
*-- if mouseover and all items are selected, then deselect all items
*-- if mouseout and all items are selected, then select all items
*/
if(state=="mouseover"&&this.allSelected) state="mouseoverAll";
if(state=="mouseout"&&this.allSelected) state="mouseoutAll";
if(state=="mousedown"&&this.allSelected) state="mousedownAll";
var isSelected=this.isSelected(itemNo);
switch(state)
{
case "mouseover":
isSelected?vg.html.addOrRemoveStyle("deselectedHover", eNode, true):vg.html.addOrRemoveStyle("selectedHover", eNode, true);
break;
case "mouseout":
isSelected?vg.html.addOrRemoveStyle("deselectedHover", eNode, false):vg.html.addOrRemoveStyle("selectedHover", eNode, false);
break;
case "mousedown":
this.setItemState(itemNo);
this.allSelected=(this.getSelected().length==9);
break;
case "mouseoverAll":
this.overItem=true;
this.changeClassOnAll(false);
vg.html.replaceClass(eNode, eNode.className, "selected selectedHover");
break;
case "mouseoutAll":
this.overItem=false;
var controller=this;
setTimeout(function()
{
if(!controller.overItem)
{
controller.changeClassOnAll(true);
}
}, 25 );
break;
case "mousedownAll":
this.toggleAll(false);
this.setItemState(itemNo);
this.allSelected=false;
break;
case "click":
//update hidden input field
this.setHiddenInputValue();
//call the function as specified by the onclick attribute
if(this.onClickJS!=null)
{
eval(this.onClickJS).call(this, this.getSelected());
}
break;
default:
break;
}
},
/*
*handles mouseover/mouseout/mousedown events over a nineBoxFilter colhead or rowhead
*/
onColRowHeader:function(e)
{
/*
upon rollover of a column or header row, get the column or header row's id and the
mouse state(e.g., moueover, mouseout, mousedown,click) and, based on that information, select
the appropriate items
*/
var eNode=jsCBDgetEventNode(e);
var itemID=this.getItemID(eNode);
var state=e.type;
/*
*Because we need to treat the all items are selected scenario differently, then:
*-- if mouseover and all items are selected, then changeClass on all items
*-- if mouseout and all items are selected, then changeClass all items
*/
if(state=="mouseover"&&this.allSelected) this.changeClassOnAll(false);
if(state=="mouseout"&&this.allSelected) this.changeClassOnAll(true);
switch(itemID)
{
case "value":
this.headerItemChange(0,3,6,itemID,state);
break;
case "blend":
this.headerItemChange(1,4,7,itemID,state);
break;
case "growth":
this.headerItemChange(2,5,8,itemID,state);
break;
case "large":
this.headerItemChange(0,1,2,itemID,state);
break;
case "mid":
this.headerItemChange(3,4,5,itemID,state);
break;
case "small":
this.headerItemChange(6,7,8,itemID,state);
break;
default:
break;
}
},
/*
*Changes the class state of the respective nineBoxFilter items based on the
*nineBoxFilter colhead or rowhead that was mouseover/mouseout/mousedown/click
*/
headerItemChange:function(no1,no2,no3,itemID,state)
{
var item=new Array();
item[0]=this.items[no1];
item[1]=this.items[no2];
item[2]=this.items[no3];
item[0].num=no1;
item[1].num=no2;
item[2].num=no3;
/*
*Axis is either a row, or a column in the 9-box
*if any of the items state within the axis is deselected,
*then set axisSelected to false for the mouse events below
*/
var axisSelected=true;
for(i=0;i < item.length;i++)
{
if(!this.isSelected(item[i].num))
{
axisSelected=false;
break;
}
}
var changeClass=(axisSelected&&!this.allSelected)?"deselectedHover":"selectedHover";
switch(state)
{
case "mouseover":
this.overItem=true;
for(i=0;i < item.length;i++)
{
vg.html.addOrRemoveStyle(changeClass, item[i], true)
}
break;
case "mouseout":
for(i=0;i < item.length;i++)
{
vg.html.addOrRemoveStyle(changeClass, item[i], false)
}
break;
case "mousedown":
if(this.allSelected)
{
this.toggleAll(false);
}
/*
*Determine if we should select or deselect the itmes in the axis
*/
var select=(!axisSelected||this.allSelected);
for(i=0;i < item.length;i++)
{
this.setItemState(item[i].num, select);
}
break;
case "click":
//update hidden input field
this.setHiddenInputValue();
//call the function as specified by the onclick attribute
if(this.onClickJS!=null)
{
eval(this.onClickJS).call(this, this.getSelected());
}
break;
default:
break;
}
this.allSelected=(this.getSelected().length==9 );
},
/*
*selects specific items within nineBoxFilter
*items=(STRING) comma separated string of items to be selected
*clearAll=[true/false]if true, all existing selected items will be deselected prior to the specified items being selected
*/
selectItems:function(items,clearAll)
{
var itemsArr=new Array();
itemsArr=items.split(',');
//if clearAll=true, then toggle all items to deselected, then select the items specified
if(clearAll)
{
this.toggleAll(false);
this.allSelected=false;
}
//now select the items specified
for(i=0;i < itemsArr.length;i++)
{
var itemNo=parseInt(itemsArr[i])-1;
if(itemNo >=0&&itemNo <=8) this.setItemState(itemNo,true);
}
if(this.isAllSelected()) this.allSelected=true;
//update hidden input field
this.setHiddenInputValue();
},
/*
*selects specific items within nineBoxFilter
*items=(STRING) comma separated string of items to be selected
*/
deselectItems:function(items,clearAll)
{
var itemsArr=new Array();
itemsArr=items.split(',');
//if clearAll=true, then toggle all items to selected, then deselect the items specified
if(clearAll)
{
this.toggleAll(true);
}
//now deselect the items specified
for(i=0;i < itemsArr.length;i++)
{
var itemNo=parseInt(itemsArr[i])-1;
if(itemNo >=0&&itemNo <=8) this.setItemState(itemNo,false);
}
this.allSelected=false;
//update hidden input field
this.setHiddenInputValue();
},
/*
*changes class of all items to the appropriate "state" on mouseover/mouseout
*state=true, sets class of all items to "selected"
*state=false, sets state of all items to "deselected"
*/
changeClassOnAll:function(state)
{
for(var i=0;i < this.items.length;i++)
{
vg.html.replaceClass(this.items[i], this.items[i].className, state?"selected":"deselected")
}
},
/*
*toggles all items based on value of "state"
*state=true, sets state of all items to true
*state=false, sets state of all items to false
*/
toggleAll:function(state)
{
for(var i=0;i < this.items.length;i++)
{
this.setItemState(i,state);
}
},
/*
*Sets the state of the an item to true(ie., selected) or false(ie., deselected)
*/
setItemState:function(itemNo,setStateValue)
{
/*
*If setStateValue is passed, set state to it,
*otherwise, just flip the state and change the class.
*/
this.items[itemNo].state=(setStateValue!=null)?setStateValue:!this.isSelected(itemNo);
vg.html.replaceClass(this.items[itemNo], this.items[itemNo].className, this.isSelected(itemNo)?"selected":"deselected")
},
/*
*Sets the state of the an item to true(ie., selected) or false(ie., deselected)
*/
getState:function(itemNo)
{
return this.items[itemNo].state;
},
/*
*determines if item is selected or not
*/
isSelected:function(itemNo)
{
return this.getState(itemNo);
},
/*
*determines if all items are selected
*/
isAllSelected:function()
{
for(var i=0;i <  this.items.length;i++)
{
if(!this.isSelected(i))
{
return false;
}
}
return true;
},
/*
*returns an array of those item id's that are selected
*/
getSelected:function()
{
var selectedItems=new Array();
for(var i=0;i <  this.items.length;i++)
{
if(this.isSelected(i))
{
selectedItems.push(this.items[i].id);
}
}
return selectedItems;
},
/*
*returns a comma separated string of selected items(i.e., "3,6,8,9")
*/
getSelectedItemsStr:function()
{
var selectedItemsStr="";
var selectedItems=this.getSelected();
for(i=0;i < selectedItems.length;i++)
{
var sep=(i==selectedItems.length -1)?"":",";
selectedItemsStr+=this.getItemNo(vg.html.getElement(selectedItems[i]) )+sep;
}
return(selectedItemsStr=="")?" ":selectedItemsStr;
},
/*
*returns an array of those item id's that are deselected
*/
getDeselected:function()
{
var deselectedItems=new Array();
for(var i=0;i <  this.items.length;i++)
{
if(!this.isSelected(i))
{
deselectedItems.push(this.items[i].id);
}
}
return deselectedItems;
},
/*
*returns item id of the item selected(e.g., item1, item5, item9 )
*/
getItemID:function(eNode)
{
var itemID=eNode.id.split(":");
return itemID[itemID.length-1];
},
/*
*returns item number of the item selected(e.g., 1, 3, 9)
*/
getItemNo:function(eNode)
{
var itemID=this.getItemID(eNode);
return parseInt(itemID.slice(4));
},
/*
*sets the hidden input value
*/
setHiddenInputValue:function(eNode)
{
this.hiddenInput.value=this.getSelectedItemsStr();
}
}
/*
*returns the ids of the selected items
*/
NineBoxFilter.getSelectedItems=function(id)
{
var controller=vg.comp.getController(document.getElementById(id));
return controller.getSelected();
}
/*
*returns the ids of the deselected items
*/
NineBoxFilter.getDeselectedItems=function(id)
{
var controller=vg.comp.getController(document.getElementById(id));
return controller.getDeselected();
}
/*
*sets all items of a specified nineboxfilter to selected
*/
NineBoxFilter.selectAll=function(id)
{
var controller=vg.comp.getController(document.getElementById(id));
controller.selectItems("1,2,3,4,5,6,7,8,9",true)
}
/*
*sets all items of a specified nineboxfilter to deselected
*/
NineBoxFilter.deselectAll=function(id)
{
var controller=vg.comp.getController(document.getElementById(id));
controller.deselectItems("1,2,3,4,5,6,7,8,9",true)
}
/*
*selects specific items of a specified nineboxfilter.
*id - the id of the nineBoxFilter component
*items - a comma separated string of the items to be selected(1 thru 9)
*[OPTIONAL}
*clearAll -[true/false]Default false;if true, then all items will be deselected prior to the specified items being selected
*/
NineBoxFilter.selectItems=function(id,items,clearAll)
{
var controller=vg.comp.getController(document.getElementById(id));
controller.selectItems(items,clearAll);
}
/*
*deselects specific items of a specified nineboxfilter
*id - the id of the nineBoxFilter component
*items - a comma separated string of the items to be selected(1 thru 9)
*[OPTIONAL}
*clearAll -[true/false]Default false;if true, then all items will be selected prior to the specified items being deselected
*/
NineBoxFilter.deselectItems=function(id,items,clearAll)
{
var controller=vg.comp.getController(document.getElementById(id));
controller.deselectItems(items,clearAll);
}
/**********************End of NineBoxFilter*********************************/
/**********************Start of SideTab*********************************/
//
//Constructor for SideTab
//PARAMS:
//id=sideTab id.
//
SideTab=function(id)
{
this.base=vg.Controller;
this.base(id, null);
this.id=id;
this.items=new Array();
this.selectedIndex;
this.currentItem;
this.defaultSideTabItem=this.viewNode.getAttribute('defaultSideTabItem');
//get commonly used/manipulated elements
this.sideTabCont=new Object;
this.sideTabCont=vg.html.getElement(this.id+":sideTabCont");
this.sideTabBody=new Object;
this.sideTabBody=vg.html.getElement(this.id+":sideTabBody");
this.sideTabBody.scrollDiv=new Object;
this.sideTabBody.scrollDiv=vg.html.getElements(this.sideTabBody,{tagName:'div', attrName:'class', attrValue:'roundBoxScrollDiv'});
this.sideTabBody.scrollDiv=this.sideTabBody.scrollDiv[0];
//add event Listener(s)
var controller=this;
//vg.html.addEventListener(this.viewNode, 'click', function(e){controller.configSideTab(e)});
//listen for GEO_CHANGE and DOM_CHANGE as global events
//vg.html.addEventListener(null, vg.event.GEO_CHANGE, function(e, args){controller.configSideTab(e, args)});
//vg.html.addEventListener(null, vg.event.DOM_CHANGE, function(e, args){controller.configSideTab(e, args)});
//configure sideTab component upon initial load
vg.util.execOnPageReady(function(){controller.configSideTab()});
}
SideTab.prototype=
{
configSideTab:function()
{
//don't let the sideTabBody's height be shorter than the sideTabCont's height
this.adjustSideTabHeight();
},
//Register all sideTabItems defined by the component
addItem:function(controller)
{
var length=this.items.length;
this.items[length]=controller;
controller.index=length;
},
setSelectedSideTab:function(controller)
{
this.selectedIndex=controller.index;
this.selectItem(this.selectedIndex);
//send the selected Item to the server
cbd.StateKeeper._setState(this.id, this.selectedIndex+1+"", true);
},
selectItem:function(selectedIndex)
{
//set currentItem
this.currentItem=this.items[selectedIndex];
//if the sideTabItem is already selected(ie., inState==true) do not reselect it.
if(this.items[selectedIndex].inState==false)
{
//Replace "current" with "unselected" from previously selected sideTabItem
for(i=0;i < this.items.length;i++)
{
if(this.items[i].viewNode.className.indexOf("current") >=0 )
{
this.items[i].inState=false;
vg.html.replaceClass(this.items[i].viewNode, "current","unselected" );
}
}
//Add "current" to the currently selected sideTabItem
vg.html.replaceClass(this.items[selectedIndex].viewNode, "unselected", "current" );
this.items[selectedIndex].inState=true;
//if the selected sideTabItem is the first tab, then change the sideTabComp's className to 'sideTabComp firstTab'
//if it is not the first sideTab, then change sideTabComp's className to 'sideTabComp secondaryTabs'
(selectedIndex==0)?vg.html.replaceClass(this.viewNode, "secondaryTabs", "firstTab" ):vg.html.replaceClass(this.viewNode, "firstTab", "secondaryTabs" );
}
},
//adjusts sideTabBody's height and/or the sideTabCont's height based on content
adjustSideTabHeight:function()
{
var sideTabContHeight=vg.html.getObjHeight(this.sideTabCont);
var sideTabBodyScrollDiv=vg.html.getObjHeight(this.sideTabBody.scrollDiv.parentNode);
var offsetHeight=(this.selectedIndex==0)?20:30;
(sideTabContHeight > sideTabBodyScrollDiv )?vg.html.setHeight(this.sideTabBody,sideTabContHeight+offsetHeight+"px"):vg.html.setHeight(this.sideTabBody,'auto');
}
}
//
//Constructor for SideTabItem
//PARAMS:
//id=sideTabItem id.
//
SideTabItem=function(id)
{
this.base=vg.Controller;
this.base(id, null, true);
this.id=id;
this.inState=false;
this.selectItemOnClick=this.viewNode.getAttribute('selectItemOnClick');
//add event Listener
var controller=this;
vg.html.addEventListener(this.viewNode, 'click', function(e){controller.selectedSideTab(e)});
//add item to parent controller
this.parentController=vg.comp.findController(this.viewNode, true);
this.parentController.addItem(this);
}
SideTabItem.prototype=
{
selectedSideTab:function(e)
{
/*
*if selected tag within sideTabItem is not an anchor tag and the
*sideTabItem is not already selected, then execute the "clickJS" attribute
*on the sideTabItem controller
*/
if(jsCBDgetEventNode(e).tagName.toLowerCase()!='a'&&this.inState==false)
{
eval(this.viewNode.getAttribute('clickJs'));
}
/*
*if selectItemOnClick is true, select the sideTabItem(i.e., make it look selected)
*/
if(this.selectItemOnClick=="true")
{
this.parentController.setSelectedSideTab(this);
}
var webUsageJS=this.viewNode.getAttribute('webUsageJs');
if(webUsageJS!=null)
{
eval(webUsageJS);
}
}
}
/**********************End of SideTab*********************************/
/**********************Start of Expandable Row*************************/
//Used by RIAMetaTemplate to determine if any rows are expanded
vg.expRow._hasExpandedRow=false;
vg.expRow.colImg=_cbdImagePath+"icons/nav_flipperopen.gif";
vg.expRow.expImg=_cbdImagePath+"icons/nav_flipperclosed.gif";
//
//Toggles the flipper image
//
//<span class="attention">FOR INTERNAL CBD USE ONLY</span>
//
//PARAMS:
//node - the img node of the expandable row
//show - specifies the flipper to show open or closed
//
vg.expRow._toggleFlipperImage=function(node, show)
{
node.setAttribute("src", show?vg.expRow.colImg:vg.expRow.expImg);
}
//
//Loads the url in the expanding row
//
//<span class="attention">FOR INTERNAL CBD USE ONLY</span>
//
//PARAMS:
//node - the img node of the expandable row
//location - the destination for the loaded url
//
vg.expRow._loadUrl=function(node, location)
{
//get row count and table id to generate unique id
var parentTr=vg.html.findAncestor(node,{tagName:'tr'});
var rowNumber=vg.html.getSiblings(parentTr,{tagName:'tr'}, '-').length+1;
var table=vg.html.findAncestor(node,{tagName:'table'});
var tableId=table.getAttribute('id');
var url=node.getAttribute('expandUrl');
jsCBDloadContent(url, location, 'replaceChildren', null, tableId+rowNumber);
}
//
//Creates the expanding row
//
//<span class="attention">FOR INTERNAL CBD USE ONLY</span>
//
//PARAMS:
//node - the img node of the expandable row
//
vg.expRow._createRow=function(node)
{
var parentTr=vg.html.findAncestor(node,{tagName:'tr'});
var nextRow=vg.html.getSibling(parentTr,{tagName:'tr'}, '+');
var colspan=vg.html.getElements(parentTr,{tagName:'td'}).length;
//Create new row, cell, and div
var newDiv=document.createElement("div");
var newTd=document.createElement("td");
newTd.setAttribute("colSpan", colspan);
newTd.appendChild(newDiv);
var newTr=document.createElement("tr");
newTr.setAttribute("type", "detailRow");
newTr.appendChild(newTd);
//Add the new row
if(nextRow!=null)
{
parentTr.parentNode.insertBefore(newTr, nextRow);
}
else
{
parentTr.parentNode.appendChild(newTr);
}
var expandedType=node.getAttribute("expandedType");
if(expandedType=='ROW_INFO')
{
vg.html.addStyle("infoMsg", newTr);
vg.html.addStyle("nr", newTd);
newTd.setAttribute("align", "left");
vg.html.addStyle("msgInfo", newDiv);
}
else if(expandedType=='ROW_WARN')
{
vg.html.addStyle("warnMsg", newTr);
vg.html.addStyle("nr", newTd);
newTd.setAttribute("align", "left");
vg.html.addStyle("msgWarn", newDiv);
}
}
//
//Toggles the expandable row
//
//<span class="attention">FOR INTERNAL CBD USE ONLY</span>
//
//PARAMS:
//node - the img node of the expandable row
//open - specifies the row to be open or closed
//
vg.expRow._toggleExpandableRow=function(node, open)
{
var parentTr=vg.html.findAncestor(node,{tagName:'tr'});
var nextRow=vg.html.getSibling(parentTr,{tagName:'tr'}, '+');
var hasNewRow=nextRow!=null&&nextRow.getAttribute("type")=="detailRow";
var expandedType=node.getAttribute("expandedType");
var url=node.getAttribute("expandUrl");
var message=node.getAttribute("expandedRowMessage");
if(!hasNewRow)
{
vg.expRow._createRow(node);
}
var newTr=vg.html.getSibling(parentTr,{tagName:'tr'}, '+');
var newTd=vg.html.getElements(newTr,{tagName:"td"})[0];
var newDiv=vg.html.getElements(newTd,{tagName:"div"})[0];
var show=(!jsCBDisVisibleElement(newTr)||!hasNewRow);
//open argument is used for expand/collapse all
if(open!=null)
{
show=open;
}
jsCBDtoggleElement(newTr, show);
if(!isEmpty(message))
{
if(message.charAt(0)=='#')
{
var messageId=removeChars(message, '#');
var contentDiv=document.getElementById(messageId);
newDiv.innerHTML=contentDiv.innerHTML;
}
else
{
jsCBDsetElementInnerHtml(newDiv, '<div>'+message+'</div>');
}
}
else if(url.charAt(0)=='#')
{
url=removeChars(url, '#');
var contentDiv=document.getElementById(url);
var content=contentDiv.innerHTML;
jsCBDsetElementInnerHtml(newDiv, '<div>'+content+'</div>');
}
else
{
vg.expRow._loadUrl(node, newDiv);
}
if('ROW_DETAIL'==expandedType)
{
vg.expRow._toggleFlipperImage(node, show);
}
else if('ROW_INFO'==expandedType)
{
vg.html.addOrRemoveStyle("infoInd", parentTr, show);
vg.html.addOrRemoveStyle("infoMsg", newTr, show);
}
else
{
vg.html.addOrRemoveStyle("warnInd", parentTr, show);
vg.html.addOrRemoveStyle("warnMsg", newTr, show);
}
}
//
//Opens any expanded rows
//
//<span class="attention">FOR INTERNAL CBD USE ONLY</span>
//
//PARAMS:
//none
//
vg.expRow._openAllExpandedRows=function()
{
if(vg.expRow._hasExpandedRow)
{
var expandedRows=vg.html.getElements(document,{tagName:'img', attrName:'expanded', attrValue:'true'});
for(var i=0;i < expandedRows.length;i++)
{
vg.expRow._toggleExpandableRow(expandedRows[i], true);
}
}
}
/**********************End of Expandable Row***************************/
/**********************Start of Results Row***************************/
vg.resultsRow._mouseEnter=function(node)
{
var attributes={backgroundColor:{to:'#E6EDF1'}};
vg.smil.animateElement({target:node, attr:attributes, duration:250, colorAnimation:true});
}
vg.resultsRow._mouseLeave=function(node)
{
var attributes={backgroundColor:{to:'#FFFFFF'}};
vg.smil.animateElement({target:node, attr:attributes, duration:350, colorAnimation:true});
}
/**********************End of Results Row***************************/
/**********************Start of NavDeck*********************************/
NavDeck=function(id)
{
this.base=vg.Controller;
this.base(id, null);
this.state=this.viewNode.getAttribute("state");
this.id=this.viewNode.getAttribute("id");
this.isAnimationEnabled=(this.viewNode.getAttribute("transition")==='true');
this.isTypeTab=this.viewNode.getAttribute('type')=='tab';
this.curTab=0;
this.onTransCallback=null;
this.nodes={};
this.nodes['cbdProcNav']=document.getElementById('CBD_PROCESS_NAV'+this.id);//procNav region of the NavDeck
this.nodes['cbdNavDeck']=document.getElementById('CBD_NAV_DECK'+this.id);//deck region of the NavDeck
this.nodes['rbscrolldiv']=vg.html.getElements(this.nodes['cbdNavDeck'],{tagName:'div', attrName:'class', attrValue:'roundBoxScrollDiv'}, null )[0];;
if(!this.isInitState())
{
//execute custom transition after the page loads
var navDeck=this;
vg.html.addEventListener(window, 'load', function(){navDeck.executeCustomTransition()});
}
//Set the cbd.Navigator.deckId
cbd.Navigator.deckId=id.split('_navDeck',1);
}
NavDeck.prototype=
{
executeCustomTransition:function()
{
var transFunction=this.viewNode.getAttribute("initialTransition");
if(transFunction!=null){eval(transFunction);}
},
startNav:function()
{
var procNavHolder=this.nodes['cbdProcNav'];
var boxNavDeck=vg.html.findAncestor(procNavHolder,{tagName:'div'}, function(node){return node.className&&node.className.indexOf("webReg") >=0;});
if(this.isInitState())
{
this.executeCustomTransition();
vg.html.replaceClass(this.viewNode, boxNavDeck?"initial":"OAinitial", boxNavDeck?"inProgress":"");
this.state='inProgress';
}
},
isInitState:function()
{
return this.state=='init';
}
}
NavDeck.tabAnimation=function(navDeck, isAnimationEnabled)
{
this.navDeck=navDeck;
this.navDeckNode=document.getElementById(navDeck.id);
this.navDeckTransDur="500";
this.navDeckInitTransDur="350";
this.isAnimationEnabled=isAnimationEnabled
}
NavDeck.tabAnimation.prototype=
{
/*
*check if the current deck is same as deck on the server side
*/
isDeckCurrent:function()
{
return(navDeck.curTab==navDeck.curServerSideTab);
},
/*
*Animates the CBD_NAV_DECK element(i.,e the navDeck body) from top to bottom and
*from left to right based on the current tab
*/
doTransition:function(initialDeckLoadCompleted)
{
if((!this.isDeckCurrent())&&initialDeckLoadCompleted)
{
this._doTransition(true);
navDeck.curTab=navDeck.curServerSideTab;
}
},
/*
*Animates the CBD_NAV_DECK element(i.,e the navDeck body) from top to bottom and
*from left to right based on the current tab
*/
_doTransition:function(doYUIEaseIn)
{
if(!this.isAnimationEnabled) return;
/*
*before hiding the navDeck container(i.e., rbscrolldiv), get it's height and width and
*determine if the navDeck's transition direction(i.e., transDir) should be left to right or right to left
*/
var fromWidth=this._getAnimFromWidth();
var toWidth=vg.html.getObjWidth(navDeck.nodes['cbdNavDeck']);
var toHeight=vg.html.getObjHeight(navDeck.nodes['cbdNavDeck']);
/*
*add the floatRight class if transDir=left
*/
if(navDeck.transDir=="left")
{
vg.html.addStyle("floatRight", navDeck.nodes['cbdNavDeck']);
}
/*
*before doing a step transition, hide the navDeck container(i.e., rbscrolldiv)
*so that the transition is smooth from top to bottom and left to right
*/
jsCBDtoggleVisibility(navDeck.nodes['rbscrolldiv'], false);
jsCBDtoggleElement(navDeck.nodes['rbscrolldiv'], false);
/*
*Start the navDeck step animation
*/
var THIS=this;
var afterAnim=function(){THIS._onTransComplete()};
var attributes={width:{from:fromWidth, to:toWidth}, height:{from:0, to:toHeight}}
vg.smil.animateElement({target:navDeck.nodes['cbdNavDeck'], attr:attributes, duration:this.navDeckTransDur, funcFinished:afterAnim, easeIn:doYUIEaseIn});
},
/*
*Redisplays the CBD_NAV_DECK content after the step transition has completed
*/
_onTransComplete:function()
{
//set CBD_NAV_DECK width to 100% from fix pixel that was used during animation
//so that it flexes with browser resizing
navDeck.nodes['cbdNavDeck'].style.width="100%";
//remove the floatRight class(even if it does not exist)
vg.html.removeStyle("floatRight", navDeck.nodes['cbdNavDeck']);
/*
*now show the navDeck container(i.e., rbscrolldiv) that was previously hidden during step transition
*timeout needed for IE, but, for consistency, do it for all browsers. If the functions are executed without the timeout, the rbscrolldiv will not display(for whatever reason)
*/
setTimeout(function()
{
jsCBDtoggleElement(navDeck.nodes['rbscrolldiv'], true);
jsCBDtoggleVisibility(navDeck.nodes['rbscrolldiv'], true);
navDeck.nodes['cbdNavDeck'].style.height="auto";
if(navDeck.onTransCallback!=null) navDeck.onTransCallback(cbd.Navigator.cardId);
}, 50 );
},
/*
*Determines the x position from which the _doRegTransition should start from
*when transitioning the CBD_NAV_DECK from left to right
*/
_getAnimFromWidth:function()
{
//determine the direction of the navDeck animation
if(navDeck.totalTabs%2 > 0 )//determine if the total number of steps is an odd or even number
{
navDeck.transDir=(navDeck.curServerSideTab <=Math.floor(navDeck.totalTabs/2)+1)?"right":"left";
}
else
{
navDeck.transDir=(navDeck.curServerSideTab <=navDeck.totalTabs/2)?"right":"left";
}
//get the navTabs again in case some where added/deleted in the last procNav update
navDeck.navTabs=vg.html.getElements(navDeck.nodes['cbdProcNav'],{tagName:'div', attrName:'class', attrValue:'navTabItem'}, null );
var procNavGeoData=vg.html.getObjSizePosition(navDeck.nodes['cbdProcNav']);
var tabGeoData=vg.html.getObjSizePosition(navDeck.navTabs[navDeck.curServerSideTab-1]);
//the x position from which the _doRegTransition should start from
return(navDeck.transDir=="right")?tabGeoData.x+tabGeoData.w - procNavGeoData.x+4:procNavGeoData.x+procNavGeoData.w - tabGeoData.x - 4;
},
/*
*Does transition and calls _doInitialTransAnimation if animation si enabled.
*/
_doInitialTrans:function(transDiv1,transDiv2,fadeInDur)
{
//hide transDiv1
jsCBDtoggleElement(transDiv1, false);
//begin to display transDiv2 after setting it's opacity to zero so that it can be faded in
jsCBDtoggleElement(transDiv2, true);
if(this.isAnimationEnabled)
{
this._doInitialTransAnimation(transDiv1,transDiv2,fadeInDur);
}
else
{
jsCBDtoggleVisibility(transDiv2, true);
}
},
/*
*Fades in the application specific div that surrounds the navDeck component
*/
_doInitialTransAnimation:function(transDiv1,transDiv2,fadeInDur)
{
vg.html.setOpacity(transDiv2, 0.0);
jsCBDtoggleVisibility(transDiv2, true);
//now start the fade in of transDiv2/navDeck
var attributes={opacity:{to:1}};
vg.smil.animateElement({target:transDiv2, attr:attributes, duration:fadeInDur});
/*
*While fading in the navDeck, animate the navDeck component's top padding to display the
*procNav moving from the center of the page to the top of the page
*/
var attributes={paddingTop:{from:100, to:0}}
vg.smil.animateElement({target:this.navDeckNode, attr:attributes, duration:this.navDeckInitTransDur, easeIn:false});
vg.html.replaceClass(this.navDeck, "OAinitial","");
//now execute the normal navDeck body transition showing step1 growing from top left to bottom right
navDeck.curTab=navDeck.curServerSideTab;
this._doTransition(false);
},
/*
*Animates the navDeck component's top padding to display the
*procNav moving from the center of the page to the top of the page
*/
_doReverseTransPhase1:function(transDiv1,transDiv2)
{
/*
*before hiding the navDeck container(i.e., rbscrolldiv), get it's height and width and
*determine if the navDeck's transition direction(i.e., transDir) should be left to right or right to left
*/
var fromWidth=this._getAnimFromWidth();
var toWidth=vg.html.getObjWidth(navDeck.nodes['cbdNavDeck']);
var toHeight=vg.html.getObjHeight(navDeck.nodes['cbdNavDeck']);
if(navDeck.transDir=="left")
{
vg.html.addStyle("floatRight", navDeck.nodes['cbdNavDeck']);
}
/*
*start navDeck container height transition(bottom to top)
*/
//var attr1={width:{from:toWidth, to:fromWidth}, height:{from:toHeight, to:0}}
var attr1={height:{from:toHeight, to:0}}//when reversing, transition only the height. transitioning the width just doesn't look right
vg.smil.animateElement({target:navDeck.nodes['cbdNavDeck'], attr:attr1, duration:this.navDeckTransDur, easeIn:false});
//rbscrolldiv has been faded to 0 from jsCBDhideNavDeck, so now hide it after the transition above has started
jsCBDtoggleVisibility(navDeck.nodes['rbscrolldiv'], false);
jsCBDtoggleElement(navDeck.nodes['rbscrolldiv'], false);
/*
*While fading in the navDeck, animate the navDeck component's top padding to display the
*procNav moving from the top of the page to the center of the page
*When complete, call _doReverseTransPhase2 after the fade out is complete
*to fade in the original page's content(i.e., transDiv1)
*/
var THIS=this;
var afterAnim=function(){THIS._doReverseTransPhase2(transDiv1,transDiv2)};
var attr2={paddingTop:{from:0, to:100}}
vg.smil.animateElement({target:this.navDeckNode, attr:attr2, duration:this.navDeckInitTransDur, funcFinished:afterAnim, easeIn:false});
/*
*start navDeck container's fade out
*/
var attr3={opacity:{to:0}};
vg.smil.animateElement({target:transDiv2, attr:attr3, duration:this.navDeckTransDur, easeIn:false});
},
/*
*Fades in the application specific div that surrounds the navDeck component
*/
_doReverseTransPhase2:function(transDiv1,transDiv2)
{
/*
*hide the navDeck(i.e., transDiv2)
*/
jsCBDtoggleElement(transDiv2, false);
//display transDiv1 after setting it's opacity to zero
jsCBDtoggleElement(transDiv1, true);
vg.html.setOpacity(transDiv1, 0.0);
jsCBDtoggleVisibility(transDiv2, false);
/*
*fade in the original page's content(i.e., transDiv1), then when complete call _onReverseTransComplete function
*/
var THIS=this;
var afterAnim=function(){THIS._onReverseTransComplete(transDiv1,transDiv2)};
var attributes={opacity:{to:1}};
vg.smil.animateElement({target:transDiv1, attr:attributes, duration:this.navDeckTransDur, funcFinished:afterAnim, easeIn:false});
},
/*
*Redisplays the CBD_NAV_DECK content after the transition has completed
*/
_onReverseTransComplete:function(transDiv1,transDiv2)
{
/*
*reset the navDeck elements to prepare it for another initial transition
*/
navDeck.nodes['cbdNavDeck'].style.width="100%";
navDeck.nodes['cbdNavDeck'].style.height="100%";
jsCBDtoggleVisibility(navDeck.nodes['rbscrolldiv'], true);
jsCBDtoggleElement(navDeck.nodes['rbscrolldiv'], true);
vg.html.setOpacity(navDeck.nodes['rbscrolldiv'], 1.0);
//remove the floatRight class(even if it does not exist)
vg.html.removeStyle("floatRight", navDeck.nodes['cbdNavDeck']);
}
}
/*
*public function to start the initial transition of the navDeck
*/
cbdns.jsCBDshowNavDeck=function(navDeckId,transDiv1Id,transDiv2Id,initTransDur,transDur)
{
//get initial divs that surround the initial page content from the navDeck(i.e., transDiv1 from transDiv2)
var transDiv1=document.getElementById(transDiv1Id);
var transDiv2=document.getElementById(transDiv2Id);
//get the navDeck controller based on the navDeck id passed in
var navDeck=vg.comp.getController(navDeckId+"_navDeck");
//if the initial transition duration or the normal transition duration are not null, then set the navDeck.animType transitions to them
navDeck.animType.navDeckInitTransDur=(initTransDur!=null)?initTransDur:navDeck.animType.navDeckInitTransDur;
navDeck.animType.navDeckTransDur=(transDur!=null)?transDur:navDeck.animType.navDeckTransDur;
jsCBDtoggleElement(navDeck.nodes['rbscrolldiv'], true);
//create the first post animation function
var initTransPhase=function(){navDeck.animType._doInitialTrans(transDiv1,transDiv2,navDeck.animType.navDeckInitTransDur)};
if(navDeck.viewNode.getAttribute("transition")==='true')
{
//fade the initial page content div(i.e., transDiv1) to 0, when complete, execute initTransPhase1
var attributes={opacity:{to:0}};
vg.smil.animateElement({target:transDiv1, attr:attributes, duration:navDeck.animType.navDeckInitTransDur, funcFinished:initTransPhase, easeIn:false});
}
else
{
jsCBDtoggleVisibility(transDiv1, false);
initTransPhase();
}
}
/*
*public function to execute the reversal of the initial transition of the navDeck
*/
cbdns.jsCBDhideNavDeck=function(navDeckId,transDiv1Id,transDiv2Id)
{
//get initial divs that surround the initial page content from the navDeck(i.e., transDiv1 from transDiv2)
var transDiv1=document.getElementById(transDiv1Id);
var transDiv2=document.getElementById(transDiv2Id);
//get the navDeck controller based on the navDeck id passed in
var navDeck=vg.comp.getController(navDeckId+"_navDeck");
//fade out the rbscrolldiv, when complete, execute the _doReverseTransPhase1 function
var reverseTransPhase1=function(){navDeck.animType._doReverseTransPhase1(transDiv1,transDiv2)};
var attributes={opacity:{to:0}};
vg.smil.animateElement({target:navDeck.nodes['rbscrolldiv'], attr:attributes, duration:navDeck.animType.navDeckInitTransDur, funcFinished:reverseTransPhase1, easeIn:false});
}
/**********************end of NavDeck***********************************/
/**********************Start of FlyoutContainer*********************************/
FlyoutContainer=function(id)
{
this.base=vg.Controller;
this.base(id, null);
//Hide while page loads
this.viewNode.style.display="none";
//Need to init after page loads to access offsetHeight in IE
if(cbd.loader.isPageReady())
{
this._init();
}
else
{
var foc=this;
vg.html.addEventListener(window, 'load', function(){foc._init()});
}
}
FlyoutContainer.prototype=
{
toggleOpenClose:function()
{
var openState=this.viewNode.getAttribute("open");
var onClickJs=this.viewNode.getAttribute("on_click");
if(openState=='true')
{
this.close();
}
else
{
this.open();
}
if(!isEmpty(onClickJs))
{
eval(onClickJs);
}
},
open:function()
{
Populator._execute(vg.html.getFirstChild(this.oDropElement));
vg.html.setOpacity(this.oDropElement, '0');
this.oFlyout.style.display='block';
this.oDropContainer.style.display='block';
this.oDropElement.style.display='block';
var anim=vg.smil.animateElement(this.oDropElement,'opacity',1000,0,0,1);
if(anim==null)
{
//animation failed:display immediately
vg.html.setOpacity(this.oDropElement, '1');
}
//Hide corners of oTitleElement on the flyoutDirection side
this._showCornersOnFlyoutSide(false);
this.viewNode.setAttribute('open', 'true');
},
_showCornersOnFlyoutSide:function(show)
{
var flyoutRight=this.viewNode.getAttribute('FOCDirection')=='right';
var cells=this.oTitleElement.getElementsByTagName('td');
for(var x=0;x < cells.length;x++)
{
var isRgtCell=cells[x].className.match("topRgt")!=null
||cells[x].className.match("ctrRgt")!=null
||cells[x].className.match("botRgt")!=null;
var isLftCell=cells[x].className.match("topLft")!=null
||cells[x].className.match("ctrLft")!=null
||cells[x].className.match("botLft")!=null;
if((flyoutRight&&isRgtCell)||(!flyoutRight&&isLftCell))
{
cells[x].style.display=show?"":"none";
}
}
},
close:function()
{
//Show corners of oTitleElement on the flyoutDirection side
this._showCornersOnFlyoutSide(true);
this.oDropContainer.style.display='none';
this.oFlyout.style.display='none';
this.viewNode.setAttribute('open', 'false');
},
blur:function()
{
var openState=this.viewNode.getAttribute("open");
var blurState=this.viewNode.getAttribute("FOCBlurState");
var onClickJs=this.viewNode.getAttribute("on_click");
if(openState=='true'&&blurState=='true')
{
this.close();
if(!isEmpty(onClickJs))
{
eval(onClickJs);
}
}
},
_init:function()
{
//Unhide
this.viewNode.style.display="";
//Register FOC with page
jsCBDregisterFOC(this.viewNode.getAttribute('id'));
//Default open value to false
this.viewNode.setAttribute("open", "false");
//Locate FOC elements
var components=this.viewNode.getElementsByTagName('div');
for(var x=0;x < components.length;x++)
{
if(components[x].className=='FOCFlyout')
this.oFlyout=components[x];
if(components[x].className=='FOCTitle')
this.oTitleElement=components[x];
if(components[x].className.indexOf('roundBoxScrollDiv') >=0)
this.oDropElement=components[x];
if(components[x].className=='FOCDrop')
this.oDropContainer=components[x];
if(components[x].className=='FOCTitleInit')
var oTitleInit=components[x];
if(components[x].className.indexOf('FOCLabel_1') >=0)
{
var oCoreLabel=components[x];
}
if(components[x].className=='FOCLabel_2')
{
this.oOppositeLabel=components[x];
if(isEmpty(this.oOppositeLabel.innerHTML))
{
this.oOppositeLabel.innerHTML="&#160;"
}
}
}
//Convert percentage values to px.
var vWidth=this.viewNode.getAttribute("FOCWidth");
if(!vWidth||vWidth=='null')
{
vWidth=vg.html.getObjWidth(oCoreLabel)+"px";
}
else
{
vWidth=_cbdGetScreenRelativeWidth(vWidth);
}
var vDropWidth=_cbdGetScreenRelativeWidth(this.viewNode.getAttribute("FOCDropWidth") );
var vDropHeight=_cbdGetScreenRelativeWidth(this.viewNode.getAttribute("FOCDropHeight") );
var vOffset=_cbdGetScreenRelativeWidth(this.viewNode.getAttribute("FOCOffset") );
this.viewNode.setAttribute("FOCWidth", vWidth);
this.viewNode.setAttribute("FOCDropWidth", vDropWidth);
this.viewNode.setAttribute("FOCDropHeight", vDropHeight);
this.viewNode.setAttribute("FOCOffset", vOffset);
this._relocatePopulator(vg.html.getFirstChild(this.oDropElement));
//Set the width and height of the FlyoutContainer based on user assigned attributes
this.oTitleElement.style.width=vWidth;
oTitleInit.style.width=vWidth;
var diff=1;
oTitleInit.style.height=vg.html.getObjHeight(this.oTitleElement) - diff+"px";
this.oFlyout.style.display="none";
//Set the height of the labels
var oCoreLabelHeight=vg.html.getObjHeight(oCoreLabel);
var oOppositeLabelHeight=vg.html.getObjHeight(this.oOppositeLabel);
oCoreLabel.style.height=this.oOppositeLabel.style.height=(oCoreLabelHeight >=oOppositeLabelHeight)?oCoreLabelHeight+"px":oOppositeLabelHeight+"px"
//Set the width of the Flyout element
var dropWidth=vDropWidth.split('px')[0];
var offsetWidth=vOffset.split('px')[0];
this.oFlyout.style.width=parseInt(dropWidth)+parseInt(offsetWidth)+"px"
//Set the height of the drop element
if(vDropHeight!='null'&&vDropHeight!='auto')
{
this.oDropElement.style.height=vDropHeight;
}
else
{
var height=vg.html.getObjHeight(this.oDropElement);
var maxHeight=0.8*jsCBDgetScreenHeight();
if(height > maxHeight )
{
height=maxHeight;
maxHeightState=true;
}
height=height+'px';
vDropHeight=(vDropHeight=='auto')?'auto':height;
this.viewNode.setAttribute("FOCDropHeight", height);
this.oDropElement.style.height=vDropHeight;
}
//Set the top of the drop container
var top=this.oTitleElement.style.top;
var bottom=vg.html.getObjHeight(this.oTitleElement);
this.oDropContainer.style.top=bottom - diff+"px";
this.oDropContainer.style.display='none'
//Set the width of the drop element
//DEF430925 - moved this from above the if() to prevent horizontal scrollbars in Firefox
this.oDropElement.style.width=vDropWidth;
this.setFOCFlyout();
},
_relocatePopulator:function(newNode)
{
if(!jsCBDisPopulatorLoaded(this.viewNode.id))
{
Populator._copy(this.viewNode, newNode);
Populator._remove(this.viewNode);
}
},
setFOCFlyout:function()
{
//Grab metrics
var FOCDirection=this.viewNode.getAttribute("FOCDirection");
var offsetWidth=this.viewNode.getAttribute("FOCOffset");
var dropWidth=this.viewNode.getAttribute("FOCDropWidth");
var dropHeight=this.viewNode.getAttribute("FOCDropHeight");
var width=this.viewNode.getAttribute("FOCWidth");
offsetWidth=offsetWidth.split('px')[0];
width=width.split('px')[0];
dropWidth=dropWidth.split('px')[0];
dropHeight=dropHeight.split('px')[0];
//Set the drop width
this.oDropContainer.style.width=parseInt(dropWidth)+20+"px";
//Open right
if(FOCDirection=='right')
{
this.oFlyout.style.left=(parseInt(width) - 4)+"px";
this.oDropContainer.style.left=(parseInt(width)+parseInt(offsetWidth) - 20 - 4 )+"px";
//Position Labels
this.oOppositeLabel.style.left=(parseInt(offsetWidth)) - 18+"px";
//Square off respective corners
var cells=this.oFlyout.getElementsByTagName('td');
for(var x=0;x < cells.length;x++)
{
if(cells[x].className.match("sqdtopRgt")!=null)
cells[x].className=cells[x].className.replace(/sqdtopRgt/, "topRgt");
if(cells[x].className.match("sqdtopLft")!=null)
cells[x].style.borderLeft="none";
if(cells[x].className.match("ctrLft")!=null)
cells[x].style.borderLeft="none";
if(cells[x].className.match("sqdbotLft")!=null)
cells[x].style.borderLeft="none";
}
}
//Open left
else
{
this.oFlyout.style.left=-1*(parseInt(dropWidth)+parseInt(offsetWidth) - 4 )+"px";
this.oDropContainer.style.left=-1*(parseInt(dropWidth)+parseInt(offsetWidth) - 4)+"px"
//Square off respective Flyout corners
var cells=this.oFlyout.getElementsByTagName('td');
for(var x=0;x < cells.length;x++)
{
if(cells[x].className.match("sqdtopLft")!=null)
cells[x].className=cells[x].className.replace(/sqdtopLft/, "topLft");
if(cells[x].className.match("sqdtopRgt")!=null)
cells[x].style.borderRight="none";
if(cells[x].className.match("ctrRgt")!=null)
cells[x].style.borderRight="none";
if(cells[x].className.match("sqdbotRgt")!=null)
cells[x].style.borderRight="none";
}
}
}
}
/**********************end of FlyoutContainer***********************************/
/**********************Start of AutoSuggest*************************************/
var AUTO_SUGGEST_SELECTED='selected';
var AUTO_SUGGEST_COMP_CLASS='comp-shdwBox';
var AUTO_SUGGEST_DROPDOWN_CLASS='shdwBox';
var AUTO_SUGGEST_DISABLED='disabled';
var AUTO_SUGGEST_CONTAINER='AUTO_SUGGEST_CONTAINER';
var AS_SELECT_ITEM_EVENT='AutoSuggestSelectItem';
var _cbdSelectedAutoSuggest;
AutoSuggest=function(id, numCharsToTrigger, labelColumn, tableUrl, onSelect, onValueChange, maxRowsBeforeScroll, position, defaultText, fieldIDToHide, onBlurJS)
{
this.base=vg.Controller;
this.base(id, null);
this.highlightedRow=null;
this.selectedRow=null;
var dropdownHolder=vg.html.getSibling(this.viewNode,{tagName:'span', attrName:'class', attrValue:AUTO_SUGGEST_COMP_CLASS}, "+");
this.dropdown=vg.html.getFirstChild(dropdownHolder);
this.tableContainer=vg.html.getFirstChild(vg.html.getFirstChild(this.dropdown));
this.labelInput=this.viewNode;
this.valueInput=vg.html.getSibling(this.labelInput,{tagName:'input'}, "+");
this.numCharsToTrigger=numCharsToTrigger;
this.labelColumn=labelColumn;
this.tableUrl=tableUrl;
this.onSelect=onSelect;
this.onValueChange=onValueChange;
this.maxRowsBeforeScroll=maxRowsBeforeScroll > 0?maxRowsBeforeScroll:null;
this.position=position;
this.defaultText=defaultText;
this.fieldIDToHide=fieldIDToHide;
this.cursor;
this.onBlurJS=(onBlurJS==''?null:onBlurJS);
//These are needed within _onBlurAction().  See that function for further details
this.isSuggestionsOpen=false;
this.isTabPressed=false;
this.labelInput.setAttribute("autocomplete", "off");
if(isEmpty(this.labelInput.value)&&this.defaultText)
{
this.labelInput.value=this.defaultText;
vg.html.replaceClass(this.viewNode, ASINPUT_FOCUS_CLASS, ASINPUT_NOFOCUS_CLASS);
}
//Find the td with the class "layoutTopBorder"
var asThickBorderTd=vg.html.findAncestor(this.viewNode,{tagName:"td", attrName:"class"}, function(input){return vg.html.hasStyle("layoutTopBorder", input);});
if(asThickBorderTd)
{
this.viewNode.inLayoutTopBorderTd=true;
}
this.loading=false;//set to true, when the table with suggestions is being loaded
this.scroll=false;
//Add event listeners to label input
var controller=this;
vg.html.addEventListener(this.labelInput, 'click', function(e){controller._inputClick(e);});
vg.html.addEventListener(this.labelInput, 'blur', function(e){controller._onBlurAction(e);});
vg.html.addEventListener(this.labelInput, 'keyup', function(e){controller._keyup(e);});
vg.html.addEventListener(this.labelInput, 'keydown', function(e){controller._keydown(e);});
//
//AUTO_SUGGEST_CONTAINER is now attached to the body. When we start to scroll, it continues to stay on the screen.
//So, once we start scrolling, we hide it. wrapDiv only exists in IE, hence this is for IE only.
//
var wrapDiv=document.getElementById('wrapDiv');
if(ie&&wrapDiv)
{
vg.html.addEventListener(wrapDiv, 'scroll' , function(){controller.hideSuggestions();});
}
this._addRowListeners();
vg.util.execOnPageReady(function(){controller._createAutoSugCont()});
}
AutoSuggest.prototype=
{
//
//Code to execute with the 'blur' EventListener
//
_onBlurAction:function(e)
{
this._resetDefaultText(e);
//DEF461392
//In IE, clicking the scroll bar within the suggestions dropdown triggers a blur action.  However,
//we don't want to call _blur yet because we're still technically focused on the autoSuggest.  So,
//we'll skip calling _blur() until the user does something when the suggestions dropdown is not open.
//NOTE:The only time this does not apply is when the user presses the Tab key.  Regardless of
//the state of the menu, tabbing will always be a blur event, so we'll call _blur().
if(this.isTabPressed||!this.isSuggestionsOpen)
{
this._blur(e);
}
},
//
//For positioning purposes of the dropdown within layers and other divs with overflow,
//move all dropdowns to the AUTO_SUGGEST_CONTAINER which is appended to the main div
//
_createAutoSugCont:function()
{
//if the AUTO_SUGGEST_CONTAINER container exists, don't create it again
if(document.getElementById(AUTO_SUGGEST_CONTAINER))
{
var asCont=document.getElementById(AUTO_SUGGEST_CONTAINER);
}
else
{
var asCont=document.createElement('div');
asCont.setAttribute("id", AUTO_SUGGEST_CONTAINER);
var mainElement=document.getElementById('body');
if(!mainElement)
{
//didn't find 'main'(VDP or RIA template)
//look for 'cbd-main'(CBD template)
mainElement=document.getElementById('cbd-main')
}
//Get the CSS container of the targetNode(either vg0 or vg1)
var cssContainer=vg.html._cbdGetCSSContainer(this.viewNode);
//Append the AutoSuggestContainer to the targetNode's CSS container.
cssContainer.appendChild(asCont);
}
var id=this.viewNode.getAttribute('id')+'ShdwBox';
//Set associated parent ID so the controller can be found from the menu
this.dropdown.setAttribute("associatedParentId", this.viewNode.getAttribute('id'));
//delete previous dropdown if it exists within AUTO_SUGGEST_CONTAINER
for(i=0;i < asCont.childNodes.length;i++)
{
if(id==asCont.childNodes[i].getAttribute('id') )
{
asCont.removeChild(asCont.childNodes[i])
}
}
//append dropdown to AUTO_SUGGEST_CONTAINER
asCont.appendChild(this.dropdown);
this.dropdown.style.zIndex="999";
},
//
//Show the suggestions dropdown, when the input is clicked
//
_inputClick:function(e)
{
//set to false each time the input is clicked, to ensure that it is properly reset
this.isTabPressed=false;
if(this.defaultText)
{
_cbdClearInputDefaultText(this.labelInput, this.defaultText);
}
this._showOrHideSuggestions();
},
//
//Resets the defaultText on blur
//
_resetDefaultText:function(e)
{
if(this.defaultText)
{
_cbdSetInputDefaultText(this.labelInput, this.defaultText);
}
},
//
//Hides the suggestions dropdown on blur
//TODO:document the loading flag check
//
_blur:function(e)
{
if(!this.loading)
{
this.hideSuggestions();
//execute the JS function through the blur event
if(this.onBlurJS!=null)
{
vg.comp._execEventHandler(this.onBlurJS, this.viewNode);
}
}
},
//
//Row Click handler
//TODO:pass the selected row as an argument(vs member variable)
//
_rowClick:function(e)
{
this.selectedRow=this._getEventRow(e);
this._selectRow(e, true);
},
//
//Copies the selected(click or enter) row's label into the label input,
//and the row's value into the value input(hidden).
//
//e - can be an event or a node
//sendToCobrowse - boolean, determines whether the event will be recorded for cobrowse
//(don't want to record events being played by cobrowse)
//
_selectRow:function(e, sendToCobrowse)
{
//Record the event for cobrowse
if(sendToCobrowse)
{
vg.cobrowse.recordEvent(e, this.selectedRow, AS_SELECT_ITEM_EVENT, this.selectedRow.getAttribute('value'));
}
var rowInfo=this._getRowInfo(this.selectedRow);
//TODO:add a check for this.onSelect==null
if(rowInfo.value!="cbdDisabled"&&this.onSelect(rowInfo.value, rowInfo.label, this.viewNode.getAttribute("id")) )
{
/*
*this.onSelect may block the selection(if it returns false)
*/
this._setInputValues(rowInfo);
//In IE, ensure the focus is left on the autoSuggest after selecting one of the suggestions
this.labelInput.focus();
//hide the suggestions but leave focus with the input
if(!this.loading)
{
this.hideSuggestions();
}
}
},
/*
*Handles Cobrowse custom events
*/
_handleCobrowseEvent:function(event, node, value)
{
if(event==AS_SELECT_ITEM_EVENT)
{
var table=this._getSuggestTable();
if(table)
{
var rows=this._getSuggestTableRows();
for(var i=0;i < rows.length;i++)
{
if(this._getRowInfo(rows[i]).value==value)
{
this.selectedRow=rows[i];
this._selectRow(node, false);
}
}
}
vg.cobrowse.setAttention(this.viewNode.getAttribute('id'));
}
},
//
//Sets the label and value inputs based on the passed rowInfo
//
_setInputValues:function(rowInfo, skipChange)
{
this.labelInput.value=vg.util.removeTags(rowInfo.label);
this.valueInput.value=vg.util.removeTags(rowInfo.value);
/*
*Executes client's onValueChange
*/
if(this.onValueChange!=null&&!skipChange)
{
this.onValueChange(this.viewNode.getAttribute('id'), this.valueInput.value, this.labelInput.value);
}
},
//
//Returns a{value:xxx, label:yyy}pair for the passed row
//
_getRowInfo:function(row)
{
var rowInfo=new Object();
rowInfo.value=row.getAttribute("value");
rowInfo.label=row.getAttribute("label");
//If the label wasn't specified on the row, get the label cell
if(!rowInfo.label)
{
var rowCells=vg.html.getElements(row,{tagName:'td'});
var labelCell=rowCells[this.labelColumn];
if(labelCell&&labelCell.innerText)
{
rowInfo.label=labelCell.innerText;
}
else if(labelCell&&labelCell.textContent)
{
rowInfo.label=labelCell.textContent;
}
else
{
rowInfo.label="";
}
}
return rowInfo;
},
//
//Highlights the row on mouseover
//
_rowMouseOver:function(e)
{
this._addSelectedStyle(e);
},
//
//Unhighlights the row on mouseover
//
_rowMouseOut:function(e)
{
this._removeSelectedStyle(e);
},
//
//Handles Tab Key through keydown event.  When tabbing out of the field, the current
//field will get the keyDown event for the tab, however it leaves the field before the
//keyUp event.  Therefore, we have to catch it here.
//
_keydown:function(e)
{
var key=jsCBDgetKey(jsCBDgetEvent(e));
if(key==9)
{
this.isTabPressed=true;
}
},
//
//Handles
//1) the up and down keys(moving through the suggestions)
//2) the Enter key(selects the row)
//3) other keys(manipulating input value)
//
_keyup:function(e)
{
var key=jsCBDgetKey(jsCBDgetEvent(e));
//only change highlighted row if dropdown is displayed
if(jsCBDisVisibleElement(this.dropdown)&&(key==40||key==38||key==13||key==9))
{
if(key==9)//this will never get called ... the if() above this won't allow it through, why is it here?
{
//to prevent the tab key from cobrowsing
vg.html.stopEventPropagation(e);
}
//up or down key
else if(key==40||key==38)
{
//to prevent the up and down keys from cobrowsing
vg.html.stopEventPropagation(e);
var oldRow=this.highlightedRow;
var prevRow;
var nextRow;
if(oldRow)
{
prevRow=vg.html.getSibling(oldRow,{tagName:"tr"}, "-");
nextRow=vg.html.getSibling(oldRow,{tagName:"tr"}, "+");
}
var newRow=oldRow;
//down key
if(key==40 )
{
if(oldRow&&nextRow)
{
//Not last row, go to next row
newRow=nextRow;
}
else if(!oldRow)
{
//No row highlighted, go to first row
newRow=this._getSuggestTableRows()[0];
}
}
//up key
else if(key==38&&prevRow )
{
//Not first row, go to prev row
newRow=prevRow;
}
if(oldRow)
{
this._removeSelectedStyle(oldRow);
}
if(newRow)
{
var rowInfo=this._getRowInfo(newRow);
this._setInputValues(rowInfo, true);
this._addSelectedStyle(newRow);
var optHeight=vg.html.getObjHeight(newRow);
var optionY=(optHeight*newRow.getAttribute('index'))+vg.html.getObjY(this.tableContainer);
vg.html.scrollIntoView(this.tableContainer, newRow, optHeight, optionY);
}
}
//enter key
else if(key==13&&this.highlightedRow)
{
this.selectedRow=this.highlightedRow;
this._selectRow(e, true);
}
}
else
{
/*
*Any key other than "up", "down", "enter"
*Clear the current value, and process the typed in value
*/
var controller=this;
//Delay changing the suggestions until typing has stopped for 250 ms
clearTimeout(this.typingTimeout);
this.typingTimeout=vg.util.setTimeout(function()
{
controller.valueInput.value=null;
controller._showOrHideSuggestions(true);
}, 250);
}
},
//
//Displays/hides the suggestions dropdown based on the number of chars in the input
//
//TODO:document searchForValue(when it is passed or not passed)
//
_showOrHideSuggestions:function(searchForValue)
{
if(this._hasEnoughChars())
{
this.loadTable(null, searchForValue);
}
else
{
this.hideSuggestions();
}
},
//
//Makes an AJAX request to load a new suggestions table(based on the value of the input)
//Once the table's been loaded, re-adds the row listeners,
//and configures the suggestions dropdown.
//
loadTable:function(addlParams, searchForValue)
{
var controller=this;
if(controller.loading)
{
controller.pendingReq=true;
controller.addlParams=addlParams;
controller.searchForValue=searchForValue;
}
else
{
this.loading=true;
jsCBDloadContent(this._getUrlWithParameters(addlParams), this.tableContainer, 'replaceChildren',
function()
{
controller.loading=false;
//don't send a new request, until the current one is completed)
if(controller.pendingReq)
{
controller.loadTable(controller.addlParams, controller.searchForValue);
controller.pendingReq=false;
}
//Only show the dropdown if there are rows in the table
if(controller._getSuggestTableRows().length > 0 )
{
controller._addRowListeners();
controller.showSuggestions();
controller._setDropdownHeight();
controller._setDropdownWidth();
controller._setDropdownPosition();
}
else
{
//No rows in the table, so hide the dropdown
controller.hideSuggestions();
}
controller.labelInput.focus();
});
}
},
//
//Concats the url for the AJAX request(to get a table with suggestions)
//
_getUrlWithParameters:function(addlParams)
{
var value=this.labelInput.value.replace(/[\%]/g, " ");
value=encodeURIComponent(value);
var url=jsCBDaddQueryStringParam(this.tableUrl, "cbdASId", this.viewNode.getAttribute("id"));
url=jsCBDaddQueryStringParam(url, "cbdASValue", value);
if(!isEmpty(addlParams))
{
url+="&"+addlParams;
}
return url;
},
//
//Displays the suggestions dropdown
//
showSuggestions:function()
{
this.isSuggestionsOpen=true;
jsCBDtoggleElement(this.dropdown, true);
_cbdSelectedAutoSuggest=this;
this._preventBleedThru(this.fieldIDToHide, true);
},
//
//Hides the suggestions dropdown
//
hideSuggestions:function()
{
jsCBDtoggleElement(this.dropdown, false);
_cbdSelectedAutoSuggest=null;
if(this.highlightedRow)
{
this._removeSelectedStyle(this.highlightedRow);
}
this._preventBleedThru(this.fieldIDToHide, false);
this.isSuggestionsOpen=false;
},
//
//Will hide the component(s) to help prevent it from overlaying the Suggestions.
//elemIDs - one or more IDs of the element(s) to hide
//isHideElem - set as true to hide the component, false to display it
//
_preventBleedThru:function(elemIDs, isHideElem)
{
if(ie6_proper||ie5)
{
if(elemIDs==null||elemIDs=="") return;
var list=elemIDs.split(",");
for(var x=0;x < list.length;x++)
{
var id=list[x];
if(isHideElem)
{
jsCBDsetVisibility(id,false);
}
else
{
jsCBDsetVisibility(id,true);
}
}
}
},
//
//Checks if the label input has enough chars to trigger the call to the client's JSP(returning the table)
//
_hasEnoughChars:function()
{
return this.labelInput.value.length >=this.numCharsToTrigger;
},
//
//Adds row highlighting
//
_addSelectedStyle:function(e)
{
this._addOrRemoveSelectedStyle(e, true);
},
//
//Removes row highlighting
//
_removeSelectedStyle:function(e)
{
this._addOrRemoveSelectedStyle(e, false);
},
//
//Toggles row highlighting based on the "add" parameter
//
_addOrRemoveSelectedStyle:function(e, add)
{
var row=this._getEventRow(e);
if(add)
{
if(this.highlightedRow)
{
vg.html.removeStyle(AUTO_SUGGEST_SELECTED, this.highlightedRow);
}
this.highlightedRow=row;
}
else if(this.highlightedRow==row)
{
this.highlightedRow=null;
}
vg.html.addOrRemoveStyle(AUTO_SUGGEST_SELECTED, row, add);
},
//
//Gets the parent row of the event node(the event being 'mouseover', 'click', etc)
//
_getEventRow:function(e)
{
var eNode=e.tagName?e:jsCBDgetEventNode(e);
return(eNode.tagName.toLowerCase()=='tr')?eNode:vg.html.findAncestor(eNode,{tagName:'tr'});
},
//
//Configures the width of the suggestions dropdown
//
_setDropdownWidth:function()
{
var table=this._getSuggestTable();
if(table)
{
/*
*Set the dropdown's width to 'auto', so we can get its real width
*/
vg.html.setWidth(this.dropdown, "auto");
//use offset to adjust for scroll bar and prevent horizontal scrolling in FF
var offset=this.scroll||safari?19:2;
var tableWidth=vg.html.getObjWidth(table);
if(tableWidth&&tableWidth > 0)
{
tableWidth+=26;
vg.html.setWidth(this.dropdown,(tableWidth+offset)+'px');
}
}
},
//
//Configures the height of the suggestions dropdown
//based on the max number of rows to display.
//
_setDropdownHeight:function()
{
var table=this._getSuggestTable();
if(table)
{
/*
*tableHeight - actual height of suggestion table
*displayHeight - max allowed height(before scrolling
*/
var tableHeight=vg.html.getObjHeight(table);
var rows=vg.html.getElements(table,{tagName:'tr'});
var numRowsDisplayed=rows.length;
if(this.maxRowsBeforeScroll&&rows.length > this.maxRowsBeforeScroll)
{
numRowsDisplayed=this.maxRowsBeforeScroll;
}
var displayHeight=0;
for(var i=0;i < numRowsDisplayed;i++)
{
displayHeight+=vg.html.getObjHeight(rows[i]);
}
if(tableHeight > displayHeight)
{
this.tableContainer.style.overflowY="auto";
this.scroll=true;
}
else
{
if(tableHeight < displayHeight)
{
/*
*Set dropdown's height to that of the actual table
*/
displayHeight=tableHeight;
}
this.scroll=false;
}
vg.html.setHeight(this.tableContainer, displayHeight+"px");
if(ie)
{
vg.html.setHeight(this.dropdown,(displayHeight - 8)+"px");
}
}
},
//
//Safari positioning work-around
//
_setDropdownPosition:function()
{
this.position=(this.position!="left")?"right":"left";
var data=vg.html.position({elementNode:this.dropdown, targetNode:this.viewNode, dispLoc:"auto", horzPos:this.position});
//when dropdonw position on top, we need to adjust y position to compensate for margin set in css.
if(data.elem.dispLoc.indexOf("top") > -1)
{
var marginTop=parseInt(jsCBDGetComputedStylePropertyValue(this.dropdown, "margin-top"));
vg.html.setObjTop(this.dropdown, this.dropdown.style.top.replace("px","") - marginTop);
}
},
//
//Adds row level listeners
//TODO:use mouseenter/leave events
//
_addRowListeners:function(e)
{
var controller=this;
//Add event listeners to rows
var rows=this._getSuggestTableRows();
for(var i=0;i < rows.length;i++)
{
if(this._getRowInfo(rows[i]).value!="cbdDisabled")
{
vg.html.addEventListener(rows[i], 'mouseover', function(e){controller._rowMouseOver(e);});
vg.html.addEventListener(rows[i], 'mouseout', function(e){controller._rowMouseOut(e);});
vg.html.addEventListener(rows[i], 'mousedown', function(e){controller._rowClick(e);});
}
}
},
//
//Gets the suggestions table element
//
_getSuggestTable:function()
{
var compSpan=vg.html.getElements(this.dropdown,{tagName:'span', attrName:'type', attrValue:'DataTable'})[0];
return vg.html.getElements(compSpan,{tagName:'table'})[0];
},
//
//Gets the collection of rows in the suggestion table
//
_getSuggestTableRows:function()
{
return vg.html.getElements(this._getSuggestTable(),{tagName:'tr'});
}
}
//
//Handle the keypress event to prevent submitting the form
//when selecting a row with the enter key.
//
//PARAMS:
//element - the id or an element of the AutoSuggest component
//event - the keypress event
//
//<span class="attention">FOR INTERNAL CBD USE ONLY</span>
//
AutoSuggest._allowKeyPress=function(element, event)
{
var as=vg.comp.getController(element);
if(as.highlightedRow)
{
return jsCBDblockEnterKey(event)
}
}
//
//Loads and displays the Auto-suggest table
//(used by the 'View All' item in the suggestions table)
//
//PARAMS:
//autoSuggestId - the ID of the autoSuggest component
//params(optional) - any additional parameters to be used in the AJAX call
//
cbdns.jsCBDloadAutoSuggestTable=function(autoSuggestId, params)
{
var autoSuggest=vg.comp.getController(autoSuggestId);
if(autoSuggest)
{
autoSuggest.loadTable(params);
}
}
//
//This function is called from body mousedown event and scroll event on a layer
//
cbdns.jsCBDcloseAutoSuggest=function(e)
{
if(_cbdSelectedAutoSuggest!=null)
{
//On scroll event, close the open autoSuggest. Scroll event is fired by the layer component.
if(e.type=='scroll')
{
_cbdSelectedAutoSuggest._blur();
}
else
{
var eNode=jsCBDgetEventNode(e);
if(eNode!=null)
{
var clickedOnDropdown=eNode.className&&(eNode.className==AUTO_SUGGEST_DROPDOWN_CLASS);
var clickedInsideInput=eNode.getAttribute('id')&&(eNode.getAttribute('id')==_cbdSelectedAutoSuggest.viewNode.getAttribute('id'));
var clickedInsideDropdown=vg.html.findAncestor(eNode,{tagName:'div', attrName:'class', attrValue:AUTO_SUGGEST_DROPDOWN_CLASS})!=null;
var isScrollEevent=_cbdIsScrollEvent(eNode.scrollTop, eNode.scrollLeft);
if(!clickedInsideInput&&!clickedInsideDropdown&&!clickedOnDropdown&&eNode.tagName!="HTML"&&!isScrollEevent)
{
_cbdSelectedAutoSuggest._blur();
}
}
}
}
}
//
//This function is called from the GlobalHeader component by the valueChange attribute
//
cbdns._cbdGHAutoSuggestValueChange=function(id, value, label)
{
if(value.substring(0,7)=="https:/")
{
jsCBDgoToUrl(value.substring(7));
}
else
{
document.getElementById("searchForm").submit();
}
}
cbdns.jsCBDresetAutoSuggest=function(id)
{
var autoSuggest=vg.comp.findController(id, false);
if(autoSuggest)
{
autoSuggest.labelInput.value=autoSuggest.defaultText?autoSuggest.defaultText:"";
autoSuggest.valueInput.value="";
}
}
cbdns.jsCBDgetAutoSuggestSelection=function()
{
var as=vg.html.getElements(document.getElementById('body'),{tagName:'span', attrName:'type', attrValue:'AutoSuggestInput'});
var cursorArray=null;
if(as.length > 0)
{
cursorArray=new Array();
for(var j=0;j < as.length;j++)
{
var asInput=vg.html.getElements(as[j],{tagName:'input', attrName:'type', attrValue:'text'})[0];
cursorArray[j]=vg.html.getSelection(asInput);
}
}
return cursorArray;
}
cbdns.jsCBDsetAutoSuggestSelection=function(cursorArray)
{
var as=vg.html.getElements(document.getElementById('body'),{tagName:'span', attrName:'type', attrValue:'AutoSuggestInput'});
if(cursorArray&&as.length>0&&cursorArray.length==as.length)
{
for(var j=0;j<as.length;j++)
{
var asInput=vg.html.getElements(as[j],{tagName:'input', attrName:'type', attrValue:'text'})[0];
vg.html.setSelection(asInput, cursorArray[j].start, cursorArray[j].end);
}
}
}
vg.validation.validateAndSubmitParentForm=function(caller, showWaitMsg, disableWT)
{
var form=_cbdGetParentForm(caller);
vg.validation.validateAndSubmitForm(form, caller, showWaitMsg, disableWT);
}
vg.validation.submitParentForm=function(caller, showWaitMsg, disableWT)
{
var form=_cbdGetParentForm(caller);
vg.validation.submitForm(form, caller, showWaitMsg, disableWT);
}
vg.validation.validateAndSubmitForm=function(form, submitBtn, showWaitMsg, disableWT, suppressErrorLayer)
{
if(vg.validation.validateForm(form, suppressErrorLayer))
{
vg.validation.submitForm(form, submitBtn, showWaitMsg, disableWT);
}
}
vg.validation.submitForm=function(form, caller, showWaitMsg, disableWT)
{
if(!disableWT)
{
jsCBDdcsTag();
}
if(form.tagName=='DIV')
{
var newForm=document.createElement("form");
var formParent=form.parentNode;
newForm.setAttribute('enctype', form.getAttribute('enctype'));
newForm.setAttribute('action', form.getAttribute('action'));
newForm.setAttribute('method', form.getAttribute('method'));
newForm.setAttribute('id', form.getAttribute('id'));
newForm.setAttribute('name', form.getAttribute('name'));
if(ie)
{
newForm.innerHTML=form.innerHTML;
}
else
{
while(vg.html.getFirstChild(form))
{
var node=vg.html.getFirstChild(form);
form.removeChild(node);
newForm.appendChild(node);
}
}
formParent.removeChild(form);
formParent.appendChild(newForm);
form=newForm;
}
_cbdDisableNestedForm(form, true);
if(_cbdIsVgButton(caller))
{
_trackSubmitButton(caller);
_cbdDisableSubmitButton();
}
form.submit();
var formId=form.getAttribute('id');
_cbdResetCmdLink(formId);
_cbdSetButtonHiddenInput(formId, "");
if(showWaitMsg=='true')
{
jsCBDtoggle('main', false);
jsCBDtoggle('msgOnSubmit', true);
}
}
vg.validation.validateFormById=function(formId, suppressErr, suppressErrorLayer)
{
return vg.validation.validateForm(document.getElementById(formId), suppressErr, suppressErrorLayer);
}
vg.validation.suppressErrorLayer=function(flag)
{
vg.validation.isSuppressErrorLayer=flag;
}
vg.validation.validateForm=function(form, suppressErr, suppressErrorLayer)
{
var isFormValid=true;
var firstInvalidElem=null;
var formId=form.getAttribute("id");
vg.validation.clearValidationObserverErrors(formId);
var elements=vg.html.getFormElements(form);
for(var i=0;i < elements.length;++i)
{
isFormValid=vg.validation.validateElement(elements[i], true)&&isFormValid;
if(!isFormValid&&firstInvalidElem==null)
{
firstInvalidElem=elements[i];
}
}
elements=vg.validation.getCalculatedElems(form);
for(var i=0;i < elements.length;++i)
{
isFormValid=vg.validation.validateElement(elements[i], true)&&isFormValid;
if(!isFormValid&&firstInvalidElem==null)
{
firstInvalidElem=elements[i];
}
}
if(suppressErr)
return isFormValid;
if(!isFormValid)
{
if(firstInvalidElem!=null)
{
vg.validation.registerFirstInvalidElem(firstInvalidElem);
}
if(!suppressErrorLayer)
{
vg.validation.openErrorLayer();
}
}
vg.validation.triggerValidationObservers(formId);
return isFormValid;
}
vg.validation.triggerValidationObservers=function(formId)
{
var valObserverArrays=null;
if(formId)
{
valObserverArrays=new Object();
valObserverArrays[formId]=vg.validation._valObservers[formId];
}
else
{
valObserverArrays=vg.validation._valObservers;
}
for(j in valObserverArrays)
{
var valObservers=valObserverArrays[j];
if(!isEmpty(valObservers) )
{
var valObsLength=valObservers.length;
for(var i=0;i < valObsLength;i++)
{
var node=document.getElementById(valObservers[i]);
if(node)
{
var controller=vg.comp.findController(node, false);
if(controller)
{
controller._triggerValidationObserver(vg.html.getElement(valObservers[i]) );
}
}
}
}
}
vg.validation.valObserversTimeOut=null;
}
vg.validation.clearValidationObserverErrors=function(formId)
{
var valObservers=vg.validation._valObservers[formId];
if(!isEmpty(valObservers) )
{
var valObsLength=valObservers.length;
for(var i=0;i < valObsLength;i++)
{
var validationObserverNode=document.getElementById(valObservers[i]);
if(validationObserverNode)
{
validationObserverNode.errorInputs=null;
}
}
}
}
vg.validation.getCalculatedElems=function(context)
{
return vg.html.getElements(context,{tagName:'span', attrName:'type', attrValue:'CALCULATED'});
}
vg.validation.validateElementById=function(input)
{
var compInput=vg.html.getElement(input);
var elements=vg.html.getFormElements(compInput);
var isInputValid=true;
for(var i=0;i < elements.length;++i)
{
isInputValid=vg.validation.validateElement(elements[i], true)&&isInputValid;
}
return isInputValid;
}
vg.validation.validateElement=function(input, isSubmit)
{
if(!vg.validation.isValidateClientSide(input))
{
return true;
}
var inputType=input.getAttribute('type');
if(inputType=='button'||inputType=='hidden')
{
return true;
}
var id=input.getAttribute('name');
if(id==null)
{
id=input.getAttribute('id');
}
var isValid;
var isInputGroup=vg.validation.isInputGroup(input);
var isDispersedInputGroup=vg.validation.isDispersedInputGroup(input);
var isDirty=input.dirty;
if(!isSubmit&&!isDirty&&(isEmpty(input.value)||input.value=='none'||isInputGroup))
{
isValid=true;
}
else
{
var isFirstInput=input.getAttribute('firstInput')=='true';
if(isSubmit&&isDispersedInputGroup&&!isFirstInput)
{
return true;
}
else
{
isValid=jsCBDvalidateById(id, isSubmit, true);
}
}
var methodToCall=isValid?
vg.validation.setValid:vg.validation.setInvalid;
var isStateChanged=(isValid!=vg.validation.isValid(input));
if(isStateChanged)
{
if((!isSubmit&&isInputGroup)||isDispersedInputGroup)
{
var targetInputs=vg.validation.getTargetInputs(input.name);
for(var i=0;i < targetInputs.length;++i)
{
methodToCall.call(this, targetInputs[i]);
}
}
else
{
methodToCall.call(this, input);
}
}
vg.validation._notifyValidationObserver(input, isValid);
return isValid;
}
vg.validation.isValid=function(input)
{
return(input.valid==null||input.valid==true)
}
vg.validation.setValid=function(input)
{
var inputElm=vg.html.getElement(input);
inputElm.valid=true;
var tdTarget=vg.validation.getTdTarget(inputElm);
if(tdTarget!=null)
{
jsCBDdeleteStyle(tdTarget, "err");
vg.html.removeEventListener(tdTarget, 'mouseenter', vg.validation.showErr, "error_in");
vg.html.removeEventListener(tdTarget, 'mouseleave', vg.validation.hideErr, "error_out");
}
jsCBDtoggle("form-field-info", false);
}
vg.validation.setInvalid=function(input)
{
input.valid=false;
input.dirty=true;
var tdTarget=vg.validation.getTdTarget(input);
tdTarget.childInput=input;
jsCBDaddStyle(tdTarget, "err");
tdTarget.setAttribute('errTd', 'true');
if(window.isWtLogInputErrors)
{
var lastTwoDigitsOfID=input.id.substr(input.id.length - 2);
if(!vg.validation.isInputGroup(input)||(vg.validation.isInputGroup(input)&&lastTwoDigitsOfID==":0"))
{
jsCBDSendDCSTagsThenClear("DCSext.CBDerr", input.id);
}
}
vg.html.addEventListener(tdTarget, 'mouseenter', vg.validation.showErr, "error_in");
vg.html.addEventListener(tdTarget, 'mouseleave', vg.validation.hideErr, "error_out");
}
vg.validation._valObservers=new Object();
vg.validation._notifyValidationObserver=function(input, isValid)
{
var validationObserverNode=vg.html.findAncestor(input,{attrName:'validationObserver'});
if(validationObserverNode&&validationObserverNode.getAttribute('validationObserver')=='true')
{
var validationObserverId=validationObserverNode.getAttribute("id");
var formId=_cbdGetParentForm(validationObserverNode).getAttribute("id");
var valObservers=vg.validation._valObservers[formId];
var alreadyInArray=false;
if(valObservers)
{
var valObsLength=valObservers.length;
for(var i=0;i < valObsLength&&!alreadyInArray;i++)
{
if(validationObserverId==valObservers[i])
{
alreadyInArray=true;
}
}
}
else
{
vg.validation._valObservers[formId]=new Array();
valObservers=vg.validation._valObservers[formId];
}
if(!alreadyInArray)
{
valObservers[valObservers.length]=validationObserverId;
}
var controller=vg.comp.findController(validationObserverNode, false);
if(controller)
{
controller._updateValidationObserverErrors(input, validationObserverNode,!isValid);
}
}
}
vg.validation.showErr=function(e)
{
var input=vg.validation.findTargetInput(e);
if(input==null||input.valid)
{
return;
}
var errLayer=document.getElementById("form-field-info");
var errLayerContents=document.getElementById("form-field-info-contents");
errLayerContents.innerHTML=vg.validation.getErrMsg(input);
jsCBDtoggleElement(errLayer, true);
var parentTd=vg.validation.getTdTarget(input, e);
vg.html.position({elementNode:errLayer, targetNode:parentTd, dispLoc:"auto", horzPos:"left"});
}
vg.validation.hideErr=function(e)
{
jsCBDtoggle("form-field-info", false);
}
vg.validation.findTargetInput=function(e)
{
var eNode=jsCBDgetEventNode(e);
var tdTarget;
if(eNode.getAttribute('errTd')!=null )
{
tdTarget=eNode;
}
else
{
tdTarget=vg.html.findAncestor(eNode,
{tagName:'td', attrName:'errTd', attrValue:'true'});
}
return tdTarget?tdTarget.childInput:null;
}
var errorMessageBullet="&bull;";
vg.validation.setErrorMessageBullet=function(bulletCode)
{
errorMessageBullet=bulletCode;
}
vg.validation.getErrMsg=function(input)
{
var errMsg=input.infomsg;
if(!isEmpty(errMsg))
{
return errMsg;
}
var context=input;
var parent=input.parentNode;
if(parent.getAttribute("type")=="INPUT_DESC")
{
context=parent;
}
else if(vg.validation.isDispersedInputGroup(input))
{
context=document.getElementById(input.getAttribute('name'));
}
var errElem=vg.html.getSibling(context,{attrName:'type', attrValue:'ERR_DESC'}, "-");
if(errElem!=null)
{
var errListItemId=errElem.getAttribute('errListMsgId');
var errListItem=document.getElementById(errListItemId);
return errListItem.innerHTML;
}
return "ERROR MSG NOT FOUND";
}
vg.validation.isValidateClientSide=function(input)
{
var inputContainer=input;
if(vg.validation.isDispersedInputGroup(input))
{
inputContainer=document.getElementById(input.getAttribute('name'));
if(inputContainer==null)
{
var error="The dispersed input group "+input.getAttribute('name')+
" for "+input.getAttribute('id')+" is not on the page.";
vg.util.throwException("vg.validation.isValidateClientSide", error);
}
}
else if(vg.validation.isInputGroup(input))
{
inputContainer=vg.html.findAncestor(input,{tagName:'td'});
}
if(vg.validation.isOffForElement(inputContainer))
{
return false;
}
var form=_cbdGetParentForm(inputContainer );
if(vg.validation.isOffForElement(form))
{
return false;
}
return true;
}
vg.validation.isOffForElement=function(e)
{
var cssClass=(e!=null?e.className:null);
return(!isEmpty(cssClass)&&cssClass.indexOf('jsValOff') >=0);
}
vg.validation.isDispersedInputGroup=function(input)
{
return input.getAttribute('radiogroup')=='true';
}
vg.validation.getTdTarget=function(input, e)
{
if(e!=null)
{
var eNode=jsCBDgetEventNode(e);
if(eNode.getAttribute('errTd')!=null )
{
return eNode;
}
}
var isDispersedInputGroup=vg.validation.isDispersedInputGroup(input);
var booleanCheckbox=input.getAttribute('booleanCheckbox');
if(!(isDispersedInputGroup||booleanCheckbox=='true')&&
vg.validation.isInputGroup(input)||_cbdIsRiaSelectOneMenu(input))
{
var inputTD=vg.html.findAncestor(input,{tagName:'td'});
return vg.html.findAncestor(inputTD,{tagName:'td'});
}
else
{
return vg.html.findAncestor(input,{tagName:'td'});
}
}
vg.validation.getStyleTarget=function(input)
{
if(vg.validation.isInputGroup(input))
{
return vg.html.findAncestor(input,{tagName:'label'});
}
else
{
return input;
}
}
vg.validation.isInputGroup=function(input)
{
var inputType=input.getAttribute('type');
return(inputType=='radio'||inputType=='checkbox');
}
vg.validation.closeErrLayer=function()
{
jsCBDcloseLayer('errFormLayer');
var firstInvalidElem=vg.validation.firstInvalidElem;
var isInView=vg.html.isElementInView(firstInvalidElem);
if(firstInvalidElem!=null&&!isInView)
{
var yPos=vg.html.getObjSizePosition(firstInvalidElem).y;
window.scrollTo(0, yPos);
}
jsCBDpreventSelectListBleedThru();
}
vg.validation.openErrorLayer=function()
{
vg.util.execOnPageReady(vg.validation.setupErrLayer );
}
vg.validation.openErrorLayerFinish=function()
{
jsCBDopenLayer('errFormLayer', null, null, function(){vg.button.setFocus("errFormLayer_but")});
jsCBDpreventSelectListBleedThru();
}
vg.validation.setupErrLayer=function()
{
var node=document.getElementById('errFormLayer' );
if(node )
{
vg.validation.openErrorLayerFinish();
}
else
{
jsCBDloadContent(jsCBDgetContextRoot()+'com/vanguard/util/cbd/data/jsp/ErrorLayer.jsf',
'formErrLayer', 'replaceChildren', vg.validation.openErrorLayerFinish );
}
}
vg.validation.isFirstError=function()
{
return vg.validation.firstInvalidElem==null;
}
vg.validation.registerFirstInvalidElem=function(firstInvalidElem)
{
vg.validation.firstInvalidElem=firstInvalidElem;
}
vg.validation.setRiaError=function(msg_id, state, init, ajaxVal)
{
var msg_ids=msg_id.split(" ");
var errText="";
var first=true;
var inputId, bulletCode;
var multipleErrors=(msg_ids.length >1);
for(var i=0;i < msg_ids.length;i++)
{
var errMsg=document.getElementById(msg_ids[i]);
inputId=msg_ids[i].replace(/:[a-zA-Z0-9-_]*$/, "" );
if(errMsg!=null)
{
if(!first)errText+="<BR/>";
first=false;
var msgText=errMsg.getAttribute("text");
jsCBDAddErrorMetaTag(state, inputId);
bulletCode=(isEmpty(errorMessageBullet)||(!multipleErrors))?"":errorMessageBullet;
errText+=bulletCode+"&nbsp;"+msgText;
}
}
var input=document.getElementById(inputId);
var targetInputs=vg.validation.getTargetInputs(inputId);
for(var i=0;i < targetInputs.length;++i)
{
targetInputs[i].infomsg=errText;
}
if(init)
{
var methodToCall=state?vg.validation.setInvalid:vg.validation.setValid;
for(var i=0;i < targetInputs.length;++i)
{
methodToCall.call(this, targetInputs[i]);
}
vg.validation._notifyValidationObserver(input,!state);
if(!ajaxVal&&vg.validation.isFirstError())
{
vg.validation.registerFirstInvalidElem(input);
if(!vg.validation.isSuppressErrorLayer )
{
vg.validation.openErrorLayer();
}
}
if(!vg.validation.valObserversTimeOut)
{
vg.validation.valObserversTimeOut=setTimeout(function delayedTriggerValObservers(){vg.validation.triggerValidationObservers();}, 200);
}
}
}
vg.validation.getTargetInputs=function(inputId)
{
var input=document.getElementById(inputId);
if("radioGroup"==input.getAttribute("type")||
"true"==input.getAttribute("radiogroup"))
{
return _cbdGetElementsByName('input', inputId)
}
else if(_cbdIsRiaSelectOneMenu(input))
{
return vg.html.getElements(input,{tagName:'input', attrName:'name', attrValue:inputId});
}
else
{
if(input.nodeName.toUpperCase()=="TABLE")
{
return input.getElementsByTagName('input');
}
else
{
var targetInputs=new Array();
targetInputs.push(input);
return targetInputs;
}
}
}
vg.validation.focus=function(input)
{
if(_cbdIsRiaSelectOneMenu(input))
{
input=vg.comp.getController(input).valueInput;
}
jsCBDaddStyle(vg.validation.getStyleTarget(input), "focus");
var parent=input.parentNode;
var formatFunc=parent.getAttribute('b:format');
if(formatFunc!=null)
{
_setAutoFormat(input.getAttribute("name"), eval(formatFunc), true);
input.prevVal=input.value;
}
}
vg.validation.formatTypingTimeout=null;
vg.validation.autoFormat=function(key, func)
{
clearTimeout(vg.validation.formatTypingTimeout);
vg.validation.formatTypingTimeout=vg.util.setTimeout(
function()
{
func(key);
}, 250);
}
vg.validation.blur=function(input)
{
if(_cbdIsRiaSelectOneMenu(input))
{
input=vg.comp.getController(input).valueInput;
}
var styleTarget=vg.validation.getStyleTarget(input);
if(styleTarget==null)
{
return;
}
jsCBDdeleteStyle(vg.validation.getStyleTarget(input), "focus");
vg.validation.validateElement(input);
var parent=input.parentNode;
var formatFunc=parent.getAttribute('b:format');
if(formatFunc!=null)
{
_setAutoFormat(input.getAttribute("name"), null, false);
}
if(vg.util.isDefined(input.prevVal)&&input.prevVal!=input.value)
{
if(input.onchange!=null)
{
input.onchange();
}
}
}
vg.validation.change=function(input)
{
if(vg.util.isDefined(input.prevVal))
{
input.prevVal=input.value;
}
}
vg.validation.textareafocus=function(textarea)
{
jsCBDaddStyle(vg.validation.getStyleTarget(textarea), "focus");
}
vg.validation.textareablur=function(textarea)
{
jsCBDdeleteStyle(vg.validation.getStyleTarget(textarea), "focus");
}
var PREFIX_BEHAVIOR="selTblBeh";
var COL_HEAD_BEHAVIOR="selTblBehColHd";
var ROW_HEAD_BEHAVIOR="selTblBehRowHd";
var SELECT_ALL_BEHAVIOR="selTblBehSelAll";
var DATA_CELL_BEHAVIOR="selTblBehCell";
SelectTable=function(id, isHighlightRow, type)
{
this.base=vg.Controller;
this.base(id, null);
this.isHighlightRow=isHighlightRow;
this.type=type;
this.addListeners(this.viewNode.getElementsByTagName('TH'));
this.addListeners(this.viewNode.getElementsByTagName('TD'));
var controller=vg.comp.getController(id);
vg.html.addEventListener(this.viewNode, 'show', function(e){controller.show(e)});
if(this.type=="9box")
{
this.addRoundedCorners();
}
else
{
this.show(this.viewNode);
}
}
SelectTable.prototype.addRoundedCorners_d1=function()
{
var tds=this.viewNode.getElementsByTagName("td");
var tdTypes=new Array('topLft','topRgt','botLft','botRgt');
for(i=0;i < tds.length;i++)
{
var node=tds[i];
for(j=0;j < tdTypes.length;j++)
{
if(node.className.indexOf(tdTypes[j]) >=0)
{
var divO=document.createElement("div");
var divI=document.createElement("div");
vg.html.addStyle("corner", divO);
vg.html.addStyle(tdTypes[j], divI);
divO.innerHTML=node.innerHTML;
node.innerHTML=""
divO.appendChild(divI);
node.appendChild(divO);
}
}
}
}
SelectTable.prototype.addListeners=function(items)
{
var controller=vg.comp.getController(this.viewNode.getAttribute('id'));
for(i=0;i < items.length;i++)
{
var node=items[i];
if(node.className!=null&&node.className.indexOf(PREFIX_BEHAVIOR) >=0)
{
vg.html.addEventListener(node, 'mouseenter', function(e){controller.mouseEnter(e)});
vg.html.addEventListener(node, 'mouseleave', function(e){controller.mouseLeave(e)});
}
}
}
SelectTable.prototype.countPreceding=function(parent, context, tag)
{
var count=0;
var nodes=parent.getElementsByTagName(tag);
for(var i=0;i < nodes.length;i++)
{
if(nodes[i]==context)
break;
count++;
}
return(count);
}
SelectTable.prototype.isValidColumn=function(node, currCol, col, keepheader)
{
if(node.tagName==null||node.className==null)
{
return;
}
if(node.tagName!='TD'&&(node.tagName=='TH'&&!keepheader))
return(false);
if(node.className.indexOf(PREFIX_BEHAVIOR) < 0)
return(false);
if(col >=0)
{
var colspan=node.getAttribute('colspan');
if(colspan!=null&&colspan!='1')
return(false);
if(currCol!=col)
return(false);
}
return(true);
}
SelectTable.prototype.extractRows=function(row, col, keepheader)
{
var nodes=new Array();
var colIndex=0;
var rowNodes=this.viewNode.getElementsByTagName('TR');
for(var i=0;i < rowNodes.length;i++)
{
if(row >=0&&i!=row)
{
continue;
}
var colNodes=rowNodes[i].childNodes;
var colCounter=1;
for(var j=0;j < colNodes.length;j++)
{
var node=colNodes[j];
if(this.isValidColumn(node,colCounter,col,keepheader))
{
nodes[nodes.length]=node;
}
if(node.tagName=='TD'||(node.tagName=='TH'&&keepheader))
{
colCounter++;
}
}
if(row >=0)
{
break;
}
}
return(nodes);
}
SelectTable.prototype.clearAll=function()
{
var nodes=this.viewNode.getElementsByTagName('TD');
vg.html.addOrRemoveStyleFromNodes('TableCell-sel',nodes,false);
var nodes=this.viewNode.getElementsByTagName('TH');
vg.html.addOrRemoveStyleFromNodes('TableHeadCell-sel',nodes,false);
}
SelectTable.prototype.findFirstSelectAllHeader=function()
{
var nodes=this.viewNode.getElementsByTagName('TH');
for(var i=0;i < nodes.length;i++)
{
var node=nodes[i];
if(node.className!=null&&node.className.indexOf(SELECT_ALL_BEHAVIOR) >=0)
{
return(node);
}
}
return(null);
}
SelectTable.prototype.addRoundedCorners=function()
{
var tds=this.viewNode.getElementsByTagName("td");
var tdTypes=new Array('topLft','topRgt','botLft','botRgt');
for(i=0;i < tds.length;i++)
{
var node=tds[i];
var cornerDivArray=new Array();
var divO=document.createElement("div");
vg.html.addStyle("nineBox", divO);
for(j=0;j < tdTypes.length;j++)
{
if(node.className.indexOf(tdTypes[j]) >=0)
{
var divI=document.createElement("div");
vg.html.addStyle(tdTypes[j]+"El", divI);
cornerDivArray.push(divI);
}
}
for(k=0;k < cornerDivArray.length;k++)
{
divO.appendChild(cornerDivArray[k]);
}
var span=document.createElement("span");
span.innerHTML=node.innerHTML;
node.innerHTML="";
divO.appendChild(span);
node.appendChild(divO);
}
}
SelectTable.prototype.methHighlightColumn=function(context,highlight)
{
var colPos=this.countPreceding(context.parentNode,context,context.tagName);
var nodes=this.extractRows(-1,colPos,false);
vg.html.addOrRemoveStyleFromNodes('TableCell-sel',nodes,highlight);
vg.html.addOrRemoveStyleFromNodes('TableHeadCell-sel',new Array(context),highlight);
}
SelectTable.prototype.methHighlightRow=function(context, highlight)
{
if(this.isHighlightRow)
{
var rowPos=this.countPreceding(this.viewNode,context.parentNode,'TR');
var nodes=this.extractRows(rowPos,-1,false);
vg.html.addOrRemoveStyleFromNodes('TableCell-sel',nodes,highlight);
}
vg.html.addOrRemoveStyleFromNodes('TableHeadCell-sel',new Array(context),highlight);
}
SelectTable.prototype.methHighlightAll=function(context, highlight)
{
var nodes=this.extractRows(-1,-1,false);
vg.html.addOrRemoveStyleFromNodes('TableCell-sel',nodes,highlight);
vg.html.addOrRemoveStyleFromNodes('TableHeadCell-sel',new Array(context),highlight);
}
SelectTable.prototype.methHighlightHeaders=function(context, highlight)
{
var rowPos=this.countPreceding(this.viewNode,context.parentNode,'TR');
var nodes=this.extractRows(rowPos,-1,true);
if(nodes[0]!=null&&nodes[0].className!=null&&nodes[0].className.indexOf(ROW_HEAD_BEHAVIOR) >=0)
{
vg.html.addOrRemoveStyleFromNodes('TableHeadCell-sel',new Array(nodes[0]),highlight);
}
var colspan=context.getAttribute('colspan');
if(colspan==null||colspan=='1')
{
var index=0;
var nodes=this.viewNode.getElementsByTagName('TH');
var found=false;
for(var i=0;i < nodes.length;i++)
{
if(nodes[i].className!=null&&nodes[i].className.indexOf(PREFIX_BEHAVIOR) >=0)
{
found=true;
break;
}
index++;
}
if(found)
{
var colPos=this.countPreceding(context.parentNode,context,context.tagName);
vg.html.addOrRemoveStyleFromNodes('TableHeadCell-sel',new Array(nodes[colPos+index+1]),highlight);
}
}
}
SelectTable.prototype.methHighlightCell=function(context, highlight)
{
vg.html.addOrRemoveStyleFromNodes('TableCell-sel',new Array(context),highlight);
}
SelectTable.prototype.behvSelectTableColHead=function(context, isEnter)
{
this.clearAll();
this.methHighlightColumn(context,isEnter);
}
SelectTable.prototype.behvSelectTableRowHead=function(context, isEnter)
{
this.clearAll();
this.methHighlightRow(context,isEnter);
}
SelectTable.prototype.behvSelectAll=function(context, isEnter)
{
this.clearAll();
this.methHighlightAll(context,isEnter);
}
SelectTable.prototype.behvSelectTableCell=function(context, isEnter)
{
this.clearAll();
this.methHighlightCell(context,isEnter);
this.methHighlightHeaders(context,isEnter);
}
SelectTable.prototype.dispatchEvent=function(evtNode, isEnter)
{
if(evtNode.className==null||evtNode.className==""||(evtNode.className.indexOf(PREFIX_BEHAVIOR) <0))
{
while(evtNode.nodeName!='TBODY'&&
(evtNode.className!=null&&evtNode.className.indexOf(PREFIX_BEHAVIOR) <0))
{
evtNode=evtNode.parentNode;
}
if(evtNode.className==null) return;
}
if(evtNode.className.indexOf(COL_HEAD_BEHAVIOR) >=0)
{
this.behvSelectTableColHead(evtNode,isEnter);
}
else if(evtNode.className.indexOf(ROW_HEAD_BEHAVIOR) >=0)
{
this.behvSelectTableRowHead(evtNode,isEnter);
}
else if(evtNode.className.indexOf(SELECT_ALL_BEHAVIOR) >=0)
{
this.behvSelectAll(evtNode,isEnter);
}
else if(evtNode.className.indexOf(DATA_CELL_BEHAVIOR) >=0)
{
this.behvSelectTableCell(evtNode,isEnter);
}
}
SelectTable.prototype.mouseEnter=function(e)
{
var evtNode=jsCBDgetEventNode(e);
this.dispatchEvent(evtNode,true);
}
SelectTable.prototype.mouseLeave=function(e)
{
var evt=jsCBDgetEvent(e);
var evtNode=jsCBDgetEventNode(e);
var toNode=evt.relatedTarget||evt.toElement;
while(!isEmpty(toNode)&&toNode!=evtNode&&toNode.nodeName!='BODY')
{
toNode=toNode.parentNode;
if(toNode==evtNode) return;
}
this.dispatchEvent(evtNode,false);
}
SelectTable.prototype.show=function(e)
{
var node=this.findFirstSelectAllHeader();
if(node!=null)
{
this.behvSelectAll(node,true);
}
}
vg.ageBand.HOVER='hover';
vg.ageBand.SELECTED='selected';
vg.ageBand.DEFAULT='default';
vg.ageBand.HIDE='ageBandHide';
vg.ageBand.allDefaultState=true;
vg.ageBand.inAgeBar=false;
vg.ageBand.selectedItem=null;
vg.ageBand.reset=function()
{
vg.ageBand.allDefaultState=true;
vg.ageBand.inAgeBar=false;
vg.ageBand.selectedItem=null;
}
vg.ageBand._mouseOver=function(obj, id)
{
if(vg.ageBand.allDefaultState)
{
vg.ageBand.inAgeBar=true;
vg.html.removeStyle(vg.ageBand.DEFAULT, obj);
vg.ageBand._itemHover(obj);
vg.ageBand._selectBand(id);
}
else
{
if(!vg.html.hasStyle(vg.ageBand.SELECTED, obj) )
{
vg.ageBand._itemHover(obj);
if(vg.ageBand.selectedItem)
{
vg.html.addStyle(vg.ageBand.HIDE, vg.ageBand.selectedItem);
}
}
}
}
vg.ageBand._mouseOut=function(obj, id)
{
if(vg.ageBand.allDefaultState)
{
vg.ageBand.inAgeBar=false;
vg.html.removeStyle(vg.ageBand.HOVER, obj);
vg.html.addStyle(vg.ageBand.DEFAULT, obj);
var items=vg.html.getElements(document.getElementById(id),{tagName:'div', attrName:'class', attrValue:''});
setTimeout(function()
{
if(!vg.ageBand.inAgeBar)
{
for(var i=0;i < items.length;i++)
{
items[i].className=vg.ageBand.DEFAULT;
}
}
}, 50 );
}
else
{
if(!vg.html.hasStyle(vg.ageBand.SELECTED, obj) )
{
vg.html.removeStyle(vg.ageBand.HOVER, obj);
if(vg.ageBand.selectedItem)
{
vg.html.removeStyle(vg.ageBand.HIDE, vg.ageBand.selectedItem);
}
}
}
}
vg.ageBand._onClick=function(obj, id, event)
{
var items=vg.html.getElements(document.getElementById(id),{tagName:'div', attrName:'class'}, function(node){return vg.html.hasStyle(vg.ageBand.SELECTED, node)});
for(var i=0;i < items.length;i++)
{
items[i].className="";
}
obj.className=vg.ageBand.SELECTED;
vg.ageBand.selectedItem=obj;
vg.ageBand._selectBand(id);
vg.ageBand.allDefaultState=false;
vg.cobrowse.recordEvent(jsCBDgetEvent(event), obj);
}
vg.ageBand._selectBand=function(id)
{
var items=vg.html.getElements(document.getElementById(id),{tagName:'div', attrName:'class', attrValue:vg.ageBand.DEFAULT});
for(var i=0;i < items.length;i++)
{
items[i].className="";
}
}
vg.ageBand._itemHover=function(obj)
{
vg.html.addStyle(vg.ageBand.HOVER, obj);
vg.ageBand._positionFloatingLabel(obj);
}
vg.ageBand._positionFloatingLabel=function(obj)
{
var floatingLabel=vg.html.getElements(obj,{tagName:'div', attrName:'class', attrValue:'floatLabel'})[0];
if(floatingLabel!=null&&!floatingLabel.isPositioned )
{
var container=vg.html.getSibling(floatingLabel,{tagName:'div', attrName:'class', attrValue:'container'}, "-");
var arrow=vg.html.getElements(container,{tagName:'div', attrName:'class', attrValue:'arrow'})[0];
var floatingLabelData=vg.html.getObjSizePosition(floatingLabel);
var arrowData=vg.html.getObjSizePosition(arrow);
var arrowCenter=arrowData.x+arrowData.w/2;
var leftLoc=arrowCenter - floatingLabelData.w/2
floatingLabel.style.left=leftLoc+"px";
floatingLabel.isPositioned=true;
}
}
Populator=function(cfg )
{
vg.util.attachJsonOptions(this, cfg );
var parent=document.getElementById(this.parentId);
parent.populator=this;
this.populatorLoaded=false;
if(this.execOnLoad&&!this.inline)
{
Populator._execute(parent);
}
}
Populator.exists=function(obj)
{
return obj.populator!=null;
}
Populator._copy=function(source, target)
{
target.populator=source.populator;
}
Populator._execute=function(obj, callBack)
{
if(Populator.exists(obj)&&(!jsCBDisPopulatorLoaded(obj)||obj.populator.type=='always'))
{
if(!obj.populator.inline)
{
var url=obj.populator.populatorUrl;
if(obj.populator.onLoad )
{
url=jsCBDaddQueryStringParam(url, 'cbdCallback', obj.populator.onLoad, false, false );
}
function _callback()
{
vg.html._fireCustomEvent(vg.event.DOM_CHANGE, obj );
if(callBack )
{
callBack.apply(window, arguments );
}
}
if(ie)
{
jsCBDloadContent(url, obj, 'replaceChildren', _callback );
}
else
{
vg.util.execOnPageReady
(
function()
{
jsCBDloadContent(url, obj, 'replaceChildren', _callback );
}
);
}
}
else
{
Populator._loadInlineContent(obj, callBack);
}
obj.populator.populatorLoaded=true;
}
}
Populator._loadInlineContent=function(obj, callBack)
{
var xmpTag=obj.getElementsByTagName("xmp");
_callback=callBack;
vg.util.execOnPageReady(function populatorLoad(){
jsCBDsetElementInnerHtml(obj, xmpTag[0].innerHTML, null);
if(callBack!=null)
{
setTimeout(function(){callBack()}, 50);
}
vg.html._fireCustomEvent(vg.event.DOM_CHANGE, obj );
});
}
Populator._remove=function(obj)
{
obj.populator=null;
}
cbdns.jsCBDisPopulatorLoaded=function(parentId)
{
var parent=vg.html.getElement(parentId);
if(Populator.exists(parent))
{
return parent.populator.populatorLoaded;
}
}
var SELECTED_TAB_CLASS="current";
var UNSELECTED_TAB_CLASS="unselected";
var SELECTED_TAB_ERR_CLASS="current-err";
var UNSELECTED_TAB_ERR_CLASS="unselected-err";
var DISABLED_TAB_CLASS="disabled";
TabBox=function(id)
{
this.base=vg.Controller;
this.base(id, null);
this.id=id;
var itemsWrapper=vg.html.getElements(this.viewNode,{tagName:'div', attrName:'id', attrValue:this.viewNode.getAttribute("id")+'_tabBoxItemContainer'})[0];
this.tabBoxItems=vg.html.getElements(itemsWrapper,{tagName:'div', maxDepth:1});
this.tabsDiv=vg.html.getElements(this.viewNode,{tagName:'div', attrName:'class', attrValue:'tabbox'})[0];
if(this.tabsDiv==null) this.tabsDiv=vg.html.getElements(this.viewNode,{tagName:'div', attrName:'class', attrValue:'int-tabbox'})[0];
this.isSubhead=false;
if(this.tabsDiv==null)
{
this.tabsDiv=vg.html.getElements(this.viewNode,{tagName:'div', attrName:'class', attrValue:'subhead'})[0];
if(this.tabsDiv==null) this.tabsDiv=vg.html.getElements(this.viewNode,{tagName:'div', attrName:'class', attrValue:'int-subhead'})[0];
if(this.tabsDiv!=null)
{
this.isSubhead=true;
this.parentItem=document.getElementById(this.id.substring(0, this.id.lastIndexOf(":")+1)+this.tabsDiv.getAttribute("parentitem"));
this.parentTabBox=document.getElementById(this.id.substring(0, this.id.lastIndexOf(":")));
}
}
var tabsList=vg.html.getElements(this.tabsDiv,{tagName:'ul'})[0];
this.tabs=vg.html.getElements(tabsList,{tagName:'li'});
}
TabBox.truthTable=vg.util.buildBooleanTable([
[[true,  true,  true], SELECTED_TAB_ERR_CLASS],
[[true,  true, false], SELECTED_TAB_ERR_CLASS],
[[true, false,  true], UNSELECTED_TAB_ERR_CLASS],
[[true, false, false], UNSELECTED_TAB_ERR_CLASS],
[[false,  true,  true], 'int-'+SELECTED_TAB_CLASS],
[[false,  true, false], SELECTED_TAB_CLASS],
[[false, false,  true], 'int-'+UNSELECTED_TAB_CLASS],
[[false, false, false], UNSELECTED_TAB_CLASS]
]);
TabBox.prototype=
{
_updateValidationObserverErrors:function(input, tabBoxItemNode, isError)
{
if(!tabBoxItemNode.errorInputs)
{
tabBoxItemNode.errorInputs=new Array();
}
var inputId=input.getAttribute("id");
var errorInputIdx=-1;
for(var i=0;i < tabBoxItemNode.errorInputs.length&&(errorInputIdx < 0);i++)
{
if(inputId==tabBoxItemNode.errorInputs[i])
{
errorInputIdx=i;
}
}
var foundInArray=errorInputIdx >=0;
if(isError&&!foundInArray )
{
tabBoxItemNode.errorInputs[tabBoxItemNode.errorInputs.length]=inputId;
}
else if(!isError&&foundInArray )
{
tabBoxItemNode.errorInputs.splice(errorInputIdx, 1);
}
},
_triggerValidationObserver:function(tabBoxItemNode)
{
var tabIndex, parentTabIndex, parentTab;
for(var i=0;i < this.tabBoxItems.length&&!tabIndex;i++)
{
if(this.tabBoxItems[i]==tabBoxItemNode)
{
tabIndex=i;
}
}
if(this.isSubhead)
{
tabIndex*=2;
var parentController=vg.comp.getController(this.parentTabBox);
for(var i=0;i < parentController.tabBoxItems.length&&!parentTabIndex;i++)
{
if(parentController.tabBoxItems[i]==this.parentItem)
{
parentTabIndex=i;
}
}
}
var tab=this.tabs[tabIndex];
if(parentTabIndex!=undefined)
{
parentTab=parentController.tabs[parentTabIndex];
}
var errorInputsLength=tabBoxItemNode.errorInputs?tabBoxItemNode.errorInputs.length:0;
var hasErrors=errorInputsLength > 0;
var isSelected=tab.getAttribute('mode' )=='selected'||tab.getAttribute('mode' )=='current';
var isDisabled=tab.getAttribute('mode' )=='disabled';
if(isDisabled)
{
tab.className=DISABLED_TAB_CLASS;
}
else
{
tab.className=this._setTabStyles(tabBoxItemNode, isSelected);
}
if(parentTab)
{
isSelected=parentTab.getAttribute('mode' )=='selected'||parentTab.getAttribute('mode' )=='current';
isDisabled=parentTab.getAttribute('mode' )=='disabled';
this.parentItem.errorInputs=new Array();
for(var i=0;i < this.tabBoxItems.length;i++)
{
var itemErrorInputs=this.tabBoxItems[i].errorInputs;
if(itemErrorInputs&&itemErrorInputs.length > 0)
{
this.parentItem.errorInputs=this.parentItem.errorInputs.concat(itemErrorInputs)
};
}
if(isDisabled)
{
parentTab.className=DISABLED_TAB_CLASS;
}
else
{
parentTab.className=this._setTabStyles(this.parentItem, isSelected);
}
}
},
_setTabStyles:function(tabBoxItemNode, isSelected)
{
var errorInputsLength=tabBoxItemNode.errorInputs?tabBoxItemNode.errorInputs.length:0;
var hasErrors=errorInputsLength > 0;
var style=null;
return vg.util.getBooleanTableValue(TabBox.truthTable,
[hasErrors, isSelected, tabBoxItemNode.getAttribute('internal' )=='true']);
},
_getSelectedTabIndex:function()
{
for(var i=0;i < this.tabs.length;i++)
{
if(this.tabs[i].getAttribute('mode' )=='current' ) return i;
}
return null;
},
_setTabDivBorder:function(selectedIndex)
{
var tab=this.tabBoxItems[selectedIndex];
var isInternal=tab.getAttribute('internal' )=='true';
if(!this.isSubhead)
{
if(isInternal)
{
vg.html.replaceClass(this.tabsDiv, this.tabsDiv.className, "int-tabbox");
}
else
{
vg.html.replaceClass(this.tabsDiv, this.tabsDiv.className, "tabbox");
}
}
}
}
RoundBox=function(id, fromColor, toColor)
{
this.base=vg.Controller;
this.base(id, null, true);
this.id=id;
this.inState=false;
this.fromColor=fromColor;
this.toColor=toColor;
this.HTMLElement=vg.html.getElement(this.id).getElementsByTagName('table')[0];
var controller=this;
this.mouseManager=new vg.MouseManager(
{
element:document.getElementById(this.id),
onMouseEnter:function(){controller.enterRoundBox()},
onMouseLeave:function(){controller.leaveRoundBox()}
}
);
vg.html.addEventListener(this.viewNode, 'click', function(e){controller.clickRoundBox(e)});
}
RoundBox.prototype=
{
clickRoundBox:function(e)
{
if(this.inState==false&&
jsCBDgetEventNode(e).tagName.toLowerCase()!='a'&&
jsCBDgetEventNode(e).tagName.toLowerCase()!='select'&&
jsCBDgetEventNode(e).tagName.toLowerCase()!='input')
{
eval(this.viewNode.getAttribute('clickJs'));
}
},
enterRoundBox:function()
{
vg.smil.animateElement(this.HTMLElement, 'backgroundColor', 200, 0, null, this.toColor, null, null, null, true);
},
leaveRoundBox:function()
{
vg.smil.animateElement(this.HTMLElement, 'backgroundColor', 200, 0, null, this.fromColor, null, null, null, true);
}
}
var DISABLE_DIV_CONTAINER="CBD_DISABLE_DIV_CONTAINER";
DisableModalDiv=function(coveredEl,opac,layerId,layerDelay,layerResize,waitCursor)
{
this.base=vg.Controller;
this.base(coveredEl, null);
this.coveredEl=vg.html.getElement(coveredEl);
this.coveredEl.hasCover=true;
this.layer=null;
this.minWidthDiv=null;
this.disDiv=(this.disDiv)?this.disDiv:this.createDisableModalDiv(this.coveredEl);
this.coveredEl.disDivController=this;
this.openDisableModalDiv(opac,layerId,layerDelay,layerResize,waitCursor);
}
DisableModalDiv.prototype=
{
createDisableModalDiv:function()
{
if(document.getElementById(DISABLE_DIV_CONTAINER))
{
var disDivCont=document.getElementById(DISABLE_DIV_CONTAINER);
}
else
{
var disDivCont=document.createElement('div');
disDivCont.setAttribute("id",DISABLE_DIV_CONTAINER);
document.getElementById('main').appendChild(disDivCont);
}
var disDiv=document.createElement('div');
disDiv.triggerEl=this.coveredEl;
disDiv.style.display="none";
disDiv.style.zIndex="120";
disDiv.style.background="#FFFFFF";
disDiv.style.position="absolute";
var spanNode=vg.html.findAncestor(this.coveredEl,{tagName:"span", attrName:"type", attrValue:"Layer"});
if(spanNode)
{
var layerDivNode=vg.html.getElements(spanNode,{tagName:'div'})[0];
var roundBoxDivLayer=vg.html.getElements(layerDivNode,{tagName:'div', attrName:'class', attrValue:'roundBoxScrollDiv layer'})[0];
if(!roundBoxDivLayer)
{
var roundBoxDivHLayer=vg.html.getElements(layerDivNode,{tagName:'div', attrName:'class', attrValue:'hl-roundBoxScrollDiv hl-layer'})[0];
}
var minWidthDiv=vg.html.getElements(layerDivNode,{tagName:'div', attrName:'name', attrValue:'min-width'})[0];
if(minWidthDiv)
{
var minWidthDivParent=minWidthDiv.parentNode;
if(roundBoxDivLayer&&minWidthDivParent!=roundBoxDivLayer)
{
roundBoxDivLayer.appendChild(minWidthDiv);
}
else if(roundBoxDivHLayer&&minWidthDivParent!=roundBoxDivHLayer)
{
roundBoxDivHLayer.appendChild(minWidthDiv);
}
}
if(roundBoxDivLayer)
{
roundBoxDivLayer.appendChild(disDiv );
}
else if(roundBoxDivHLayer)
{
roundBoxDivHLayer.appendChild(disDiv );
}
}
else
{
disDivCont.appendChild(disDiv );
}
if(!disDivCont.divArray )
{
disDivCont.divArray=new Array();
}
if(!disDivCont.divArray[disDiv])
{
disDivCont.divArray.push(disDiv);
}
this.disDiv=disDiv;
this.layer=layerDivNode;
this.minWidthDiv=minWidthDiv;
return disDiv;
},
openDisableModalDiv:function(opac,layerId,layerDelay,layerResize,waitCursor)
{
this.disDiv.pos=this.positionSizeDisableModalDiv(this.coveredEl);
this.setDisDivOpacity(opac);
if(ie&&CBD_FLOATING_HEAD)
{
this.coveredEl.setAttribute('covered','true');
vg.html._fireCustomEvent(vg.event.ELEMENT_DISABLED, this.coveredEl );
}
waitCursor=(waitCursor!=null)?waitCursor:true;
if(waitCursor)
this.disDiv.style.cursor="wait";
jsCBDtoggleElement(this.disDiv, true);
if(this.layer&&this.minWidthDiv)
{
if(ie)
{
var offsetObj=this.coveredEl;
var topOffset=0;
var leftOffset=0;
while(offsetObj&&offsetObj!=this.disDiv.parentNode)
{
topOffset+=offsetObj.offsetTop;
leftOffset+=offsetObj.offsetLeft;
offsetObj=offsetObj.offsetParent;
}
this.disDiv.style.left=leftOffset+"px";
this.disDiv.style.top=topOffset+"px";
this.disDiv.style.position="absolute";
}
else
{
this.disDiv.style.left=this.coveredEl.offsetLeft - this.minWidthDiv.offsetLeft+"px";
this.disDiv.style.top=this.coveredEl.offsetTop - this.minWidthDiv.offsetTop - 1+"px";
this.disDiv.style.position="relative";
}
vg.html.setWidth(this.disDiv,this.coveredEl.pos.w+2+"px");
vg.html.setHeight(this.disDiv,this.coveredEl.pos.h+2+"px");
}
if(layerId!=null)
{
this.layerId=layerId;
this.layerDelay=(layerDelay!=null)?layerDelay:"5";
this.layerResize=(layerResize!=null)?layerResize:true;
this.layerState=true;
this.waitCursor=waitCursor;
this.positionSizeDisableLayer();
this.openDisableLayer();
}
},
setDisDivOpacity:function(opac)
{
this.opac=(opac==null)?".75":opac;
vg.html.setOpacity(this.disDiv,this.opac);
},
positionSizeDisableModalDiv:function()
{
var layerDiv=this.layer;
var pos=vg.html.getObjSizePosition(this.coveredEl, layerDiv);
this.coveredEl.pos=pos;
var disDiv=this.disDiv;
if(!layerDiv&&disDiv )
{
disDiv.style.left=pos.x -1+"px";
disDiv.style.top=pos.y - 1+"px";
vg.html.setWidth(disDiv,pos.w+2+"px");
vg.html.setHeight(disDiv,pos.h+2+"px");
}
return pos;
},
positionSizeDisableLayer:function()
{
var layer=vg.comp.getController(document.getElementById(this.layerId));
var disDiv=this.disDiv;
var coveredEl=this.coveredEl;
if(this.layerResize)
{
var w,h
h=.5*disDiv.pos.h;
h=(h > "200")?"200":(h < "150")?"150":h;
w=2*h;
w=(w > "400")?"400":(w < "300")?"300":(w > .8*disDiv.pos.w)?.8*disDiv.pos.w:w;
layer.width=w+"px";
layer.height=h+"px";
layer.positionLeft=disDiv.pos.x+(disDiv.pos.w-w)/2;
layer.resize();
}
layer.reposition();
layer.roundBox.style.width="100%";
if(this.waitCursor)
layer.roundBox.style.cursor="wait";
},
openDisableLayer:function()
{
var controller=this;
this.t=setTimeout(function()
{
if(controller.layerState)
{
jsCBDopenLayer(controller.layerId);
}
}, parseFloat(controller.layerDelay)*1000 );
}
}
_cbdGlobalObjects=new Array("cbd","vg", "chatPopup", "errCount", "pageLevelErrors", "allValidators", "_flashCharts", "flyoutArray", "FOCArray","Deck","DeckItem","RolloverMenu","RolloverMenuItem","SideTab","SideTabItem","CheckBox","InfoBox","RadioButton","NineBoxFilter","NavDeck","FlyoutContainer","AutoSuggest","SelectList","SelectTable","Populator","TabBox","RoundBox","DisableModalDiv","SelectOneMenu", "_cbdLooseFuncs");
if(!window._cbdNamespaceBackup )
{
_cbdNamespaceBackup={};
}
vg.util.loadJSIntoNS=function(load)
{
var _isJSfunctionsLoaded=function()
{
return(window.jsfunctionsLoaded);
}
var _cbdLoadLoader=function()
{
window.basePageLoaded=true;
jsCBDloadScript(load.server+window.loaderWebContextRoot+'/javascript/loader.js' );
_cbdCheckConditionsAndExecute(_isCBDLoaderDefined, _cbdLoadCoreFiles);
}
var _cbdLoadCoreFiles=function()
{
cbd.loader.require("RIA");
cbd.loader.require('AJAX');
cbd.loader.require('VG');
cbd.loader.require('FORMCHECK');
if(load.jsFiles)
{
var length=load.jsFiles.length;
for(var index=0;index < length;index++)
{
cbd.loader.addModule({
name:load.jsFiles[index],
type:'js',
fullpath:load.server+window.loaderWebContextRoot+load.jsFiles[index]
});
cbd.loader.require(load.jsFiles[index]);
}
}
cbd.loader.addCallback(function(){vg.util.execFunc(load.callback)});
cbd.loader.load();
}
var _cbdloadJSIntoNS=function(){
if(!(load.server)||(load.server==null))
{
load.server="";
}
_cbdSaveOriginalNamespace();
if(load.contextRoot!=null)
{
_cbdContextRoot=load.contextRoot;
}
window.jsfunctionsLoaded=false;
window.loaderWebBase=load.server;
if(load.webContextRoot)
{
window.loaderWebContextRoot=load.webContextRoot;
}
else
{
window.loaderWebContextRoot='/web'
}
jsCBDloadScript(load.server+window.loaderWebContextRoot+'/javascript/jsfunctions.js');
_cbdCheckConditionsAndExecute(_isJSfunctionsLoaded,_cbdLoadLoader);
}
_cbdCheckConditionsAndExecute(_cbdAreDelayedEventsFinished, _cbdloadJSIntoNS)
}
cbdns._cbdSaveOriginalNamespace=function()
{
for(var prop in window)
{
if(prop.indexOf('jsCBD')==0||prop.indexOf('_cbd')==0)
{
_cbdNamespaceBackup[prop]=window[prop];
}
}
for(i=0;i < _cbdGlobalObjects.length;i++)
{
_cbdNamespaceBackup[_cbdGlobalObjects[i]]=window[_cbdGlobalObjects[i]];
if(window[_cbdGlobalObjects[i]]instanceof Array)
{
window[_cbdGlobalObjects[i]]=new Array();
}
else
{
window[_cbdGlobalObjects[i]]=null;
}
}
}
vg.util.Map=function()
{
this.objArray=new Array();
}
vg.util.Map.prototype=
{
put:function(key, val)
{
this.objArray[key]=val;
},
get:function(key)
{
return this.objArray[key];
}
}
vg.util.restoreOriginalNS=function(func)
{
var _restore=function()
{
vg.html._cbdCopyProperties(_cbdNamespaceBackup._cbdLooseFuncs, window);
vg.html._cbdCopyProperties(_cbdNamespaceBackup, window);
vg.util.execFunc(func);
}
_cbdCheckConditionsAndExecute(_cbdAreDelayedEventsFinished, _restore)
}
vg.html._cbdCopyProperties=function(sourceNode, destinationNode)
{
for(var prop in sourceNode)
{
destinationNode[prop]=sourceNode[prop];
}
}
vg.html._cbdGetCSSContainer=function(targetNode)
{
return cssContainer=vg.html.findAncestor(targetNode,{},
function(node)
{
return vg.html.hasStyle("vg0", node)||vg.html.hasStyle("vg1", node);
}
);
}
vg.cobrowse._cbdSetFilter=function(events, pollrate, play, record, parameters){
if(events.events!=null){
events=events.events;
pollrate=events.pollrate;
play=events.play;
record=events.record;
parameters=events.parameters;
}
vg.cobrowse.event=events;
if(pollrate!=null){
VG.conf.pollrate=pollrate;
BBLive.conf.recorder.flushBuffer=pollrate;
}
if(play!=null){
vg.cobrowse.play=play;
}
if(record!=null){
vg.cobrowse.record=record;
}
if(parameters!=null){
vg.cobrowse.parameters=parameters;
}
}
vg.cobrowse._cbdSetFilterOptions=function(){
var all=true;
var events='';
for(var i=0;i < document.dbg_tab5.events.length;i++)
{
if(document.dbg_tab5.events[i].checked)
{
if(events!='') events+=",";
events+=document.dbg_tab5.events[i].value;
}
else
{
all=false;
}
}
if(all) events='*'
var play=document.dbg_tab5.eventType[0].checked
var record=document.dbg_tab5.eventType[1].checked
var parameters=document.dbg_tab5.eventType[2].checked
var pollrate=document.getElementById('Pollrate').value;
vg.cobrowse._cbdSetFilter(events,pollrate,play, record, parameters);
}
vg.cobrowse._cbdIsEventFiltered=function(event){
var isEventFiltered=false;
var events=vg.cobrowse.event;
if(events=="*")
{
isEventFiltered=true;
}
else
{
if(events.indexOf(event)>-1)
{
isEventFiltered=true;
}
}
return isEventFiltered;
}
vg.cobrowse._cbdDisableFilter=function(){
vg.cobrowse.capture=false;
vg.cobrowse.event="*";
vg.cobrowse.pollrate=300;
vg.cobrowse.play=true;
vg.cobrowse.record=true;
}
vg.cobrowse._cbdEnableFilter=function(){
vg.cobrowse.capture=true;
}
HeightSyncCallout=function(tbId,clId)
{
this.base=vg.Controller;
this.tabbox=vg.html.getElement(tbId);
this.callout=vg.html.getElement(clId);
this.tabDiv=this.tabbox.getElementsByTagName('div')[0];
this.roundBox=this.tabbox.getElementsByTagName('table')[0];
this.scrollDiv=vg.html.getElements(this.roundBox,{tagName:'div', attrName:'class', attrValue:'roundBoxScrollDiv'})[0];
var controller=this;
vg.html.addEventListener(this.tabbox, 'click', function(e){controller.adjustHeight(e)});
vg.html.addEventListener(null, vg.event.GEO_CHANGE, function(e, args){controller.adjustHeight(e,args)});
vg.html.addEventListener(null, vg.event.DOM_CHANGE, function(e, args){controller.adjustHeight(e,args)});
vg.html.addEventListener(window, 'resize', function(e, args){controller.adjustHeight(e,args);});
this.adjustHeight();
}
HeightSyncCallout.prototype=
{
adjustHeight:function()
{
vg.html.setHeight(this.roundBox,(ie)?"100%":"auto");
vg.html.setHeight(this.scrollDiv,(ie)?"":"auto");
vg.html.setHeight(this.callout,(ie)?"100%":"auto");
var tabboxHeight=vg.html.getObjHeight(this.tabbox);
var tabDivHeight=vg.html.getObjHeight(this.tabDiv);
var scrollDivHeight=vg.html.getObjHeight(this.scrollDiv.parentNode);
var calloutHeight=vg.html.getObjHeight(this.callout);
if(tabboxHeight > calloutHeight )
{
vg.html.setHeight(this.callout,tabboxHeight+"px")
}
else
{
vg.html.setHeight(this.scrollDiv,calloutHeight-tabDivHeight+"px");
}
}
}
LinkBar=function(id,isAjaxRequest,allSelected)
{
this.base=vg.Controller;
this.base(id, null);
this.id=id;
this.items=new Array();
this.allSelected=allSelected;
this.selectedIndex=parseInt(this.viewNode.getAttribute('selecteditem'));
var controller=this;
if(!isAjaxRequest) vg.util.execOnPageReady(function(){controller.initLinkBar()});
}
LinkBar.prototype=
{
initLinkBar:function()
{
var selectedNode=this.items[this.selectedIndex];
if(!this.allSelected)
{
var link=selectedNode.viewNode;
link.setAttribute('orig_onclick', link.getAttribute("onclick"));
link.setAttribute('onclick', null);
}
},
configLinkBar:function(selectedNode)
{
for(var i=0;i < this.items.length;i++)
{
jsCBDtoggleLink(this.items[i].viewNode, true, "current");
this.items[i].selected=false;
}
if(!this.allSelected)
{
jsCBDtoggleLink({link:this.items[selectedNode.index].viewNode, state:false, disabledClass:"current", suppressDisableAttr:true});
}
selectedNode.selected=true;
this.selectedIndex=selectedNode.index;
this.viewNode.setAttribute('selecteditem',selectedNode.index);
cbd.StateKeeper._setState(this.id, String(this.selectedIndex), true);
},
addItem:function(controller)
{
var length=this.items.length;
this.items[length]=controller;
controller.index=length;
}
}
LinkBarItem=function(id,selectItemOnClick)
{
this.base=vg.Controller;
this.base(id, null, true);
this.id=id;
this.selected=false;
this.selectItemOnClick=selectItemOnClick;
var controller=this;
vg.html.addEventListener(this.viewNode, 'click', function(e){controller.selectLinkItem(e)});
this.parentController=vg.comp.findController(this.viewNode, true);
this.parentController.addItem(this);
}
LinkBarItem.prototype=
{
selectLinkItem:function(e)
{
if(this.selectItemOnClick&&!this.selected)
{
this.parentController.configLinkBar(this);
}
var webUsageJS=this.viewNode.getAttribute('webUsageJs');
if(webUsageJS!=null)
{
eval(webUsageJS);
}
}
}
var mBarMap=new vg.util.Map();
vg.comp.Mbar=function(cfg)
{
vg.util.attachJsonOptions(this, cfg);
this.base=vg.Controller;
var THIS=this;
this.base(THIS.id, null);
this.menuBar=null;
this.menuItemCobrowseDelay=null;
var initGH_menus=function()
{
var menuBar=new YAHOO.widget.MenuBar(THIS.id,{lazyload:THIS.lazyload, showdelay:THIS.showdelay, autosubmenudisplay:THIS.autosubmenudisplay});
menuBar.render();
mBarMap.put(THIS.id, menuBar);
if(ie6_proper)
{
var subMenus=menuBar.getSubmenus();
for(var i=0;i < subMenus.length;i++)
{
var subMenu=subMenus[i];
subMenu.show();
subMenu.hide();
}
if(!THIS.globalHeader&&!THIS.autosubmenudisplay)
{
menuBar._bStopMouseEventHandlers=true;
}
}
if(THIS.globalHeader)
{
THIS.menuBar=menuBar;
THIS._setShowEvent();
THIS._controlTabKey();
THIS._controlSubMenuClose();
}
};
if(RIA)
{
vg.util.execOnPageReady(initGH_menus);
}
else
{
vg.util.execOnPageReady(
function(){setTimeout(initGH_menus, 100);}
);
}
}
vg.comp.Mbar.prototype=
{
_controlTabKey:function()
{
var items=this.menuBar.getItems();
var THIS=this;
for(var i=0;i < items.length;i++)
{
var item=items[i];
item.subscribe("focus", function(type, args)
{
if(THIS.menuBar.openedMenu!=null&&THIS.menuBar.openedMenu._oSubmenu)
{
THIS.menuBar.openedMenu._oSubmenu.hide();
}
THIS.menuBar.openedMenu=this;
this._oSubmenu.show();
});
}
var lastItem=items[items.length - 1];
if(lastItem!=null&&lastItem._oSubmenu)
{
var subMenuItems=lastItem._oSubmenu.getItems();
var lastSubMenuItem=subMenuItems[subMenuItems.length - 1];
lastSubMenuItem.subscribe("blur", function(type, args)
{
THIS.menuBar.openedMenu._oSubmenu.hide();
});
}
},
_controlSubMenuClose:function()
{
var items=this.menuBar.getItems();
for(var i=0;i < items.length;i++)
{
var item=items[i];
item.mouseManager=new vg.MouseManager(
{
item:item,
menuBar:this.menuBar,
element:document.getElementById(item.id),
onMouseEnter:function(e){vg.comp.Mbar.mouseEnter(this.menuBar, e)},
onMouseLeave:function(e){vg.comp.Mbar.mouseLeave(this.menuBar, e, this.item)}
});
}
},
_setShowEvent:function()
{
var THIS=this;
THIS.menuBar.subscribe("show", function(type, args)
{
THIS.activeMenu=THIS.menuBar.activeItem._oSubmenu;
vg.html.addStyle('yuimenubaritem-selected', THIS.menuBar.activeItem.element);
var yPos=THIS.activeMenu.cfg.getProperty("y");
THIS.activeMenu.cfg.setProperty("y", yPos - 1);
if(THIS.menuBar.activeItem.element.getAttribute("id")!="gh-current")
{
var xPos=THIS.activeMenu.cfg.getProperty("x");
THIS.activeMenu.cfg.setProperty("x", xPos - 1);
}
var link=THIS.menuBar.activeItem._oAnchor;
var event=new Object();
event.isRiaEvent=true;
vg.cobrowse.recordEvent(event, link, 'show');
clearTimeout(THIS.menuBar.delayTimer);
THIS.menuBar.cfg.setProperty("showdelay", 0);
if(!THIS.activeMenu.cobrowseItemsListenersSet&&vg.cobrowse.isCobrowseActive())
{
THIS.activeMenu.cobrowseItemsListenersSet=true;
THIS._addMenuItemsCobrowseEventListeners();
}
});
THIS.menuBar.subscribe("hide", function(type, args)
{
var link=THIS.menuBar.activeItem._oAnchor;
var event=new Object();
event.isRiaEvent=true;
vg.cobrowse.recordEvent(event, link, 'hide');
THIS.menuBar.delayTimer=vg.util.setTimeout(function(){THIS.menuBar.cfg.setProperty("showdelay", 250);}, 100);
});
},
_addMenuItemsCobrowseEventListeners:function()
{
var THIS=this;
var activeMenuItems=THIS.activeMenu.getItems();
for(var i=0;i < activeMenuItems.length;i++)
{
vg.html.addEventListener(activeMenuItems[i].element, 'mouseover',
function(e){
var e=jsCBDgetEvent(e)
var eventCopy=new Object();
vg.html._cbdCopyProperties(e, eventCopy)
var eNode=jsCBDgetEventNode(e);
THIS.menuItemCobrowseDelay=vg.util.setTimeout(
function(){
THIS.menuItemCobrowseDelay=null;
vg.cobrowse.recordEvent(eventCopy, eNode, 'mouseover', null, false);
}, 200);
}
);
vg.html.addEventListener(activeMenuItems[i].element, 'mouseleave',
function(e){
if(THIS.menuItemCobrowseDelay!=null)
{
clearTimeout(THIS.menuItemCobrowseDelay);
}
else
{
vg.cobrowse.recordEvent(e, jsCBDgetEventNode(e), 'mouseleave', null, false);
}
}
);
}
},
_handleCobrowseEvent:function(eventName, node, value)
{
if(eventName=="mouseover")
{
vg.comp.Mbar.highlight(node);
}
else if(eventName=="mouseleave")
{
vg.comp.Mbar.mouseleave(node);
}
else
{
var items=this.menuBar.getItems();
var THIS=this;
for(var i=0;i < items.length;i++)
{
var item=items[i];
if(item._oAnchor.id==node.id)
{
if(eventName=="show")
{
item._oSubmenu.show();
}
else
{
item._oSubmenu.hide();
}
}
}
}
}
}
vg.comp.Mbar.mouseEnter=function(menuBar, e)
{
clearTimeout(menuBar.hideTimer);
}
vg.comp.Mbar.mouseLeave=function(menuBar, e, item)
{
if(menuBar.activeItem==null)
{
return;
}
var activeMenu=menuBar.activeItem._oSubmenu;
if(activeMenu!=null)
{
var menuPos=vg.html.getObjSizePosition(activeMenu.body);
var mouse=vg.util.getMousePos(e);
var endOfMenuOnX=menuPos.x+menuPos.w;
var endOfMenuOnY=menuPos.y+menuPos.h;
var endOfExtentionAreaY=endOfMenuOnY+50;
var inXExtArea=(menuPos.x < mouse.x)&&(mouse.x < endOfMenuOnX);
var inYExtArea=(endOfMenuOnY < mouse.y)&&(mouse.y < endOfExtentionAreaY);
if(inXExtArea&&inYExtArea)
{
menuBar.hideTimer=vg.util.setTimeout(function(){vg.comp.Mbar.close(item);}, 500);
}
else
{
vg.comp.Mbar.close(item);
}
}
}
vg.comp.Mbar.close=function(item)
{
if(item._oSubmenu!=null)
{
item._oSubmenu.hide();
vg.html.removeStyle('yuimenubaritem-selected', item.element);
}
}
vg.comp.Mbar.highlight=function(item)
{
if(item.tagName.toLowerCase()=='a')
{
vg.html.addStyle('yuimenuitemlabel-hover', item);
}
else
{
vg.html.addStyle('yuimenuitemlabel-hover', vg.html.getFirstChild(item));
}
}
vg.comp.Mbar.mouseleave=function(item)
{
if(item.tagName.toLowerCase()=='a')
{
vg.html.replaceClass(item, 'yuimenuitemlabel-hover', 'yuimenuitemlabel');
}
else
{
vg.html.replaceClass(vg.html.getFirstChild(item), 'yuimenuitemlabel-hover', 'yuimenuitemlabel');
}
}
vg._removeFilter=function(fBarId, fId, onremove)
{
var fBarInput=document.getElementById(fBarId+"_x");
fBarInput.value=fId;
if(onremove!=null)
{
onremove(fBarId, fId);
}
}

