

var charset='GBK';
var url=location.href;
/*
 * this was not always work. In IE, if the referer using js to set
 * location.href, this will be null
 */
var referer=document.referrer;


if(document.charset)// IE
	charset=document.charset;
if(document.characterSet){// ff
	charset=document.characterSet;
	if(charset=='x-gbk')
		charset='gbk';
}
// alert(charset);
var cs=charset.toLowerCase();
if(cs.indexOf('gbk')==-1 && cs.indexOf('gb2312')==-1 && cs.indexOf('utf-8')==-1){
	// an unsupported charset, for the represent page contains chinese.
	// we expected the 'charset' attribute do the right thing here.
	// By the way, unicode doesn't work both in IE and FF.
	charset='GBK'
}
// alert(charset);

var selfHref='http://cms.tengshang.com/cms/browse/script.shtml?charset='+charset+'&url='+encodeURIComponent(url)+'&referer='+encodeURIComponent(referer);
document.write('<script type="text/javascript" charset="' + charset + '" src="' + selfHref + '"><\/script>');