

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 RemoveOption1(ddlTo,dllFrom)
{
	//alert("hi");
	var count=0;
		var selectedArray = new Array();
         var selObj=document.getElementById(ddlTo);
		  for (i=0;i<selObj.options.length;i++) 
		  {
		  	if (selObj.options[i].selected) 
			{			
     				selectedArray[count] = selObj.options[i].index;
      				count++;
		    }	
				    	    
  		 }
  		 //alert(selectedArray);
  		 
	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;
//alert(selLength);
	for(i=selLength-1; i>=0; i--)
	{
		//var con= selectedArray[i].split(",");
		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) {
			//alert(theSelFrom.options[i].text);
			selectedText[selectedCount]=theSelFrom.options[i].text;
			//alert(theSelFrom.options[i].value);
			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;
	if(theText!='Select')
	{
		theSel.options[selLength]=newOpt;
	}
}

}


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;
}


function select_ddl()
{	
	ddl=document.getElementById('category1');
	for (i = 0; i < ddl.options.length; i++) {
		ddl.options[i].selected =true;
	}
}

/*function Fillcategory() 
{
	field1=document.getElementById('category1');
	field2=document.getElementById('txtG0');
	field3=0;field5=0;
	field2.options.length=0;
 	var i;
 	var count = 0;
         var selectedArray = new Array();
         var selObj=document.getElementById('category1');
		  for (i=0;i<selObj.options.length;i++) 
		  {
		  	if (selObj.options[i].selected) 
			{			
     				selectedArray[count] = selObj.options[i].value;
					//document.getElementById('txtG0').value=selectedArray[count];
      				count++; 
					
		    }		    	    
  		 }
  	 
  	for(j=0;j<count;j++)
  	{ 
	  	 	var con= selectedArray[j].split(",");
	  	 	if(j==0)
            {
            field3=sStateArray[con];
            }
             else if(con == selectedArray[j].split(","))
             {
                  	field3 =sStateArray[con];
			 }
			 else
			 {

				field3 = field3+sStateArray[con];
			}
			if(con==0 || con==1)
			{
				field5=field3;
			}
			else
			{
			field5=field3;
			}
 	 		
  			
	} 
		for(i=0;i<field5.split("|").length;i++)
		{
		 
         field2.options[i]=new Option(field5.split("|")[i])
         field2.options[i].value=[i];
        }
}*/
function Refillstate1() 
{		
		ddl=document.getElementById('category1');	
		for (i = 0; i < ddl.options.length; i++) {
			ddl.options[i].selected =true;
		}
		field1=document.getElementById('category1');
		field2=document.getElementById('txtG0');
		field3=0;
		field2.options.length=0;
		var i;
		var count = 0;
			 var selectedArray = new Array();
			 var selObj=document.getElementById('category1');
			  for (i=0;i<selObj.options.length;i++) 
			  {
				if (selObj.options[i].selected) 
				{			
						selectedArray[count] = selObj.options[i].value;
						count++;
				}		    	    
			 }
		 
		for(j=0;j<count;j++)
		{ 
				var con= selectedArray[j].split(",");
				//alert(con);
				if(j==0)
				{
				field3=sStateArray[con];
				}
				 else if(con == selectedArray[j].split(","))
				 {
						field3 =sStateArray[con];
				 }
				 else
				 {
	
					field3 = field3+sStateArray[con];
				}
				if(con==0 || con==1)
				{
					field5=field3;
				}
				else
				{
					field5=field3;
				}				
		 } 
		for(i=0;i<field5.split("|").length;i++)
		{
		 
		 field2.options[i]=new Option(field5.split("|")[i])
		 field2.options[i].value=[i];
		}		
}