	//AJAX general scripts
		var http = false;
		if(navigator.appName == "Microsoft Internet Explorer") {
		  http = new ActiveXObject("Microsoft.XMLHTTP");
		} else {
		  http = new XMLHttpRequest();
		}
		var http1 = false;
		if(navigator.appName == "Microsoft Internet Explorer") {
		  http1 = new ActiveXObject("Microsoft.XMLHTTP");
		} else {
		  http1 = new XMLHttpRequest();
		}
		
function disableEnterKey(e)
{
     var key;      
     if(window.event)
          key = window.event.keyCode; //IE
     else
          key = e.which; //firefox      
     return (key != 13);
}

var timeout_key = 0;

//roll,over row
function mouse_event(obj, newClass) 
{
	return;
	parent.document.getElementById('debug_window').innerHTML = parent.document.getElementById('debug_window').innerHTML+'.';
	if(newClass == '' && obj.className == 'hlt')
	{
		window.clearTimeout(timeout_key); 		
		mouse_event2(obj, newClass);
	}
	else if(newClass == 'hlt')
	{		
			timeout_key = window.setTimeout(function(){mouse_event2(obj, newClass)},100);   	 	 
	}
}	

function mouse_event2(obj, newClass) 
{
	obj.className = newClass
}


var tooltip=function(){
	var id = 'tt';
	var top = 3;
	var left = 3;
	var maxw = 300;
	var speed = 30;
	var timer = 60;
	var endalpha = 95;
	var alpha = 0;
	var tt,t,c,b,h;
	var ie = document.all ? true : false;
	return{
		show:function(v,w){
			if(tt == null){
				tt = document.createElement('div');
				tt.setAttribute('id',id);
				t = document.createElement('div');
				t.setAttribute('id',id + 'top');
				c = document.createElement('div');
				c.setAttribute('id',id + 'cont');
				b = document.createElement('div');
				b.setAttribute('id',id + 'bot');
				tt.appendChild(t);
				tt.appendChild(c);
				tt.appendChild(b);
				document.body.appendChild(tt);
				tt.style.opacity = 0;
				tt.style.filter = 'alpha(opacity=0)';
				document.onmousemove = this.pos;
			}
			tt.style.display = 'block';
			c.innerHTML = v;
			tt.style.width = w ? w + 'px' : 'auto';
			if(!w && ie){
				t.style.display = 'none';
				b.style.display = 'none';
				tt.style.width = tt.offsetWidth;
				t.style.display = 'block';
				b.style.display = 'block';
			}
			if(tt.offsetWidth > maxw){tt.style.width = maxw + 'px'}
			h = parseInt(tt.offsetHeight) + top;
			clearInterval(tt.timer);
			tt.timer = setInterval(function(){tooltip.fade(1)},timer);
		},
		pos:function(e){
			var u = ie ? event.clientY + document.documentElement.scrollTop : e.pageY;
			var l = ie ? event.clientX + document.documentElement.scrollLeft : e.pageX;
			tt.style.top = (u - h) + 'px';
			tt.style.left = (l + left) + 'px';
		},
		fade:function(d){
			var a = alpha;
			if((a != endalpha && d == 1) || (a != 0 && d == -1)){
				var i = speed;
				if(endalpha - a < speed && d == 1){
					i = endalpha - a;
				}else if(alpha < speed && d == -1){
					i = a;
				}
				alpha = a + (i * d);
				tt.style.opacity = alpha * .01;
				tt.style.filter = 'alpha(opacity=' + alpha + ')';
			}else{
				clearInterval(tt.timer);
				if(d == -1){tt.style.display = 'none'}
			}
		},
		hide:function(){
			clearInterval(tt.timer);
			tt.timer = setInterval(function(){tooltip.fade(-1)},timer);
		}
	};
}();

function highlight_row(row,state)
{				
	//alert(this.className);
	if(state == true)				
	{
		row.className='list_row_selected';										
	}
	else
	{
		row.className='list_row';					
	}
	//document.body.style.cursor='pointer';
}

function getFlashVersion(){ 
  // ie 
  try { 
    try { 
      // avoid fp6 minor version lookup issues 
      // see: http://blog.deconcept.com/2006/01/11/getvariable-setvariable-crash-internet-explorer-flash-6/ 
      var axo = new ActiveXObject('ShockwaveFlash.ShockwaveFlash.6'); 
      try { axo.AllowScriptAccess = 'always'; } 
      catch(e) { return '6,0,0'; } 
    } catch(e) {} 
    return new ActiveXObject('ShockwaveFlash.ShockwaveFlash').GetVariable('$version').replace(/\D+/g, ',').match(/^,?(.+),?$/)[1]; 
  // other browsers 
  } catch(e) { 
    try { 
      if(navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin){ 
        return (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]).description.replace(/\D+/g, ",").match(/^,?(.+),?$/)[1]; 
      } 
    } catch(e) {} 
  } 
  return '0,0,0'; 
} 




function hide_media_panel()
{
		document.getElementById('media_player_panel').className='transparent_class';
}

function show_media_panel()
{
		document.getElementById('media_player_panel').className='';
}


function submit_form(action)
{	
	//update action field with this action and submit
	if(action)
	{
			document.getElementById('action').value = action;
	}	
				
	if(document.getElementById('submit_progress'))
	{
		document.getElementById('submit_progress').style.display = ''; 
	}
					
	//uncheck any rows that are not visible	
	formObj = form1
   for (var i=0;i < formObj.length;i++) 
   {
      fldObj = formObj.elements[i];    
      if(fldObj.type == 'checkbox' && fldObj.className != 'ignore')
      {       	  
	      	var row_id = fldObj.value;
	      	if(document.getElementById(row_id))
	      	{
			      	if(document.getElementById(row_id).style.display == 'none') 
			      	{
			      		fldObj.checked = false;
			      	}
			     }
       }
   }  
	document.form1.submit();	
}




function submit_form_with_search_string(action, search_type)
{	
	document.getElementById('search_type').value = search_type;
	
	//ass above except a space is added to the search string is it exists
	if(document.getElementById('search_string'))
		document.getElementById('search_string').value = document.getElementById('search_string').value+' ';
	
	//update action field with this action and submit
	if(action)
	{
			document.getElementById('action').value = action;
	}
	
	if(document.getElementById('generate_report'))
		document.getElementById('generate_report').value = 'yes';	
	
	//remove any export modes	
	if(document.getElementById('export_mode'))
		document.getElementById('export_mode').value = '';	
		
				
	//uncheck any rows that are not visible	
	formObj = form1
   for (var i=0;i < formObj.length;i++) 
   {
      fldObj = formObj.elements[i];    
      if(fldObj.type == 'checkbox' && fldObj.className != 'ignore')
      {       	  
	      	var row_id = fldObj.value;
	      	if(document.getElementById(row_id).style.display == 'none') 
	      	{
	      		fldObj.checked = false;
	      	}
       }
   }  
    document.form1.target = '';
	document.form1.submit();	
}

function submit_form_export(action, export_mode)
{	
	//ass above except a space is added to the search string is it exists
	if(document.getElementById('export_mode'))
		document.getElementById('export_mode').value = export_mode;
		
	if(document.getElementById('generate_report'))
		document.getElementById('generate_report').value = 'yes';
		
	//update action field with this action and submit
	if(action)
	{
			document.getElementById('action').value = action;
	}	
				
	//uncheck any rows that are not visible	
	formObj = form1
   for (var i=0;i < formObj.length;i++) 
   {
      fldObj = formObj.elements[i];    
      if(fldObj.type == 'checkbox' && fldObj.className != 'ignore')
      {       	  
	      	var row_id = fldObj.value;
	      	if(document.getElementById(row_id).style.display == 'none') 
	      	{
	      		fldObj.checked = false;
	      	}
       }
   }  
   document.form1.target = '_new';   
	document.form1.submit();	
	document.form1.target = '';
	if(document.getElementById('export_mode'))
		document.getElementById('export_mode').value = '';
	 
}


function submit_form_generate(action,sort_by)
{	
	
	
	//ass above except a space is added to the search string is it exists
	if(document.getElementById('generate_report'))
		document.getElementById('generate_report').value = 'yes';
		
	if(document.getElementById('sort_by'))
		document.getElementById('sort_by').value = sort_by;				
		
	if(document.getElementById('export_mode'))
		document.getElementById('export_mode').value = '';		
	//update action field with this action and submit
	if(action)
	{
			document.getElementById('action').value = action;
	}	
				
	//uncheck any rows that are not visible	
	formObj = form1
   for (var i=0;i < formObj.length;i++) 
   {
      fldObj = formObj.elements[i];    
      if(fldObj.type == 'checkbox' && fldObj.className != 'ignore')
      {       	  
	      	var row_id = fldObj.value;
	      	if(document.getElementById(row_id))
	      	{
			      	if(document.getElementById(row_id).style.display == 'none') 
			      	{
			      		fldObj.checked = false;
			      	}
			     }
       }
   }  
   //document.form1.target = '_new';
   if(document.getElementById('submit_progress'))
	{
		document.getElementById('submit_progress').style.display = ''; 
	}
     document.form1.target = '';
	document.form1.submit();	
}



function submit_multiform(action,jump_to_section)
{	
	//update action field with this action and submit
	if(action)
	{
			document.getElementById('action').value = action;
	}	
	
	if(jump_to_section)
	{
			document.getElementById('jump_to_section').value = jump_to_section;
	}	
					
	document.form1.submit();	
}

function new_song_submit(action)
{	
	if(parent.document.getElementById('media_player_position').value < 10)
	{
		  parent.player.sendEvent('SEEK',10);
	}
	else
	{	
				//this function checks if 10 secs have been played before submitting
				//update action field with this action and submit
				if(action)
				{
						document.getElementById('action').value = action;
				}	
				//uncheck any rows that are not visible	
				formObj = form1
			   for (var i=0;i < formObj.length;i++) 
			   {
			      fldObj = formObj.elements[i];
			      if(fldObj.type == 'checkbox')
			      { 
				      	var row_id = fldObj.value;
				      	if(document.getElementById(row_id).style.display == 'none') 
				      	{
				      		fldObj.checked = false;
				      	}
			       }
			   }  
				document.form1.submit();	
	}
}



function TestFileType( fileName, fileTypes ) {
if (!fileName) return;

dots = fileName.split(".")
//get the part AFTER the LAST period.
fileType = "." + dots[dots.length-1];

return (fileTypes.join(".").indexOf(fileType) != -1) ?
alert('That file is OK!') : 
alert("Please only upload files that end in types: \n\n" + (fileTypes.join(" .")) + "\n\nPlease select a new file and try again.");
}


function ajax_upload_progress(id)
{						   
		var http = false;		
		if(navigator.appName == "Microsoft Internet Explorer") {
		  http = new ActiveXObject("Microsoft.XMLHTTP");
		} else {
		  http = new XMLHttpRequest();
		}
		now = new Date();		
		http.open("GET", "ajax/get_upload_progress.php?id="+id+'&now='+now);
		http.onreadystatechange=function() {
		  if(http.readyState == 4) {
		  	if(http.responseText)
		  	{
		    	document.getElementById('upload_progress').innerHTML=http.responseText;
		    }
		    //setTimeout("alert('aa');",1000);		
		    setTimeout("ajax_upload_progress("+id+")",500);		
		  }
		}
		http.send(null);
}





function get_upload_progress(id)	
{							
				//destroy and recreate AJAX http object
			var http = false;
			if(navigator.appName == "Microsoft Internet Explorer") {
			  http = new ActiveXObject("Microsoft.XMLHTTP");
			} else {
			  http = new XMLHttpRequest();
			}								
			var post_data = '';
			//create timestamp to prevent cacheing			
			var now = new Date();							
			var ajax_url = 'ajax/get_upload_progress.php?id=4545545&Action=' + now;						
			http.abort();
			http.open("POST", ajax_url, true);
			http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");			
			http.setRequestHeader("Content-length", post_data.length);
			http.setRequestHeader("Connection", "close");				
				  document.getElementById('upload_progress').innerHTML='1ss';	
		  http.onreadystatechange=function() 
		  {				
			  	document.getElementById('upload_progress').innerHTML='2ss';			  	
					  if(http.readyState == 4) 
					  {						  																					
											 if(http.responseText != "")
											 {
											 		alert(http.responseText); 
											 			
											 			document.getElementById('upload_progress').innerHTML=http.responseText;
											 														 			
									    }
					  }
					  
					  //setTimeout("get_upload_progress(id)", 1000);		
				}
				http.send(post_data);
				//document.getElementById('upload_progress').innerHTML='3ss';	
}
	
function selectAll(formObj, isInverse) 
{
	buttontext = document.getElementById('select_all').innerHTML
	if(buttontext == "select all")
	{
		document.getElementById('select_all').innerHTML = "select none";
		document.getElementById('select_all').title="Click here to deselect clips"
		isInverse = 0;
	}
	if(buttontext == "select none")
	{
		document.getElementById('select_all').innerHTML = "select all";
		document.getElementById('select_all').title="Click here to select all clips"
		isInverse = 1;
	}

	
   for (var i=0;i < formObj.length;i++) 
   {
      fldObj = formObj.elements[i];
      if (fldObj.type == 'checkbox')
      { 
         if(isInverse)
            fldObj.checked = false;
         else fldObj.checked = true; 
       }
   }
   
}		


function check_this(row_id)
{
		formObj = form1;
	 for (var i=0;i < formObj.length;i++) 
   {
      fldObj = formObj.elements[i];
      if (fldObj.type == 'checkbox')
      { 
            fldObj.checked = false;
       }
   }
		document.getElementById(row_id).checked = true;
}


var status_timeout = 100;			
			
function start_ajax(row_state_array,ajax_name,post_data,newest_record_id)
{			
			//destroy and recreate AJAX http object
			var http = false;
			if(navigator.appName == "Microsoft Internet Explorer") {
			  http = new ActiveXObject("Microsoft.XMLHTTP");
			} else {
			  http = new XMLHttpRequest();
			}								
			
			//create timestamp to prevent cacheing			
			var now = new Date();							
			var ajax_url = 'ajax/'+ajax_name+'.php?newest_record_id='+newest_record_id+'&Action=' + now;						
			http.abort();
			http.open("POST", ajax_url, true);
			http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");			
			http.setRequestHeader("Content-length", post_data.length);
			http.setRequestHeader("Connection", "close");				
				  
		  http.onreadystatechange=function() 
		  {				  	
				  if(http.readyState == 4) 
				  {						  																					
				  				//	parent.document.getElementById('debug_window').innerHTML= ajax_url+'<br>'+http.responseText;
										 if(http.responseText != "" && http.responseText != "null")
										 {
										 			//parent.document.getElementById('debug_window').innerHTML= http.responseText;
													//alert(http.responseText);   
													//parent.document.getElementById('debug_window).innerHTML = http.responseText;
													if(http.responseText == "reload")
											  	{								 										  	
											 			 window.location = window.location.href;
											  	}
											  	else
											 		{			
															 	var row_array = eval("(" + http.responseText + ")");													
																for (row in row_array)
																{
																	for(row_state in row_state_array)
																	{
																				var row_state = row_state_array[row_state];																																	
																				var row_id = row_array[row]['id'];																
																				var row_status = row_array[row]['status'];																			
																				var number_of_matches = row_array[row]['number_of_matches'];		
																				var row_progress = row_array[row]['progress'];																			
																				var listeners = row_array[row]['listeners'];																			
																				if(row_progress)
																				{																					
																					if(document.getElementById('status_'+row_id))
																					{
																						document.getElementById('status_'+row_id).innerHTML=row_progress;
																					}
																				}
																				if(listeners > 0)
																				{
																					//parent.document.getElementById('debug_window').innerHTML= parent.document.getElementById('debug_window').innerHTML+'<BR>'+row_state+'_'+row_id+'_listeners';
																					document.getElementById(row_state+'_'+row_id+'_listeners').innerHTML= listeners;																																																																																				
																				}
																				
																				if(number_of_matches)
																				{																					
																					document.getElementById('number_of_matches_'+row_id).innerHTML=number_of_matches;
																				}
																				
																				if(row_status == row_state)
																				{
																					//alert(row_state+'_'+row_id);
																					if(document.getElementById(row_state+'_'+row_id)) document.getElementById(row_state+'_'+row_id).style.display='';
																				}
																				else
																				{
																					//parent.document.getElementById('debug_window').innerHTML= parent.document.getElementById('debug_window').innerHTML+'<BR>Hide'+row_state+'_'+row_id;
																					if(document.getElementById(row_state+'_'+row_id)) document.getElementById(row_state+'_'+row_id).style.display='none';
																				}																			
																		}											
																}														  
													}
								    	}
								    	if(status_timeout	< 2000) status_timeout = status_timeout+100;				
											setTimeout("start_ajax(row_state_array,ajax_name,post_data,newest_record_id)", status_timeout);									
					}
			}
			http.send(post_data);				
}



// ===================================================================
// Author: Matt Kruse <matt@mattkruse.com>
// WWW: http://www.mattkruse.com/
//
// NOTICE: You may use this code for any purpose, commercial or
// private, without any further permission from the author. You may
// remove this notice from your final code if you wish, however it is
// appreciated by the author if at least my web site address is kept.
//
// You may *NOT* re-distribute this code in any way except through its
// use. That means, you can include it in your product, or your web
// site, or any other form where the code is actually being used. You
// may not put the plain javascript up on your site for download or
// include it in your javascript libraries for download. 
// If you wish to share this code with others, please just point them
// to the URL instead.
// Please DO NOT link directly to my .js files from your site. Copy
// the files to your server and use them there. Thank you.
// ===================================================================

// HISTORY
// ------------------------------------------------------------------
// June 12, 2003: Modified up and down functions to support more than
//                selected option
/*
DESCRIPTION: These are general functions to deal with and manipulate
select boxes. Also see the OptionTransfer library to more easily 
handle transferring options between two lists

COMPATABILITY: These are fairly basic functions - they should work on
all browsers that support Javascript.
*/

// -------------------------------------------------------------------
// selectUnselectMatchingOptions(select_object,regex,select/unselect,true/false)
//  This is a general function used by the select functions below, to
//  avoid code duplication
// -------------------------------------------------------------------
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);
		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;
					}
				}
			}
		}
	}
		
// -------------------------------------------------------------------
// selectMatchingOptions(select_object,regex)
//  This function selects all options that match the regular expression
//  passed in. Currently-selected options will not be changed.
// -------------------------------------------------------------------
function selectMatchingOptions(obj,regex) {
	selectUnselectMatchingOptions(obj,regex,"select",false);
	}
// -------------------------------------------------------------------
// selectOnlyMatchingOptions(select_object,regex)
//  This function selects all options that match the regular expression
//  passed in. Selected options that don't match will be un-selected.
// -------------------------------------------------------------------
function selectOnlyMatchingOptions(obj,regex) {
	selectUnselectMatchingOptions(obj,regex,"select",true);
	}
// -------------------------------------------------------------------
// unSelectMatchingOptions(select_object,regex)
//  This function Unselects all options that match the regular expression
//  passed in. 
// -------------------------------------------------------------------
function unSelectMatchingOptions(obj,regex) {
	selectUnselectMatchingOptions(obj,regex,"unselect",false);
	}
	
// -------------------------------------------------------------------
// sortSelect(select_object)
//   Pass this function a SELECT object and the options will be sorted
//   by their text (display) values
// -------------------------------------------------------------------
function sortSelect(obj) {
	var o = new Array();
	if (obj.options==null) { 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);
		}
	}

// -------------------------------------------------------------------
// selectAllOptions(select_object)
//  This function takes a select box and selects all options (in a 
//  multiple select object). This is used when passing values between
//  two select boxes. Select all options in the right box before 
//  submitting the form so the values will be sent to the server.
// -------------------------------------------------------------------
function selectAllOptions(obj) {
	for (var i=0; i<obj.options.length; i++) {
		obj.options[i].selected = true;
		}
	}
	
// -------------------------------------------------------------------
// moveSelectedOptions(select_object,select_object[,autosort(true/false)[,regex]])
//  This function moves options between select boxes. Works best with
//  multi-select boxes to create the common Windows control effect.
//  Passes all selected values from the first object to the second
//  object and re-sorts each box.
//  If a third argument of 'false' is passed, then the lists are not
//  sorted after the move.
//  If a fourth string argument is passed, this will function as a
//  Regular Expression to match against the TEXT or the options. If 
//  the text of an option matches the pattern, it will NOT be moved.
//  It will be treated as an unmoveable option.
//  You can also put this into the <SELECT> object as follows:
//    onDblClick="moveSelectedOptions(this,this.form.target)
//  This way, when the user double-clicks on a value in one box, it
//  will be transferred to the other (in browsers that support the 
//  onDblClick() event handler).
// -------------------------------------------------------------------
function moveSelectedOptions(from,to,a,b,from_name,tab_title) {
	// Unselect matching options, if required
	if (arguments.length>3) {
		var regex = arguments[3];
		if (regex != "") {
			unSelectMatchingOptions(from,regex);
			}
		}
	// Move them over
	for (var i=0; i<from.options.length; i++) {
		var o = from.options[i];
		if (o.selected) {
			to.options[to.options.length] = new Option( o.text, o.value, false, false);
			}
		}
	// Delete them from original
	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;
	
	//update numbers		
	var number_of_unallocated = document.getElementById(from_name+'_drop').options.length;
	var number_of_allocated = document.getElementById(from_name+'_list[]').options.length;
	document.getElementById(from_name+'_drop_label').innerHTML = tab_title+" Unallocated("+number_of_unallocated+")";
	document.getElementById(from_name+'_list[]_label').innerHTML = tab_title+" Allocated("+number_of_allocated+")";
	
	}

// -------------------------------------------------------------------
// copySelectedOptions(select_object,select_object[,autosort(true/false)])
//  This function copies options between select boxes instead of 
//  moving items. Duplicates in the target list are not allowed.
// -------------------------------------------------------------------
function copySelectedOptions(from,to) {
	var options = new Object();
	for (var i=0; i<to.options.length; i++) {
		options[to.options[i].value] = to.options[i].text;
		}
	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) {
				to.options[to.options.length] = new Option( o.text, o.value, false, false);
				}
			}
		}
	if ((arguments.length<3) || (arguments[2]==true)) {
		sortSelect(to);
		}
	from.selectedIndex = -1;
	to.selectedIndex = -1;
	}

// -------------------------------------------------------------------
// moveAllOptions(select_object,select_object[,autosort(true/false)[,regex]])
//  Move all options from one select box to another.
// -------------------------------------------------------------------
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]);
		}
	}

// -------------------------------------------------------------------
// copyAllOptions(select_object,select_object[,autosort(true/false)])
//  Copy all options from one select box to another, instead of
//  removing items. Duplicates in the target list are not allowed.
// -------------------------------------------------------------------
function copyAllOptions(from,to) {
	selectAllOptions(from);
	if (arguments.length==2) {
		copySelectedOptions(from,to);
		}
	else if (arguments.length==3) {
		copySelectedOptions(from,to,arguments[2]);
		}
	}

// -------------------------------------------------------------------
// swapOptions(select_object,option1,option2)
//  Swap positions of two options in a select list
// -------------------------------------------------------------------
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;
	}
	
// -------------------------------------------------------------------
// moveOptionUp(select_object)
//  Move selected option in a select list up one
// -------------------------------------------------------------------
function moveOptionUp(obj) {
	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;
				}
			}
		}
	}

// -------------------------------------------------------------------
// moveOptionDown(select_object)
//  Move selected option in a select list down one
// -------------------------------------------------------------------
function moveOptionDown(obj) {
	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;
				}
			}
		}
	}

// -------------------------------------------------------------------
// removeSelectedOptions(select_object)
//  Remove all selected options from a list
//  (Thanks to Gene Ninestein)
// -------------------------------------------------------------------
function removeSelectedOptions(from) { 
	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; 
	} 

// -------------------------------------------------------------------
// removeAllOptions(select_object)
//  Remove all options from a list
// -------------------------------------------------------------------
function removeAllOptions(from) { 
	for (var i=(from.options.length-1); i>=0; i--) { 
		from.options[i] = null; 
		} 
	from.selectedIndex = -1; 
	} 

// -------------------------------------------------------------------
// addOption(select_object,display_text,value,selected)
//  Add an option to a list
// -------------------------------------------------------------------
function addOption(obj,text,value,selected) {
	if (obj!=null && obj.options!=null) {
		obj.options[obj.options.length] = new Option(text, value, false, selected);
		}
	}

