/*******************************************************************************
 * URI Setting
 ******************************************************************************/
/*
 * Moved to template header.tpl
var USERS_URI_SERVER_MAIN = "/";
var USERS_URI_SERVER_APP  = "/sale/";
var USERS_URI_SERVER_EXT  = "";
*/


/*******************************************************************************
 * Xhtml Target _blank
 *
 * @return void
 ******************************************************************************/
function externalLinks(){
	if(!document.getElementsByTagName) {
		return;
	}
	var anchors=document.getElementsByTagName("a");
	for (var i=0; i<anchors.length; i++) {
		var anchor=anchors[i];
		if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external") {
			anchor.target="_blank";
		}
	}
}
window.onload=externalLinks;



/*******************************************************************************
 * Add to bookmark e.g: <input type="button" value="Add To Bookmark"
 * onclick="addBookmark('GoodSourcing','http://www.goodsourcing.hk')"/>
 ******************************************************************************/
function addBookmark(title,url)
{
	if (window.sidebar)
	{
		window.sidebar.addPanel(title, url,"");
	}
	else if( document.all )
	{
		window.external.AddFavorite( url, title);
	}
	else if( window.opera && window.print )
	{
		return true;
	}
}// End





/*******************************************************************************
 * URL redirect
 *
 * @param targ
 * @param selObj
 * @param restore
 * @return
 ******************************************************************************/
function sRedirect(targ, selObj, restore)
{
	eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
	if (restore) selObj.selectedIndex=0;
}// End




/*******************************************************************************
 * Get random string
 *
 * @return
 ******************************************************************************/
function getStringRandom()
{
	return String(Math.random()).substr(3, 16);
}// End




/*******************************************************************************
 * ext substr
 *
 * @param xstr
 * @param xlength
 * @return
 ******************************************************************************/
function xsubString(xstr, xlength)
{
	if (xstr.length <= xlength)
	{
		return xstr;
	}
	else
	{
		return xstr.substr(0, xlength - 3) + '...';
	}
}// End



/*******************************************************************************
 * Print
 *
 * @param v
 * @return
 ******************************************************************************/
function echo(str)
{
	document.write(str);
}

/*******************************************************************************
 * replaceAll： eg: yourstring.replaceAll("要替换的字符", "替换成什么");
 ******************************************************************************/
String.prototype.replaceAll = function (AFindText,ARepText)
{
	raRegExp = new RegExp(AFindText,"g");
	return this.replace(raRegExp,ARepText);
}// End




/*******************************************************************************
 * 字符串前后空格处理。 如果想替换中间的空格，请用replaceAll方法。
 * 用法： String.trim();
 ******************************************************************************/
String.prototype.trim=function()
{
	return this.replace(/(^\s*)|(\s*$)/g,"");// 将字符串前后空格,用空字符串替代。
}// End




/*******************************************************************************
 * 编码HTML 和 解码Html。 在评论的时候为了防止用户提交带有恶意的脚本，可以先过滤HTML标签，过滤掉双引号，单引号，符号&，符号<，符号
 ******************************************************************************/
String.prototype.htmlEncode=function()
{
	return this.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\"/g,"&#34;").replace(/\'/g,"&#39;");
}// End

String.prototype.htmlDecode=function()
{
	return this.replace(/\&amp\;/g, '\&').replace(/\&gt\;/g, '\>').replace(/\&lt\;/g, '\<').replace(/\&quot\;/g, '\'').replace(/\&\#39\;/g, '\'');
}// End


/*******************************************************************************
 * Jquery 加载后的通用处理
 ******************************************************************************/
$(function()
{
	$("a").bind("focus",function(){if(this.blur) this.blur();});

	if($.browser.msie && /6.0/.test(navigator.userAgent))
	{
		$('.fls li, .DataDsBox .DataList .Records').hover(function(){
				$(this).addClass('hover');
			},function(){
				$(this).removeClass('hover');
			});
	}

});

