function popupEvent(ev, w, h) {
  var winl = (screen.width - w) / 2;
  var wint = (screen.height - h) / 2;
  win = window.open( ev ,"","scrollbars=yes,status=no,location=no,toolbar=no,menubar=no,directories=no,resizable=yes,width=" + w + ",height=" + h + ",top=" + wint + ",left=" + winl + "");
  if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

var arrOldValues;


function DeselectAllList(CONTROL){
for(var i = 0;i < CONTROL.length;i++){
CONTROL.options[i].selected = false;
}
}


function FillListValues(CONTROL, maxsel){
var arrNewValues;
var intNewPos;
var numofseles=0;
var strTemp = GetSelectValues(CONTROL);
arrNewValues = strTemp.split(",");
for(var i=0;i<arrNewValues.length-1;i++){
if(arrNewValues[i]==1){
intNewPos = i;
}
}
for(var i=0;i<arrOldValues.length-1;i++){
if (arrOldValues[i]==1)
{
numofseles++;
}
if (numofseles<maxsel)
{
if(arrOldValues[i]==1 && i != intNewPos){
if (CONTROL.options[i].value!='0')
{
CONTROL.options[i].selected= true;
}
else
{
CONTROL.options[i].selected= false;
}
}
else if(arrOldValues[i]==0 && i != intNewPos){
CONTROL.options[i].selected= false;
}

if(arrOldValues[intNewPos]== 1){
CONTROL.options[intNewPos].selected = false;
}
else{
if (CONTROL.options[intNewPos].value!=='0')
{
CONTROL.options[intNewPos].selected = true;
}
else
{
CONTROL.options[intNewPos].selected = false;
}
}
}
}
}


function GetSelectValues(CONTROL){
var strTemp = "";
var showerror=false;
for(var i = 0;i < CONTROL.length;i++){
if(CONTROL.options[i].selected == true){
if (CONTROL.options[i].value=="0")
{
showerror=true;
}
strTemp += "1,";
}
else{
strTemp += "0,";
}
}

return strTemp;
}

function GetCurrentListValues(CONTROL){
var strValues = "";
strValues = GetSelectValues(CONTROL);
arrOldValues = strValues.split(",")
}
