﻿// JScript 文件
//去除字符两边空格
function trim(str)
{
    return str.replace(/(^\s*)|(\s*$)/g, "");
}
//去除字符左边空格
function lTrim(str)
{
    return str.replace(/(^\s*)/g, "");
}
//去除字符右边空格
function rTrim(str)
{
    return str.replace(/(\s*$)/g, "");
}

//排序开始
function moveUp(obj)
{
if(obj==null) return;
with (obj){
	if(selectedIndex==0){
		options[length]=new Option(options[0].text,options[0].value);
		options[0]=null;
		selectedIndex=length-1;
		}
	else if(selectedIndex>0) moveG(obj,-1);
	}
}

function moveDown(obj)
{
if(obj==null) return;
with (obj){
	if(selectedIndex==length-1){
		var otext=options[selectedIndex].text;
		var ovalue=options[selectedIndex].value;
		for(i=selectedIndex; i>0; i--){
			options[i].text=options[i-1].text;
			options[i].value=options[i-1].value;
			}
		options[i].text=otext;
		options[i].value=ovalue;
		selectedIndex=0;
		}
	else if(selectedIndex>=0 && selectedIndex<length-1) moveG(obj,+1);
	}
}

function moveG(obj,offset)
{
if(obj==null) return;
//alert("11");
with (obj){
	var desIndex=selectedIndex+offset;
	var otext=options[desIndex].text;
	var ovalue=options[desIndex].value;
	options[desIndex].text=options[selectedIndex].text;
	options[desIndex].value=options[selectedIndex].value;
	options[selectedIndex].text=otext;
	options[selectedIndex].value=ovalue;
	selectedIndex=desIndex;
	}
}

function save1(obj)
{
	//alert(obj.options.length)
	var tmpstr="";
	for(i=0;i<obj.options.length;i++)
	{
		tmpstr+=obj.options[i].value+",";
		window.location="productclass.asp?action=sort&sortstr="+tmpstr;
	}
}
//排序结束