var g_ROOTPATH = "/eng/";

function setRootPath( p_sPath ){
	g_ROOTPATH = p_sPath;
}
var bBigSite = window.location.href.indexOf("gate/big5")<0?false:true;
//innerText 在firfox中兼容处理  ---start
function isIE(){ //ie?
   if (window.navigator.userAgent.toLowerCase().indexOf("msie")>=1) 
    return true; 
   else 
    return false; 
} 

if(!isIE()){ //firefox innerText define
   HTMLElement.prototype.__defineGetter__(     "innerText", 
    function(){
     var anyString = "";
     var childS = this.childNodes;
     for(var i=0; i<childS.length; i++) {
      if(childS[i].nodeType==1)
       anyString += childS[i].tagName=="BR" ? '\n' : childS[i].innerText;
      else if(childS[i].nodeType==3)
       anyString += childS[i].nodeValue;
     }
     return anyString;
    } 
   ); 
   HTMLElement.prototype.__defineSetter__(     "innerText", 
    function(sText){ 
     this.textContent=sText; 
    } 
   ); 
}
//innerText 在firfox中兼容处理  ---end
function menuFix() { 
var sfEls = document.getElementById("nav").getElementsByTagName("li"); 
var sfEls1 = document.getElementById("nav1").getElementsByTagName("li"); 
var sfEls2 = document.getElementById("nav2").getElementsByTagName("li"); 
var sfEls3 = document.getElementById("nav3").getElementsByTagName("li"); 
var sfEls4 = document.getElementById("nav4").getElementsByTagName("li"); 

for (var i=0; i<sfEls.length; i++) { 
sfEls[i].onmouseover=function() { 
this.className+=(this.className.length>0? " ": "") + "sfhover"; 
} 
sfEls[i].onMouseDown=function() { 
this.className+=(this.className.length>0? " ": "") + "sfhover"; 
} 
sfEls[i].onMouseUp=function() { 
this.className+=(this.className.length>0? " ": "") + "sfhover"; 
} 
sfEls[i].onmouseout=function() { 
this.className=this.className.replace(new RegExp("( ?|^)sfhover\\b"), 
""); 
} 
} 
for (var i=0; i<sfEls1.length; i++) { 
sfEls1[i].onmouseover=function() { 
this.className+=(this.className.length>0? " ": "") + "sfhover"; 
} 
sfEls1[i].onMouseDown=function() { 
this.className+=(this.className.length>0? " ": "") + "sfhover"; 
} 
sfEls1[i].onMouseUp=function() { 
this.className+=(this.className.length>0? " ": "") + "sfhover"; 
} 
sfEls1[i].onmouseout=function() { 
this.className=this.className.replace(new RegExp("( ?|^)sfhover\\b"), 
""); 
} 
} 
for (var i=0; i<sfEls2.length; i++) { 
sfEls2[i].onmouseover=function() { 
this.className+=(this.className.length>0? " ": "") + "sfhover"; 
} 
sfEls2[i].onMouseDown=function() { 
this.className+=(this.className.length>0? " ": "") + "sfhover"; 
} 
sfEls2[i].onMouseUp=function() { 
this.className+=(this.className.length>0? " ": "") + "sfhover"; 
} 
sfEls2[i].onmouseout=function() { 
this.className=this.className.replace(new RegExp("( ?|^)sfhover\\b"), 
""); 
} 
} 
for (var i=0; i<sfEls3.length; i++) { 
sfEls3[i].onmouseover=function() { 
this.className+=(this.className.length>0? " ": "") + "sfhover"; 
} 
sfEls3[i].onMouseDown=function() { 
this.className+=(this.className.length>0? " ": "") + "sfhover"; 
} 
sfEls3[i].onMouseUp=function() { 
this.className+=(this.className.length>0? " ": "") + "sfhover"; 
} 
sfEls3[i].onmouseout=function() { 
this.className=this.className.replace(new RegExp("( ?|^)sfhover\\b"), 
""); 
} 
} 
for (var i=0; i<sfEls4.length; i++) { 
sfEls4[i].onmouseover=function() { 
this.className+=(this.className.length>0? " ": "") + "sfhover"; 
} 
sfEls4[i].onMouseDown=function() { 
this.className+=(this.className.length>0? " ": "") + "sfhover"; 
} 
sfEls4[i].onMouseUp=function() { 
this.className+=(this.className.length>0? " ": "") + "sfhover"; 
} 
sfEls4[i].onmouseout=function() { 
this.className=this.className.replace(new RegExp("( ?|^)sfhover\\b"), 
""); 
} 
} 
} 


<!-------
//日期显示
function DateIndex()
{
date1=new Date()
y=date1.getYear()
d=date1.getDate()
m=date1.getMonth()
w=date1.getDay()

switch(w)
{
	case 0:(w='日');break
	case 1:(w='一');break
	case 2:(w='二');break
	case 3:(w='三');break
	case 4:(w='四');break
	case 5:(w='五');break
	case 6:(w='六');break
}
document.write('<font color=#000000 class=day>'+''+y+'年'+(m+1)+'月'+d+'日'+'&nbsp;&nbsp;')
document.write('&nbsp;星期'+w)
document.write('</font>')
}

<!-------
//日期显示
function Dat1()
{
date1=new Date()
y=date1.getYear()
d=date1.getDate()
m=date1.getMonth()
w=date1.getDay()

switch(w)
{
	case 0:(w='日');break
	case 1:(w='一');break
	case 2:(w='二');break
	case 3:(w='三');break
	case 4:(w='四');break
	case 5:(w='五');break
	case 6:(w='六');break
}
document.write('<font color=blue size=2px>'+''+y+'年'+(m+1)+'月'+d+'日'+'')
document.write('&nbsp;星期'+w)
document.write('</font>')
}

//提交表单验证
function checkform(form)
{
if(form.user.value==""||form.password.value=="")
{
alert("用户名和密码均必须填写！")
return
}
else
{
form.submit()
}
}

//首页页头导航


//打印函数
function 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;
	var strContent;
	var dtitle=document.getElementById('News_Body_Title').innerHTML;
	var dsubtitle=document.getElementById('News_Body_subitle').innerHTML;
	var dsource=document.getElementById('News_Body_source').innerHTML;
	var dtime=document.getElementById('News_Body_Time').innerHTML;
	css="\n<style>"
	+"\n td,.f12{font-size:12.0pt;line-height:150%}"
	+"\n .f24 {font-size:24px;}"
	+"\n .f14 {font-size:14px;}"
	+"\n .title14 {font-size:14px;line-height:130%}"
	+"\n .bt {font-size:16pt}"
	+"\n</style>";
	
	str +=	css;
	str +=	'\n<meta http-equiv="content-type" content="text/html; charset=utf-8">';
	str +=	'\n<title>'+document.title+'</title>';
	str +=  '\n<script language="javascript"> function createPageHTML( s1,s2,s3,s4 ){ } </script>';		
	str +=	"\n<body bgcolor=#ffffff topmargin=5 leftmargin=5 marginheight=5 marginwidth=5 onLoad='window.print()'>";
	str +=	"\n<center>";
	str +=	"\n<table width=650 border=0 cellpadding=0 cellspacing=0 bgcolor=#EDF0F5><tr><td style='padding-top:20px;' align='center'>";
	str +=	"<span style='font-size:16px;font-weight:bold;'>"+dtitle+"</span>";
	str +=	"</td></tr></table>";
	str +=	"\n<table width=650 border=0 cellpadding=0 cellspacing=0 bgcolor=#EDF0F5><tr><td style='padding:3px;' align='center'>";
	str +=	"<span style='font-size:16px;font-weight:bold;'>"+dsubtitle+"</span>";
	str +=	"</td></tr></table>";
	str +=	"\n<table width=650 border=0 cellpadding=0 cellspacing=0 bgcolor=#EDF0F5><tr><td style='padding:3px;' align='center'>";
	str +=	"<span style='font-size:16px;font-weight:bold;'>"+dsource+"</span>";
	str +=	"</td></tr></table>";
	str +=	"\n<table width=650 border=0 cellpadding=0 cellspacing=0 bgcolor=#EDF0F5><tr><td align='center'>";
	str +=	"<span style='font-size:14px;'>"+dtime+"</span>";
	str +=	"</td></tr></table>";
	str +=	"\n<table width=650 border=0 cellpadding=0 cellspacing=0 bgcolor=#EDF0F5><tr><td style='padding:20px'>";
	
	//wsw@2004-4-27 修改处理div的方式
	//var arDivs = document.getElementsByTagName('DIV');
	//for (var t=0; t<arDivs.length; t++)
	//{
	//	var objDiv = arDivs[t];
	//	if(objDiv.style.width == "600")
	//	{
	//		objDiv.removeAttribute('style');
	//		break;
	//	}
	//}
	
	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
	}
	//strTmp = strTmp.replace(/<div[^>]*>/ig,"");	//过滤掉</DIV>
	
	//wsw@2004-4-26 正则表达式中字符串提取功能([\s\S]*?)需要IE5.5以上版本才能支持
	strTmp = strTmp.replace(/<div[^>]*>([\s\S]*?)<\/div>/ig,"$1");	//过滤</DIV>
	//wsw@2004-4-26 分开处理替换<div>可以在IE5.0实现预览打印
	//strTmp = strTmp.replace(/<div[^>]*>/ig,"");
	//strTmp = strTmp.replace(/<\/div>/ig,"");

	strTmp = strTmp.replace(/width=760/ig,"width=100%");
	strTmp = strTmp.replace(/width=660/ig,"width=100%");
	str += strTmp;
	
	str +=	"</td></tr></table>";
	str += "<br><TABLE cellSpacing=0 cellPadding=0 width=650 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 style=font-size:14px>Embassy of the People's Republic of China in Kingdom of tonga  All Rights Reserved</TD></TR>	</TBODY></TABLE></CENTER></TD></TR></TBODY></TABLE>";
	str += "</center>";
	str +=	"</body></html>";
	document.write(str);
	document.close();
}

//文章推荐使用的函数
function openSendMail( sDocTitle ) {

	var sUrl = "http://app.fmprc.gov.cn/comments/send_mail.jsp?DocTitle="+sDocTitle+"&URL="+window.location.href;

	nWidth  = 430;
	nHeight = 230;

	var winMsg = open( sUrl,"","left=300,top=250,width="+nWidth+",height="+nHeight+",menubar=no,status=no,titlebar=no,resizable=no,scrollbars=no" );
			
	if( winMsg.opener==null ) {
		winMsg.opener = window;
	}
	winMsg.focus();
}


//推荐给朋友的新函数
function validate_form() {

	var str0,str1,str2,str3,str4,str;

	validity = true; // assume valid

	if (!check_email(document.Form2000.FriendEmail.value)) {
		validity = false;
		alert('Invalid Email Address!');
	}

	if( validity ) {
		str0="MFA Web Site Suggest This News";
		str1="Hello!";
		str2="Your Friend Suggests You To Read This New:";
		str3="\u201C"+document.title+"\u201D"+"\n\nLink Url:";
		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+"?Subject=Your Friend Suggests You To Read It";
	}
	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+"?Subject=推荐新闻";
	}
	return validity;
}

//判断用户填写的EMail是否有效函数
function check_email( address ) {
	if( (address=="")||(address.indexOf('@')==-1)||(address.indexOf('.')==-1) )
		return false;

	return true;
}

//打印函数(不带图片)
function doPrint_noImgs() {
	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;
	var strContent;
	
	css="\n<style>"
	+"\n td,.f12{font-size:12.0pt;line-height:150%}"
	+"\n .f24 {font-size:24px;}"
	+"\n .f14 {font-size:14px;}"
	+"\n .title14 {font-size:14px;line-height:130%}"
	+"\n .bt {font-size:16pt}"
	+"\n</style>";
	
	str +=	css;
	str +=	'\n<meta http-equiv="content-type" content="text/html; charset=utf-8">';
	str +=	'\n<title>'+document.title+'</title>';
	str +=  '\n<script language="javascript"> function createPageHTML( s1,s2,s3,s4 ){ } </script>';	
	str +=	"\n<body bgcolor=#ffffff topmargin=5 leftmargin=5 marginheight=5 marginwidth=5 onLoad='window.print()'>";
	str +=	"\n<center>";
	str +=	"\n<table width=650 border=0 cellpadding=0 cellspacing=0 bgcolor=#EDF0F5><tr><td style='padding:20px'>";
	
	//wsw@2004-4-27 修改处理div的方式
	//var arDivs = document.getElementsByTagName('DIV');
	//for (var t=0; t<arDivs.length; t++)
	//{
	//	var objDiv = arDivs[t];
	//	if(objDiv.style.width == "600")
	//	{
	//		objDiv.removeAttribute('style');
	//		break;
	//	}
	//}
	
	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
	}

	//strTmp = strTmp.replace(/<div[^>]*>/ig,"");	//过滤掉</DIV>
	
	//wsw@2004-4-26 正则表达式中字符串提取功能([\s\S]*?)需要IE5.5以上版本才能支持
	strTmp = strTmp.replace(/<div[^>]*>([\s\S]*?)<\/div>/ig,"$1");	//过滤</DIV>
	//wsw@2004-4-26 分开处理替换<div>可以在IE5.0实现预览打印
	//strTmp = strTmp.replace(/<div[^>]*>/ig,"");
	//strTmp = strTmp.replace(/<\/div>/ig,"");
	strTmp = strTmp.replace(/width=760/ig,"width=100%");
	strTmp = strTmp.replace(/width=660/ig,"width=100%");

	str += strTmp;
	
	str +=	"</td></tr></table>";
	str += "<br><TABLE cellSpacing=0 cellPadding=0 width=650 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 style=font-size:14px>中华人民共和国外交部 2003 版权所有 &reg;</TD></TR>	<TR><TD height=10><IMG height='1' alt='' src='./7_c.gif' width='1' border='0'></TD></TR><TR><TD align=middle style=font-size:14px>地址：北京市朝阳区朝阳门南大街 2 号&nbsp;&nbsp; 邮编：100701&nbsp;&nbsp;电话：86-10-65961114&nbsp;&nbsp;京ICP备06038296号</TD></TR></TBODY></TABLE></CENTER></TD></TR></TBODY></TABLE>";
	str += "</center>";
	str +=	"</body></html>";
	document.write(str);
	document.close();
	
	var imgs= document.getElementsByTagName("IMG");
	if(imgs.length){
		for(var i=0;i<imgs.length;i++){
			imgs[i].style.display="none";
		}
	} else {
		imgs.style.display="none";
	}
	
}

 function getElById(_sId){
             return document.getElementById(_sId);
            }
 

            //根据id获得指定元素的内部文本
            function getInnerTextById(_sElId){
             var oEl = getElById(_sElId);
             return oEl.childNodes[0].nodeValue;
            }
 
            //去除字符串左边的所有空格
            function LTrim( p_string ){
             var nLen = p_string.length;
             var nStartPose = 0;
             for(var i=0; i<nLen; i++){
              var sChar = p_string.charAt(i);
              if(sChar == ' ' || sChar == '　'){
               continue;
              }
 
              nStartPose = i;
              break;
             }
 
             return p_string.substring(nStartPose);
            }

function search_checkeng() {
var sword =document.getElementById("sw").value.replace(/^\s+|\s+$/g,"");
	
if (sword=='أدخل كلمة البحث الرئيسية') {
	alert('أدخل كلمة البحث الرئيسية!');
	return false;
} else {	
	return true;
	}
}
function ScrollImages()
{
	var demo=document.getElementById("demo");
	var demo1=document.getElementById("demo1");
	var demo2=document.getElementById("demo2");
	var speed=40 
	demo2.innerHTML=demo1.innerHTML 
	function Marquee(){ 
	if(demo2.offsetWidth-demo.scrollLeft<=0) 
	demo.scrollLeft-=demo1.offsetWidth 
	else{ 
	demo.scrollLeft++ 
	} 
	} 
	var MyMar=setInterval(Marquee,speed) 
	demo.onmouseover=function() {clearInterval(MyMar)} 
	demo.onmouseout=function() {MyMar=setInterval(Marquee,speed)} 	
}

function ScrollImgLeft(){  
           var speed=30;  
           var scroll_begin = document.getElementById("scroll_begin");  
           var scroll_end = document.getElementById("scroll_end");  
           var scroll_div = document.getElementById("scroll_div");  
           scroll_end.innerHTML=scroll_begin.innerHTML;  
           function Marquee(){  
              if(scroll_end.offsetWidth-scroll_div.scrollLeft<=0)  
                  scroll_div.scrollLeft-=scroll_begin.offsetWidth;  
              else  
                  scroll_div.scrollLeft++;  
             }  
         var MyMar=setInterval(Marquee,speed);  
         scroll_div.onmouseover=function() {clearInterval(MyMar);}  
         scroll_div.onmouseout=function() {MyMar=setInterval(Marquee,speed);}  
      } 

function displaySubMenu(li) {
    var subMenu = li.getElementsByTagName("ul")[0];
    subMenu.style.display = "block";
}
function hideSubMenu(li) {
    var subMenu = li.getElementsByTagName("ul")[0];
    subMenu.style.display = "none";
}

function main_writesearch()
{
	document.write('<div class="Left_Search">'+
					  '<form action="http://www.fmprc.gov.cn/wjb/eng_search.jsp" method="post" '+
					  'style="margin-bottom:0" onsubmit="return search_checkeng()">'+
				'<input type="hidden" name="siteid" value="5050" />'+
				'<input type="hidden" name="sitename" value="to_ara" />'+
				'<input type="text" name="sw" id="sw" onclick="'+"javascript:if(this.value=='أدخل كلمة البحث الرئيسية') this.value=''"+
				'" value="أدخل كلمة البحث الرئيسية" />'+
                   '<input id="submit" name="sw" type="image" src="'+g_ROOTPATH+'images/Search_Button.gif" />'+
                    '</form>'+
                '</div>');	
}


function main_writeheader()
{
	today=new Date();
		var hours = today.getHours();
		var minutes = today.getMinutes();
		var seconds = today.getSeconds();
		function initArray(){
		this.length=initArray.arguments.length
		for(var i=0;i<this.length;i++)
		this[i+1]=initArray.arguments[i]  }
		var d=new initArray("يوم الأحد","يوم الاثنين","يوم الثلاثاء","يوم الأربعاء","يوم الخميس","يوم الجمعة","يوم السبت"); 
		 document.write('<div class="Top_Index">'+
		'<div class="Time">'+'<span style="float:left;">'+d[today.getDay()+1]+'</span> <span style="float:right;">'+today.getDate()+'-'+(today.getMonth()+1)+'-'+today.getYear()+'</span>'+
		'</div>'+
            '<div class="Border">'+
                '<a onclick="this.style.behavior='+"'url(#default#homepage)';this.setHomePage('http://www.cascf.org/ara/');"+'" style="cursor:pointer;">اجعل موقعنا صفحتك الرئيسية</a> &nbsp;| &nbsp;<a href="../'+g_ROOTPATH+'chn">中文</a>'+
            '</div>'+
        '</div>'+
        '<div class="Top"></div>');
}


function main_writefooter()
{
	document.write('<div class="Body_Bottom">'+
        'جميع الحقوق محفوظة لدى وزارة خارجية جمهورية الصين الشعبية عام 2011 م<br />'+
        '<a href="mailto:focac@mfa.gov.cn">رقم التليفون</a> الاتصال بنا العنوان: رقم 2 الشارع الجنوبي، تشاو يانغ من، حي تشاو يانغ، مدينة'+
		' <a href="http://www.diantong21cn.com" target="_blank">Web Design:点通润和</a>'+
	'</div>');
}
