NamepaceManager.Register("Apc.WC");
if(typeof (Apc.WC.DDButton)=="undefined"){
NamepaceManager.Register("Apc.WC.DDButton");
var listDropDownPickers=new Array();
var currentDropDownList=null;
var openDropDownList=null;
function hideDropDownLists(){
if(typeof (listDropDownPickers)!="undefined"){
for(var i=0;i<listDropDownPickers.length;i++){
listDropDownPickers[i].style.display="none";
openDropDownList=null;
}
}
};
findPos=function(_2){
var _3=0;
var _4=0;
if(_2.offsetParent){
do{
_3+=_2.offsetLeft;
_4+=_2.offsetTop;
}while(_2=_2.offsetParent);
}
return [_3,_4];
};
Apc.WC.DDButton=function(_5,_6,_7,_8,_9,_a,_b,_c,_d){
this.ControlId=_5;
this.LblTextBoxId=_6;
this.DrpControlId=_7;
this.DisabledImage=_a;
this.ClientValueSelectEvent=_8;
this.Enabled=_b;
this.ImageId=_c;
this.EnabledImage=_d;
this.EnableTextColor=null;
this.CurrentDrpValue=_9;
this.CustomDropdownControl=null;
this.LblTextBoxControl=null;
this.DrpControl=null;
this.Image=null;
this.ImageOnMouseOverEvent=null;
this.ImageOnMouseOutEvent=null;
this.CustomDropdownControlListManager=null;
this.RelativeObject=null;
this.ObjectCreated=false;
ApcRegistry.Register(this,this.ControlId,this.GetType());
};
Apc.WC.DDButton.prototype={ensureObjectsCreated:function(){
if(!this.ObjectCreated){
this.CustomDropdownControlListManager=ApcRegistry.GetManager(this.DrpControlId);
if(this.CustomDropdownControl==null){
this.CustomDropdownControl=document.getElementById(this.ControlId);
}
if(this.LblTextBoxControl==null){
this.LblTextBoxControl=document.getElementById(this.LblTextBoxId);
}
if(this.DrpControl==null){
this.DrpControl=document.getElementById(this.DrpControlId);
}
if(this.Image==null){
this.Image=document.getElementById(this.ImageId);
}
listDropDownPickers[listDropDownPickers.length]=this.DrpControl;
this.ImageOnMouseOverEvent=this.Image.onmouseover;
this.ImageOnMouseOutEvent=this.Image.onmouseout;
this.EnableTextColor=this.LblTextBoxControl.style.color;
this.ObjectCreated=true;
if(!this.Enabled){
this.disable();
}
}
},setRelativeObject:function(_e){
this.RelativeObject=_e;
},getSelectedValue:function(){
var _f=0;
this.ensureObjectsCreated();
if(document.all){
_f=this.LblTextBoxControl.innerText;
}else{
_f=this.LblTextBoxControl.textContent;
}
return (_f);
},hide:function(){
this.ensureObjectsCreated();
this.CustomDropdownControl.style.display="none";
},show:function(){
this.ensureObjectsCreated();
this.CustomDropdownControl.style.display="";
},disable:function(){
this.ensureObjectsCreated();
if(this.Enabled){
this.Image.src=this.DisabledImage;
this.ImageOnMouseOverEvent=this.Image.onmouseover;
this.ImageOnMouseOutEvent=this.Image.onmouseout;
this.Image.onmouseover=null;
this.Image.onmouseout=null;
this.LblTextBoxControl.style.color="#A3A3A3";
this.Enabled=false;
}
},enable:function(){
this.ensureObjectsCreated();
if(!this.Enabled){
this.Image.onmouseover=this.ImageOnMouseOverEvent;
this.Image.onmouseout=this.ImageOnMouseOutEvent;
this.LblTextBoxControl.style.color="#000000";
this.Image.src=this.EnabledImage;
this.Enabled=true;
}
},OnDropDownClick:function(){
this.ensureObjectsCreated();
if(this.Enabled){
if(this.DrpControl.style.display==""){
hideDropDownLists();
}else{
hideDropDownLists();
var pos=findPos(this.CustomDropdownControl);
this.DrpControl.style.display="";
var _11=0;
var _12=0;
var _13=Apc.JS.Browser.DocumentBody;
var _14=document.all?_13.scrollLeft+_13.clientWidth:pageXOffset+window.innerWidth-15;
var _15=document.all?Math.min(_13.scrollHeight,_13.clientHeight):Math.min(document.body.offsetHeight,window.innerHeight);
var _16=this.DrpControl.offsetWidth;
var _17=this.DrpControl.offsetHeight;
_11=pos[0];
var _18=_15+_13.scrollTop-(pos[1]+this.CustomDropdownControl.offsetHeight);
if(_18<(_17)){
_12=pos[1]-this.DrpControl.offsetHeight;
}else{
_12=pos[1]+this.CustomDropdownControl.offsetHeight;
}
this.DrpControl.style.left=_11+"px";
this.DrpControl.style.top=_12+"px";
if(document.all){
valueTextArray=this.CustomDropdownControl.innerText.split("\n");
valueText=valueTextArray[0];
}else{
valueTextArray=this.CustomDropdownControl.textContent.split("\n");
valueText=valueTextArray[1];
}
valueText=this.replace(valueText,"\n","");
this.CustomDropdownControlListManager.SelectValueRow(valueText);
currentDropDownList=this.DrpControl;
openDropDownList=null;
}
}
},replace:function(_19,_1a,by){
var _1c=_19.length,_1d=_1a.length;
if((_1c==0)||(_1d==0)){
return _19;
}
var i=_19.indexOf(_1a);
if((!i)&&(_1a!=_19.substring(0,_1d))){
return _19;
}
if(i==-1){
return _19;
}
var _1f=_19.substring(0,i)+by;
if(i+_1d<_1c){
_1f+=this.replace(_19.substring(i+_1d,_1c),_1a,by);
}
return _1f;
},SelectValue:function(val){
this.ensureObjectsCreated();
this.SetDefaultValue(val);
var _21=window[this.ClientValueSelectEvent];
if(typeof (_21)!="undefined"){
_21(this.CurrentValue);
}
},SetDefaultValue:function(_22){
this.ensureObjectsCreated();
var _23=null;
_23=this.CustomDropdownControlListManager.GetSelectedValue(_22);
if(_23!=null){
if(document.all){
this.LblTextBoxControl.innerText=_23;
}else{
this.LblTextBoxControl.textContent=_23;
}
this.CurrentValue=_23;
this.hideDropDownControl();
}else{
alert("Value not exists");
}
},AssignValue:function(_24){
this.ensureObjectsCreated();
var _25=null;
_25=this.CustomDropdownControlListManager.GetSelectedValue(_24);
if(_25!=null){
this.SelectValue(_25);
}else{
alert("Value not exists");
}
},hideDropDownControl:function(){
this.ensureObjectsCreated();
this.DrpControl.style.display="none";
},GetType:function(){
return ("Apc.WC.DDButton");
}};
documentDrpLstClicked=function(e){
e=(e)?e:((window.event)?window.event:"");
var _27=document.documentElement.scrollTop;
var _28=document.documentElement.scrollLeft;
var x=e.clientX+_28;
var y=e.clientY+_27;
if(currentDropDownList!=null){
if(openDropDownList!=null){
var pos=findPos(openDropDownList);
if(x<pos[0]||x>pos[0]+openDropDownList.offsetWidth||y<pos[1]||y>pos[1]+openDropDownList.offsetHeight){
hideDropDownLists();
}
}else{
openDropDownList=currentDropDownList;
}
}
};
if(document.all){
document.body.attachEvent("onclick",documentDrpLstClicked);
window.attachEvent("onresize",hideDropDownLists);
window.attachEvent("onscroll",hideDropDownLists);
window.attachEvent("onblur",hideDropDownLists);
}else{
document.addEventListener("click",documentDrpLstClicked,false);
window.addEventListener("resize",hideDropDownLists,false);
window.addEventListener("scroll",hideDropDownLists,false);
window.addEventListener("blur",hideDropDownLists,false);
}
}


