/**
 * 去除空白字符
 */
String.prototype.trim = function() 
{	
	return this.replace(/^\s+|\s+$/g,"");
}
String.prototype.ltrim = function() 
{	
	return this.replace(/^\s+/,"");
}
String.prototype.rtrim = function() 
{	
	return this.replace(/\s+$/,"");
}

/**
 * 选择语系
 */
function generalSelectLanguage(language)
{
	document.location.href = "./language.php?language=" + language;
}

/**
 * 得到子分类
 */
function generalGetSubSorts(type)
{
	if(type == "1")
	{
		var visibale = 1;
		var hidden = 2;
	}
	
	if(type == "2")
	{
		var visibale = 2;
		var hidden = 1;
	}
	
	var div = document.getElementById("div_sub_sort_" + visibale).style;
	div["position"] = "absolute";
	div["display"] = "";

	if(type == "1")
	{
		div["left"] = "255px";
		div["top"] = "320px";
	}

	if(type == "2")
	{
		div["left"] = "230px";
		div["top"] = "360px";
	}

	document.getElementById("div_sub_sort_" + hidden).style["display"] = "none";
}

/**
 * 搜索
 */
function generalSearch()
{
	try
	{
		if(document.getElementById("search").value.trim() == "")
		{
			alert(LANG_JS_SEARCH_IS_NOT_NULL);//搜尋條件不能為空
				document.getElementById("year").focus();
				return false;
		}
	}
	catch (e)
	{
		return false;
	}
	
	document.getElementById("form_search").submit();
}

/**
 * 回首页
 */
function generalGoHome()
{
	document.location.href = "index.php";
}

/**
 *
 */
function generalPageUpDown(type)
{
	var size = document.getElementById("ifr_intro").value;
	try//ie
	{
		if(type == "up")
			document.frames("ifr_intro").window.scroll(0, size - 300);
		if(type == "down")
			document.frames("ifr_intro").window.scroll(0, size + 300);
	}
	catch (e)//firefox
	{
		if(type == "up")
			document.getElementById("ifr_intro").contentDocument.body.scrollTop = size - 300;
		if(type == "down")
			document.getElementById("ifr_intro").contentDocument.body.scrollTop = size + 300;
	}

	document.getElementById("ifr_intro").value = ""
}