function RemoveOption(ddlTo,dllFrom)
{
	
	var theSelFrom=document.getElementById(dllFrom);
    var theSelTo=document.getElementById(ddlTo);
	var selLength=theSelFrom.length;
	
	var selectedText=new Array();
	var selectedValues=new Array();
	var selectedCount=0;
	var i;

	for(i=selLength-1; i>=0; i--)
	{
		if(theSelFrom.options[i].selected)
		{
			selectedText[selectedCount]=theSelFrom.options[i].text;
			selectedValues[selectedCount]=theSelFrom.options[i].value;
			deleteOption(theSelFrom, i);
			selectedCount++;
		}
	}
function deleteOption(theSel, theIndex){	
	var selLength=theSel.length;
	if(selLength>0)	{
		theSel.options[theIndex]=null;
	}
}
}

 
 
 function addOptions(dllFrom,ddlTo){

 	var theSelFrom=document.getElementById(dllFrom);
    var theSelTo=document.getElementById(ddlTo);


	var selLength=theSelFrom.length;

	var selectedText=new Array();
	var selectedValues=new Array();
	var selectedCount=0;
	
	var cou1=1;
	var adflag=0;
	var i;
	
	for(i=selLength-1; i>=0; i--)
	{
	
		if(theSelFrom.options[i].selected)
		{
			
			for(j=0;j<theSelTo.length;j++)
			{
				cou1=1;
				
				if(theSelTo.options[j].text==theSelFrom.options[i].text)
				
				{cou1=0
				}
			}	
			
			if (cou1==1) {
			selectedText[selectedCount]=theSelFrom.options[i].text;
			selectedValues[selectedCount]=theSelFrom.options[i].value;
			selectedCount++;
			}
			//
		}			
			
	}

	if (theSelTo.length>0)	{
	
			for(i=selectedCount-1; i>=0; i--){	
				adflag=0;
				for (j=0;j<theSelTo.length;j++)	{
					if(selectedText[i]==theSelTo.options[j].text && adflag==0)
					{adflag=1}
				}
				if(adflag==0){addOption(theSelTo, selectedText[i], selectedValues[i]);}
			}
	}
	else
	{
		for(i=selectedCount-1; i>=0; i--)
		{ addOption(theSelTo, selectedText[i], selectedValues[i]);}	
	}

	function addOption(theSel, theText, theValue){

	var newOpt=new Option(theText, theValue);
	var selLength=theSel.length;
	theSel.options[selLength]=newOpt;
}

}


function hidden(ddlRole1,mulvalue)
{
 
	    document.getElementById(mulvalue).value="";
	    ddl=document.getElementById(ddlRole1);
		for (i = 0; i < ddl.options.length; i++) {
		ddl.options[i].selected =false;
		}
		var ddlout=document.getElementById(ddlRole1).length;
		for(var i=0;i<ddlout;i++)
		{
			document.getElementById(mulvalue).value+=document.getElementById(ddlRole1).options[i].value+",";
		}
		
var mystr=document.getElementById(mulvalue).value;
var outstr = ((mystr.charAt(mystr.length-1,1) == ",") ? mystr.substring(0,mystr.length-1) : mystr);
document.getElementById(mulvalue).value=outstr;
}

function gethidden(ddlRole1,mulvalue)
{
 
	    document.getElementById(mulvalue).value="";
	    ddl=document.getElementById(ddlRole1);	
		for (i = 0; i < ddl.options.length; i++) {
		ddl.options[i].selected =false;
		}
		var ddlout=document.getElementById(ddlRole1).length;
		for(var i=0;i<ddlout;i++)
		{
			document.getElementById(mulvalue).value+=document.getElementById(ddlRole1).options[i].value+",";
		}
		
var mystr=document.getElementById(mulvalue).value;
var outstr = ((mystr.charAt(mystr.length-1,1) == ",") ? mystr.substring(0,mystr.length-1) : mystr);
document.getElementById(mulvalue).value=outstr;
if( document.getElementById(mulvalue).value==''){document.getElementById('multiRoleout').length=0;}
}


function gethiddenRole(mulvalue)
{
	    document.getElementById(mulvalue).value="";
				var frm = document.frmRole;
		var l=0;
for(k=0;k<frm.elements.length;k++)
	{

	
		if(frm.elements[k].type == "checkbox")
		{

			if(frm.elements[k].checked == true)
			{
				document.getElementById(mulvalue).value+=k+",";
			}
			else
			{
			}
		}
	}
}

function getRole1(mul)
{
	    //alert("welcome");
		document.getElementById(mul).value="";
		var frm = document.frmRole;
		var l=0;
for(k=0;k<frm.elements.length;k++)
	{
		if(frm.elements[k].type == "checkbox")
		{
			if(frm.elements[k].checked == true)
			{
				var kval=frm.elements[k].value;
				document.getElementById(mul).value+=kval+",";
			}
			else
			{
			}
		}
	}
var mystr=document.getElementById(mul).value;
var outstr = ((mystr.charAt(mystr.length-1,1) == ",") ? mystr.substring(0,mystr.length-1) : mystr);
document.getElementById(mul).value=outstr;
}

function RefillRole()
{
	//alert(document.getElementById('multiCatein').selectedIndex)
	var i;
 	var count = 0;
 	var count1=0;
 	field3=0;
         var selectedArray = new Array();
         var selObj=document.getElementById('multiCatein');
		  for (i=0;i<selObj.options.length;i++) 
		  {
		  	if (selObj.options[i].value) 
			{			
     				selectedArray[count] = selObj.options[i].value;
      				count++;
		    }	
				    	    
  		 }
  		// alert(count);
         //alert(selectedArray);
	var strURL="role.php?id1="+selectedArray;
	//alert(strURL);
	var req = getXMLHTTP();

	if (req)
	 {
		req.onreadystatechange = function()
		 {
		//alert(req.responseText);
			if (req.readyState == 4)
			 {
				// only if "OK"
				if (req.status == 200)
				 {
					document.getElementById('rolediv').innerHTML=req.responseText;				
				 }
				 else
				 {
					alert("There was a problem while using XMLHTTP:\n" + req.statusText);
				 }
			}
		}
		req.open("GET", strURL, true);
		req.send(null);
	}
}

function clear_role()
{
		if(document.getElementById('multiCatein').length == 0)
		{			
			document.getElementById('multiRolein').length=0;
		
		}
}
/*
function remover(move,outbox,inbox){
	var inbox=document.getElementById(inbox);
	var outbox=document.getElementById(outbox);

 if(move == move)
 {
   for(x = 0;x<(inbox.length);x++)
  {
   if(inbox.options[x])
   {
    inbox.options[x] = null;
    x = -1;
   }
  }
 }

 
 return true;
}


function mover(move,outbox,inbox)
{
	

	var inbox=document.getElementById(inbox);
	var outbox=document.getElementById(outbox);
	 if(move == move)
 {
 
   for(x = 0;x<(inbox.length);x++)
  {
   if(inbox.options[x])
   {
   
    inbox.options[x] = null;
    x = -1;
   }
  }
  for(x = 0;x<(outbox.length);x++)
  {
   if(outbox.options[x])
   {
    with(inbox)
    {
     options[options.length] = new Option(outbox.options
[x].text,outbox.options[x].value);
    }
    
   }
  }
 }
 return true;
}
*/