window.status="欢迎光临黄金评论网 www.hjplw.com";

//======================================================
//背景缓存 消除IE鼠标划过背景闪烁
//Remove IE mouse flickering
//======================================================
try {
	document.execCommand("BackgroundImageCache", false, true);
}
catch(e) {}

//======================================================
//加入收藏
//======================================================
function addFavorite(url,name){	
	if (window.sidebar)
	{
		window.sidebar.addPanel(name, url, "");
	}
	else if( window.opera && window.print )
	{
		var mbm = document.createElement('a');
		mbm.setAttribute('rel','sidebar');
		mbm.setAttribute('href',url);
		mbm.setAttribute('title',name);
		mbm.click();
	}
	else if (document.all)
	{
		window.external.addFavorite(url,name);
	}
} 


//======================================================
//导航菜单背景css处理
//======================================================

function $(){
	var a=document.getElementById("mNav").getElementsByTagName("li");
	for(var i=0;i<a.length;i++){
		a[i].onmouseover=function(){
			this.tmpClass=this.className;
			this.className+="2";
		} ;
		a[i].onmouseout=function(){
			this.className=this.tmpClass;
		} 
	}
}
$();

//======================================================
//黄金价格换算
//======================================================
function Rmb2Dollar() {
	var d=document,$='getElementById',goldPrice=d[$]("goldPrice").value,rate=d[$]("rate").value,resultPrice=goldPrice * 31.1034768 / rate;
	d[$]('resultPrice').style.display = '' ;
	d[$]("resultPrice").innerHTML = "<span class='cc60'>"+ goldPrice +"</span>元/克 约为 <span class='cc60'>"+ resultPrice.toFixed(2) +"</span>美元/盎司";
}
function Dollar2Rmb() {
	var d=document,$='getElementById',goldPrice=d[$]("goldPrice").value,rate=d[$]("rate").value,resultPrice= goldPrice * rate / 31.1034768;
	d[$]('resultPrice').style.display = '' ;
	d[$]("resultPrice").innerHTML = "<span class='cc60'>"+ goldPrice +"</span>美元/盎司 约为 <span class='cc60'>"+ resultPrice.toFixed(2) +"</span>元/克";
}


//======================================================
//html传递参数
//======================================================
var LocString=String(window.document.location.href);   
function getQueryStr(str){   
	var rs = new RegExp("(^|)"+str+"=([^\&]*)(\&|$)","gi").exec(LocString), tmp; 
		if(tmp=rs){   
		return tmp[2];   
		} 
	return "";   
}


//======================================================
//DOM /flash插入
//======================================================
var Swf;
function Swf(vars,swf,w,h,bg,v) {
    this._vars = vars;
    this._swf = swf;
    this._w = w;
    this._h = h;
    this._bg = bg;
    this._v = v;
}
	//Swf.prototype.flashvars = function(str) {
	//    var uri = top.window.location.href;
	//    this._vars = str + "&request_uri=" + uri;
	//}
Swf.prototype.write = function() {
    var out = "";
    if (navigator.plugins && navigator.mimeTypes && navigator.mimeTypes.length) {
        out += '<embed flashvars="'+this._vars+'" src="'+this._swf+'" width="'+this._w+'" height="'+this._h+'" bgcolor="'+this._bg+'"';
        out += ' quality="high" menu="false" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"';
        out += ' />'
    } else {
        out += '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"';
        out += ' codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version='+this._v+'"';
        out += ' width="'+this._w+'" height="'+this._h+'">';
        out += ' <param name="movie" value="'+this._swf+'" />';
        out += ' <param name="bgcolor" value="'+this._bg+'" />';
        out += ' <param name="flashvars" value="'+this._vars+'" />';
        out += ' <param name="allowScriptAccess" value="sameDomain" />';
		out += ' <param name="wmode" value="transparent" />';
        out += ' <param name="quality" value="high" />';
        out += ' <param name="menu" value="false" />';
        out += '</object>';
    }
    document.write(out);
}

//======================================================
//右键加入收藏
//======================================================
function right(mousebutton){
	if (navigator.appName == 'Netscape' && mousebutton.which==3){ 
		addFavorite('http://www.hjplw.com/','黄金评论网') 
		return false; 
	}else 	if (navigator.appName == 'Netscape' && mousebutton.which==2) { 
		addFavorite('http://www.hjplw.com/','黄金评论网') 
		return false; 
	}else if (navigator.appName == 'Microsoft Internet Explorer' && event.button == 2) { 
		addFavorite('http://www.hjplw.com/','黄金评论网') 
		return false; 
	}
	return true;

} 
//document.onmousedown = right;


//======================================================
//点击复制本页网址
//======================================================
function copyToClipBoard(){
	var title = document.getElementById("title").innerHTML;
	var url = location.href;
	var clipBoardContent = ''; 
	clipBoardContent = title + "\r\n" + url;
	
	if (window.clipboardData){	//IE
		window.clipboardData.setData("Text",clipBoardContent);
		//alert("你已复制链接及标题，请粘贴到QQ/MSN/POPO/UC等发给好友!");
	}
	else if (window.netscape){	//mozilla
		netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
		var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);
		if (!clip) return;
		var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);
		if (!trans) return;
		trans.addDataFlavor('text/unicode');
		var str = new Object();
		var len = new Object();
		var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
		var copytext=clipBoardContent;
		str.data=copytext;
		trans.setTransferData("text/unicode",str,copytext.length*2);
		var clipid=Components.interfaces.nsIClipboard;
		if (!clip) return false;
		clip.setData(trans,null,clipid.kGlobalClipboard);
	}
	return false;
}


//======================================================
//文章图片宽度太大进行缩放
//======================================================
function ReImgSize(){
	var g=document.getElementById("main").getElementsByTagName("image")
	for (i=0;i<g.length;i++){
		if (document.getElementsByName("image")){
			if (g[i].width>535){
			   g[i].width="535"
			   try{
				   g[i].outerHTML='<a href="'+g[i].src+'" target="_blank" title="在新窗口打开图片">'+g[i].outerHTML+'</a>'
				}catch(e){}
			}
		}else{
			if (g[i].width>400){
				g[i].title="在新窗口打开图片"
				g[i].style.cursor="pointer"
				g[i].onclick=function(e){window.open(this.src)}
			}
		}
	}
}
ReImgSize();