/* JQuery for 對折王廣告*/
document.write('<script type="text/javascript" language="JavaScript" src="http://www.nownews.com/include_ver8/js/jquery-1.3.2.min.js"></script>');

/* 修正 IE6 a:hover 背景圖片問題
---------------------------------- */
try {
  document.execCommand("BackgroundImageCache", false, true);
} catch(err) {}

/* 修正 IE6 透明 PNG 問題
---------------------------------- */
function correctPNG() {
	for(var i=0; i<document.images.length; i++) {
		var img = document.images[i]
		var imgName = img.src.toUpperCase()
		if (imgName.substring(imgName.length-3, imgName.length) == "PNG") {
			var imgID = (img.id) ? "id='" + img.id + "' " : ""
			var imgClass = (img.className) ? "class='" + img.className + "' " : ""
			var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
			var imgStyle = "display:inline-block;" + img.style.cssText 
			if (img.align == "left") imgStyle = "float:left;" + imgStyle
			if (img.align == "right") imgStyle = "float:right;" + imgStyle
			if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
			var strNewHTML = "<span " + imgID + imgClass + imgTitle
			+ " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
			+ "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
			+ "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
			img.outerHTML = strNewHTML
			i = i-1
		}
	}
}
if (document.all) {
	window.attachEvent("onload", correctPNG);
}

/* 顯示/隱藏內容
--------------------------------------- */
function ShowHide(SwitchID,OpenID,CloseID) {
	var vobj;
	// SwitchID 開與關循環
	if (SwitchID > ''){
		vobj=document.getElementById(SwitchID);
		if (vobj.style.display=='') {
			vobj.style.display='none';
		} else {
			vobj.style.display='';
		}
	}
	
	// OpenID 只開不關
	if (OpenID > ''){
		vobj=document.getElementById(OpenID);
		vobj.style.display='';
	}	

	// CloseID 只關不開
	if (CloseID > ''){		
		vobj=document.getElementById(CloseID);
		vobj.style.display='none';
	}
}

/* 變換首頁頭條123
---------------------------------------------- */
function switch_headline(HeadlineID) {
	var h1;
	var h2;
	var h3;	
	var img1;
	var img2;
	var img3;	
	h1=document.getElementById('headline_1');
	h2=document.getElementById('headline_2');
	h3=document.getElementById('headline_3');
	img1=document.getElementById('head_1');
	img2=document.getElementById('head_2');
	img3=document.getElementById('head_3');	

	// 頭條1
	if (HeadlineID == '1'){
		h1.style.display='';
		h2.style.display='none';
		h3.style.display='none';
		img1.src='http://www.nownews.com/include_ver8/images/now_1over.gif';
		img2.src='http://www.nownews.com/include_ver8/images/now_2up.gif';
		img3.src='http://www.nownews.com/include_ver8/images/now_3up.gif';
	}	

	// 頭條2
	if (HeadlineID == '2'){
		h1.style.display='none';
		h2.style.display='';
		h3.style.display='none';	
		img1.src='http://www.nownews.com/include_ver8/images/now_1up.gif';
		img2.src='http://www.nownews.com/include_ver8/images/now_2over.gif';
		img3.src='http://www.nownews.com/include_ver8/images/now_3up.gif';
	}	
	
	// 頭條3
	if (HeadlineID == '3'){
		h1.style.display='none';
		h2.style.display='none';
		h3.style.display='';	
		img1.src='http://www.nownews.com/include_ver8/images/now_1up.gif';
		img2.src='http://www.nownews.com/include_ver8/images/now_2up.gif';
		img3.src='http://www.nownews.com/include_ver8/images/now_3over.gif';
	}	
}

/*  改變新聞字體大小
------------------------------------------------ */
function biggerfont() {
  document.getElementById('news_content').style.fontSize="19px";
}

function mediumfont() {
  document.getElementById('news_content').style.fontSize="15px";
}

function smallfont() {
  document.getElementById('news_content').style.fontSize="13px";
}

/*  改變圖片
------------------------------------------------ */
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

/*  Jump Menu
------------------------------------------------- */
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

/* Google廣告*/
document.write('<script type="text/javascript" language="JavaScript" src="http://www.nownews.com/include_ver8/js/googleAD.js"></script>');

/* 延遲顯示圖片*/
//document.write('<script type="text/javascript" language="JavaScript" src="http://www.nownews.com/include_ver8/js/jquery.lazyload.js"></script>');

/* 左欄廣告修正*/
//document.write('<script type="text/javascript" language="JavaScript" src="http://www.nownews.com/include_ver8/js/left_adfix.js">
//<
//script>');