// JavaScript Document
// Scripts are by Andy T.Leung
// No unauthorized use of this file is permitted under any circumstances

//General Libraries
var MSIE=navigator.userAgent.indexOf("MSIE");
var NETS=navigator.userAgent.indexOf("Netscape");
var OPER=navigator.userAgent.indexOf("Opera");
var OPERMOBILE=navigator.userAgent.indexOf("Opera Mobi");
var Safari=navigator.userAgent.indexOf("Safari");
var Camino=navigator.userAgent.indexOf("Camino");
var Mozilla=navigator.userAgent.indexOf("Gecko");
var Firefox=navigator.userAgent.indexOf("Firefox");
var Konqueror=navigator.userAgent.indexOf("Konqueror");
var Chrome=navigator.userAgent.indexOf("Chrome");

function strNum(str1)
{
	str1 = str1+'';
	var re = new RegExp("[\\D]+","g");
	str1 = str1.replace(re,'')*1;
	return parseInt(str1);
}

function timeStrToSec(timeStr)
{
	var tempArr1 = timeStr.split(":");
	var tempArr2 = new Array();
	var thisSec = 0;
	
	for(var i=tempArr1.length - 1,ii=0; i>=0; i--,ii++)
	{
		tempArr2[ii] = tempArr1[i];
	}
	
	if(tempArr2.length >= 1)
		thisSec += tempArr2[0]*1;
	if(tempArr2.length >= 2)
		thisSec += tempArr2[1]*60;
	if(tempArr2.length >= 3)
		thisSec += tempArr2[2]*60*24;
		
	return thisSec;
}

function addressToObj(str1){
	var thisObj = new Object();
	thisObj.address = str1;
	thisObj.args = "";
	thisObj.argsArr = new Array();
	var result = str1;
	var re = new RegExp("^([^?]+)\\?(.+)$");
	var m = re.exec(str1);
	if (m != null) {
		if(m.length == 3)
		{
			thisObj.address = m[1];
			thisObj.args = m[2];
			
			var tempArray = thisObj.args.split("&");
			for(var i=0; i<tempArray.length; i++){
				if(tempArray[i] == "")
					continue;
				var indArg = tempArray[i].split('=');
				if(indArg.length == 2)
					thisObj.argsArr[indArg[0]] = indArg[1];
				else if(indArg.length == 1)
					thisObj.argsArr[indArg[0]] = '';
			}
		}
    }
	return thisObj;
}

function flashMovie(movieName) {
    /*if (MSIE > -1) {
        return window[movieName];
    } else {
        return document[movieName];
    }*/
	if(NETS > -1 || OPER > -1)
		return null;
	
	if(document.embeds[movieName])
		return document.embeds[movieName];
	if(window.document[movieName])
		return window.document[movieName];
	if(window[movieName])
		return window[movieName];
	if(document[movieName])
		return document[movieName];

	return null;
}

//DOM Management Starts
function DOMRemoveChilds(obj){
	if(obj == undefined)
		return;
	if ( obj.childNodes.length > 0 )
	{
		while ( obj.childNodes.length >= 1 )
		{
			if ( obj.firstChild.childNodes.length > 0 )
			{
				DOMRemoveChilds(obj.firstChild);
			}
			obj.removeChild( obj.firstChild );       
		}
	}
}
function DOMRemove(obj){
	if(obj == undefined)
		return;
	DOMRemoveChilds(obj);
	var temp = obj.parentNode;
	temp.removeChild(obj);
}
//DOM Management Ends

//Cookie Handling Starts
var cookieExpiration = 36500;
function createCookie(name,value,days) {
	if (days != undefined && days != "") {
		var date = new Date();
		date.setTime(date.getTime()+(days*86400000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

function eraseAllCookies() {
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var name = ca[i].split('=')[0];
		eraseCookie(name);
	}
}
//Cookie Handling Ends

//XML Management
function loadXMLString(txt) 
{
	try //Internet Explorer
	{
		xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
		xmlDoc.async=false;
		xmlDoc.loadXML(txt);
		return(xmlDoc); 
	}
	catch(e)
	{
		try //Firefox, Mozilla, Opera, etc.
		{
			parser=new DOMParser();
			xmlDoc=parser.parseFromString(txt,"text/xml");
			return(xmlDoc);
		}
		catch(e) {}
	}
	return(null);
}

function getNodeText(obj)
{
	if(obj == undefined)
		return null;
	if(obj.text != undefined)
		return obj.text;
	else
		return obj.textContent;
}

//Ajax Functions
var ajaxReqResult = new Array();
function ajaxRequest(name, url) {
	var newAjaxObj = new Object();	

	if (window.XMLHttpRequest) { // Mozilla, Safari,...
		newAjaxObj.http_request = new XMLHttpRequest();
		if (newAjaxObj.http_request.overrideMimeType) {
			newAjaxObj.http_request.overrideMimeType('text/xml');
		}
	} else if (window.ActiveXObject) { // IE
		try {
			newAjaxObj.http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				newAjaxObj.http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}

	if (!newAjaxObj.http_request) {
		//alert('Giving up :( Cannot create an XMLHTTP instance');
		return false;
	}
	newAjaxObj.http_request.onreadystatechange = function(){
		var thisObj = newAjaxObj;
		var thisName = name;
		if (thisObj.http_request.readyState == 4) {
			if (thisObj.http_request.status == 200 || thisObj.http_request.status == 304) {
				ajaxReqResult[thisName].txt = thisObj.http_request.responseText;
				ajaxReqResult[thisName].xml = loadXMLString(thisObj.http_request.responseText);
				//ajaxReqResult[thisName].xml = thisObj.http_request.responseXML;
				if(ajaxReqResult[thisName].onResponse != undefined)
					ajaxReqResult[thisName].onResponse();
				//delete ajaxReqResult[thisName];
			} else {
				if(ajaxReqResult[thisName].onException != undefined)
					ajaxReqResult[thisName].onException();
				//alert('There was a problem with the request.');
			}
			delete thisObj;
		}
	};
	newAjaxObj.http_request.open('GET', url, true);
	newAjaxObj.http_request.send(null);
}
var ajaxPostResult = new Array();
function ajaxPost(name, url, postContentArr) {
	var newAjaxObj = new Object();	

	if (window.XMLHttpRequest) { // Mozilla, Safari,...
		newAjaxObj.http_request = new XMLHttpRequest();
		if (newAjaxObj.http_request.overrideMimeType) {
			newAjaxObj.http_request.overrideMimeType('text/xml');
		}
	} else if (window.ActiveXObject) { // IE
		try {
			newAjaxObj.http_request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				newAjaxObj.http_request = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {}
		}
	}

	if (!newAjaxObj.http_request) {
		//alert('Giving up :( Cannot create an XMLHTTP instance');
		return false;
	}
	newAjaxObj.http_request.onreadystatechange = function(){
		var thisObj = newAjaxObj;
		var thisName = name;
		if (thisObj.http_request.readyState == 4) {
			if (thisObj.http_request.status == 200 || thisObj.http_request.status == 304) {
				ajaxPostResult[thisName].txt = thisObj.http_request.responseText;
				ajaxPostResult[thisName].xml = loadXMLString(thisObj.http_request.responseText);
				//ajaxPostResult[thisName].xml = thisObj.http_request.responseXML;
				if(ajaxPostResult[thisName].onResponse != undefined)
					ajaxPostResult[thisName].onResponse();
				//delete ajaxPostResult[thisName];
			} else {
				if(ajaxPostResult[thisName].onException != undefined)
					ajaxPostResult[thisName].onException();
				//alert('There was a problem with the request.');
			}
			delete thisObj;
		}
	};
	
	var postContent = '';
	for( var key in postContentArr)
			postContent += key+"="+postContentArr[key]+"&";
	if(postContent != '')
		postContent = postContent.substring(0,postContent.length-1);
	
	newAjaxObj.http_request.open('POST', url, true);
	newAjaxObj.http_request.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
	newAjaxObj.http_request.send(postContent);
}
//AJax Functions End

//Image Handling Starts
var defaultImg = "loading.gif";
var imgLoadRetryDelay = 1000;
var imgLoadMaxAttempt = 3;
var imgLoader_loaded = new Array();

function imgLoader(obj, imgName, failAction){
	if(obj == undefined)
		return;
	obj.setAttribute('imgName',imgName);
	
	obj.onload = function (evt){
		//Fix Firefox Corrupt Images, when images are loaded rapidly.
		if(obj.getAttribute('imgSerial') == '1')
		{
			imgLoader_loaded[imgName] = (strNum(imgLoader_loaded[imgName])+1);
			obj.setAttribute('imgSerial',imgLoader_loaded[imgName]);
			
			obj.src = '';
			setTimeout("imgLoader(document.getElementById(\""+obj.id+"\"), \""+imgName+"\");",1);
			return;
		}
		var loadDoneAction = obj.getAttribute('loadDone');
		if(loadDoneAction != undefined && loadDoneAction != null && loadDoneAction != '')
		{
			eval(loadDoneAction);
		}
	}
	obj.onerror = function (evt){
		var requireLoad = true;
		
		if(obj.getAttribute('loadAttempt') == undefined){
			obj.setAttribute('loadAttempt','1');
		} else if(strNum(obj.getAttribute('loadAttempt')) <= imgLoadMaxAttempt){
			obj.setAttribute('loadAttempt',(strNum(obj.getAttribute('loadAttempt')) + 1));
		}
		if(strNum(obj.getAttribute('loadAttempt')) >= imgLoadMaxAttempt)
		{
			obj.src = defaultImg;
			requireLoad = false;
		}		
		if(requireLoad){
			obj.src = '';
			setTimeout("imgLoader(document.getElementById(\""+obj.id+"\"), \""+imgName+"\");",imgLoadRetryDelay);
		}
	}
	
	if(imgName == undefined || imgName == null || imgName == '')
		imgName = defaultImg;
	
	/*var img = new Image(); 
	img.onerror = function (evt){
		obj.src = defaultImg;
		var loadDoneAction = obj.getAttribute('loadDone');
		if(loadDoneAction != undefined && loadDoneAction != null && loadDoneAction != '')
		{
			eval(loadDoneAction);
		}
	}
	img.onload = function (evt){	
		obj.onload = function (evt){
			var loadDoneAction = obj.getAttribute('loadDone');
			if(loadDoneAction != undefined && loadDoneAction != null && loadDoneAction != '')
			{
				eval(loadDoneAction);
			}
		}		
		obj.src = imgName;
	}
	img.src = imgName;*/
	if(imgLoader_loaded[imgName] == undefined)
	{
		imgLoader_loaded[imgName] = '1';
		obj.setAttribute('imgSerial',imgLoader_loaded[imgName]);
		var newAjaxObj = new Object();	
	
		if (window.XMLHttpRequest) { // Mozilla, Safari,...
			newAjaxObj.http_request = new XMLHttpRequest();
			if (newAjaxObj.http_request.overrideMimeType) {
				newAjaxObj.http_request.overrideMimeType('text/xml');
			}
		} else if (window.ActiveXObject) { // IE
			try {
				newAjaxObj.http_request = new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e) {
				try {
					newAjaxObj.http_request = new ActiveXObject("Microsoft.XMLHTTP");
				} catch (e) {}
			}
		}
	
		if (!newAjaxObj.http_request) {
			//alert('Giving up :( Cannot create an XMLHTTP instance');
			return false;
		}
		newAjaxObj.http_request.onreadystatechange = function(){
			if (newAjaxObj.http_request.readyState == 4) {
				if (newAjaxObj.http_request.status == 200 || newAjaxObj.http_request.status == 304) {
					//obj.src = '';
					//alert(document.getElementById(obj.id).src);
					obj.src = imgName;
				} else {
					//obj.src = defaultImg;
					if(failAction == undefined || failAction == null || failAction == false)
					{
						var loadFailAction = obj.getAttribute('loadFail');
						if(loadFailAction != undefined && loadFailAction != null && loadFailAction != '')
						{
							eval(loadFailAction);
						}
					}
					//alert('There was a problem with the request.');
				}
				delete newAjaxObj.http_request;
				delete newAjaxObj;
			}
		};
		newAjaxObj.http_request.open('GET', imgName, true);
		newAjaxObj.http_request.send(null);
	} else {
		imgLoader_loaded[imgName] = (strNum(imgLoader_loaded[imgName])+1);
		obj.setAttribute('imgSerial',imgLoader_loaded[imgName]);
		obj.src = imgName;
		//if(MSIE > -1)
		//else
		//	setTimeout("document.getElementById(\""+obj.id+"\").setAttribute(\"src\",\""+imgName+"\");",2000);
	}
}

function imgRefine(name, expectedWid, expectedHei){
	var thisIcon = document.getElementById(name);
	var scaleRatio = 1;
	var newWid;
	var newHei;
	if(thisIcon == undefined)
		return;
	if(thisIcon.width >= thisIcon.height)
	{
		if(thisIcon.width > expectedWid)
		{	
			scaleRatio = expectedWid / thisIcon.width;
			newWid = parseInt(expectedWid)+'px';
			newHei = parseInt(thisIcon.height * scaleRatio)+'px';
			thisIcon.style.width = newWid;
			thisIcon.style.height = newHei;
		}
	}else{
		if(thisIcon.height > expectedHei)
		{	
			scaleRatio = expectedHei / thisIcon.height;
			newWid = parseInt(thisIcon.width * scaleRatio)+'px';
			newHei = parseInt(expectedHei)+'px';
			thisIcon.style.width = newWid;
			thisIcon.style.height = newHei;
		}
	}
}

function imgGetThrumbNailName(str1)
{
	var result = str1;
	var re = new RegExp("^(.+)\\.(.+)$");
	var m = re.exec(str1);	
	if (m != null) {
		if(m.length == 3)
			result = m[1]+'_s.'+m[2];
    }
	return result;
}

//Associative Array Tools
function countArr(array1)
{
	var num = 0;
	for (var i in array1)
		num++;
	return num;
}

function sortAssoc(aInput)
{
	var aTemp = new Array();
	for (var sKey in aInput)
		aTemp.push([sKey, aInput[sKey]]);
	aTemp.sort(function () {return arguments[0][0] - arguments[1][0]});

	var aOutput = new Array();
	for (var nIndex = 0; nIndex < aTemp.length; nIndex++)
	{
		aOutput[aTemp[nIndex][0]] = aTemp[nIndex][1];
	}

	return aOutput;
}

function sortAssocRev(aInput)
{
	var aTemp = new Array();
	for (var sKey in aInput)
		aTemp.push([sKey, aInput[sKey]]);
	aTemp.sort(function () {return arguments[0][0] - arguments[1][0]});

	var aOutput = new Array();
	for (var nIndex = aTemp.length-1; nIndex >=0; nIndex--)
	{
		aOutput[aTemp[nIndex][0]] = aTemp[nIndex][1];
	}

	return aOutput;
}

var scnWid,scnHei, getScreenInfoReady=false;
var deskHei=screen.availHeight;
var deskWid=screen.availWidth;
function getScreenInfo(){
	var thisWid=0, thisHei=0;
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		thisWid = window.innerWidth;
		thisHei = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		thisWid = document.documentElement.clientWidth;
		thisHei = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		thisWid = document.body.clientWidth;
		thisHei = document.body.clientHeight;
	}
	if(thisWid < 400)
		thisWid = 400;
	if(thisHei < 300)
		thisHei = 300;
	scnWid = thisWid;
	scnHei = thisHei;
	getScreenInfoReady = true;
}

function moveWindow(obj, x, y){
	obj.moveTo(x,y);
}

function andyPopup(address, winname, winWid, winHei, position){
	if(position == undefined || position == null)
		return null;
	var posCmd = position.split(',');
	if(posCmd.length != 2)
		return null;
	
	var poppedWindow = window.open(address, winname,'width='+winWid+',height='+winHei+',left=0,top=0,toolbar=0,location=0, directories=0, status=0, menubar=0, scrollbars=1');
	var thisX=0;
	var thisY=0;
	
	switch(posCmd[0].toLowerCase())
	{
		case 'left':
			thisX = 0;
			break;
		case 'center':
			thisX = Math.floor((deskWid - winWid)/2);
			if(thisX < 0)
				thisX = 0;
			break;
		case 'right':
			thisX = deskWid - winWid;
			if(thisX < 0)
				thisX = 0;
			break;
	}
	switch(posCmd[1].toLowerCase())
	{
		case 'top':
			thisY = 0;
			break;
		case 'center':
			thisY = Math.floor((deskHei - winHei)/2);
			if(thisY < 0)
				thisY = 0;
			break;
		case 'bottom':
			thisY = deskHei - winHei;
			if(thisY < 0)
				thisY = 0;
			break;
	}
	
	try
	{
		moveWindow(poppedWindow, thisX, thisY);
		poppedWindow.focus();
	}
	catch (e)
	{
	}
	return poppedWindow;
}

function andyPopupCheckDate(keepDays, postDateTime)
{
	if(keepDays == undefined || keepDays == null)
		keepDays = 30;
	if(postDateTime == undefined || postDateTime == null)
		lastModDate=new Date(document.lastModified);
	else	
		lastModDate=new Date(postDateTime);
	
	var timeBefore = new Date();
	timeBefore.setTime(timeBefore.getTime() - (86400000*keepDays));
	if(timeBefore.getTime() > lastModDate.getTime())
	  self.close();
}

function andytleungScriptInit()
{
	getScreenInfo();
}

setTimeout("andytleungScriptInit()",1000);

//News Functions
var rtnewsDefaultShowDays = 7;
var rtnewsContent = new Array();

function rtnews_get(postAction){
	var ajaxRTNewsGetName = 'rtnews';
	ajaxReqResult[ajaxRTNewsGetName] = new Object();
	ajaxReqResult[ajaxRTNewsGetName].onResponse = function(){
		var newsContent = ajaxReqResult[ajaxRTNewsGetName].xml.documentElement.getElementsByTagName('news');
		for(var i=0; i<newsContent.length; i++)
		{
			var thisPublishDate = getNodeText(newsContent[i].getElementsByTagName('publishdate')[0]);
			var thisKey = new Date(thisPublishDate).getTime();
			var thisEndDate = getNodeText(newsContent[i].getElementsByTagName('enddate')[0]);
			var thisTitle = getNodeText(newsContent[i].getElementsByTagName('title')[0]);
			var thisMsg = getNodeText(newsContent[i].getElementsByTagName('message')[0]);
			var thisDisabled = getNodeText(newsContent[i].getElementsByTagName('disable')[0]);
			rtnewsContent[thisKey] = new Object();
			rtnewsContent[thisKey].publishDate = thisPublishDate;
			rtnewsContent[thisKey].endDate = thisEndDate;
			rtnewsContent[thisKey].title = thisTitle;
			rtnewsContent[thisKey].msg = thisMsg;
			rtnewsContent[thisKey].isDisable = thisDisabled;
		}
		rtnewsContent = sortAssocRev(rtnewsContent);
		var checkEmptyResult = rtnews_checkempty();
		if(checkEmptyResult == true && postAction != undefined && postAction != "")
			eval(postAction);
	};
	ajaxReqResult[ajaxRTNewsGetName].onException = function(){
	};
	ajaxRequest(ajaxRTNewsGetName,'/xml/rtnews.xml');
}

function rtnews_checkempty(){
	var result = false;
	var now = new Date();
	for (var sKey in rtnewsContent)
	{
		if(rtnewsContent[sKey].isDisable != null && rtnewsContent[sKey].isDisable.toLowerCase() == "true")
			continue;
		var thisPublishDate;
		thisPublishDate = new Date(rtnewsContent[sKey].publishDate);
		var thisEndDate;
		if( rtnewsContent[sKey].endDate == null || rtnewsContent[sKey].endDate == "")
		{
			thisEndDate = new Date();
			thisEndDate.setTime(thisPublishDate.getTime() + (86400000*rtnewsDefaultShowDays));
		}
		else
		{
			thisEndDate = new Date(rtnewsContent[sKey].endDate);
		}
		if(thisEndDate.getTime() >= now.getTime())
		{
			result = true;
			break;
		}
	}
	return result;
}

function getNewsDate(dtstr)
{
	var timeObj = new Date(dtstr);
	var thisMonth = '0'+(timeObj.getMonth()+1);
	thisMonth = thisMonth.substr(thisMonth.length-2,2);
	var thisDate = '0'+timeObj.getDate();
	thisDate = thisDate.substr(thisDate.length-2,2);
	var timeStr = timeObj.getFullYear()+'-'+thisMonth+'-'+thisDate;
	return timeStr;
}

function getNewsDateTime(dtstr, showSec)
{
	var timeObj = new Date(dtstr);
	var thisMonth = '0'+(timeObj.getMonth()+1);
	thisMonth = thisMonth.substr(thisMonth.length-2,2);
	var thisDate = '0'+timeObj.getDate();
	thisDate = thisDate.substr(thisDate.length-2,2);
	var thisHour = '0'+timeObj.getHours();
	thisHour = thisHour.substr(thisHour.length-2,2);
	var thisMinute = '0'+timeObj.getMinutes();
	thisMinute = thisMinute.substr(thisMinute.length-2,2);
	var thisSecond = '0'+timeObj.getSeconds();
	thisSecond = thisSecond.substr(thisSecond.length-2,2);
	var timeStr = timeObj.getFullYear()+'-'+thisMonth+'-'+thisDate+' '+thisHour+':'+thisMinute;
	if(showSec != undefined && showSec == true)
	{
		timeStr += ':'+thisSecond;
	}
	return timeStr;
}

function rtnews_view(objName){
	var now = new Date();
	var resultContent = "<table>";
	var i = 1;
	for (var sKey in rtnewsContent)
	{
		if(rtnewsContent[sKey].isDisable != null && rtnewsContent[sKey].isDisable.toLowerCase() == "true")
			continue;
		var thisEndDate;
		if(rtnewsDefaultShowDays < 0)
		{
			thisEndDate = new Date();
			thisEndDate.setTime(thisEndDate.getTime() + 86400000);
		}else if( rtnewsContent[sKey].endDate == null || rtnewsContent[sKey].endDate == "")
		{
			thisEndDate = new Date(rtnewsContent[sKey].publishDate);
			thisEndDate.setTime(thisEndDate.getTime() + (86400000*rtnewsDefaultShowDays));
		}
		else
		{
			thisEndDate = new Date(rtnewsContent[sKey].endDate);
		}
		if(thisEndDate.getTime() >= now.getTime())
		{
			resultContent += "<tr><td id='rtnews_table_news_title_"+i+"'>"+getNewsDate(rtnewsContent[sKey].publishDate)+"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"+rtnewsContent[sKey].title+"</td></tr>" +
			"<tr><td id='rtnews_table_news_msg_"+i+"'>"+rtnewsContent[sKey].msg+"</td></tr>"+
			"<tr><td><hr width=\"100%\"></td></tr>";
			//alert(rtnewsContent[sKey].publishDate+' '+rtnewsContent[sKey].endDate+' '+rtnewsContent[sKey].title+' '+rtnewsContent[sKey].msg);
			i++;
		}
	}
	resultContent += "</table>";
	document.getElementById(objName).innerHTML += resultContent;
}

//Bible
var bibleDefaultShowDays = 30;
var bibleContent = new Array();

function bible_get(postAction){
	var ajaxBibleGetName = 'bible';
	ajaxReqResult[ajaxBibleGetName] = new Object();
	ajaxReqResult[ajaxBibleGetName].onResponse = function(){
		var thisBibleContent = ajaxReqResult[ajaxBibleGetName].xml.documentElement.getElementsByTagName('statement');
		for(var i=0; i<thisBibleContent.length; i++)
		{
			var thisPublishDate = getNodeText(thisBibleContent[i].getElementsByTagName('publishdate')[0]);
			var thisKey = new Date(thisPublishDate).getTime();
			var thisEndDate = getNodeText(thisBibleContent[i].getElementsByTagName('enddate')[0]);
			var thisContent = getNodeText(thisBibleContent[i].getElementsByTagName('content')[0]);
			var thisDisabled = getNodeText(thisBibleContent[i].getElementsByTagName('disable')[0]);
			bibleContent[thisKey] = new Object();
			bibleContent[thisKey].publishDate = thisPublishDate;
			bibleContent[thisKey].endDate = thisEndDate;
			bibleContent[thisKey].content = thisContent;
			bibleContent[thisKey].isDisable = thisDisabled;
		}
		bibleContent = sortAssocRev(bibleContent);
		if(postAction != undefined && postAction != "")
			eval(postAction);
	};
	ajaxReqResult[ajaxBibleGetName].onException = function(){
	};
	ajaxRequest(ajaxBibleGetName,'/xml/bible.xml');
}

function bible_view(objName){
	var now = new Date();
	var resultContent = "<table width=\"100%\" border=\"0\" cellpadding=\"2\" cellspacing=\"0\">";
	var i = 1;
	for (var sKey in bibleContent)
	{
		if(bibleContent[sKey].isDisable != null && bibleContent[sKey].isDisable.toLowerCase() == "true")
			continue;
		var thisPublishDate = new Date(bibleContent[sKey].publishDate);
		if(thisPublishDate.getTime() >= now.getTime())
			continue;
		var thisEndDate;
		if(bibleDefaultShowDays < 0)
		{
			thisEndDate = new Date();
			thisEndDate.setTime(thisEndDate.getTime() + 86400000);
		}else if( bibleContent[sKey].endDate == null || bibleContent[sKey].endDate == "")
		{
			thisEndDate = new Date(bibleContent[sKey].publishDate);
			thisEndDate.setTime(thisEndDate.getTime() + (86400000*bibleDefaultShowDays));
		}
		else
		{
			thisEndDate = new Date(bibleContent[sKey].endDate);
		}
		if(thisEndDate.getTime() >= now.getTime())
		{
			resultContent += "<tr><td id='bible_table_content_"+i+"'>"+bibleContent[sKey].content+"</td></tr>";
			//alert(rtnewsContent[sKey].publishDate+' '+rtnewsContent[sKey].endDate+' '+rtnewsContent[sKey].title+' '+rtnewsContent[sKey].msg);
			i++;
		}
	}
	resultContent += "</table>";
	document.getElementById(objName).innerHTML += resultContent;
}

//Main Page News
var mainnewsDefaultShowDays = 180;
var mainnewsContent = new Array();

function mainnews_get(postAction){
	var ajaxMainNewsGetName = 'mainnews';
	ajaxReqResult[ajaxMainNewsGetName] = new Object();
	ajaxReqResult[ajaxMainNewsGetName].onResponse = function(){
		var thisNewsContent = ajaxReqResult[ajaxMainNewsGetName].xml.documentElement.getElementsByTagName('news');
		for(var i=0; i<thisNewsContent.length; i++)
		{
			var thisPublishDate = getNodeText(thisNewsContent[i].getElementsByTagName('publishdate')[0]);
			var thisKey = new Date(thisPublishDate).getTime();
			var thisEndDate = getNodeText(thisNewsContent[i].getElementsByTagName('enddate')[0]);
			var thisTitle = getNodeText(thisNewsContent[i].getElementsByTagName('title')[0]);
			var thisMessage = getNodeText(thisNewsContent[i].getElementsByTagName('message')[0]);
			var thisDisabled = getNodeText(thisNewsContent[i].getElementsByTagName('disable')[0]);
			mainnewsContent[thisKey] = new Object();
			mainnewsContent[thisKey].publishDate = thisPublishDate;
			mainnewsContent[thisKey].endDate = thisEndDate;
			mainnewsContent[thisKey].title = thisTitle;
			mainnewsContent[thisKey].msg = thisMessage;
			mainnewsContent[thisKey].isDisable = thisDisabled;
		}
		mainnewsContent = sortAssocRev(mainnewsContent);
		if(postAction != undefined && postAction != "")
			eval(postAction);
	};
	ajaxReqResult[ajaxMainNewsGetName].onException = function(){
	};
	ajaxRequest(ajaxMainNewsGetName,'/xml/news.xml');
}

function mainnews_view(objName){
	var now = new Date();
	var resultContent = "<table width=\"100%\" border=\"0\" cellpadding=\"2\" cellspacing=\"0\">";
	var i = 1;
	for (var sKey in mainnewsContent)
	{
		if(mainnewsContent[sKey].isDisable != null && mainnewsContent[sKey].isDisable.toLowerCase() == "true")
			continue;
		var thisPublishDate = new Date(mainnewsContent[sKey].publishDate);
		if(thisPublishDate.getTime() >= now.getTime())
			continue;
		var thisEndDate;
		if(mainnewsDefaultShowDays < 0)
		{
			thisEndDate = new Date();
			thisEndDate.setTime(thisEndDate.getTime() + 86400000);
		}else if( mainnewsContent[sKey].endDate == null || mainnewsContent[sKey].endDate == "")
		{
			thisEndDate = new Date(mainnewsContent[sKey].publishDate);
			thisEndDate.setTime(thisEndDate.getTime() + (86400000*mainnewsDefaultShowDays));
		}
		else
		{
			thisEndDate = new Date(mainnewsContent[sKey].endDate);
		}
		if(thisEndDate.getTime() >= now.getTime())
		{
			resultContent += "<tr><td id='mainnews_table_news_title_"+i+"' style=\"background-color:#E7E7E7\">"+getNewsDate(mainnewsContent[sKey].publishDate)+"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"+mainnewsContent[sKey].title+"</td></tr>" +
			"<tr><td id='mainnews_table_news_msg_"+i+"'>"+mainnewsContent[sKey].msg+"</td></tr>";
			i++;
		}
	}
	resultContent += "</table>";
	document.getElementById(objName).innerHTML += resultContent;
}

//Activities News
var activitiesnewsDefaultShowDays = 180;
var activitiesnewsContent = new Array();

function activitiesnews_get(postAction){
	var ajaxActivitiesNewsGetName = 'activitiesnews';
	ajaxReqResult[ajaxActivitiesNewsGetName] = new Object();
	ajaxReqResult[ajaxActivitiesNewsGetName].onResponse = function(){
		var thisNewsContent = ajaxReqResult[ajaxActivitiesNewsGetName].xml.documentElement.getElementsByTagName('news');
		for(var i=0; i<thisNewsContent.length; i++)
		{
			var thisPublishDate = getNodeText(thisNewsContent[i].getElementsByTagName('publishdate')[0]);
			var thisKey = new Date(thisPublishDate).getTime();
			var thisEndDate = getNodeText(thisNewsContent[i].getElementsByTagName('enddate')[0]);
			var thisTitle = getNodeText(thisNewsContent[i].getElementsByTagName('title')[0]);
			var thisMessage = getNodeText(thisNewsContent[i].getElementsByTagName('message')[0]);
			var thisDisabled = getNodeText(thisNewsContent[i].getElementsByTagName('disable')[0]);
			activitiesnewsContent[thisKey] = new Object();
			activitiesnewsContent[thisKey].publishDate = thisPublishDate;
			activitiesnewsContent[thisKey].endDate = thisEndDate;
			activitiesnewsContent[thisKey].title = thisTitle;
			activitiesnewsContent[thisKey].msg = thisMessage;
			activitiesnewsContent[thisKey].isDisable = thisDisabled;
		}
		activitiesnewsContent = sortAssocRev(activitiesnewsContent);
		if(postAction != undefined && postAction != "")
			eval(postAction);
	};
	ajaxReqResult[ajaxActivitiesNewsGetName].onException = function(){
	};
	ajaxRequest(ajaxActivitiesNewsGetName,'/xml/activities_news.xml');
}

function activitiesnews_view(objName){
	var now = new Date();
	var resultContent = "<table width=\"100%\" border=\"0\" cellpadding=\"2\" cellspacing=\"0\">";
	var i = 1;
	for (var sKey in activitiesnewsContent)
	{
		if(activitiesnewsContent[sKey].isDisable != null && activitiesnewsContent[sKey].isDisable.toLowerCase() == "true")
			continue;
		var thisPublishDate = new Date(activitiesnewsContent[sKey].publishDate);
		if(thisPublishDate.getTime() >= now.getTime())
			continue;
		var thisEndDate;
		if(activitiesnewsDefaultShowDays < 0)
		{
			thisEndDate = new Date();
			thisEndDate.setTime(thisEndDate.getTime() + 86400000);
		}else if( activitiesnewsContent[sKey].endDate == null || activitiesnewsContent[sKey].endDate == "")
		{
			thisEndDate = new Date(activitiesnewsContent[sKey].publishDate);
			thisEndDate.setTime(thisEndDate.getTime() + (86400000*activitiesnewsDefaultShowDays));
		}
		else
		{
			thisEndDate = new Date(activitiesnewsContent[sKey].endDate);
		}
		if(thisEndDate.getTime() >= now.getTime())
		{
			resultContent += "<tr><td id='activitiesnews_table_news_title_"+i+"' style=\"background-color:#E7E7E7\">"+getNewsDate(activitiesnewsContent[sKey].publishDate)+"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"+activitiesnewsContent[sKey].title+"</td></tr>" +
			"<tr><td id='activitiesnews_table_news_msg_"+i+"'>"+activitiesnewsContent[sKey].msg+"</td></tr>";
			i++;
		}
	}
	resultContent += "</table>";
	document.getElementById(objName).innerHTML += resultContent;
}

//Award News
var awardnewsDefaultShowDays = 365;
var awardnewsContent = new Array();

function awardnews_get(postAction){
	var ajaxAwardNewsGetName = 'awardnews';
	ajaxReqResult[ajaxAwardNewsGetName] = new Object();
	ajaxReqResult[ajaxAwardNewsGetName].onResponse = function(){
		var thisNewsContent = ajaxReqResult[ajaxAwardNewsGetName].xml.documentElement.getElementsByTagName('news');
		for(var i=0; i<thisNewsContent.length; i++)
		{
			var thisPublishDate = getNodeText(thisNewsContent[i].getElementsByTagName('publishdate')[0]);
			var thisKey = new Date(thisPublishDate).getTime();
			var thisEndDate = getNodeText(thisNewsContent[i].getElementsByTagName('enddate')[0]);
			var thisTitle = getNodeText(thisNewsContent[i].getElementsByTagName('title')[0]);
			var thisMessage = getNodeText(thisNewsContent[i].getElementsByTagName('message')[0]);
			var thisDisabled = getNodeText(thisNewsContent[i].getElementsByTagName('disable')[0]);
			awardnewsContent[thisKey] = new Object();
			awardnewsContent[thisKey].publishDate = thisPublishDate;
			awardnewsContent[thisKey].endDate = thisEndDate;
			awardnewsContent[thisKey].title = thisTitle;
			awardnewsContent[thisKey].msg = thisMessage;
			awardnewsContent[thisKey].isDisable = thisDisabled;
		}
		awardnewsContent = sortAssocRev(awardnewsContent);
		if(postAction != undefined && postAction != "")
			eval(postAction);
	};
	ajaxReqResult[ajaxAwardNewsGetName].onException = function(){
	};
	ajaxRequest(ajaxAwardNewsGetName,'/xml/award_news.xml');
}

function awardnews_view(objName){
	var now = new Date();
	var resultContent = "<table width=\"100%\" border=\"0\" cellpadding=\"2\" cellspacing=\"0\">";
	var i = 1;
	for (var sKey in awardnewsContent)
	{
		if(awardnewsContent[sKey].isDisable != null && awardnewsContent[sKey].isDisable.toLowerCase() == "true")
			continue;
		var thisPublishDate = new Date(awardnewsContent[sKey].publishDate);
		if(thisPublishDate.getTime() >= now.getTime())
			continue;
		var thisEndDate;		
		if(awardnewsDefaultShowDays < 0)
		{
			thisEndDate = new Date();
			thisEndDate.setTime(thisEndDate.getTime() + 86400000);
		}else if( awardnewsContent[sKey].endDate == null || awardnewsContent[sKey].endDate == "")
		{
			thisEndDate = new Date(awardnewsContent[sKey].publishDate);
			thisEndDate.setTime(thisEndDate.getTime() + (86400000*awardnewsDefaultShowDays));
		}
		else
		{
			thisEndDate = new Date(awardnewsContent[sKey].endDate);
		}
		if(thisEndDate.getTime() >= now.getTime())
		{
			resultContent += "<tr><td id='awardnews_table_news_title_"+i+"' style=\"background-color:#E7E7E7\">"+getNewsDate(awardnewsContent[sKey].publishDate)+"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"+awardnewsContent[sKey].title+"</td></tr>" +
			"<tr><td id='awardnews_table_news_msg_"+i+"'>"+awardnewsContent[sKey].msg+"</td></tr>";
			i++;
		}
	}
	resultContent += "</table>";
	document.getElementById(objName).innerHTML += resultContent;
}

//Download
var downloadDefaultShowDays = -1;
var downloadContent = new Array();

function download_get(postAction){
	var ajaxDownloadGetName = 'download';
	ajaxReqResult[ajaxDownloadGetName] = new Object();
	ajaxReqResult[ajaxDownloadGetName].onResponse = function(){
		var thisNewsContent = ajaxReqResult[ajaxDownloadGetName].xml.documentElement.getElementsByTagName('file');
		for(var i=0; i<thisNewsContent.length; i++)
		{
			var thisPublishDate = getNodeText(thisNewsContent[i].getElementsByTagName('publishdate')[0]);
			var thisKey = new Date(thisPublishDate).getTime();
			var thisEndDate = getNodeText(thisNewsContent[i].getElementsByTagName('enddate')[0]);
			var thisText = getNodeText(thisNewsContent[i].getElementsByTagName('text')[0]);
			var thisPath = getNodeText(thisNewsContent[i].getElementsByTagName('path')[0]);
			var thisDescription = getNodeText(thisNewsContent[i].getElementsByTagName('description')[0]);
			var thisDisabled = getNodeText(thisNewsContent[i].getElementsByTagName('disable')[0]);
			downloadContent[thisKey] = new Object();
			downloadContent[thisKey].publishDate = thisPublishDate;
			downloadContent[thisKey].endDate = thisEndDate;
			downloadContent[thisKey].text = thisText;
			downloadContent[thisKey].path = thisPath;
			downloadContent[thisKey].description = thisDescription;
			downloadContent[thisKey].isDisable = thisDisabled;
		}
		downloadContent = sortAssocRev(downloadContent);
		if(postAction != undefined && postAction != "")
			eval(postAction);
	};
	ajaxReqResult[ajaxDownloadGetName].onException = function(){
	};
	ajaxRequest(ajaxDownloadGetName,'/xml/download.xml');
}

function download_view(objName){
	var now = new Date();
	var resultContent = "<table width=\"100%\" border=\"0\" cellpadding=\"2\" cellspacing=\"0\">";
	var i = 1;
	var thisBGColor = ["#FFFFFF","#E7E7E7"];
	for (var sKey in downloadContent)
	{
		if(downloadContent[sKey].isDisable != null && downloadContent[sKey].isDisable.toLowerCase() == "true")
			continue;
		var thisPublishDate = new Date(downloadContent[sKey].publishDate);
		if(thisPublishDate.getTime() >= now.getTime())
			continue;
		var thisEndDate;
		if(downloadDefaultShowDays < 0)
		{
			thisEndDate = new Date();
			thisEndDate.setTime(thisEndDate.getTime() + 86400000);
		}else if( downloadContent[sKey].endDate == null || downloadContent[sKey].endDate == "")
		{
			thisEndDate = new Date(downloadContent[sKey].publishDate);
			thisEndDate.setTime(thisEndDate.getTime() + (86400000*downloadDefaultShowDays));
		}
		else
		{
			thisEndDate = new Date(downloadContent[sKey].endDate);
		}
		if(thisEndDate.getTime() >= now.getTime())
		{
			resultContent += "<tr><td id='download_table_news_title_"+i+"' style=\"background-color:"+thisBGColor[i%thisBGColor.length]+"\">"+getNewsDate(downloadContent[sKey].publishDate)+"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\""+downloadContent[sKey].path+"\">"+downloadContent[sKey].text+"</a></td></tr>" +
			"<tr><td id='download_table_news_msg_"+i+"' style=\"background-color:"+thisBGColor[i%thisBGColor.length]+"\">"+downloadContent[sKey].description+"</td></tr>";
			i++;
		}
	}
	resultContent += "</table>";
	document.getElementById(objName).innerHTML += resultContent;
}

//Tender
var tenderDefaultShowDays = 30;
var tenderContent = new Array();

function tender_get(postAction){
	var ajaxTenderGetName = 'tender';
	ajaxReqResult[ajaxTenderGetName] = new Object();
	ajaxReqResult[ajaxTenderGetName].onResponse = function(){
		var thisNewsContent = ajaxReqResult[ajaxTenderGetName].xml.documentElement.getElementsByTagName('file');
		for(var i=0; i<thisNewsContent.length; i++)
		{
			var thisPublishDate = getNodeText(thisNewsContent[i].getElementsByTagName('publishdate')[0]);
			var thisKey = new Date(thisPublishDate).getTime();
			var thisEndDate = getNodeText(thisNewsContent[i].getElementsByTagName('enddate')[0]);
			var thisText = getNodeText(thisNewsContent[i].getElementsByTagName('text')[0]);
			var thisAttachment = thisNewsContent[i].getElementsByTagName('attachment');
			var thisDisabled = getNodeText(thisNewsContent[i].getElementsByTagName('disable')[0]);
			tenderContent[thisKey] = new Object();
			tenderContent[thisKey].publishDate = thisPublishDate;
			tenderContent[thisKey].endDate = thisEndDate;
			tenderContent[thisKey].text = thisText;
			tenderContent[thisKey].attachments = thisAttachment;
			tenderContent[thisKey].isDisable = thisDisabled;
		}
		tenderContent = sortAssocRev(tenderContent);
		if(postAction != undefined && postAction != "")
			eval(postAction);
	};
	ajaxReqResult[ajaxTenderGetName].onException = function(){
	};
	ajaxRequest(ajaxTenderGetName,'/xml/tender.xml');
}

function tender_view(objName){
	var now = new Date();
	var resultContent = "<table width=\"100%\" border=\"0\" cellpadding=\"2\" cellspacing=\"0\">";
	var i = 1;
	var thisBGColor = ["#FFFFFF","#E7E7E7"];
	for (var sKey in tenderContent)
	{
		if(tenderContent[sKey].isDisable != null && tenderContent[sKey].isDisable.toLowerCase() == "true")
			continue;
		var thisPublishDate = new Date(tenderContent[sKey].publishDate);
		if(thisPublishDate.getTime() >= now.getTime())
			continue;
		var thisEndDate;
		if(tenderDefaultShowDays < 0)
		{
			thisEndDate = new Date();
			thisEndDate.setTime(thisEndDate.getTime() + 86400000);
		}else if( tenderContent[sKey].endDate == null || tenderContent[sKey].endDate == "")
		{
			thisEndDate = new Date(tenderContent[sKey].publishDate);
			thisEndDate.setTime(thisEndDate.getTime() + (86400000*tenderDefaultShowDays));
		}
		else
		{
			thisEndDate = new Date(tenderContent[sKey].endDate);
		}
		if(thisEndDate.getTime() >= now.getTime())
		{
			resultContent += "<tr><td id='tender_table_news_item1_"+i+"' style=\"background-color:"+thisBGColor[i%thisBGColor.length]+";vertical-align:top\" width=\"80\">招標項目︰</td><td id='tender_table_news_item2_"+i+"' style=\"background-color:"+thisBGColor[i%thisBGColor.length]+";vertical-align:top\">"+tenderContent[sKey].text+"</td></tr>" +
			"<tr><td id='tender_table_news_publishdate1_"+i+"' style=\"background-color:"+thisBGColor[i%thisBGColor.length]+";vertical-align:top\" width=\"80\">發佈日期︰</td><td id='tender_table_news_publishdate2_"+i+"' style=\"background-color:"+thisBGColor[i%thisBGColor.length]+";vertical-align:top\">"+getNewsDate(tenderContent[sKey].publishDate)+"</a></td></tr>" +		
			"<tr><td id='tender_table_news_attachment1_"+i+"' style=\"background-color:"+thisBGColor[i%thisBGColor.length]+";vertical-align:top\" width=\"80\">招標內容︰</td><td id='tender_table_news_attachment2_"+i+"' style=\"background-color:"+thisBGColor[i%thisBGColor.length]+";vertical-align:top\">";
			for(var ii=0; ii < tenderContent[sKey].attachments.length; ii++)
			{
				if(ii > 0)
					resultContent += "<br/>";
				var thisFilename = getNodeText(tenderContent[sKey].attachments[ii].getElementsByTagName('text')[0]);
				var thisFilepath = getNodeText(tenderContent[sKey].attachments[ii].getElementsByTagName('path')[0]);
				resultContent += "<a href=\""+thisFilepath+"\" target=\"_blank\">"+thisFilename+"</a>";
			}			
			resultContent += "</td></tr>" +
			"<tr><td id='tender_table_news_deadline1_"+i+"' style=\"background-color:"+thisBGColor[i%thisBGColor.length]+";vertical-align:top\" width=\"80\">截止日期︰</td><td id='tender_table_news_deadline2_"+i+"' style=\"background-color:"+thisBGColor[i%thisBGColor.length]+";vertical-align:top\">"+getNewsDateTime(tenderContent[sKey].endDate)+"</td></tr>";
			i++;
		}
	}
	resultContent += "</table>";
	document.getElementById(objName).innerHTML += resultContent;
}

//Video
var videoDefaultShowDays = -1;
var videoContent = new Array();

function video_get(postAction){
	var ajaxVideoGetName = 'download';
	ajaxReqResult[ajaxVideoGetName] = new Object();
	ajaxReqResult[ajaxVideoGetName].onResponse = function(){
		var thisVideoContent = ajaxReqResult[ajaxVideoGetName].xml.documentElement.getElementsByTagName('video');
		for(var i=0; i<thisVideoContent.length; i++)
		{
			var thisPublishDate = getNodeText(thisVideoContent[i].getElementsByTagName('publishdate')[0]);
			var thisKey = new Date(thisPublishDate).getTime();
			var thisEndDate = getNodeText(thisVideoContent[i].getElementsByTagName('enddate')[0]);
			var thisVideoName = getNodeText(thisVideoContent[i].getElementsByTagName('videoname')[0]);
			var thisVideoInfo = getNodeText(thisVideoContent[i].getElementsByTagName('info')[0]);
			var thisPath = getNodeText(thisVideoContent[i].getElementsByTagName('path')[0]);
			var thisXMLPath = getNodeText(thisVideoContent[i].getElementsByTagName('xmlpath')[0]);
			var thisDisabled = getNodeText(thisVideoContent[i].getElementsByTagName('disable')[0]);
			videoContent[thisKey] = new Object();
			videoContent[thisKey].publishDate = thisPublishDate;
			videoContent[thisKey].endDate = thisEndDate;
			videoContent[thisKey].videoName = thisVideoName;
			videoContent[thisKey].videoInfo = thisVideoInfo;
			videoContent[thisKey].path = thisPath;
			videoContent[thisKey].xmlpath = thisXMLPath;
			videoContent[thisKey].isDisable = thisDisabled;
		}
		videoContent = sortAssocRev(videoContent);
		if(postAction != undefined && postAction != "")
			eval(postAction);
	};
	ajaxReqResult[ajaxVideoGetName].onException = function(){
	};
	ajaxRequest(ajaxVideoGetName,'/xml/video_album/getXML.php');
}

function video_view(objName){
	var now = new Date();
	var resultContent = "<table width=\"100%\" border=\"0\" cellpadding=\"2\" cellspacing=\"0\">";
	var i = 1;
	var thisBGColor = ["#FFFFFF","#E7E7E7"];
	for (var sKey in videoContent)
	{
		if(videoContent[sKey].isDisable != null && videoContent[sKey].isDisable.toLowerCase() == "true")
			continue;
		var thisPublishDate = new Date(videoContent[sKey].publishDate);
		if(thisPublishDate.getTime() >= now.getTime())
			continue;
		var thisEndDate;
		if(videoDefaultShowDays < 0)
		{
			thisEndDate = new Date();
			thisEndDate.setTime(thisEndDate.getTime() + 86400000);
		}else if( videoContent[sKey].endDate == null || videoContent[sKey].endDate == "")
		{
			thisEndDate = new Date(videoContent[sKey].publishDate);
			thisEndDate.setTime(thisEndDate.getTime() + (86400000*videoDefaultShowDays));
		}
		else
		{
			thisEndDate = new Date(videoContent[sKey].endDate);
		}
		if(thisEndDate.getTime() >= now.getTime())
		{
			resultContent += "<tr><td id='video_table_news_title_"+i+"' style=\"background-color:"+thisBGColor[i%thisBGColor.length]+"\">"+getNewsDate(videoContent[sKey].publishDate)+"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href=\"#\" onclick=\"andyPopup('/flv/player.html?xml="+videoContent[sKey].xmlpath+"','video',365,515,'center,center');\">"+videoContent[sKey].videoName+"</a></td></tr>" +
			"<tr><td id='video_table_news_msg_"+i+"' style=\"background-color:"+thisBGColor[i%thisBGColor.length]+"\">"+videoContent[sKey].videoInfo+"</td></tr>";
			i++;
		}
	}
	resultContent += "</table>";
	document.getElementById(objName).innerHTML += resultContent;
}

//Flash Control
function flashMovie(movieName) {
    /*if (MSIE > -1) {
        return window[movieName];
    } else {
        return document[movieName];
    }*/
	if(NETS > -1 || OPER > -1)
		return null;
	
	if(document.embeds[movieName])
		return document.embeds[movieName];
	if(window.document[movieName])
		return window.document[movieName];
	if(window[movieName])
		return window[movieName];
	if(document[movieName])
		return document[movieName];

	return null;
}

function flashMovieSetSrc(movieName, filename){
	var thisPlayer = flashMovie(movieName);
	if(thisPlayer != undefined && thisPlayer != null)
	{
		thisPlayer.setSrc(filename);
	}
}

function flashMoviePlay(movieName, filename){
	var thisPlayer = flashMovie(movieName);
	if(thisPlayer != undefined && thisPlayer != null)
	{
		if(filename != undefined && filename != null)
			thisPlayer.playFile(filename);
		else
			thisPlayer.playFile();
	}
}

function flashMovieStop(movieName){
	var thisPlayer = flashMovie(movieName);
	if(thisPlayer != undefined && thisPlayer != null)
	{
		thisPlayer.stopFile();
	}
}

function flashMoviePause(movieName){
	var thisPlayer = flashMovie(movieName);
	if(thisPlayer != undefined && thisPlayer != null)
	{
		thisPlayer.pauseFile();
	}
}

function flashMovieSetCaption(movieName, caption){
	var thisPlayer = flashMovie(movieName);
	if(thisPlayer != undefined && thisPlayer != null)
	{
		thisPlayer.setCaption(caption);
	}
}

var popupHistory = readCookie('realtime_news_popup');
function popnow(){
	if(popupHistory == null)
	{
		var popUpsBlocked = true;
		var mine = window.open('','','width=1,height=1,left=0,top=0,scrollbars=no');
		if(!mine || mine.closed || typeof mine.closed=='undefined')
		{
		} else {
			var popUpsBlocked = false;
			mine.close();
		}
		
		var thisWarning = document.getElementById('popupblockermsg');
		
		if(popUpsBlocked)
			{
				if(thisWarning != undefined)
				{
					thisWarning.innerHTML = "↑↑↑　　　請關閉所有彈出式視窗封鎖功能，以觀看本校即時資訊！　　　↑↑↑";
					 thisWarning.style.backgroundColor="#F00";
					 thisWarning.style.color="#FFF";
				}
			}
			else
			{
				if(thisWarning != undefined)
				{
					thisWarning.style.wordSpacing = 0;
				}
				andyPopup("/RTNews/rtnews_xml.html","rtnews",320,240,'center,center');
				createCookie('realtime_news_popup','true');
			}
	}
}
