                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                if(!window.__td){window.__MT=100;window.__ti=0;window.__td=[];window.__td.length=__MT;window.__noTrace=false;

}




if(typeof vp=="undefined"){
var vp={};
}






vp.core=function core(){if(!window.__noTrace){__td[__ti]=arguments;__ti=__ti>=__MT?0:__ti+1;}};






vp.core.isArray=function core_isArray(v)
{if(!window.__noTrace){__td[__ti]=arguments;__ti=__ti>=__MT?0:__ti+1;}
return v&&typeof v=="object"&&v.constructor==Array;
};








vp.core.applyProperties=function core_applyProperties(oObj1,oObj2,aProps)
{if(!window.__noTrace){__td[__ti]=arguments;__ti=__ti>=__MT?0:__ti+1;}
if(aProps)
{
for(var i=0;i<aProps.length;i++)
{
oObj2[aProps[i]]=oObj1[aProps[i]];
}
}
else
{
for(var sProp in oObj1)
{
oObj2[sProp]=oObj1[sProp];
}
}
};








vp.core.getNestedProperty=function core_getNestedProperty(oObj,sProp)
{if(!window.__noTrace){__td[__ti]=arguments;__ti=__ti>=__MT?0:__ti+1;}
var sNestedProp=sProp;
var oNestedTarget=oObj;
var iDotPos=sNestedProp.indexOf(".");

while(iDotPos>=0)
{
var sCurrentProp=sNestedProp.substr(0,iDotPos);
sNestedProp=sNestedProp.substr(iDotPos+1);

if(!oNestedTarget[sCurrentProp])
{
return undefined;
}
oNestedTarget=oNestedTarget[sCurrentProp];

iDotPos=sNestedProp.indexOf(".");
}

return oNestedTarget[sNestedProp];
};









vp.core.setNestedProperty=function core_setNestedProperty(oObj,sProp,vValue)
{if(!window.__noTrace){__td[__ti]=arguments;__ti=__ti>=__MT?0:__ti+1;}
var sNestedProp=sProp;
var oNestedTarget=oObj;
var iDotPos=sNestedProp.indexOf(".");

while(iDotPos>=0)
{
var sCurrentProp=sNestedProp.substr(0,iDotPos);
sNestedProp=sNestedProp.substr(iDotPos+1);

if(!oNestedTarget[sCurrentProp])
{
throw new Error("The property "+sCurrentProp+" could not be found in "+sProp);
}

oNestedTarget=oNestedTarget[sCurrentProp];

iDotPos=sNestedProp.indexOf(".");
}

oNestedTarget[sNestedProp]=vValue;
};








vp.core.applyPropertyMap=function core_applyPropertyMap(oTarget,oMap)
{if(!window.__noTrace){__td[__ti]=arguments;__ti=__ti>=__MT?0:__ti+1;}
for(var sProp in oMap)
{
vp.core.setNestedProperty(oTarget,sProp,oMap[sProp]);
}
};






vp.core.shallowCopy=function core_shallowCopy(oObj)
{if(!window.__noTrace){__td[__ti]=arguments;__ti=__ti>=__MT?0:__ti+1;}
var oNew={};
for(var sProp in oObj)
{
oNew[sProp]=oObj[sProp];
}
return oNew;
};







vp.core.shallowIsEqual=function core_shallowIsEqual(oObj1,oObj2)
{if(!window.__noTrace){__td[__ti]=arguments;__ti=__ti>=__MT?0:__ti+1;}
var sProp;
var iObj2PropCount=0;
var iObj1PropCount=0;
for(sProp in oObj2)
{
iObj2PropCount++;
}

for(sProp in oObj1)
{
iObj1PropCount++;
if(typeof(oObj2[sProp])=="undefined")
{
return false;
}
else if(oObj2[sProp]!==oObj1[sProp])
{
return false;
}
}

if(iObj1PropCount!=iObj2PropCount)
{
return false;
}

return true;
};







vp.core.initProperty=function core_initProperty(oObject,sPropertyName,vValue)
{if(!window.__noTrace){__td[__ti]=arguments;__ti=__ti>=__MT?0:__ti+1;}
if(typeof(oObject[sPropertyName])=="undefined")
{
oObject[sPropertyName]=vValue;
}
};






vp.core.requireArg=function core_requireArg(sName,vValue)
{if(!window.__noTrace){__td[__ti]=arguments;__ti=__ti>=__MT?0:__ti+1;}
if(typeof(vValue)=="undefined")
{
throw new Error("The argument '"+sName+"' is required.");
}

return vValue;
};







vp.core.getBoolean=function core_getBoolean(v,bDefault)
{if(!window.__noTrace){__td[__ti]=arguments;__ti=__ti>=__MT?0:__ti+1;}
if(typeof(bDefault)=="undefined")
{
bDefault=false;
}

if(typeof(v)=="boolean")
{
return v;
}

if(!v)
{
return bDefault;
}

switch(v.toString().toLowerCase())
{
case"yes":
case"true":
case"ok":
case"1":
return true;
default:
return false;
}
};







vp.core.getNumber=function core_getNumber(v,nDefault)
{if(!window.__noTrace){__td[__ti]=arguments;__ti=__ti>=__MT?0:__ti+1;}
if(typeof(nDefault)=="undefined")
{
nDefault=0;
}

if(typeof(v)=="boolean")
{
return v?1:0;
}
else if(typeof(v)=="undefined"||v===null||v==="")
{
return nDefault;
}

var nNum=new Number(v);

if(!isNaN(nNum.valueOf()))
{
return nNum.valueOf();
}
else
{
return nDefault;
}
};








vp.core.setObjectReference=function core_setObjectReference(oObj,oRef,sName)
{if(!window.__noTrace){__td[__ti]=arguments;__ti=__ti>=__MT?0:__ti+1;}

if(!window.__ObjRefs)
{
window.__ObjRefs=[];
}

var iRef=parseInt(vp.core.getAttribute(oObj,"__objrefid",-1));


if(iRef<=-1)
{
iRef=window.__ObjRefs.length;
oObj.setAttribute("__objrefid",iRef.toString());
window.__ObjRefs[iRef]={};
}

window.__ObjRefs[iRef][sName]=oRef;
};








vp.core.getObjectReference=function core_getObjectReference(oObj,sName,oWindow)
{if(!window.__noTrace){__td[__ti]=arguments;__ti=__ti>=__MT?0:__ti+1;}
var oTargetWindow=oWindow||window;

if(!oTargetWindow.__ObjRefs)
{
return null;
}

var iRef=parseInt(vp.core.getAttribute(oObj,"__objrefid",-1));
if(iRef<=-1)
{
return null;
}

return oTargetWindow.__ObjRefs[iRef][sName];
};







vp.core.removeObjectReferenceAttribute=function core_removeObjectReferenceAttribute(oObj,oWindow)
{if(!window.__noTrace){__td[__ti]=arguments;__ti=__ti>=__MT?0:__ti+1;}
var oTargetWindow=oWindow||window;

if(!oTargetWindow.__ObjRefs)
{
return;
}

oObj.removeAttribute("__objrefid");
};




vp.core.clearClosures=function core_clearClosures()
{if(!window.__noTrace){__td[__ti]=arguments;__ti=__ti>=__MT?0:__ti+1;}
for(var i=0;i<window.__objs.length;i++)
{
window.__objs[i]=null;
window.__funs[i]=null;
}
};








Function.prototype.getClosure=function(oScope)
{

if(!window.__objs)
{
window.__objs=[];
window.__funs=[];
}


var oFunction=this;


var objId=oScope.__objId;
if(!objId)
{
window.__objs[objId=oScope.__objId=window.__objs.length]=oScope;
}


var funId=oFunction.__funId;
if(!funId)
{
window.__funs[funId=oFunction.__funId=window.__funs.length]=oFunction;
}


if(!oScope.__closures)
{
oScope.__closures=[];
}


var closure=oScope.__closures[funId];
if(closure)
{
return closure;
}


oScope=null;
oFunction=null;


window.__objs[objId].__closures[funId]=function()
{
return window.__funs[funId].apply(window.__objs[objId],arguments);
};

window.__objs[objId].__closures[funId].__isClosure=true;
window.__objs[objId].__closures[funId].__funId=funId;
window.__objs[objId].__closures[funId].__objId=objId;

return window.__objs[objId].__closures[funId];
};













vp.core.getDelayedFunction=function core_getDelayedFunction(fnFunction,iMinTimeBetweenCalls)
{if(!window.__noTrace){__td[__ti]=arguments;__ti=__ti>=__MT?0:__ti+1;}

var bCanCallFunction=true;



var bWaitingToBeCalled=false;




var aWaitingArguments=arguments;

return function()
{
if(bCanCallFunction&&!bWaitingToBeCalled)
{


fnFunction.apply(this,arguments);
bCanCallFunction=false;

window.setTimeout(function()
{
bCanCallFunction=true;
},
iMinTimeBetweenCalls);
}

if(!bCanCallFunction&&!bWaitingToBeCalled)
{


bWaitingToBeCalled=true;

window.setTimeout(function()
{
bWaitingToBeCalled=false;
fnFunction.apply(this,aWaitingArguments);
},
iMinTimeBetweenCalls);
}
};
};

vp.core.markAsClosure=function core_markAsClosure(fnFunction)
{if(!window.__noTrace){__td[__ti]=arguments;__ti=__ti>=__MT?0:__ti+1;}
fnFunction.__isClosure=true;
};









vp.core.getAttribute=function core_getAttribute(oNode,sAttrName,vDefaultValue)
{if(!window.__noTrace){__td[__ti]=arguments;__ti=__ti>=__MT?0:__ti+1;}
if(!oNode.parsed&&!oNode.getAttribute)
{
return vDefaultValue;
}

var vValue=oNode.getAttribute(sAttrName);

if(vValue===null||typeof(vValue)=="undefined")
{
vValue=oNode[sAttrName];
}

if(vValue===null||typeof(vValue)=="undefined")
{
return vDefaultValue;
}
else
{
return vValue;
}
};









vp.core.getElement=function core_getElement(vElement,sFunc)
{if(!window.__noTrace){__td[__ti]=arguments;__ti=__ti>=__MT?0:__ti+1;}

if(typeof vElement=="string")
{
vElement=vp.ui.get(vElement);

if(!vElement)
{
throw new Error(sFunc+": No element with the ID '"+vElement+"' exists.");
}
}


if(!vElement)
{
throw new Error("Call to "+sFunc+"() with a null element reference.");
}


return vElement;
};