document.write("<a name=\"0\"></a>");

//当前站点ID
var g_nSiteId = 53;
//当前站点名称
var g_sSiteName = "cgsan_eng";

var g_ROOTPATH = "/chn/";

function setRootPath( p_sPath ){
	g_ROOTPATH = p_sPath;
}

function main_writeHeader()
{
	document.write("<TR><TD><IMG SRC=" + g_ROOTPATH + "images/top.gif></TD></TR>");
}

function main_writeSearch()
{
	var sUrl = "http://211.99.196.31/search/new/se.jsp";
	var sHtml = "<form method=post action=\""+sUrl+"\">";
	sHtml += "<input type=hidden name=siteid value=\""+g_nSiteId+"\">";
	sHtml += "<input type=hidden name=sitename value=\""+g_sSiteName+"\">";
	sHtml += "<DIV ALIGN='center'>"+
				          "<input type='text' name='sw' size='20'><br>"+
				          "<select name='select' size='1' >"+
				            "<option value=1>This Site</option>"+
							"<option value=0>All Site</option>"+
				          "</select>"+
						  "<input type='submit' name='Submit' value='Search'>"+
				    "</DIV>";
	sHtml += "</form>";
	document.write(sHtml);
}

function main_dateSearch()
{		
	//定义时间函数
	var now = new Date();
	var nowYear = now.getYear();
	var nowMonth = (now.getMonth() + 1);
	var nowDay = now.getDate();
	
	var chnlid;
	chnlid = document.getElementsByTagName("META").item("ChannelID").content;
		
	//var nowDay = new Date(); //why@2003-08-31

	document.write("<form name='frmSearch' action='http://211.99.196.31/search/new/eng_sse.jsp' method=post>");
	document.write("<TABLE cellSpacing='0' cellPadding='0' border='0' bFontSize='FALSE' styleType='0'><TR height=10>");
    document.write("      <TD>&nbsp;&nbsp;</TD></TR>");   
    document.write("<TR height=15>");
    document.write("<TD>");

	document.write("<select name=yf>");
    var i;
    for( i=1998;i<=nowYear;i++ ){
		document.write("<option value=\"" + i + "\" " + ((i == nowYear)?"selected":"") + ">" + i + "</option>");
    }
	document.write("</select>");
    document.write("Year");

    document.write("<select name=mf>");
    for( i=1;i<=12;i++ ){
		document.write("<option value=\"" + i + "\" " + ((i == nowMonth)?"selected":"") + ">" + i + "</option>");
    }
	document.write("</select>");
    document.write("Month");

	document.write("<select name=df>");
    for( i=1;i<=31;i++ ){
		document.write("<option value=\"" + i + "\" " + i + ">" + i + "</option>");
    }    
	document.write("</select>Day&nbsp;To&nbsp;");

	document.write("<select name=yt>");
    for( i=1998;i<=nowYear;i++ ){
		document.write("<option value=\"" + i + "\" " + ((i == nowYear)?"selected":"") + ">" + i + "</option>");
    }    
	document.write("</select>");
	document.write("Year");

    document.write("<select name=mt>");
    for( i=1;i<=12;i++ ){
		document.write("<option value=\"" + i + "\" " + ((i == nowMonth)?"selected":"") + ">" + i + "</option>");
    }
    document.write("</select>Month");

	document.write("<select name=dt>");
    for( i=1;i<=31;i++ ){
		document.write("<option value=\"" + i + "\" " + ((i == nowDay)?"selected":"") + ">" + i + "</option>");
    }
	document.write("</select>");

    document.write("Day&nbsp;&nbsp;</TD></TR>");
	document.write("<TR height='15'><TD>Keyword:&nbsp;<input type='text' name='sw' size='15'>&nbsp;&nbsp;"
					+"<input type='hidden' name='siteid' value='53'>"
					+"<input type='hidden' name='sitename' value='cgsan_eng'>"
					+"<input type='hidden' name='channelid'>"
					+"<input type='hidden' name='channelname' value=''>"
					+"<input type='hidden' name='select' value='1'>"
					+"<input type='submit' name='Submit' value='Search'>");
	document.write("</TD></TR>");
	document.write("</TABLE>");
	document.write("</form>");
	frmSearch.channelid.value=chnlid;
}

function main_writeFoot()
{
	document.write("<TR><TD WIDTH='100%' HEIGHT='66' BGCOLOR='#7F96BF' ALIGN='CENTER'>"
					+"<FONT SIZE='2' COLOR='#FFFFFF'>Copyright &reg; Consulate General of the People's Republic of China in San Francisco</FONT>"
					+"</TD></TR>");
}

 
 function main_doPrint()
{
	var str="<html>";
	var article;
	var css;
	var strAdBegin="<!--NEWSZW_HZH_BEGIN-->";
	var strAdEnd="<!--NEWSZW_HZH_END-->";
	var strFontSize='【<A href="javascript:doZoom(16)">大</A> <A href="javascript:doZoom(14)">中</A> <A href="javascript:doZoom(12)">小</A>】'
	var strdoPrint="doPrint()";
	var strTmp;
	
	css="<style>"
	+"td,.f12{font-size:12px}"
	+".f24 {font-size:24px;}"
	+".f14 {font-size:14px;}"
	+".title14 {font-size:14px;line-height:130%}"
	+".l17 {line-height:170%;}"
	+"</style>";
	
	str +=	css;
	str +=	'<meta http-equiv="content-type" content="text/html; charset=gb2312">';
	str +=	'<title>'+document.title+'</title>';
	str +=	"<body bgcolor=#ffffff topmargin=5 leftmargin=5 marginheight=5 marginwidth=5 onLoad='window.print()'>";
	str +=	"<center>";
	str +=	"<table width=700 border=0 cellpadding=0 cellspacing=20 bgcolor=#EDF0F5><tr><td>";
	
	article=document.getElementById('article').innerHTML;
	if(article.indexOf(strAdBegin)!=-1){
		str +=article.substr(0,article.indexOf(strAdBegin));
		strTmp=article.substr(article.indexOf(strAdEnd)+strAdEnd.length, article.length);
	}else{
		strTmp=article
	}
	//str +=strTmp.substr(0,strTmp.indexOf(strFontSize));
	//strTmp=strTmp.substr(strTmp.indexOf(strFontSize)+strFontSize.length, strTmp.length);
	str += strTmp;
	//str +=strTmp.substr(0,strTmp.indexOf(strdoPrint));
	//str +="window.print()";
	//str +=strTmp.substr(strTmp.indexOf(strdoPrint)+strdoPrint.length, strTmp.length);
	str +=	"</td></tr></table>";
	str += "<br><TABLE cellSpacing=0 cellPadding=0 width=700 border=0 align=center><TBODY><TR><TD height=10><IMG height='1' alt='' src='./7_c.gif' width='1' border='0'></TD></TR><TR><TD align=middle bgColor=#efefef>Copyright &copy; 2003, Ministry of Foreign Affairs of the People's Republic of China</TD></TR>	<TR><TD height=10><IMG height='1' alt='' src='./7_c.gif' width='1' border='0'></TD></TR><TR><TD align=middle>Contact us Address: No. 2, Chaoyangmen Nandajie, Chaoyang District, Beijing, 100701 Tel: 86-10-65961114 </TD></TR></TBODY></TABLE></CENTER></TD></TR></TBODY></TABLE>";
	str += "</center>";
	str +=	"</body></html>";
	document.write(str);
	document.close();
}

//推荐给朋友的新函数
function validate_form() {

	var str0,str1,str2,str3,str4,str;

	validity = true; // assume valid

	if (!check_email(document.Form2000.FriendEmail.value)) {
		validity = false;
		alert('您输入的Email无效或者为空！');
	}

	if( validity ) {
		str0="外交部网站推荐新闻";
		str1="您好!";
		str2="您的朋友向您推荐外交部网站新闻:";
		str3="“"+document.title+"”"+"\n\n链接网址：";
		str4=this.location;
		str=str0+"\n"+str1+"\n"+str2+"\n"+str3+"\n"+str4+"\n";
		document.Form2000.Context.value=str;

		document.Form2000.action="mailto:"+document.Form2000.FriendEmail.value+"?\&amp;Subject=推荐新闻";
	}
	return validity;
}

//推荐给朋友的新函数2
function validate_form2() {

	var str0,str1,str2,str3,str4,str;

	validity = true; // assume valid

	if (!check_email(document.Form2003.FriendEmail2.value)) {
		validity = false;
		alert('您输入的Email无效或者为空！');
	}

	if( validity ) {
		str0="外交部网站推荐新闻";
		str1="您好!";
		str2="您的朋友向您推荐外交部网站新闻:";
		str3="“"+document.title+"”"+"\n\n链接网址：";
		str4=this.location;
		str=str0+"\n"+str1+"\n"+str2+"\n"+str3+"\n"+str4+"\n";
		document.Form2003.Context2.value=str;

		document.Form2003.action="mailto:"+document.Form2003.FriendEmail2.value+"?\&amp;Subject=推荐新闻";
	}
	return validity;
}

//判断用户填写的EMail是否有效函数
function check_email( address ) {
	if( (address=="")||(address.indexOf('@')==-1)||(address.indexOf('.')==-1) )
		return false;

	return true;
}