  
 
var moving = false;


function HighLightTR(el, backColor,altColor){
  
  if (el.bgColor==backColor) {
	  el.bgColor=altColor;
	  return;
  }  
  el.bgColor=backColor;
  preEl = el;
}

 
function checkedFilter(control,controlLabel,value,selectionDisplayControl,selectedData,lookup)
{
 	
  HighLightTR(control.parentNode.parentNode,'#d9e9fe','ffffff');		

  // checked field
  if (control.checked) { 
  
    //Data exists
    if ((document.getElementById(selectionDisplayControl).value != null) && (document.getElementById(selectionDisplayControl).value != 'undefined')) {
    document.getElementById(selectionDisplayControl).value = document.getElementById(selectionDisplayControl).value + value + ",";
    document.getElementById(selectedData).value = document.getElementById(selectedData).value  + lookup + ",";
    }
    else //no current data
    {    
    document.getElementById(selectionDisplayControl).value = value + ",";   
    document.getElementById(selectedData).value =  lookup + ",";
    }
  }
  else // unchecked field
  { 
	document.getElementById(selectionDisplayControl).value = document.getElementById(selectionDisplayControl).value.replace(value + "," ,"");
	document.getElementById(selectedData).value = document.getElementById(selectedData).value.replace(lookup + "," ,"");
  }
 

  try {
   document.getElementById(selectionDisplayControl).innerHTML = '<table><tr><td style="width:100%"><font class="SEMCombo_valuestext">' + document.getElementById(selectionDisplayControl).value.substr(0,18) + '...</font></td><td><img src="/publiclib2/SEMCombo/dropdownarrow.png" /></td></tr></table>';
  }
  catch (ex)
  {
  }
  
  if (document.getElementById(selectionDisplayControl).value.length > 18) 
  {
	  document.getElementById(selectionDisplayControl).innerHTML = document.getElementById(selectionDisplayControl).innerHTML;
  }  
  if (document.getElementById(selectionDisplayControl).value.length == 0)  
  {	
	document.getElementById(selectionDisplayControl).innerHTML = '<table><tr><td style="width:100%"><font color="#000000" class="SEMCombo_valuestext">Select ' + controlLabel + '</font></td><td><img src="/publiclib2/SEMCombo/dropdownarrow.png" /></td></tr></table>';
  }
}

function closeMultiSelect(moveControlID)
{
  if (moving==true) return false;
  moving=true; 
  moveLimit = 190;
  moveIncrement = 15;  
  currentPosition = 0;
  document.getElementById(moveControlID).style.display='block';  
  intervalID = setInterval("animateUP('" + moveControlID +"')", 15); 
}

function animateUP(moveControlID) 
{  
 document.getElementById(moveControlID).style.display='none';
 clearInterval(intervalID);  
 moving=false;
} 		

function openMultiSelect(control,moveControlID)
{	
if (moving==true) return false;
moving=true;
 
moveLimit =  160;//control.style.top;  //125 height of control + padding space

moveIncrement = 15;  
currentPosition = 0;
document.getElementById(moveControlID).style.display='block';
intervalID = setInterval("animate('" + moveControlID +"')", 15); 
}

function animate(moveControlID) 
{   
 if (currentPosition < moveLimit) 
  {   
    currentPosition += moveIncrement;   
    document.getElementById(moveControlID).style.height = currentPosition + "px";  	
	
  }  
  else 
  
  {
	  clearInterval(intervalID);  
	  moving=false;
  }
 } 		
 
 
 function SEMCombo(controlID, controlLabel, optionLabels ,optionValues, category)
 {

document.write('         <input name="' + controlID + '" type="hidden" id="' + controlID + '_selection" value=""/>');
document.write('        <div onclick="openMultiSelect(this,\'' + controlID  + category + '_movethis\')" class="SEMCombo_values" id="' + controlID  + category + '_display"><table><tr><td style="width:100%"  class="SEMCombo_valuestext">Select ' + controlLabel + '</td><td><img alt="" src="/publiclib2/SEMCombo/dropdownarrow.png" /></td></tr></table></div>');
document.write('		<div id="' + controlID  + category + '_movethis" style="overflow:hidden;display:none;width:160px;border:solid 1px #111;"> 		    ');
document.write('		    <div id="' + controlID  + category + '_divctr" style="overflow:auto;height:135px;width:100%;border:solid 0px #000000;">');
document.write('			<table class="SEMCombo_title" style="background:#ffffff" id="' + controlID  + category + '_display" cellspacing="0" cellpadding="0" width="150px">');
document.write('			');

var optionLoop;
for (optionLoop=0; optionLoop<optionLabels.length; optionLoop++)
{
 document.write('            	<tr id="row1" class="SEMCombo_multirow">');
 document.write('					<td class="SEMCombo_checkboxLabel">' + optionLabels[optionLoop] + '</td>');
 document.write('					<td id="' + controlID  + category + '_cell" class="SEMCombo_checkboxArea">');
 document.write('                    <input class="SEMCombo_checkboxArea" id="' + controlID  + category + '_selector' + optionLoop + '" onclick="checkedFilter(this,\'' + controlLabel + '\',\'' + optionLabels[optionLoop] + '\',\'' + controlID  + category + '_display\',\'' + controlID + '_selection' + '\',\'' + optionValues[optionLoop] + '\')' + '" type="checkbox" value="' + optionValues[optionLoop] + '"/>');
 document.write('                    </td>');
 document.write('				</tr>'); 
}

document.write('                ');
document.write('                ');
document.write('			</table>			 ');
document.write('		</div> ');
document.write('        <table cellspacing="0" cellpadding="0" width="170px" height="30px">');
document.write('<tr class="SEMCombo_footer">');
document.write(' <td colspan="2" class="SEMCombo_footer"<center><img onclick="closeMultiSelect(\'' + controlID  + category + '_movethis\');" src="/publiclib2/images15/btn_ok.gif" /></center></td> ');
document.write('</tr>');
document.write('                </table> ');
document.write('        </div>');

 }
 