﻿ function enc(str) {return encodeURI(str);} 
                
                
function getServiceResults(url, soap, xml) 
{  
  try {  
		if (xml.length > 0) {  
			var xmlHTTP;  
			if(window.XMLHttpRequest){  
			//For Firefox, Safari, Opera  
			xmlHttp = new XMLHttpRequest();  
			}  
			else if(window.ActiveXObject){  
				//For IE 5  
				xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
			} else if(window.ActiveXObject){   
				//For IE 6+  
				xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");  
			}	  
                //           "xmlHttp = new ActiveXObject("Microsoft.XMLHTTP\  
			xmlHttp.open("POST", url, false);  
			xmlHttp.setRequestHeader("SOAPAction", soap);  
			xmlHttp.setRequestHeader("Content-Type", "text/xml");
			xmlHttp.send(xml);  
			//alert(xmlHttp.responseText);  
			return xmlHttp.responseXML.documentElement;  
			//return xmlHttp.responseText;  
		}  
	}  
	catch(e) {  
		alert(e.message);  
	}  
}				
				
function getServiceResults_async(url, soap, xml,baseUrl) 
{  
    try {  
          if (xml.length > 0) 
		  {  
            var xmlHTTP;  
            if(window.XMLHttpRequest)
			{  
				//For Firefox, Safari, Opera  
				xmlHttp = new XMLHttpRequest();  
			}  
			else if(window.ActiveXObject)
			{  
				//For IE 5  
				xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			else if(window.ActiveXObject)
			{   
				//For IE 6+  
				xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
			}  
			//xmlHttp = new ActiveXObject("Microsoft.XMLHTTP  
            xmlHttp.open("POST", url, true);  
            xmlHttp.setRequestHeader("SOAPAction", soap);  
            xmlHttp.setRequestHeader("Content-Type", "text/xml");  
            xmlHttp.onreadystatechange = function() {if (xmlHttp.readyState ==4 ) { renderRes(xmlHttp.responseXML.documentElement,baseUrl); }    }  

            //alert('Sending'); 

            xmlHttp.send(xml);  
            //alert(xmlHttp.responseText);  
            return;  
                //"return xmlHttp.responseXML.documentElement;  
                //"//return xmlHttp.responseText;  
        }  
    }  
    catch(e) {  
        alert(e.message);  
    }  
}

function filter(firstLetter,name,roleType,activityArea,isHeb,url,baseUrl)
{  
	document.body.style.cursor='wait'; 
                
    var theTable=document.getElementById('alphon_table_main'); 
    var len=theTable.rows.length;
    for (var i=0; i<len-1; i++) 
      {theTable.deleteRow(1);} 

    newRowWait = theTable.insertRow(-1); 
    newCell = newRowWait.insertCell(0); 
    newCell.innerHTML = '<img src="/_layouts/images/oranim/pleasewait.gif" /> ';  
    

    var URL = url+ "/_layouts/alphonfilter.asmx";  

    var SoapAction = "http://alphonfilter/filter";  

    var UpdateXML = '<?xml version="1.0" encoding="utf-8"?>';  
    UpdateXML += '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ';  
    UpdateXML += 'xmlns:xsd="http://www.w3.org/2001/XMLSchema" ';  
    UpdateXML += 'xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">';  
    UpdateXML += '<soap:Body>';  

    UpdateXML +='<filter xmlns="http://alphonfilter/">';  

    UpdateXML += '<firstLetter>';  
    UpdateXML += enc(firstLetter);  
    UpdateXML += '</firstLetter>';  

    UpdateXML += '<name>';  
    UpdateXML += enc(name);  
    UpdateXML += '</name>';  

    UpdateXML += '<department>';  
    UpdateXML += '</department>';  

    UpdateXML += '<roleType>';  
    UpdateXML += roleType;  
    UpdateXML += '</roleType>';  

    UpdateXML += '<activityArea>';  
    UpdateXML += activityArea ; 
    UpdateXML += '</activityArea>';  

    UpdateXML += '<isHeb>';  
    UpdateXML += isHeb ; 
    UpdateXML += '</isHeb>';  

    UpdateXML += '</filter>';  
    UpdateXML += '</soap:Body>';  
    UpdateXML += '</soap:Envelope>';  


    //"alert('wait'); 


    //" alert('Prepering to send'); 
   getServiceResults_async(URL, SoapAction, UpdateXML,baseUrl);  

}



function renderRes(webserv,baseUrl)
{ 
    var theTable=document.getElementById('alphon_table_main'); 
    //" alert('Yo'); 
    var users=webserv.getElementsByTagName('User'); 
   
    //"alert(users[0].getAttributeNode('Name').text);  
    //"alert(users[0].getAttributeNode('Name').value);  

    for (var i=0; i<users.length; i++) 
    { 
		var user=users[i];  
		var newRow = theTable.insertRow(-1); 

		if (i%2 == 0) {  
		newRow.style.background='#edebeb'; 
    }  

    newCell = newRow.insertCell(0); 
    newCell.innerHTML = '<a href="'+ baseUrl +'personal/' + user.getAttributeNode("UserName").value + '/default.aspx" class="alphon">'+ user.getAttributeNode("Name").value+'</a>';  
    newCell.className ="alphon";
    //newCell.style.border='1 solid #edebeb'; 


    newCell = newRow.insertCell(1); 
    newCell.innerHTML = user.getAttributeNode("Role").value; 
    //newCell.style.border='1 solid #edebeb'; 
    //newCell.style.fontFamily='arial, sans-serif';
    //newCell.style.fontSize='12px';
newCell.className ="alphon";

    newCell = newRow.insertCell(2); 
    newCell.innerHTML = user.getAttributeNode("ActivityAreas").value; 
    //newCell.style.border='1 solid #edebeb'; 
    //newCell.style.fontFamily='arial, sans-serif';
    //newCell.style.fontSize='12px';
newCell.className ="alphon"; 


       
    newCell = newRow.insertCell(3); 
    newCell.innerHTML = user.getAttributeNode("Phone").value; 
    //newCell.style.border='1 solid #edebeb'; 
    //newCell.style.fontFamily='arial, sans-serif'; 
    //newCell.style.fontSize='12px'; 
    newCell.style.direction='ltr'; 
    newCell.dir='ltr'; 
     newCell.align='center'; 
newCell.className ="alphon";
	 
    //" alert('s'+user.getAttributeNode("Email").value+'s'); 

    newCell = newRow.insertCell(4); 
	
    if (user.getAttributeNode("Email").value.replace(" ","")!='') {newCell.innerHTML = '<a href=mailto:'+user.getAttributeNode("Email").value+' style="border:none;"> <img src="/_layouts/images/Oranim/icon_send.gif" style="border:none;"/> </a>';} 
    newCell.align='center'; 
    //newCell.style.border='1 solid #edebeb'; 
    //newCell.style.fontFamily='arial, sans-serif';
    //newCell.style.fontSize='12px';
newCell.className ="alphon";

    newCell = newRow.insertCell(5); 
    newCell.innerHTML = '<a href="'+baseUrl+'personal/' + user.getAttributeNode("UserName").value + '/default.aspx" style="cursor:pointer;"><img src="/_layouts/images/Oranim/home.gif" alt="mysite" style="border:0;"/></div>'; 
    newCell.align='center'; 
    //newCell.style.border='1 solid #edebeb'; 
    //newCell.style.fontFamily='arial, sans-serif';
    //newCell.style.fontSize='12px';
newCell.className ="alphon";
    } 

     
      {theTable.deleteRow(1);} 
    document.body.style.cursor=''; 

}

function openTab_courseSearch(id,num) 
{  
        var baseTabId=id+'_tab_'; 
        var baseBtnId=id+'_btn_'; 
        var baseImgLeftId=id+'_imgRight_'; 
        var baseImgRightId=id+'_imgLeft_'; 
        var i=0; 
        while (true) {
        i++;  
        fullTabId=baseTabId+i;  
        fullBtnId=baseBtnId+i;  

        fullImgLeftId=baseImgLeftId+i;  
        fullImgRightId=baseImgRightId+i;  

        var tab=document.getElementById(fullTabId);  
        if (tab==null) break;  
        tab.style.display='none';  

        var btn=document.getElementById(fullBtnId);  
                //btn.style.background='white';  
        btn.style.backgroundImage='url(http://www.oranim.ac.il/sites/heb/_layouts/images/oranim/tab_pattern.jpg)'; 
        btn.style.backgroundRepeat='repeat-x'; 
        btn.style.color='#444444'; 

        var imgLeft=document.getElementById(fullImgLeftId);  
        var imgRight=document.getElementById(fullImgRightId);  
        imgLeft.src='http://www.oranim.ac.il/sites/heb/_layouts/images/oranim/tab_left.jpg'; 
        imgRight.src='http://www.oranim.ac.il/sites/heb/_layouts/images/oranim/tab_right.jpg'; 

        }  
        var tab=document.getElementById(baseTabId+num);  
        tab.style.display='block';  
        var btn=document.getElementById(baseBtnId+num);  
                //btn.style.background='#efefef';  
        btn.style.backgroundImage='url(http://www.oranim.ac.il/sites/heb/_layouts/images/oranim/tab_pattern_down.jpg)'; 
        btn.style.backgroundRepeat='repeat-x'; 
        btn.style.color='#ffffff'; 
        btn.style.backgroundPosition= '0px 1px'; 

        var imgLeft=document.getElementById(baseImgLeftId+num);  
        var imgRight=document.getElementById(baseImgRightId+num);  
        imgLeft.src='http://www.oranim.ac.il/sites/heb/_layouts/images/oranim/tab_left_down.jpg'; 
        imgRight.src='http://www.oranim.ac.il/sites/heb/_layouts/images/oranim/tab_right_down.jpg'; 
}

function printTable_courseSearch() 
{
    var newWin=window.open('','',''); 
	var table=document.getElementById('searchResultTable');
	//newWin.document.firstChild.firstChild.innerHTML = '<link rel="stylesheet" href="http://test.oranim.ac.il/sites/heb/_styles/oranim2.css" />';
  //alert(table.outerHTML);
  
  newWin.document.write('<html><head><link rel="stylesheet" href="http://test.oranim.ac.il/sites/heb/_styles/oranim2.css" /></head>');
  newWin.document.write('<body>');
  newWin.document.write("<div dir=rtl><table cellpadding='5px' id='searchResultTable' width=740px cellspacing=0 style='border-collapse: collapse; border:solid 1;  border-color:#edebeb;'>"+table.innerHTML+'</table></div>');
  newWin.document.write('</body>');
  newWin.document.write('</html>');

  newWin.document.close();
  
  //newWin.document.body.innerHTML='<link rel="stylesheet" href="http://test.oranim.ac.il/sites/heb/_styles/oranim2.css" /><div dir=rtl>'+table.outerHTML+'</div>';  
    
    //alert(newWin.document.firstChild.innerHTML);
    
    newWin.print(); 
} 


function filterHugs(faculty,year,selectBox,toReset,url){ 

     var URL = url + '/_layouts/alphonfilter.asmx';  

    var SoapAction = "http://alphonfilter/getHugs";  

  var UpdateXML = '<?xml version="1.0" encoding="utf-8"?>';  
    UpdateXML += '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ';  
    UpdateXML += 'xmlns:xsd="http://www.w3.org/2001/XMLSchema" ';  
    UpdateXML += 'xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">';  
    UpdateXML += '<soap:Body>';  

 UpdateXML +='<getHugs xmlns="http://alphonfilter/">';  

UpdateXML += '<faculty>';  
UpdateXML += enc(faculty);  
UpdateXML += '</faculty>';  

UpdateXML += '<year>';  
UpdateXML += year;  
UpdateXML += '</year>';  

UpdateXML += '<isHeb>';  
UpdateXML += 1;  
UpdateXML += '</isHeb>';  

UpdateXML += '</getHugs>';  
    UpdateXML += '</soap:Body>';  
    UpdateXML += '</soap:Envelope>';  

    var webserv = getServiceResults(URL, SoapAction, UpdateXML);  

            var max=selectBox.options.length; 

            var selectedValue=selectBox.options[selectBox.selectedIndex].value; 
      
   for (var i=0; i<max; i++) {selectBox.remove(0);}  

  
 
    try{
	 selectBox.add(new Option('חוג','')); 
}
catch(ex) {
      selectBox.add(new Option('חוג',''),null); 
    }
	 
	 
    var hugs=webserv.getElementsByTagName('Hug'); 

	

   for (var i=0; i<hugs.length; i++) 
   {
		var hug=hugs[i]; 
		try{
		selectBox.add(new Option(hug.getAttributeNode("HugName").value,hug.getAttributeNode("HugName").value) );  
}
catch(ex) {
      
		selectBox.add(new Option(hug.getAttributeNode("HugName").value,hug.getAttributeNode("HugName").value),null );  
    }
		
		
		if ( (!toReset)&&(selectedValue==hug.getAttributeNode("HugName").value) ) 
			{selectBox.selectedIndex=i+1;} 
	}  
   
		if ((toReset)||(selectedValue=='')) 
			{selectBox.selectedIndex=0;}  

}  


function openTab_personal(id,num) {  
                            var baseTabId=id+'_tab_'; 
                            var baseBtnId=id+'_btn_'; 
                            var baseImgLeftId=id+'_imgRight_'; 
                            var baseImgRightId=id+'_imgLeft_'; 
          var i=0; 
          while (true) {
          i++;  
          fullTabId=baseTabId+i;  
          fullBtnId=baseBtnId+i;  

          fullImgLeftId=baseImgLeftId+i;  
          fullImgRightId=baseImgRightId+i;  

          var tab=document.getElementById(fullTabId);  
          if (tab==null) break;  
          tab.style.display='none';  

          var btn=document.getElementById(fullBtnId);  
          //btn.style.background='white';  
          btn.style.backgroundImage='url(http://www.oranim.ac.il/sites/heb/_layouts/images/oranim/tab_pattern.jpg)';
          btn.style.backgroundRepeat='repeat-x'; 
          btn.style.color='#444444'; 

          var imgLeft=document.getElementById(fullImgLeftId);  
          var imgRight=document.getElementById(fullImgRightId);  
          imgLeft.src='http://www.oranim.ac.il/sites/heb/_layouts/images/oranim/tab_left.jpg'; 
          imgRight.src='http://www.oranim.ac.il/sites/heb/_layouts/images/oranim/tab_right.jpg'; 

          }  
          var tab=document.getElementById(baseTabId+num);  
          tab.style.display='block';  
          var btn=document.getElementById(baseBtnId+num);  
          //btn.style.background='#efefef';  
          btn.style.backgroundImage='url(http://www.oranim.ac.il/sites/heb/_layouts/images/oranim/tab_pattern_down.jpg)'; 
          btn.style.backgroundRepeat='repeat-x'; 
          btn.style.color='#ffffff'; 
          //btn.style.backgroundPosition= '0px 1px'; \n"+

          var imgLeft=document.getElementById(baseImgLeftId+num);  
          var imgRight=document.getElementById(baseImgRightId+num);  
          imgLeft.src='http://www.oranim.ac.il/sites/heb/_layouts/images/oranim/tab_left_down.jpg'; 
          imgRight.src='http://www.oranim.ac.il/sites/heb/_layouts/images/oranim/tab_right_down.jpg'; 
}

function displayTeam(type,url,baseUrl,siteId){ 

                 
     var URL = url + '/_layouts/alphonfilter.asmx';  
 
    var SoapAction = "http://alphonfilter/getSiteTeam";  

  var UpdateXML = '<?xml version="1.0" encoding="utf-8"?>';  
    UpdateXML += '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ';  
    UpdateXML += 'xmlns:xsd="http://www.w3.org/2001/XMLSchema" ';  
    UpdateXML += 'xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">';  
    UpdateXML += '<soap:Body>';  

 UpdateXML +='<getSiteTeam xmlns="http://alphonfilter/">';  

UpdateXML += '<siteId>';  
UpdateXML +=   siteId;  
UpdateXML += '</siteId>';  

UpdateXML += '<roleType>';  
UpdateXML += type;  
UpdateXML += '</roleType>';  

UpdateXML += '<isHeb>';  
UpdateXML += 1;  
UpdateXML += '</isHeb>';  

UpdateXML += '</getSiteTeam>';  
    UpdateXML += '</soap:Body>';  
    UpdateXML += '</soap:Envelope>';  

	 
    var webserv = getServiceResults(URL, SoapAction, UpdateXML);
     
      var newWin=window.open('','','');
      newWin.document.write('<html><head><title></title><link rel="stylesheet" href="http://www.oranim.ac.il/sites/heb/_styles/oranim2.css" /></head>');
      newWin.document.write('<body>');

      newWin.document.write("<table dir='rtl' align='right' id='alphon_table_main' width=740px cellspacing=0 style='border-collapse: collapse; border:solid 1;  border-color:#edebeb;'>");

      newWin.document.write("<tr>");

      newWin.document.write("<th align='right' width='162px' class='alphon'>שם</th>");
      newWin.document.write("<th align='right' width='139px' class='alphon'>תפקידים</th>");
      newWin.document.write("<th align='right' width='213px' class='alphon'>תחומי פעילות</th>");
      newWin.document.write("<th align='center' width='96px' class='alphon'>מספר טלפון</th>");
      newWin.document.write("<th align='center' width='55px' class='alphon'>דואל</th>");
      newWin.document.write("<th align='center' width='74px' class='alphon'>אתר אישי</th>");

      newWin.document.write("</tr>");
      newWin.document.write("</table>");
      newWin.document.write("</body>");
      newWin.document.write("</html>");
     // Debug.Write("trying to get url
      
var theTable=newWin.document.getElementById('alphon_table_main'); 
    var len=theTable.rows.length;
    for (var i=0; i<len-1; i++) 
     {theTable.deleteRow(1);} 

     var users=webserv.getElementsByTagName('User'); 


    for (var i=0; i<users.length; i++) 
    { 
    var user=users[i];  
    var newRow = theTable.insertRow(-1); 

    if (i%2 == 0) {  
     newRow.style.background='#edebeb'; 
      

    }  

       newCell = newRow.insertCell(0); 
    newCell.innerHTML = '<a href="'+baseUrl+'personal/' + user.getAttributeNode("UserName").value + '/default.aspx" class="alphon">'+ user.getAttributeNode("Name").value+'</a>'; 

    newCell.style.border='1 solid #edebeb'; 


    newCell = newRow.insertCell(1); 
    newCell.innerHTML = user.getAttributeNode("Role").value; 
    newCell.style.border='1 solid #edebeb'; 
    newCell.style.fontFamily='arial, sans-serif';
    newCell.style.fontSize='13px';

    newCell = newRow.insertCell(2); 
    newCell.innerHTML = user.getAttributeNode("ActivityAreas").value; 
    newCell.style.border='1 solid #edebeb'; 
    newCell.style.fontFamily='arial, sans-serif';
    newCell.style.fontSize='13px';
	
    newCell = newRow.insertCell(3); 
    newCell.innerHTML = user.getAttributeNode("Phone").value; 
    newCell.style.border='1 solid #edebeb'; 
    newCell.style.fontFamily='arial, sans-serif'; 
    newCell.style.fontSize='13px'; 
    newCell.style.direction='ltr'; 
    newCell.dir='ltr'; 
     newCell.align='center'; 

    //" alert('s'+user.getAttributeNode("Email").value+'s'); 

    newCell = newRow.insertCell(4); 
    if (user.getAttributeNode("Email").value!='') {newCell.innerHTML = '<a href=mailto:'+user.getAttributeNode("Email").value+' style="border:none;"> <img src="/_layouts/images/Oranim/icon_send.gif" style="border:none;"/> </a>';} 
    newCell.align='center'; 
    newCell.style.border='1 solid #edebeb'; 
    newCell.style.fontFamily='arial, sans-serif';
    newCell.style.fontSize='13px';
	
    newCell = newRow.insertCell(5); 
    newCell.innerHTML = '<a href="' + baseUrl + 'personal/' + user.getAttributeNode("UserName").value + '/default.aspx"  style="cursor:pointer;"><img src="/_layouts/images/Oranim/home.gif" alt="mysite" style="border:0;"/></div>'; 
    newCell.align='center'; 
    newCell.style.border='1 solid #edebeb'; 
    newCell.style.fontFamily='arial, sans-serif';
    newCell.style.fontSize='13px';


    } 

}

 /* SOURCE FILE: selectbox.js */
            function hasOptions(obj){if(obj!=null && obj.options!=null){return true;}}
            function selectUnselectMatchingOptions(obj,regex,which,only){if(window.RegExp){if(which == "select"){var selected1=true;var selected2=false;}else if(which == "unselect"){var selected1=false;var selected2=true;}else{return;}var re = new RegExp(regex);if(!hasOptions(obj)){return;}for(var i=0;i<obj.options.length;i++){if(re.test(obj.options[i].text)){obj.options[i].selected = selected1;}else{if(only == true){obj.options[i].selected = selected2;}}}}}
            function selectMatchingOptions(obj,regex){selectUnselectMatchingOptions(obj,regex,"select",false);}
            function selectOnlyMatchingOptions(obj,regex){selectUnselectMatchingOptions(obj,regex,"select",true);}
            function unSelectMatchingOptions(obj,regex){selectUnselectMatchingOptions(obj,regex,"unselect",false);}
            function sortSelect(obj){var o = new Array();if(!hasOptions(obj)){return;}for(var i=0;i<obj.options.length;i++){o[o.length] = new Option( obj.options[i].text, obj.options[i].value, obj.options[i].defaultSelected, obj.options[i].selected) ;}if(o.length==0){return;}o = o.sort(
            function(a,b){if((a.text+"") <(b.text+"")){return -1;}if((a.text+"") >(b.text+"")){return 1;}return 0;});for(var i=0;i<o.length;i++){obj.options[i] = new Option(o[i].text, o[i].value, o[i].defaultSelected, o[i].selected);}}
            function selectAllOptions(obj){if(!hasOptions(obj)){return;}for(var i=0;i<obj.options.length;i++){obj.options[i].selected = true;}}
            function moveSelectedOptions(from,to){if(arguments.length>3){var regex = arguments[3];if(regex != ""){unSelectMatchingOptions(from,regex);}}if(!hasOptions(from)){return;}for(var i=0;i<from.options.length;i++){var o = from.options[i];if(o.selected){if(!hasOptions(to)){var index = 0;}else{var index=to.options.length;}to.options[index] = new Option( o.text, o.value, false, false);}}for(var i=(from.options.length-1);i>=0;i--){var o = from.options[i];if(o.selected){from.options[i] = null;}}if((arguments.length<3) ||(arguments[2]==true)){sortSelect(from);sortSelect(to);}from.selectedIndex = -1;to.selectedIndex = -1;}
            function copySelectedOptions(from,to){var options = new Object();if(hasOptions(to)){for(var i=0;i<to.options.length;i++){options[to.options[i].value] = to.options[i].text;}}if(!hasOptions(from)){return;}for(var i=0;i<from.options.length;i++){var o = from.options[i];if(o.selected){if(options[o.value] == null || options[o.value] == "undefined" || options[o.value]!=o.text){if(!hasOptions(to)){var index = 0;}else{var index=to.options.length;}to.options[index] = new Option( o.text, o.value, false, false);}}}if((arguments.length<3) ||(arguments[2]==true)){sortSelect(to);}from.selectedIndex = -1;to.selectedIndex = -1;}
            function moveAllOptions(from,to){selectAllOptions(from);if(arguments.length==2){moveSelectedOptions(from,to);}else if(arguments.length==3){moveSelectedOptions(from,to,arguments[2]);}else if(arguments.length==4){moveSelectedOptions(from,to,arguments[2],arguments[3]);}}
            function copyAllOptions(from,to){selectAllOptions(from);if(arguments.length==2){copySelectedOptions(from,to);}else if(arguments.length==3){copySelectedOptions(from,to,arguments[2]);}}
            function swapOptions(obj,i,j){var o = obj.options;var i_selected = o[i].selected;var j_selected = o[j].selected;var temp = new Option(o[i].text, o[i].value, o[i].defaultSelected, o[i].selected);var temp2= new Option(o[j].text, o[j].value, o[j].defaultSelected, o[j].selected);o[i] = temp2;o[j] = temp;o[i].selected = j_selected;o[j].selected = i_selected;}
            function moveOptionUp(obj){if(!hasOptions(obj)){return;}for(i=0;i<obj.options.length;i++){if(obj.options[i].selected){if(i != 0 && !obj.options[i-1].selected){swapOptions(obj,i,i-1);obj.options[i-1].selected = true;}}}}
            function moveOptionDown(obj){if(!hasOptions(obj)){return;}for(i=obj.options.length-1;i>=0;i--){if(obj.options[i].selected){if(i !=(obj.options.length-1) && ! obj.options[i+1].selected){swapOptions(obj,i,i+1);obj.options[i+1].selected = true;}}}}
            function removeSelectedOptions(from){if(!hasOptions(from)){return;}for(var i=(from.options.length-1);i>=0;i--){var o=from.options[i];if(o.selected){from.options[i] = null;}}from.selectedIndex = -1;}
            function removeAllOptions(from){if(!hasOptions(from)){return;}for(var i=(from.options.length-1);i>=0;i--){from.options[i] = null;}from.selectedIndex = -1;}
            function addOption(obj,text,value,selected){if(obj!=null && obj.options!=null){obj.options[obj.options.length] = new Option(text, value, false, selected);}}


            /* SOURCE FILE: OptionTransfer.js */

            function OT_transferLeft(){moveSelectedOptions(this.right,this.left,this.autoSort,this.staticOptionRegex);this.update();}
            function OT_transferRight(){moveSelectedOptions(this.left,this.right,this.autoSort,this.staticOptionRegex);this.update();}
            function OT_transferAllLeft(){moveAllOptions(this.right,this.left,this.autoSort,this.staticOptionRegex);this.update();}
            function OT_transferAllRight(){moveAllOptions(this.left,this.right,this.autoSort,this.staticOptionRegex);this.update();}
            function OT_saveRemovedLeftOptions(f){this.removedLeftField = f;}
            function OT_saveRemovedRightOptions(f){this.removedRightField = f;}
            function OT_saveAddedLeftOptions(f){this.addedLeftField = f;}
            function OT_saveAddedRightOptions(f){this.addedRightField = f;}
            function OT_saveNewLeftOptions(f){this.newLeftField = f;}
            function OT_saveNewRightOptions(f){this.newRightField = f;}
            function OT_update(){var removedLeft = new Object();var removedRight = new Object();var addedLeft = new Object();var addedRight = new Object();var newLeft = new Object();var newRight = new Object();for(var i=0;i<this.left.options.length;i++){var o=this.left.options[i];newLeft[o.value]=1;if(typeof(this.originalLeftValues[o.value])=="undefined"){addedLeft[o.value]=1;removedRight[o.value]=1;}}for(var i=0;i<this.right.options.length;i++){var o=this.right.options[i];newRight[o.value]=1;if(typeof(this.originalRightValues[o.value])=="undefined"){addedRight[o.value]=1;removedLeft[o.value]=1;}}if(this.removedLeftField!=null){this.removedLeftField.value = OT_join(removedLeft,this.delimiter);}if(this.removedRightField!=null){this.removedRightField.value = OT_join(removedRight,this.delimiter);}if(this.addedLeftField!=null){this.addedLeftField.value = OT_join(addedLeft,this.delimiter);}if(this.addedRightField!=null){this.addedRightField.value = OT_join(addedRight,this.delimiter);}if(this.newLeftField!=null){this.newLeftField.value = OT_join(newLeft,this.delimiter);}if(this.newRightField!=null){this.newRightField.value = OT_join(newRight,this.delimiter);}}
            function OT_join(o,delimiter){var val;var str="";for(val in o){if(str.length>0){str=str+delimiter;}str=str+val;}return str;}
            function OT_setDelimiter(val){this.delimiter=val;}
            function OT_setAutoSort(val){this.autoSort=val;}
            function OT_setStaticOptionRegex(val){this.staticOptionRegex=val;}
            function OT_init(theform){this.form = theform;
			                  if(!theform[this.left]){alert("OptionTransfer init(): Left select list does not exist in form!"); return false;}
							  if(!theform[this.right]){alert("OptionTransfer init(): Right select list does not exist in form!"); return false;}
							  this.left=theform[this.left];this.right=theform[this.right];
							  for(var i=0;i<this.left.options.length;i++){this.originalLeftValues[this.left.options[i].value]=1;}for(var i=0;i<this.right.options.length;i++){this.originalRightValues[this.right.options[i].value]=1;}if(this.removedLeftField!=null){this.removedLeftField=theform[this.removedLeftField];}if(this.removedRightField!=null){this.removedRightField=theform[this.removedRightField];}if(this.addedLeftField!=null){this.addedLeftField=theform[this.addedLeftField];}if(this.addedRightField!=null){this.addedRightField=theform[this.addedRightField];}if(this.newLeftField!=null){this.newLeftField=theform[this.newLeftField];}if(this.newRightField!=null){this.newRightField=theform[this.newRightField];}this.update();}
            function OptionTransfer(l,r)
			{
			//alert("here?");
			this.form = null;
			this.left=l;
			this.right=r;
			this.autoSort=true;
			this.delimiter=",";
			this.staticOptionRegex = "";
			this.originalLeftValues = new Object();
			this.originalRightValues = new Object();
			this.removedLeftField = null;
			this.removedRightField = null;
			this.addedLeftField = null;
			this.addedRightField = null;
			this.newLeftField = null;
			this.newRightField = null;
			this.transferLeft=OT_transferLeft;
			this.transferRight=OT_transferRight;
			this.transferAllLeft=OT_transferAllLeft;
			this.transferAllRight=OT_transferAllRight;
			this.saveRemovedLeftOptions=OT_saveRemovedLeftOptions;
			this.saveRemovedRightOptions=OT_saveRemovedRightOptions;
			this.saveAddedLeftOptions=OT_saveAddedLeftOptions;
			this.saveAddedRightOptions=OT_saveAddedRightOptions;
			this.saveNewLeftOptions=OT_saveNewLeftOptions;
			this.saveNewRightOptions=OT_saveNewRightOptions;
			this.setDelimiter=OT_setDelimiter;
			this.setAutoSort=OT_setAutoSort;
			this.setStaticOptionRegex=OT_setStaticOptionRegex;
			this.init=OT_init;
			this.update=OT_update;}
			
            function isUserSelected(userName) {var selectbox=document.getElementById('inList'); for (var i=0; i<selectbox.options.length; i++ ) {/*alert(selectbox.options[i].text+' '+userName+' '+((selectbox.options[i].text==userName)));*/ if (selectbox.options[i].text==userName) return true;} return false;} 

