function searchMasterdataMultiWide(varname,searchname,divname, onComplete, delegationID, countryID, NPMSCheck_YN) {
  var selected=0;
  if (document.getElementById(varname) && $F(varname)) selected=$F(varname);
  var search='';
  if (document.getElementById(searchname) && $F(searchname)) search=$F(searchname);

  if(!delegationID){
      delegationID = 0;
  }
  if(!countryID){
      countryID = 0;
  }
  if(!NPMSCheck_YN){
      NPMSCheck_YN = 0;
  }
  
  var params = "object=masterdatamultiwide&varname="+varname+"&search="+search+"&selected="+selected+"&delegationID="+delegationID+"&countryID="+countryID+"&NPMSCheck_YN="+NPMSCheck_YN;
  
  if(!onComplete){
      onComplete = function(){};
  }
  
  new Ajax.Updater(divname, "getDropdown.php", {method:"get", parameters:params, onComplete:onComplete});
}

function searchAttendee(varname,searchname,divname, eventFunction) {
  var selected=0;
  if (document.getElementById(varname) && $F(varname)) selected=$F(varname);
  var search='';
  if (document.getElementById(searchname) && $F(searchname)) search=$F(searchname);
  if(!eventFunction){
      eventFunction = 0;
  }
  
  var params = "object=attendee&varname="+varname+"&search="+search+"&selected="+selected+"&EventFunction="+eventFunction;
  new Ajax.Updater(divname, "getDropdown.php", {method:"get", parameters:params});
}

function searchAttendeeMulti(varname,searchname,divname, onComplete, eventFunction) {
  var selected=0;
  if (document.getElementById(varname) && $F(varname)) selected=$F(varname);
  var search='';
  if (document.getElementById(searchname) && $F(searchname)) search=$F(searchname);
  
  if(!eventFunction){
      eventFunction = 0;
  }
  
  var params = "object=attendeemulti&varname="+varname+"&search="+search+"&selected="+selected+"&EventFunction="+eventFunction;

  if(!onComplete){
      onComplete = function(){};
  }

  new Ajax.Updater(divname, "getDropdown.php", {method:"get", parameters:params, onComplete:onComplete});
}

function searchAttendeeMultiWide(varname,searchname,divname, onComplete, eventFunction, additionalAttributes) {
  var selected=0;
  if (document.getElementById(varname) && $F(varname)) selected=$F(varname);
  var search='';
  if (document.getElementById(searchname) && $F(searchname)) search=$F(searchname);
  
  if(!eventFunction){
      eventFunction = 0;
  }
  
  var params = "object=attendeemultiwide&varname="+varname+"&search="+search+"&selected="+selected+"&EventFunction="+eventFunction+"&"+additionalAttributes;
  
  if(!onComplete){
      onComplete = function(){};
  }
  
  new Ajax.Updater(divname, "getDropdown.php", {method:"get", parameters:params, onComplete:onComplete});
}

function searchAttendeeMultiWideEventFunction(varname,searchname,divname, onComplete, eventFunction) {
  var selected=0;
  if (document.getElementById(varname) && $F(varname)) selected=$F(varname);
  var search='';
  if (document.getElementById(searchname) && $F(searchname)) search=$F(searchname);
  
  if(!eventFunction){
      eventFunction = 0;
  }
  
  var params = "object=attendeemultiwideeventfunction&varname="+varname+"&search="+search+"&selected="+selected+"&EventFunction="+eventFunction
  
  if(!onComplete){
      onComplete = function(){};
  }
  
  new Ajax.Updater(divname, "getDropdown.php", {method:"get", parameters:params, onComplete:onComplete});
}

function searchAttendeeMultiAttends(varname,searchname,divname) {
  var selected=0;
  if (document.getElementById(varname) && $F(varname)) selected=$F(varname);
  var search='';
  if (document.getElementById(searchname) && $F(searchname)) search=$F(searchname);
  var params = "object=attendeemultiattends&varname="+varname+"&search="+search+"&selected="+selected;
  new Ajax.Updater(divname, "getDropdown.php", {method:"get", parameters:params});
}

function searchAttendeeMultiWideAttends(varname,searchname,divname) {
  var selected=0;
  if (document.getElementById(varname) && $F(varname)) selected=$F(varname);
  var search='';
  if (document.getElementById(searchname) && $F(searchname)) search=$F(searchname);
  var params = "object=attendeemultiwideattends&varname="+varname+"&search="+search+"&selected="+selected;
  new Ajax.Updater(divname, "getDropdown.php", {method:"get", parameters:params});
}

function searchAttendeeMultiWidePermanent(varname,searchname,divname) {
  var selected=0;
  if (document.getElementById(varname) && $F(varname)) selected=$F(varname);
  var search='';
  if (document.getElementById(searchname) && $F(searchname)) search=$F(searchname);
  var params = "object=attendeemultiwidepermanent&varname="+varname+"&search="+search+"&selected="+selected;
  new Ajax.Updater(divname, "getDropdown.php", {method:"get", parameters:params});
}

// move entries of select boxes ***********************************************

var NS4 = (navigator.appName == "Netscape" && parseInt(navigator.appVersion) < 5);

function listSort(lb) {
            //alert(id);
            //var lb = document.getElementById(id);
            //alert(lb);
            //var oldValue = lb[lb.selectedIndex].value;
            //alert(oldValue);

            arrTexts = new Array();

            for(i=0; i<lb.length; i++) {
                arrTexts[i] = lb.options[i].text.toLowerCase()+'\n'+lb.options[i].text+'\n'+lb.options[i].value+'\n'+lb.options[i].title;
            }
            arrTexts.sort();
            for(i=0; i<lb.length; i++) {
                el = arrTexts[i].split('\n');
                lb.options[i].text = el[1];
                lb.options[i].value = el[2];
                lb.options[i].title = el[3];

                //if(oldValue == lb.options[i].value)
                //    lb.options[i].selected = true;
                //else
                //    lb.options[i].selected = false;
            }
}

function addOption(theSel, theText, theValue, theTitle)
{
  var newOpt = new Option(theText, theValue);
  newOpt.title = theTitle;
  var selLength = theSel.length;
  theSel.options[selLength] = newOpt;
}

function deleteOption(theSel, theIndex)
{
  var selLength = theSel.length;
  if(selLength>0)
  {
    theSel.options[theIndex] = null;
  }
}

function containsOption(theSel,text,value)
{
  var r=false;
  if (theSel) {
    for(i=0; i<theSel.length; i++) {
      if (theSel.options[i].text==text && theSel.options[i].value==value) {
        r=true;
        break;
      }
    }
  }
  return r;
}

function moveOptions2(idFrom,idTo,sort,allowmultipleoccurrences) // theSelFrom, theSelTo
{

  var theSelFrom = document.getElementById(idFrom);
  var theSelTo = document.getElementById(idTo);

  var selLength = 0;
  if (theSelFrom) selLength = theSelFrom.length;
  var selectedText = new Array();
  var selectedValues = new Array();
  var selectedTitle = new Array();
  var selectedCount = 0;

  var i;

  // Find the selected Options in reverse order
  // and delete them from the 'from' Select.
  for(i=selLength-1; i>=0; i--)
  {
    if(theSelFrom && theSelFrom.options[i].selected)
    {
      selectedText[selectedCount] = theSelFrom.options[i].text;
      selectedValues[selectedCount] = theSelFrom.options[i].value;
      selectedTitle[selectedCount] = theSelFrom.options[i].title;
      deleteOption(theSelFrom, i);
      selectedCount++;
    }
  }

  // Add the selected text/values in reverse order.
  // This will add the Options to the 'to' Select
  // in the same order as they were in the 'from' Select.
  for(i=selectedCount-1; i>=0; i--)
  {
    if (allowmultipleoccurrences || !containsOption(theSelTo, selectedText[i], selectedValues[i])) {
      if (theSelTo && theSelTo.options) addOption(theSelTo, selectedText[i], selectedValues[i], selectedTitle[i]);
    }
  }

  if (theSelTo && theSelTo.options && sort) listSort(theSelTo);

  if(NS4) history.go(0);
}

function moveOptions(idFrom,idTo) // theSelFrom, theSelTo
{
  moveOptions2(idFrom,idTo,1,0)
}

function moveOptionsToEnd(idFrom,idTo) // theSelFrom, theSelTo
{
  moveOptions2(idFrom,idTo,0,0)
}

function moveOptionsAllowMultiple(idFrom,idTo) // theSelFrom, theSelTo
{
  moveOptions2(idFrom,idTo,1,1)
}

function selectAll(id) {
  var myElement = document.getElementById(id);
  if (myElement && myElement.options) {
    for(i=0; i<myElement.length; i++)
    {
      myElement.options[i].selected=true;
    }
  }
}


// get value of checked radio button ******************************************
function radioValue(rObj) {
  for (var i=0; i<rObj.length; i++) if (rObj[i].checked) return rObj[i].value;
  return false;
}

// get value of checked radio button ******************************************
function selectValue(sObj) {
  if (sObj)
    return sObj.options[sObj.selectedIndex].value;
  return false;
}

// open url in new window *****************************************************
function openWindow(url) {
  cmWindow=window.open(url,'cmPopup','width=1020,height=710,left=0,top=0,scrollbars=1');
  cmWindow.focus();
}