$(document).ready(function() {
	
	//选中右移
    var $chooseing_li = $("#chooseing li");
	$chooseing_li.live('click', function() {
		var mychoice = this.innerHTML;
		$(this).remove();
	    var ul = document.getElementById("selected");
		$(ul).append("<li>" + mychoice + "<input type='button' class='movedel'/><input type='button' class='movedown'/><input type='button' class='moveup'/></li>");
	   
	});
	
    //选中左移
	$('#selected li input.movedel').live('click', function() {	
		
		var mychoice = $(this).parents("li").text();
		
		$(this).parents("li").remove();
	    var ul = document.getElementById("chooseing");
		$(ul).append("<li>" + mychoice + "</li>");
	   
	});
	
	
		//上移
	
	$('#selected li input.moveup').live('click', function() {	
    	
        var li = $(this).parents("li");
        if (li.index() != 0) {
			li.fadeOut().fadeIn();
			li.prev().before(li);
		}
    });    
		
					
			 //下移
    var $down = $('#selected li input.movedown');
    var len = $down.length;
    $down.live('click', function() {	
    	
        var li = $(this).parents("li");
       
        if (li.index() != len) {
        	
			li.fadeOut().fadeIn();
            li.next().after(li);
        }
    });
    
    $('#okbutton .cancelinfo').click(function() {	
    	
//  	document.execCommand("Refresh");
        window.location.reload();
  //    window.location.href=window.location.href;
    });
    
     $('#okbutton .saveinfo').live('click', function() {
     	var lis = $('#selected li');
     	var len = lis.length;
     	var temp = "";
     	var selected = "";
     	
 	    for(var i=0; i<len;i++) {
 		   var selectedli = $(lis[i]).text();		   
 		   temp = selectedli;
 		   selected = selected + "," + temp;		   
    	}	    
 	    document.getElementById("selected_ops").value = selected.substring(1,selected.length);
   	
     });	
});


