function in_array(str,arr)
{
	for(var i=0;i<arr.length;i++)	if(str==arr[i])	return true;
	return false;
}

Array.prototype.unique = function()
{
	var a = [];
	for(var i=0;i<this.length;i++)
	{
		if(!in_array(this[i],a))	a.push(this[i]);
	}
	return a;
}

function _G(id)
{
	return document.getElementById(id);
}

function redirect(url)
{
	window.location.replace(url);
}

function get_ext(path)
{
	return path.substr(path.lastIndexOf('.') + 1, path.length).toLowerCase();
}

function is_image(ext)
{
	return $.inArray(ext,['jpg','gif','png','bmp','jpeg'])!=-1;
}

function preview(src,str,w)
{
	document.getElementById('message').style.display = (src || str) ? '' : 'none';
	$('#message').empty();
	if(!w)	var w=400;
	if(src)	$('#message').append(insert_img(decodeURIComponent(src),w));
	if(str)
	{
		$('#message').append('<p Style="width:'+w+'px;overflow:hidden;text-align:left;line-height:18px">'+(decodeURIComponent(str).replace(/\+/g,' '))+'</p>');
	}
}
function check_all(id)
{
	(id ? $('#'+id+' input[type="checkbox"][name!="chkall"]') : $('form input[type="checkbox"][name!="chkall"]')).each(function(){$(this).attr('checked',($(this).attr('checked') ? false : true))});
}
//jquery下显示采用display:block，这导致在火狐下的tbody格式乱套了
function show_hide(id)
{
	return _G(id).style.display = _G(id).style.display=='none' ? '' : 'none';
}
//删除指定节点
function $RN(id)
{
	_G(id).parentNode.removeChild(_G(id));
}
function $CE(tagName)
{
    return document.createElement(tagName);
}
function $RC(father,son)
{
	return _G(father).removeChild(_G(son)); 
}

if(typeof(decode)!='function')
{
	function decode(str)
	{
		return decodeURIComponent(str).replace(/\+/g,' ');
	}
}
