//以下是打印当前浏览页面
function PrintIt()
{
	var IE5 = ((navigator.appVersion.indexOf("MSIE") != -1) && (navigator.appVersion.substr(22,1) >= 5)) ? 1 : 0;
	var NS = (navigator.appName == 'Netscape') ? 1 : 0;
	if ((IE5) || (NS))
	{
		window.print();
	}
	else
	{
		alert("您用的是IE4.0，不支持直接打印。请用\n\nCtrl+p或单击鼠标右键,选菜单中的[打印]！");
	}
}

//以下是保持左边BORDER随窗口内容滚动而自动滚动
function KB_keepItInIE(theName, theWantTop, theWantLeft)
{
	theRealTop = parseInt(document.body.scrollTop);
	theTrueTop = theWantTop+theRealTop;
	document.all[theName].style.top = theTrueTop;
	theRealLeft = parseInt(document.body.scrollLeft);
	theTrueLeft = theWantLeft+theRealLeft;
	document.all[theName].style.left = theTrueLeft;
}

function KB_keepItInNN(theName, theWantX, theWantY)
{
	theRealLay = document.layers[theName];
	theBadX = self.pageYOffset;
	theBadY = self.pageXOffset;
	theRealX = theBadX+theWantX;
	theRealY = theBadY+theWantY;
	theRealLay.moveTo(theRealY, theRealX);
}

IE4 = (document.all) ? 1 : 0;
NN4 = (document.layers) ? 1 : 0;
if (document.all.border)//检测当前页面中是否有ID为"border"的层
{

	if (IE4)
	{
		setInterval('KB_keepItInIE("border",0,0)',1);
	}

	if (NN4)
	{
		setInterval('KB_keepItInNN("border",0,0)',1);
	}
}

//以下是双击自动滚屏
var currentpos, timer4ScrollWin;
function Init4ScrollWin()
{
	timer4ScrollWin = setInterval("ScrollWin()", 50);
}

function StopScrollWin()
{
	clearInterval(timer4ScrollWin);
}

function ScrollWin()
{
	currentpos = document.body.scrollTop;
	window.scroll(0, ++currentpos);
	if (currentpos != document.body.scrollTop)
	{
		StopScrollWin();
	}
}

document.onmousedown=StopScrollWin;
document.ondblclick=Init4ScrollWin;


/*
Function: Draw bottom with classname char
  Author: Purple Endurer
   Input: strMainID -- The ID of main label
		  strBtmID  -- The ID of bottom label
		  strColor  -- The bottom char color
		  strBgcolor-- The bottom color
		  nMainTop  -- The top of main label
		  nMainLeft -- The left of main label
  Output: (none)
*/
function DrawBottom(strMainID, strBtmID, strColor, strBgcolor, nMainTop, nMainLeft)
{
	var show = document.getElementById(strMainID);
	var BtmfontSize = parseInt(show.style.fontSize) * 0.8;
	nBtmCharNum = Math.round(show.offsetWidth / BtmfontSize);
	var str = "<B>" + new Array(nBtmCharNum).join(show.className) +"</B>";
	var elm = document.getElementById(strBtmID);
	elm.innerHTML = str;

	with (elm.style)
	{
		position="absolute";
		fontSize = BtmfontSize;
		top = nMainTop + show.offsetHeight * 1.5;
		left = nMainLeft + show.offsetLeft;
		width = show.offsetWidth;
		color = strColor;
		backgroundColor = strBgcolor;
		overflow = "hidden";
	}
}


function WriteBodyMagin()
{
	var BodyLeftMargin = 0;
	var BodyRightMargin = 0;

	if (screen.width > 800)
	{
		BodyRightMargin = BodyLeftMargin = (screen.width - 800)/2;
	}

	document.write("<BODY style='margin-left=" + BodyLeftMargin + "; margin-right=" + BodyRightMargin + "';>");
}


/*
Function: Write page link in the index page
  Author: Purple Endurer
   Input: strChannelName	-- the channel name of index page
		  iPageCount		-- The count of all pages
		  iFirstPageNo		-- The first page NO of the file name
		  iCurrentPageNo	-- current index page NO
  Output: (none)
*/

function WritePageLink(strChannelName, iPageCount, iFirstPageNo, iCurrentPageNo)
{
	document.write('<TABLE WIDTH=100% style="border-bottom: 2 #33FF00 solid; margin-top: 20;"><TR><TD style="color:#33FF00;font-size:24; margin: 15 0 0 0; font-weight: bolder; filter: Shadow(color=#999999,direction=140); text-align:center;">' + strChannelName + '&nbsp;[' + iCurrentPageNo + ']</TD>');
	
	document.write('<TD align=right>&nbsp;&nbsp;共' + iPageCount + '页：');

	var i = 1;

	for (j = iFirstPageNo; i <= iPageCount; i++, j++)
	{
		if (i == iCurrentPageNo)
		{
			document.write('<b>' + i + '</b>&nbsp;');
		}
		else
		{
			document.write('<a href="list' + (j==0 ? '' : j) + '.htm" class="list">[' + i + ']</a>&nbsp;');
		}
	}
	document.write('</TD></TR></TABLE>');
}

//缩放对象. 调用方式: zoomObj(this)
function zoomObj(o)
{
	var zoom = parseInt(o.style.zoom, 10)||100;
	zoom += event.wheelDelta/12;
	if (zoom>0)
	{
		o.style.zoom=zoom+'%';
	}
	return false;
}

//输出LOGO 和 特色之乡图片
function writeHeadLogoPic1()
{
	document.write('<TABLE CELLPADDING="0" CELLSPACING="0" style="border:0; width:790"><TR><TD><IMG src="/images/logo.gif" style="filter:chroma(color=white);"></TD><TD><img name="ImgBox" src="/images/donglan_oil_chestnut.jpg" class="ImgBannar"></TD><TD><div id="banner_text" CLASS="Div4Img"></div></TD></TR></TABLE>');
}	//writeHeadLogoPic1()

String.prototype.trim = function() 
{ 
	return this.replace(/(^\s*)|(\s*$)/g, ""); 
} 

String.prototype.isNum  = function()
{
	return (/^(\-?)(\d+)$/.test(this));
}

function genSearch1(sTitle,sPath,sfsName)
{
	var sSite = "http://www.hcny.gov.cn" + sPath;
	var s ='<FIELDSET class="fs_g"><LEGEND><div class="fs_title_g"><nobr ID="Subject">&nbsp;&nbsp;';
	s += sTitle;
	s += '&nbsp;&nbsp;</nobr></div></LEGEND>';
	s += '<FORM name=gs action=\"http://www.google.com/custom\" method=get onmouseover="this.q.select();" onmouseout="this.q.blur();" title="先输入关键字，然后点击[检索]按钮">'
	s += '<style type="text/css">#ctl_txt {star: expression(onmouseover=function(){this.style.backgroundColor="#6699FF"},onmouseout=function(){this.style.backgroundColor="#FFFFFF"}) }</style>';
	s += '<CENTER><INPUT type="hidden" name="cof" VALUE="T:green;L:http://www.hcny.gov.cn/images/logo.gif;AH:center;VLC:#551A8B;GL:0;S:';
	s += sSite;
	s += ';">';
	s += '<INPUT type="hidden" name="domains" value="';
	s += sSite;
	s += '">';
	s += '<INPUT type="hidden" name="hl" value="zh-CN">';
	s += '<INPUT type="hidden" CHECKED name="sitesearch" value="';
	s += sSite;
	s += '">';
	s += '<INPUT maxLength="2048" style="border-style: solid; border-width: 1" name="q" ID="ctl_txt"><BR><BR>';
	s += '<INPUT type="submit" value="检索" name="btnG" style="background: #FFFF00"';
	if ("undefined" != typeof(sfsName))
	{
		s += " onclick=\"parent.document.frames[\'";
		s += sfsName;
		s += "\'].cols=\'10%, *\';\"";
	}
	s += '>　<INPUT type="button" value="帮助" name="btnHelp" onclick="window.open(';
	s += "'http://www.google.cn/support/', 'newwindow', 'top=100,left=200, width=530, height=180, scrollbars=yes')";
	s += '"  style="background: #99FF00">';
	s += '　<INPUT type="button" value="大全" name="btnAll" onclick="window.open(';
	s += "'http://www.google.com/intl/zh-CN/about.html', 'newwindow', 'top=100,left=200, width=530, height=180, scrollbars=yes')";
	s += '" style="background: #99FF00">';	s += '<BR>powered&nbsp;by<a href="http://www.google.com"><IMG SRC="/images/google.gif" border="0" ALT="点击这里可以使用最好的搜索引擎来检索信息！"  style="filter:chroma(color=white;"></a>';
	s += '</FORM><A HREF="/netres/sitescan.htm" target="_parent" class="list">站内Yahoo搜索……</a></CENTER><BR>';
	s += '</FIELDSET>';
	return s;
}

/*
功能：计算中文字符串的实际长度/字符数(把每个中文都换成**,然后求长度)
作者：meizz(梅花雪)
源自：http://community.csdn.net/Expert/topic/3679/3679503.xml?temp=.8518183
*/
String.prototype.lenB = function()
{
	return this.replace(/[^\x00-\xff]/g,"**").length;
}

function genSharCode()
{
	return "<script type=\"text\/javascript\" src=\"http:\/\/www.passit.cn\/js\/passit_default_new.js?pub=0&simple=1\" charset=\"UTF-8\"><\/script><script type=\"text\/javascript\">bookmark_service_div=\"kxzt,baiduHi,bookmark,baidu,douban,sohuweibo,163weibo,qqweibo,tianysq,shouji,tianyisq,taonw,baohw,renmk,msn,more\";bookmark_service=\"qqkj,sinaweibo,xnzt,qq,more\";<\/script><div class=\"passit_def_div\"><a class=\"passit_default\" href=\"http:\/\/www.passit.cn\/bookmark.html\" target=\"_blank\"><img src=\"http:\/\/www.passit.cn\/images\/de_passit_logo.gif\" align=\"absmiddle\">分享|<\/a><\/div>"; 
}


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;
