var oldsite="";
var XMLHttp={_objPool: [],_getInstance: function(){for(var i=0;i<this._objPool.length;i++){if(this._objPool[i].readyState==0||this._objPool[i].readyState==4){return this._objPool[i];}}this._objPool[this._objPool.length]=this._createObj();return this._objPool[this._objPool.length-1];},_createObj: function (){if(window.XMLHttpRequest){var objXMLHttp=new XMLHttpRequest();}else{var MSXML=['MSXML2.XMLHTTP.5.0', 'MSXML2.XMLHTTP.4.0', 'MSXML2.XMLHTTP.3.0', 'MSXML2.XMLHTTP','Microsoft.XMLHTTP'];for(var n=0; n<MSXML.length; n ++){try{var objXMLHttp=new ActiveXObject(MSXML[n]);break;}catch(e){}}}/*some versions of mozilla don't readyState property*/if(objXMLHttp.readyState==null){objXMLHttp.readyState=0;objXMLHttp.addEventListener("load",function(){objXMLHttp.readyState=4;if(typeof objXMLHttp.onreadystatechange=="function"){objXMLHttp.onreadystatechange();}},false);}return objXMLHttp;},sendReq: function (method,url,data,callback,arg1){var objXMLHttp=this._getInstance();with(objXMLHttp){try{if(url.indexOf("?") > 0){url+="&randnum=" + Math.random();}else{url+="?randnum=" + Math.random();}open(method,url,true);setRequestHeader('Content-Type','application/x-www-form-urlencoded; charset=UTF-8');onreadystatechange=function (){if(objXMLHttp.readyState == 4 && (objXMLHttp.status == 200 || objXMLHttp.status == 304)){callback(objXMLHttp,arg1);}}}catch(e){alert(e);}send(data);}}};
var BrowserType=detectBrower();function detectBrower(){var sUserAgent=navigator.userAgent;var isOpera=sUserAgent.indexOf("Opera")>-1;if(isOpera)return "Opera";var isKHTML=sUserAgent.indexOf("KHTML")>-1 || sUserAgent.indexOf("Konqueror")>-1 || sUserAgent.indexOf("AppleWebKit")>-1;var isSafari=sUserAgent.indexOf("AppleWebKit")>-1 && isKHTML;var isKonq=sUserAgent.indexOf("Konqueror")>-1 && isKHTML;if(isSafari) return "Safari";if(isKonq) return "Konqueror";var isIE7=sUserAgent.indexOf("compatible")>-1&&sUserAgent.indexOf("MSIE 7.0")>-1&&!isOpera;var isIE6=sUserAgent.indexOf("compatible")>-1&&sUserAgent.indexOf("MSIE 6.0")>-1&&!isOpera;if(isIE7) return "IE7";else if(isIE6) return "IE6";var isMoz=sUserAgent.indexOf("Gecko")>-1 && !isKHTML;if(isMoz) return "Mozilla";return "None";}
if(BrowserType=="Mozilla"||BrowserType=="Safari"){HTMLElement.prototype.removeNode=function(){this.parentNode.removeChild(this);};extendEventObject();emulateAttachEvent();var eventArr=["click","dblclick","mouseover","mouseout","mousedown","mouseup","mousemove","keydown","keypress","keyup"];emulateEventHandlers(eventArr);emulateCurrentStyle();Event.LEFT=0;Event.MIDDLE=1;Event.RIGHT=2;}else{Event={};Event.LEFT=1;Event.MIDDLE=4;Event.RIGHT=2;}
function getscrollHeight(){return Math.max(document.body.scrollHeight,document.documentElement.clientHeight);}
var gDivMask=null;function showMaskDiv(bgclr,op){if(gDivMask==null||!gDivMask){var str;gDivMask=document.createElement("DIV");switch(BrowserType){case "Opera":case "Safari":str="opacity:"+op+";";break;case "Mozilla":str="-moz-opacity:"+op+";";break;default:str="filter:alpha(opacity="+(op*100)+");";break;}gDivMask.style.cssText="position:absolute;top:0px;left:0px;height:"+getscrollHeight()+"px;width:"+document.body.clientWidth+"px;background-color:"+bgclr+";"+str;document.body.appendChild(gDivMask);}}function closeMaskDiv(){if(gDivMask==null)return;document.body.removeChild(gDivMask);gDivMask=null;}
var	gDivData=null;function createDataDiv(){var newdiv;newdiv=document.createElement("DIV");var left=(document.body.clientWidth-400)/2;var top=Math.max(document.documentElement.scrollTop, document.body.scrollTop)+100;var str='background-color:#fff;font-size:10pt;z-index:100;position:absolute;left:'+left+'px;top:'+top+'px;';newdiv.style.cssText=str;return newdiv;}
function closeDataDiv(){if(gDivData==null)return;document.body.removeChild(gDivData);gDivData=null;closeMaskDiv();return false;}
function changecity(lang)
{
	var obj=document.getElementById("cbocity");
	var selected = obj.options[obj.selectedIndex];
	document.cookie = "rbncityname="+encodeURIComponent(selected.value)+"; expires="+(new Date(Date.parse(new Date())+(1000*60*60*24*365)).toGMTString())+"; path=/";
	if (lang == 'zh-CN')
    	top.location.href="/city/";
    else
    	top.location.href="/city/zh-TW/";
}
function doFix()
{
/*	var blankImg = '<?php echo JURI::base(); ?>modules/mod_jweather/tmpl/blank.gif';
	var jwObject = $('jweather_<?php echo $params->get('idname'); ?>');

	var elements = jwObject.getElements('img');
	elements.each(function(el){
		var src = el.src;

		// test for png
		if ( /\.png$/.test( src.toLowerCase() ) && el.getStyle('filter') == '' ) {
			if (el.currentStyle.width == 'auto' && el.currentStyle.height == 'auto')
			{
				el.style.width = el.offsetWidth + 'px';
				el.style.height = el.offsetHeight + 'px';
			}

			// set filter
			el.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" +
				                        src + "',sizingMethod='scale')";
			// set blank image
			el.src = blankImg;
		}
		else
		{
			// remove filter
			el.runtimeStyle.filter = "";
		}
	});
*/
}
function did(objID){return document.getElementById(objID);}
function DoWstr(DoWk) {return "SunMonTueWedThuFriSatSun".substr(3*DoWk, 3)};
function LZ(x){return (x>=10||x<0?"":"0") + x; }
function PadZero(num){return num;}
function buildTime(srvtime,texttodisp,timeoffset,dst)
      {
        if(dst=="*"){var dispflag="*";}else {var dispflag="&nbsp;";}
        houris=srvtime.getUTCHours();
        minis =srvtime.getUTCMinutes();
        secondis=srvtime.getUTCSeconds();
        
        yy=Math.abs(parseInt(secdiff/1000));
        adjminadd=yy % 60;
        zz=yy%60;
        yy=(yy-adjminadd)/60;
        if (secdiff<0){yy=yy*(-1);}
        if (secdiff<0){zz=zz*(-1);}
        Y = Math.abs(timeoffset);
        minadd = parseInt(Y % 60);
        Y=(Y-minadd)/60;
        if(timeoffset<0){Y=Y*(-1);if(minadd!=0){Y=Y-1;}}
        calcseconds=Math.abs(secondis)+zz;
        calcminutes=Math.abs(minis+minadd)+yy;
       // calcminutes=Math.abs(minis+timeoffset)+yy;
        calchours=houris+Y;
        
with (N = new Date()) {	
	N.setUTCHours(calchours,calcminutes,calcseconds);
	curdate=N.getUTCFullYear()+"/"+(N.getUTCMonth()+1)+"/"+N.getUTCDate();
	if(DispDay){dayofweek="("+DoWstr(N.getUTCDay())+")";}else{dayofweek="";}
    return spantxt+texttodisp+"<\/span>&nbsp;"+spantxt2+curdate+" "+LZ(N.getUTCHours())+":"+LZ(N.getUTCMinutes())+dispflag+" "+dayofweek+"<\/span>";
    }     
}                   
function RunTZclock(){
      var srvtime=new Date();
      var Q=srvtime.getTime();
      RunTZclockTimer=setTimeout("RunTZclock()", 1000-Q%1000);
      if(typeof z1text!="undefined")
            {var time1=buildTime(srvtime,z1text,z1time,z1dst);
            if(did("RC1"))did("RC1").innerHTML=time1;}
      if(typeof z2text!="undefined")
            {var time2=buildTime(srvtime,z2text,z2time,z2dst);
            if(did("RC2"))did("RC2").innerHTML=time2;}
      if(typeof z3text!="undefined")
            {var time3=buildTime(srvtime,z3text,z3time,z3dst);
            if(did("RC3"))did("RC3").innerHTML=time3;}
      if(typeof z4text!="undefined")
            {var time4=buildTime(srvtime,z4text,z4time,z4dst);
            if(did("RC4"))did("RC4").innerHTML=time4;}
      if(typeof z5text!="undefined")
            {var time5=buildTime(srvtime,z5text,z5time,z5dst);
            if(did("RC5"))did("RC5").innerHTML=time5;}
      if(typeof z6text!="undefined")
            {var time6=buildTime(srvtime,z6text,z6time,z6dst);
            if(did("RC6"))did("RC6").innerHTML=time6;}
      if(typeof z7text!="undefined")
            {var time7=buildTime(srvtime,z7text,z7time,z7dst);
            if(did("RC7"))did("RC7").innerHTML=time7;}
      if(typeof z8text!="undefined")
            {var time8=buildTime(srvtime,z8text,z8time,z8dst);
            if(did("RC8"))did("RC8").innerHTML=time8;}
      if(typeof z9text!="undefined")
            {var time9=buildTime(srvtime,z9text,z9time,z9dst);
            if(did("RC9"))did("RC9").innerHTML=time9;}
      if(typeof z10text!="undefined")
            {var time10=buildTime(srvtime,z10text,z10time,z10dst);
            if(did("RC10"))did("RC10").innerHTML=time10;}
}

function getweather(lang, city){XMLHttp.sendReq("POST","/rbnfiles/mod_weather.php","lang="+lang+"&city="+city,getweather_callback);}
function getweather_callback(obj){document.getElementById('weatherinfo').innerHTML = obj.responseText;}
function getnews(lang,divid,newsid){getnewsfeed(lang,divid,newsid,0);}
function getnewsfeed(lang,divid,newsid,detail){document.getElementById(divid).innerHTML='';if(detail==1)document.getElementById('waitbox').style.display='block';XMLHttp.sendReq("POST","/rbnfiles/mod_newsfeed.php","lang="+lang+"&newsid="+newsid+"&detail="+detail,getnews_callback,divid);}
function getnews_callback(obj,divid){var box=document.getElementById('waitbox');if(box!=null)box.style.display='none';document.getElementById(divid).innerHTML = obj.responseText;}
function getworldtime(lang){XMLHttp.sendReq("POST","/rbnfiles/mod_worldtime.php","lang="+lang,getworldtime_callback);}
function getworldtime_callback(obj){var script=document.createElement("script");script.text=obj.responseText;document.getElementsByTagName("head")[0].appendChild(script);RunTZclock();}
function emailCheck(emailStr){var emailPat=/^(.+)@(.+)$/;var matchArray=emailStr.match(emailPat);if (matchArray==null){return false;}else{return true;}}
function logomover(){document.getElementById("logo").style.cursor='pointer';}
function logomout(){}
function logoclick(lang){window.location='/index.php?lang='+lang;}
function showview(lat,lng,y,p)
{
	var myPano = new GStreetviewPanorama(document.getElementById("pano"));
	fenwayPark = new GLatLng(lat, lng);
	myPOV = {yaw:y, pitch:p};
	myPano.setLocationAndPOV(fenwayPark, myPOV);
	GEvent.addListener(myPano, "error", handleNoFlash);
}
function handleNoFlash(errorCode){if (errorCode == 603) {alert("Error: Flash doesn't appear to be supported by your browser");return;}}  
function showpt(ev,no,title,url,furl,id,nm){if(typeof ev!="undefined"){if(window.event){window.event.returnValue=false;}else{ev.preventDefault();}}document.getElementById("hdncurpt").value=no;XMLHttp.sendReq("POST","/rbnfiles/mod_photo.php","t="+title+"&url="+escape(url)+"&furl="+escape(furl)+"&id="+id+"&nm="+nm,showpt_callback);}
function showpt_callback(obj){if(gDivData==null){showMaskDiv("#000",0.5);gDivData=createDataDiv();document.body.appendChild(gDivData);}gDivData.innerHTML=obj.responseText;var no=document.getElementById("hdncurpt").value;if(no==1){document.getElementById("prev").disabled=true;}if(no==30){document.getElementById("next").disabled=true;}}
function chgphoto(dire){var no=document.getElementById("hdncurpt").value;if(dire==1){no--;}else{no++;}document.getElementById("p"+no).onclick();}
