

var ie=false;
if(document.all) { ie=true; };

var check_off = "/wpresources/lcms/skins/default/images/controls/unchecked.gif";
var check_on  = "/wpresources/lcms/skins/default/images/controls/checked.gif";

function SDTComboObject(name) {
 this.id="SDTComboObject"+SDTComboObject._c++;
 SDTComboObject.all[this.id] = this;
 this.elementName = new Array();
 this.elementValue = new Array();
 this.elementChecked = new Array();
 this.elementHasCheck = new Array();
 this.elementClass = new Array();
 this.itemCount = -1;
 this.objectDiv = null;
 this.holderDiv = null;
 this.objectName = name;
 this.visible = false; 
}

var p = SDTComboObject.prototype;
p.toString = function() { return "SDTComboObject.all."+this.id };
SDTComboObject.all = [];
SDTComboObject._c = 0;

p.addElement = function(n,v,c,disp,css) {
 this.itemCount++;
 this.elementName[this.itemCount] = n;
 this.elementValue[this.itemCount] = v;
 this.elementChecked[this.itemCount] = c; 
 this.elementHasCheck[this.itemCount] = disp;
 this.elementClass[this.itemCount] = css == null ? '' : css;
}
p.removeElement = function(i) {
 this.elementName.slice(i,1);
 this.elementValue.slice(i,1);
 this.elementChecked.slice(i,1);
 this.elementClass.slice(i,1);
 this.itemCount--;
}

p.setDiv = function(o) {
 this.objectDiv = document.getElementById(o); 
}

p.getImage = function(i) {
 if (this.elementChecked[i]) { return check_on; } else { return check_off; }
}

p.redraw = function() {
 var tmphtml = "";
 tmphtml='<table width="100%" cellspacing="0" cellpadding="2" border="0">';
 // tmphtml=tmphtml+'<tr><td width="20">&nbsp;</td><td>&nbsp;</td></tr>';
 for(i=0;i<=this.itemCount;i++) {
  if((i%2)==0) { bgstr="#E5F2F8"; } else { bgstr="#FFFFFF"; }
  
  if(this.elementHasCheck[i]) {	
    tmphtml=tmphtml+'<tr bgcolor="'+bgstr+'" onMouseOver="this.style.backgroundColor=\'#108EC1\';" onMouseOut="this.style.backgroundColor=\'';
    tmphtml=tmphtml+bgstr+'\';"><td class="'+ (this.elementClass[i] != '' ? this.elementClass[i] :  'comboitem') + '" valign="middle" style="border-bottom:1px solid #E3E3E3;">';
    tmphtml=tmphtml+'<a href="javascript:'+this.objectName+'.toggleCheck('+i+');"><img src="'+this.getImage(i)+'" border="0"></a>&nbsp;';
    //tmphtml=tmphtml+'<td valign="middle" align="left" width="100%" style="border-bottom:1px solid #E3E3E3;"><span >';
    tmphtml=tmphtml+'<span >';
    tmphtml=tmphtml+this.elementName[i]+"</span></td>";
    tmphtml=tmphtml+'</tr>';
  } else {
    //tmphtml=tmphtml+'<tr bgcolor="#108EC1" color="white"><td colspan="2" valign="middle" align="left" style="border-bottom:1px solid #E3E3E3;"><span class="'+ (this.elementClass[i] != '' ? this.elementClass[i] :  'tccomboitembold')+'">';
    
    //tmphtml=tmphtml+this.elementName[i]+"</td>";
    tmphtml=tmphtml+'<tr><td bgcolor="#108EC1" class="tccomboitembold">'+this.elementName[i]+"</td>";
    tmphtml=tmphtml+'</tr>';  
  }
 }
 tmphtml=tmphtml+'</table>';
 this.objectDiv.innerHTML=tmphtml;
 // alert(tmphtml);
}


p.show = function() {
	//alert('show');
 //if(ie) { this.objectDiv.style.visibility="visible"; } else { this.objectDiv.visibility="show"; }
 this.objectDiv.style.display = "block";
 this.visible=true;
}

p.hide = function() {
 //if(ie) { this.objectDiv.style.visibility="hidden"; } else { this.objectDiv.visibility="hide"; } 
 this.objectDiv.style.display = "none";
 this.visible=false;
}

p.toggleCheck = function(i) {
 this.elementChecked[i]=!this.elementChecked[i];
 this.redraw();
}

p.toggle = function() {
 this.visible=!this.visible;
 if(this.visible) { this.show(); } else { this.hide(); }
}

p.getValue = function() {
  ret='';
  for(i=0;i<=this.itemCount;i++) {
   if(this.elementChecked[i] && this.elementHasCheck[i]) { ret+=this.elementValue[i]+';'; }
  }
  return ret;
}
