function displayTopBanner() {
	var html = '';
	var bFlashEnabled = false;
	if (bFlashEnabled) {
		html = '                  <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="778" height="95"> ';
		html = html + '                    <param name="movie" value="banner2.swf"> ';
		html = html + '                    <param name="quality" value="high"> ';
		html = html + '                    <param name="wmode" value="transparent"> ';
		html = html + '                    <embed src="banner2.swf" width="778" height="95" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="transparent"></embed> ';
		html = html + '                  </object>';
	} else {
		html = '';
		eTopBanner.style.background = 'url(images/topbanner.jpg)';
		document.write('<script language=javascript src=data.jsp?mode=js></script>');
		document.body.onload = function() { eTopBannerBody.innerHTML = '<marquee class=topMarquee>' + V_TopMarqueeText + '</marquee>'; }
	}
	document.write(html);
}

function setPagePath(htmlSrc) {
	var separator = '&nbsp;&gt;&nbsp;';

	var pathElement = eSubPath;
	htmlSrc = htmlSrc.replace(/\[sp\]/ig, separator);
	pathElement.innerHTML = htmlSrc;
}

function showClock(initTime) {
	document.write(FormatDateTime(new Date(initTime), 1));
}

/**************************************************************
 FormatDateTime: Returns an expression formatted as a date or 
                 time. If DateTime is null then false is
                 returned.

 Parameters:
      DateTime   = Date/Time expression to be formatted
      FormatType = Numeric value that indicates the date/time 
                   format used. If omitted, GeneralDate is used
                   0 = Very Long Date/Time Format (Thu hai, 10/06/2000 12:02:30)
                   1 = Long Date/Time Format (Thu hai, 10/06/2000)
                   2 = Short Date (01/10/00)
                   3 = Long Time (04:20:23)
                   4 = Military Time (04:43)

 Returns: String
***************************************************************/
function FormatDateTime(DateTime, FormatType)
{
	if (DateTime == null)
		return (false);

	if (FormatType < 0)
		FormatType = 1;

	if (FormatType > 4)
		FormatType = 1;

	var strDate = "";
	var strDay = "";
	var strMonth = "";
	var strMonthNumber = "";
	var strYear = "";
	var strshortTime = "";
	var strlongTime = "";


	if (strDate.toUpperCase() == "NOW")
	{
		var myDate = new Date();
		strDate = String(myDate);
	}
	else
	{
		var myDate = new Date(DateTime);
		strDate = String(myDate);
	}

	strDay = new String(strDate.substring(0, 3));
	if (strDay == "Sun") strDay = "Chủ Nhật";
	if (strDay == "Mon") strDay = "Thứ Hai";
	if (strDay == "Tue") strDay = "Thứ Ba";
	if (strDay == "Wed") strDay = "Thứ Tư";
	if (strDay == "Thu") strDay = "Thứ Năm";
	if (strDay == "Fri") strDay = "Thứ Sáu";
	if (strDay == "Sat") strDay = "Thứ Bảy";

	strMonth = new String(strDate.substring(4, 7));
	if (strMonth == "Jan") { strMonth = "Tháng một";        strMonthNumber = "01"; }
	if (strMonth == "Feb") { strMonth = "Tháng hai";          strMonthNumber = "02"; }
	if (strMonth == "Mar") { strMonth = "Tháng ba";           strMonthNumber = "03"; }
	if (strMonth == "Apr") { strMonth = "Tháng tư";          strMonthNumber = "04"; }
	if (strMonth == "May") { strMonth = "Tháng năm";         strMonthNumber = "05"; }
	if (strMonth == "Jun") { strMonth = "Tháng sáu";         strMonthNumber = "06"; }
	if (strMonth == "Jul") { strMonth = "Tháng bảy";        strMonthNumber = "07"; }
	if (strMonth == "Aug") { strMonth = "Tháng tám";         strMonthNumber = "08"; }
	if (strMonth == "Sep") { strMonth = "Tháng chín";         strMonthNumber = "09"; }
	if (strMonth == "Oct") { strMonth = "Tháng mười";      strMonthNumber = "10"; }
	if (strMonth == "Nov") { strMonth = "Tháng mười một";strMonthNumber = "11"; }
	if (strMonth == "Dec") { strMonth = "Tháng mười hai";  strMonthNumber = "12"; }


	var curPos = 11;
	var strMonthDay = new String(strDate.substring(8, 10));
	if (strMonthDay.charAt(1) == " ")
	{
		strMonthDay = "0" + strMonthDay.charAt(0);
		curPos--;
	}	
	
	if (strDate.substring(curPos+4,curPos+5) == " ")	
	{
		strYear = new String(strDate.substring(curPos, curPos + 4));
		strshortTime =  new String(strDate.substring(curPos + 5, curPos + 10));
		strlongTime =  new String(strDate.substring(curPos + 5, curPos + 13));
	}
	else
	{
		strYear =  new String(strDate.substring(strDate.length - 4, strDate.length));
		strshortTime =  new String(strDate.substring(curPos, curPos + 5));
		strlongTime =  new String(strDate.substring(curPos, curPos + 8));
	}


	// Format Type decision time!
	if (FormatType == 0)
		strDate = strDay + ", " + strMonthDay + "/" + strMonthNumber + "/" + strYear + " " + strlongTime;
	else if (FormatType == 1)
		strDate = strDay + ", " + strMonthDay + "/" + strMonthNumber + "/" + strYear;
	else if (FormatType == 2)
		strDate = strMonthDay + "/" + strMonthNumber + "/" + strYear;
	else if (FormatType == 3)
		strDate = strlongTime;
	else if (FormatType == 4)
		strDate = strshortTime;

	return strDate;
}





// Functions implementation //---------------------------------------------------


function setCookie(sName, sValue) {
  document.cookie = sName + "=" + escape(sValue) + "; expires=Fri, 31 Dec 2099 23:59:59 GMT";
}

function getCookie(sName) {
  // cookies are separated by semicolons
  var aCookie = document.cookie.split("; ");
  for (var i=0; i < aCookie.length; i++)
  {
    // a name/value pair (a crumb) is separated by an equal sign
    var aCrumb = aCookie[i].split("=");
    if (sName == aCrumb[0]) 
      return unescape(aCrumb[1]);
  }

  // a cookie with the requested name does not exist
  return null;
}

function delCookie(sName) {
  document.cookie = sName + "=" + escape(getCookie(sName)) + "; expires=Fri, 31 Dec 1999 23:59:59 GMT;";
}






// Advertisement functions //===================================================

/*
// BEGIN HELP //================================================================

function displayAdRotator(locationName)
	Display an advertisement rotator

displayLogos(locationName)
	Display a LIST of advertisements

// END HELP //================================================================
*/




// BEGIN VARIABLES //================================================================

// Define advertisement array: //////// (each row has the following fields: [ID, Caption, Image, URL, LocationName] )
/*
var v_AdList = [
	['25','sotran-logistic','Media/Advertisement/sotran-aalogistic(1).gif','http://www.sotrans.com.vn','LOGO'],
	['29','viethoa-hungdao','Media/Advertisement/viethoa-hungdao.gif','http://www.viethoagroup.com','LOGO'],
	['21','biendong-hanhan','Media/Advertisement/biendong-hanhan(1).gif','http://www.biendong.com.vn','LOGO'],
	['30','phuongnam-CFS','Media/Advertisement/phuongnam-CFS.gif','http://www.pntcshipping.com','LOGO'],
	['31','chinashipping-thaminco','Media/Advertisement/chinashipping-thaminco(1).gif','http://www.cscl.com.cn','LOGO'],
	['32','golbook-ITL','Media/Advertisement/golbook-ITL.gif','http://www.golbook.com','LOGO'],
	['33','loma-konoike','Media/Advertisement/Loma-konoike(1).gif','http://www.lomalogistics.com','LOGO'],
	['34','T&MExpress-AP','Media/Advertisement/T&M-AP(1).gif','http://www.alpha-tmexpress.com','LOGO'],
	['35','T&MFORWARDING-ANKHAI','Media/Advertisement/T&Mforwarding-ANKHAI.gif','http://www.tmforwarding.com','LOGO'],
	['36','COSCO-GTL','Media/Advertisement/cosco-GTL.gif','http://www.cosco.com','LOGO']
];
*/
// THIS LIST HAS BEEN COMMENTED OUT => DEFINE EXTERNALLY!


// Time interval between two advertisements ////////
var nSkipInterval = 5000;

// END VARIABLES //================================================================







// BEGIN FUNCTIONS //================================================================

function getAd(ad) {
	var src = '';
		var image = ad[2];
		var link = ad[3];
		var locxn = ad[4];
		var target = ad.length>=6?ad[5]:'_blank';
			if (image.match(/\.swf$/i) != null) {
				src = src + '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://active.macromedia.com/flash4/cabs/swflash.cab#version=4,0,0,0" width="468" height="60">';
				src = src + '  <param name="movie" value="'+ image +'">';
				src = src + '  <param name="quality" value="high">';
				src = src + '  <param name="bgcolor" value="#B3CFE7">';
				src = src + '  <embed name="home1" src="'+ image +'" quality="high" bgcolor="#B3CFE7" width="468" height="60"';
				src = src + '    type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash">';
				src = src + '  </embed>';
				src = src + '</object>';
			} else {
				src = '<a href="'+ link +'" target="'+ target + '"><img border=0 src="'+ image +'"></a>';
			}
	src = src + '';
	return src;
}


window.AdProperties = new Array();

function displayAdRotator(locationName) {	// Ad Rotator
	var i;
	if (!window.AdProperties[locationName + '__bAdBoxConstructed']) {
		// Construct banner array to generate a random index for Top Banner
		window.AdProperties[locationName + '__nAdIndex'] = -1;
		window.AdProperties[locationName + '__bStillHaveBanner'] = true;
		if (typeof(v_AdList) == 'object')
			if (v_AdList.length > 0) {
				var i, n = 0, aAdIndexes = new Array();
				for (i=0; i<v_AdList.length; i++)
					if (v_AdList[i][4] == locationName)		// gotcha, a disired Ad!
						aAdIndexes[n++] = i;
				window.AdProperties[locationName + '__nAdIndex'] = aAdIndexes[Math.round(Math.random() * 1000) % (aAdIndexes.length)] - 1;
			}

		document.write('<div id="eAdBox__'+ locationName +'"></div>');
		window.AdProperties[locationName + '__bAdBoxConstructed'] = true;
		
	}
	if (typeof(v_AdList) == 'object') {
		var html = null, bGotBanner = false;
		for (i=0; i<v_AdList.length; i++) {
			var ad = v_AdList[i];
			var locxn = ad[4];

			if (locxn == locationName && (i > window.AdProperties[locationName + '__nAdIndex'] || !window.AdProperties[locationName + '__bStillHaveBanner']))	{ // ad type = Banner
				if (!bGotBanner) {
					html = '<table cellpadding=0 cellspacing=0 width="100%"><tr><td align=center>' + getAd(v_AdList[i]) + '</td></tr></table>';
					window.AdProperties[locationName + '__nAdIndex'] = i;
					bGotBanner = true;
					window.AdProperties[locationName + '__bStillHaveBanner'] = false;
				} else window.AdProperties[locationName + '__bStillHaveBanner'] = true;
			}
		}
		if (html != null)
			document.getElementById('eAdBox__'+ locationName).innerHTML = html;
		setTimeout('displayAdRotator("'+ locationName +'")', nSkipInterval);
	}
}


function displayLogos(locationName) {
	if (v_AdList.length <= 0) return ;
	var i, src = '<table cellspacing=0 cellpadding=3 align=center>';
	for (i=0; i<v_AdList.length; i++) {
		var ad = v_AdList[i];	
		if (ad[4] == locationName) {
			src += '<tr><td>';
			src += getAd(v_AdList[i]);
			src += '</td></tr>';
		}
	}
	src = src + '</table>';
	document.write(src);
}

// END FUNCTIONS //================================================================
