function playit(id)
{
window.open('/play.asp?id='+id,'1ting1','width=400,height=400');
}
function list()
{
window.open("about:blank","1tinglist");
}
function CheckOthers(form)
{
	for (var i=0;i<form.elements.length;i++)
	{
		var e = form.elements[i];
//		if (e.name != 'chkall')
			if (e.checked==false)
			{
				e.checked = true;// form.chkall.checked;
			}
			else
			{
				e.checked = false;
			}
	}
}

function CheckAll(form)
{
	for (var i=0;i<form.elements.length;i++)
	{
		var e = form.elements[i];
//		if (e.name != 'chkall')
			e.checked = true// form.chkall.checked;
	}
}

function od_add( aobj, flag)
{
	try
	{
		var width = 398;
		var height = 160;
		var left = ( screen.width - width ) / 2;
		var top = ( screen.height - height ) / 2;
		var href = aobj.href;
		var t = new Date();
		var time = Date.parse(t.toUTCString())/1000;
		href += '&t=' + time;
		var param = 'resizable=0, scrollbars=0, width=' + width + ', height=' + height + ', left=' + left + ', top=' + top;
		if(flag == 1) param += ',location=1';
		window.open( href, '_blank', param );
	}
	catch( e )
	{
		;
	}
	return false;
}
//musicbox
function SetCookie(sName,sValue)
{
	date = new Date();
	date.setYear(date.getYear()+10);
	document.cookie = sName + "=" + escape(sValue) + ";expires=" + date.toGMTString()+";path=/";
}
function GetCookie(sName)
{
	// cookies are separated by semicolons
	var aCookie = document.cookie.split(";");
	for (var i=0; i < aCookie.length; i++)
	{
		// a name/value pair (a crumb) is separated by an equal sign
		var aCrumb = aCookie[i].split("=");
		if (Trim(aCrumb[0])==sName)
		{
			return unescape(aCrumb[1]);
		}
	}
	// a cookie with the requested name does not exist
	return null;
}
function musicbox_read(list)
{
	var the_values = GetCookie("HansMusicBox");
	//alert("value:"+the_values);
	var values = new Array ();
	if(the_values != null )
	values = the_values.split("&");
	for (var i = 0 ; i < values.length ; i ++)
	{
		var items = values[i].split("#");
		var tmp_items = new Array ();
		tmp_items["song"] = items[0];
		tmp_items["singer"]= items[1];
		tmp_items["album"] = items[2];
		tmp_items["url"] = items[3];
		list[i] = tmp_items;
	}
}
function musicbox_write(list)
{
	var s = "";
	for(var i=0;i<list.length;i++)
	{
		var tmp_items = list[i];
		var s1 = tmp_items["song"]+"#"+tmp_items["singer"]+"#"+tmp_items["album"]+"#"+tmp_items["url"];
		if( i!=(list.length-1) )
			s = s+s1+"&";
		else
			s = s+s1;
	}
	SetCookie("HansMusicBox",s);
}
function musicbox_add(song,singer,album,url)
{
	try
	{
		var width = 398;
		var height = 160;
		var left = ( screen.width - width ) / 2;
		var top = ( screen.height - height ) / 2;
		var href = '/musicboxadd.htm?'+escape(song+'#'+singer+'#'+album+'#'+url);
		var param = 'resizable=0, scrollbars=0, width=' + width + ', height=' + height + ', left=' + left + ', top=' + top;
		window.open( href, '_blank', param );
	}
	catch( e )
	{
		return false;
	}
	return false
}
function musicbox_add1(song,singer,album,url)
{
	var list = new Array();
	musicbox_read(list);
	var tmp_items		= new Array();
	tmp_items["song"]	= song;
	tmp_items["singer"]	= singer;
	tmp_items["album"]	= album;
	tmp_items["url"]	= url;
	list[list.length]	= tmp_items;
	musicbox_write(list);
	//alert("已经加入音乐盒！");
}
function musicbox_delete(index)
{
	var list = new Array();
	musicbox_read(list);
	if (index>=0&&index<list.length)
	{
		for(var i=index;i<(list.length-1);i++)
			list[i]=list[i+1];
		list.pop();
	}
	musicbox_write(list);
}

function musicbox_up()
{
	try
	{
		var width = 310;
		var height = 160;
		var left = ( screen.width - width ) / 2;
		var top = ( screen.height - height ) / 2;
		var href = '/musicbox_up.asp';
		var param = 'resizable=0, scrollbars=0, width=' + width + ', height=' + height + ', left=' + left + ', top=' + top;
		window.open( href, 'musicbox_up', param );
	}
	catch( e )
	{
		;
	}
}

function musicbox_down()
{
	try
	{
		var width = 310;
		var height = 160;
		var left = ( screen.width - width ) / 2;
		var top = ( screen.height - height ) / 2;
		var href = '/musicbox_down.asp';
		var param = 'resizable=0, scrollbars=0, width=' + width + ', height=' + height + ', left=' + left + ', top=' + top;
		window.open( href, 'musicbox_down', param );
	}
	catch( e )
	{
		;
	}
}

/*
==================================================================
字符串操作
Trim(string):去除字符串两边的空格
==================================================================
*/
/*
==================================================================
LTrim(string):去除左边的空格
==================================================================
*/
function LTrim(str)
{
    var whitespace = new String(" \t\n\r");
    var s = new String(str);
    if (whitespace.indexOf(s.charAt(0)) != -1)
    {
        var j=0, i = s.length;
        while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
        {
            j++;
        }
        s = s.substring(j, i);
    }
    return s;
}
/*
==================================================================
RTrim(string):去除右边的空格
==================================================================
*/
function RTrim(str)
{
    var whitespace = new String(" \t\n\r");
    var s = new String(str);
	if (whitespace.indexOf(s.charAt(s.length-1)) != -1)
    {
        var i = s.length - 1;
        while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
        {
            i--;
        }
        s = s.substring(0, i+1);
    }
    return s;
}
/*
==================================================================
Trim(string):去除前后空格
==================================================================
*/
function Trim(str)
{
    return RTrim(LTrim(str));
}