/* /Skins/Default/Scripts/VIEPortalNG.Banner.js ---------- */

/* ----------------------------------------------------------------------

	VIE Portal - Banner Library
	Written by Quynh Nguyen - VIEPortal.net

	Notes: using Prototype.js, script.aculo.us effects.js and jQuery (with $j)

-----------------------------------------------------------------------	*/

function vieBanner()
{
	this.objectId;
	this.info = null;
	
	this.itemCss = "";
	this.titleCss = "bannerTitle";
	this.descriptionCss = "bannerDescription";
	
	this.desktopId = "";
	this.portletId = "";
	this.offsetTop = 10;
	
	this.isRotator = false;
	this.rotator = null;
	this.roratorCss = "";
	
	this.processId = -1;
}

vieBanner.prototype = {

	init : function ()
	{
		// get name of object variable
		if(arguments.length > 0) {
			this.objectId = arguments[0];
		}
		if(this.objectId == null || this.objectId == "")
		{
			alert("The variable name of banner object must be not null.");
			return;
		}

		// get other settings
		if(arguments.length > 1) {
			this.titleCss = arguments[1];
		}
		
		if(arguments.length > 2) {
			this.descriptionCss = arguments[2];
		}
		
		if(arguments.length > 3) {
			this.roratorCss = arguments[3];
		}
	}
	,
	
	show : function ()
	{
		// check rotator banner state
		this.isRotator = this.info[1] > this.info[2] && this.info[2] == 1 
										&& this.info[5] && this.info[6] > 0 && this.info[7] > 0;
		
		// create banners
		if(this.info[9] != 1 && this.info[9] != 2) {
			this.createBanners();
		}
		
		// show banners
		switch(this.info[9])
		{
			// popup
			case 1:
				this.popup();
				break;
				
			// inline popup
			case 2:
				this.inline();
				break;
				
			// slliding
			case 3:
			case 4:
				this.slide();
				break;
			
			// normal
			default:
				break;
		}
		
		// change (switch items)
		if(!this.isRotator && this.info[1] > this.info[2] && this.info[9]!=1 && this.info[9]!=2)
		{
			var __b = this;
			this.processId = window.setTimeout( function() { __b.change(); }, this.info[4] * 1000);
		}
	}
	,
	
	// show as popup
	popup : function()
	{
		var url = this.info[11] + 'Display/' + this.desktopId + '/' + this.portletId;
		var width = this.info[6];
		if(width == 0) {
			width = 500;
		}
		var height = this.info[7];
		if(height == 0) {
			height = 500;
		}
		___openPopup(url, width, height);
	}
	,
	
	// show as inline popup
	inline : function()
	{
		var url = this.info[11] + 'Display/' + this.desktopId + '/' + this.portletId;
		var width = this.info[6];
		if(width == 0) {
			width = 500;
		}
		var height = this.info[7];
		if(height == 0) {
			height = 500;
		}
		myLightWindow.activateWindow({href: url, title: 'VIEPortal NG Banners', width:width, height:height});
	}
	,
	
	// show as sliding
	slide : function()
	{
		// get the scroll banner by Id
		var slidingObj = $('View_' + this.info[0]);
		if(!slidingObj) {
			return;
		}
		
		// computing the starting positions of the banner	
		var type = 0;
		if(this.info[9] == 4) {
			type = 1;
		}
		
		var startX, startY = 0;
		if(document.body.clientWidth < this.info[8]) {
			startX = -200;
		}	
		else
		{
			// scroll left
			if(type == 0) {
				startX = 1;
			}
			// scroll right
			else {
				startX = document.body.clientWidth - 200;
			}
		}
		
		// display the banner
		slidingObj.style.display = "block";
		slidingObj.style.position = "absolute";

		// set positions and scrolling
		slidingObj.x = startX;
		slidingObj.y = startY;
		this.slidingBanners(slidingObj, type);
	}
	,
	
	// chagen )switch items)
	change : function()
	{
		// prepare information
		var maxIndex = this.info[1];
		var step = this.info[2];
		var currentIndex = this.info[3];
		if(step >= maxIndex) {
			return;
		}
			
		// change banner
		var nextIndex = currentIndex;
		for(var index=0; index < step; index++)
		{
			var layerId = this.objectId + "_" + (index + 1);
			nextIndex++;
			if(nextIndex > maxIndex)
				nextIndex = 1;
			this.replaceItemHtml(layerId, nextIndex);
		}
			
		// update
		if(nextIndex >= maxIndex) {
			nextIndex = 0;
		}
		this.info[3] = nextIndex;
		
		var __b = this;
		this.processId = window.setTimeout(function() { __b.change(); }, this.info[4] * 1000);
		
		// reposistion icons of portlets
		___repositionPortletIcons();
	}
	,
	
	replaceItemHtml : function(layerId, infoIndex)
	{
		// get layer
		var layer = $(layerId);
		if(!layer) {
			return;
		}
		
		// get information	
		var width = 0, height = 0;
		if(this.info[5])
		{
			width = this.info[6];
			height = this.info[7];
		}
		
		// prepare banner display code
		var bannerInfo = this.info[11 + infoIndex];
		var html = '';
		switch (bannerInfo[4])
		{
			case 'Image':
				html = this.getImageBannerHtml(bannerInfo, width, height);
				break;
				
			case 'Flash':
				html = this.getFlashBannerHtml(bannerInfo, width, height);
				break;
				
			case 'Video':
				html = this.getVideoBannerHtml(bannerInfo, width, height);
				break;
				
			case 'Text':
				html = this.getTextBannerHtml(bannerInfo, width, height);
				break;
				
			default:
				break;
		}
		
		// update new HTML code
		layer.innerHTML = html;
	}
	,

	// display banners of popup/inline	
	display : function ()
	{
		// check rotator banner state
		this.isRotator = this.info[1] > this.info[2] && this.info[2] == 1 
										&& this.info[5] && this.info[6] > 0 && this.info[7] > 0;
		
		// create banners
		this.createBanners();
		
		// change (switch items)
		if(!this.isRotator && this.info[1] > this.info[2] && this.info[9]!=1 && this.info[9]!=2)
		{
			var __b = this;
			this.processId = window.setTimeout( function() { __b.change(); }, this.info[4] * 1000);
		}
	}
	,
	
	createBanners : function ()
	{
		// create banners
		var html = "";
		if(this.isRotator) {
			html = this.getBannerHtml(1, this.info[1], true);
		}
		else {
			html = this.getBannerHtml(1, this.info[2], false);
		}
		$('View_' + this.info[0]).innerHTML = html;
		
		// only one item will be displayed, then use as rotator
		if(this.isRotator)
		{
			this.rotator = new vieRotator();
			this.rotator.effect = "opacity";
			this.rotator.init(this.objectId + ".rotator", this.objectId + "_Rotator", this.info[4], false, '', true, true);
		}
	}
	,
	
	getBannerHtml : function (startIndex, endIndex, isRotator)
	{
		// computing fixed width & height
		var width = 0, height = 0;
		if(this.info[5])
		{
			width = this.info[6];
			height = this.info[7];
		}

		// prepare html
		var html = '';
		
		if(isRotator)
		{
			html += '<div style="overflow:hidden;position:relative;width:';
			if(width > 0) {
				html += width + 'px;';
			}
			else {
				html += 'auto;';
			}
			html += 'height:';
			if(height > 0) {
				html += height + 'px;';
			}
			else {
				html += 'auto;';
			}
			html += '" id="' + this.objectId + '_Rotator"';
			if(this.roratorCss != "")
			{
				html += ' class="' + this.roratorCss + '"';
			}
			html += '>';
		}
		
		// generate items
		for(var index=startIndex; index <= endIndex; index++)
		{
			var id = this.objectId + '_' + index;
			html += this.getBannerItemHtml(this.info[11 + index], id, width, height, isRotator);
		}
		
		if(isRotator) {
			html += '</div>';
		}
		
		return html;
	}
	,

	getBannerItemHtml : function (info, id, width, height, isRotator)
	{
		var html = '<div id="' + id + '"';
		if(isRotator)
		{
			html += ' style="position:absolute;top:0px;left:0px;';
			if(width > 0) {
				html += 'width:' + width + 'px;';
			}
			if(height > 0) {
				html += 'height:' + height + 'px;';
			}
			html += '"';
		}
		else
		{
			html += ' style="position:relative;text-align:center;';
			if(width > 0) {
				html += 'width:' + width + 'px;';
			}
			if(height > 0) {
				html += 'height:' + height + 'px;';
			}
			html += '"';
			html += ' class="';
			if(this.itemCss != "") {
				html += this.itemCss + ' ';
			}
			if(this.info[10] == 0) {
				html += 'clear';
			}
			else {
				html += 'left';
			}
			html += '"';
		}
		html += '>';
		switch (info[4])
		{
			case 'Image':
				html += this.getImageBannerHtml(info, width, height);
				break;
				
			case 'Flash':
				html += this.getFlashBannerHtml(info, width, height);
				break;
				
			case 'Video':
				html += this.getVideoBannerHtml(info, width, height);
				break;
				
			case 'Text':
				html += this.getTextBannerHtml(info, width, height);
				break;
				
			default:
				break;
		}
		html += '</div>';
		return html;
	}
	,
		
	getImageBannerHtml : function(info, width, height)
	{
		var html = '';
		if(info[3] != '')
		{
			html += '<a href="' + info[8] + '"';
			if(info[6] != '' && info[6] != '_self') {
				html += '" target="' + info[6] + '"';
			}
			html += '>';
		}
		html += this.getImageHtml(info[7], info[1], width, height);
		if(info[3] != '') {
			html += '</a>';
		}
		return html;
	}
	,
	
	getFlashBannerHtml : function(info, width, height)
	{
		var html = ___getFlashPlayerCode(info[7], width, height, "__f_" + info[0]);
		if(info[5] && info[3] != '') {
			html += this.getWrapperHtml(info[8], info[1], width, height);
		}
		return html;
	}
	,
	
	getVideoBannerHtml : function(info, width, height)
	{
		var html = '';
		if(info[7].indexOf('.flv')>0) {
			html += ___getFlashMediaPlayerCode(___vieportalGlobalUrl + 'Common/Controls/MediaPlayer.swf', info[7], width, height, true, "__v_" + info[0]);
		}
		else {
			html += ___getWindowsMediaPlayerCode(info[7],width, height, true, "__v_" + info[0]);
		}
		if(info[5] && info[3] != '') {
			if(info[7].indexOf('.flv')>0) {
				html += this.getWrapperHtml(info[8], info[1], width, height - 24);
			}
			else {
				html += this.getWrapperHtml(info[8], info[1], width, height);
			}
		}
		return html;
	}
	,
	
	getTextBannerHtml : function(info, width, height)
	{
		var html = '<div style="';
		if(width > 0) {
			html += 'width:' + width + 'px;';
		}
		if(height > 0) {
			html += 'height:' + height + 'px;';
		}
		html += '"><div';
		if(this.titleCss != "") {
			html += ' class="' + this.titleCss + '"';
		}
		html += '>';
		if(info[3] != "")
		{
			html += '<a href="' + info[8] + '"';
			if(info[6] != '' && info[6] != '_self')
			{
				html += '" target="' + info[6] + '"';
			}
			html += '>';
		}
		html += info[1];
		if(info[3] != '') {
			html += '</a>';
		}
		html += '</div><div';
		if(this.descriptionCss != "") {
			html += ' class="' + this.descriptionCss + '"';
		}
		html += '>' + info[2] + '</div></div>';
		return html;
	}
	,
	
	getImageHtml : function(imageUri, title, width, height)
	{
		var imgHtml = '<img border="0" alt="' + title + '" src="' + imageUri + '"';
		if(width > 0 || height > 0)
		{
			imgHtml += ' style="';
			if(width > 0) {
				imgHtml += 'width:' + width + 'px;';
			}
			if(height > 0) {
				imgHtml += 'height:' + height + 'px;';
			}
			imgHtml += '"';
		}
		return imgHtml + '/>';
	}
	,
	 
	getWrapperHtml : function(url, target, width, height)
	{
		var html = '<div style="position:absolute;top:0px;left:0px;';
		if(width > 0) {
			html += 'width:' + width + 'px;';
		}
		if(height > 0) {
			html += 'height:' + height + 'px;';
		}
		html += '"><a href="' + url + '"';
		if(target != '') {
			html += ' target="' + target + '"';
		}
		html += '>' + this.getImageHtml(___vieportalGlobalUrl + 'Common/Images/dot.gif', '', width, height)
					+ '</a></div>';
		return html;
	}
	,
	
	slidingBanners : function(slidingObj, type)
	{
		// hide banner if screen width is less than minimum screen width (best value: 1280 pixels)
		if (document.body.clientWidth < this.info[8])
		{
			slidingObj.style.display = "none";
			this.waitSlidingBanners(slidingObj, type, 1000);
			return;
		}
		else if(slidingObj.style.display == "none") {
			slidingObj.style.display = "block";
		}
			
		// re-computing the positions
		var ns = navigator.appName.indexOf("Netscape") != -1;
		var startX, startY;
		var pY = 0;

		// computing offset
		if (document.documentElement && document.documentElement.scrollTop) {
			pY = ns ? pageYOffset : document.documentElement.scrollTop;
		}	
		else if (document.body) {
			pY = ns ? pageYOffset : document.body.scrollTop;
		}
		
		// computing top position
		if (document.body.scrollTop > this.offsetTop) {
			startY = 2;
		}
		else {
			startY = this.offsetTop;
		}
		
		// computing left position
		// scroll left
		if(type == 0) {
			startX = 1;
		}
		// scroll right
		else {
			startX = document.body.clientWidth - Element.getWidth(slidingObj);
		}
		
		// re-positions		
		slidingObj.y += (pY + startY - slidingObj.y)/8;
		slidingObj.style.left = startX + "px";
		slidingObj.style.top = slidingObj.y + "px";

		// for scrolling smoothly
		if(slidingObj.style.top.indexOf(".") > 0) {
			this.waitSlidingBanners(slidingObj, type, 30);
		}
		else {
			this.waitSlidingBanners(slidingObj, type, 100);
		}
	}
	,
	
	waitSlidingBanners : function(slidingObj, type, time)
	{
		var __b = this;
		this.processId = window.setTimeout(function() { __b.slidingBanners(slidingObj, type); }, time);
	}
};
/* /Skins/Default/Scripts/VIEPortalNG.DateTime.js ---------- */

/* ----------------------------------------------------------------------

	VIE Portal - DateTime Library
	Written by Quynh Nguyen - VIEPortal.net

-----------------------------------------------------------------------	*/

function vieDateTime()
{
	this.language = "en";
	this.showDate = true;
	this.dateFormat = "mm-dd yyyy";
	this.showDay = true;
	this.showTime = true;
	this.showAsGMT = false;
}

vieDateTime.prototype = {

	getDateTime : function ()
	{
		var days = new Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
		var months = new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
		if(this.language == "vi")
		{
			days = new Array("Ch&#7911; nh&#7853;t","Th&#7913; hai","Th&#7913; ba","Th&#7913; t&#432;","Th&#7913; n&#259;m","Th&#7913; s&#225;u","Th&#7913; b&#7843;y");
			months = new Array("01","02","03","04","05","06","07","08","09","10","11","12");
		}
		
		var now = new Date();
		
		var day = "";
		var date = "";
		var month = "";
		var time = "";
		var first_date_num ="";
		var result = "";

		// show date
		if(this.showDate)
		{
			// long date
			if(this.showDay)
				day = days[now.getDay()] + ", ";
			month = months[now.getMonth()];
			date = now.getDate();
			if (date < 10)
				date = "0" + date;
			result += day + this.dateFormat.replace(/dd/g, date).replace(/mm/g, month).replace(/yyyy/g, now.getFullYear());
		}
		
		// show time
		if(this.showTime)
		{
			var symbol = "AM";
			if(this.showAsGMT) {
				time = new String(now.getUTCHours());
			}
			else {
				time = new String(now.getHours());
			}
			
			if(time >= 12) {
				time = time - 12;
				symbol = "PM";
			}
			
			if (time.length < 2) {
				time = "0" + time;
			}
			var minute = new String(now.getMinutes());
			if (minute.length < 2) {
				minute = "0"+ minute;
			}
			time = time  + ":" + minute + "&nbsp;" + symbol;
			if(this.showAsGMT) {
				time += " (GMT)";
			}
			if(result!="") {
				result += "  ";
			}
			result += time;
		}
		return result;
	}
	,
	
	show : function ()
	{
		// get culture language
		this.language = arguments[0] || "";
		if(this.language=="")
			this.language = calLanguage;
	
		// change format
		if(this.language == "vi") {
			this.dateFormat = "dd/mm/yyyy";
		}
		
		// get html and display
		var html = "<div style='white-space:nowrap;'>" + this.getDateTime() + "</div>";
		document.write(html);
	}
};

function _showDateTime()
{
	var dt = new vieDateTime();
	dt.showDate = arguments[0]||true;
	dt.showTime = arguments[1]||true;
	dt.showDay = arguments[2]||true;
	dt.showAsGMT = arguments[3]||false;
	var language = arguments[4]||"";
	dt.show(language);
}

function _showEnglishDateTime()
{
	var dt = new vieDateTime();
	dt.showDate = arguments[0]||true;
	dt.showTime = arguments[1]||true;
	dt.showDay = arguments[2]||true;
	dt.showAsGMT = arguments[3]||false;
	dt.show("en");
}
/* /Skins/Default/Scripts/VIEPortalNG.Menu.js ---------- */

/* ----------------------------------------------------------------------

	VIE Portal - Menu Library
	Written by Quynh Nguyen - VIEPortal.net

	Notes: using Prototype.js ($) and jQuery ($j)

-----------------------------------------------------------------------	*/

function vieMenu()
{
	this.objectId = "";
	
	this.menuId = "";
	this.menuItems = [];
	
	this.subMenuId = "";
	this.subMenuPrefix = "hSub";
	this.subMenuPosition = "under";
	this.subMenuAlignment = "left";				// left, center or none
	
	this.activeCss = "";
	this.activeStartCss = "";
	this.activeEndCss = "";
	this.inactiveCss = "";
	this.inactiveStartCss = "";
	this.inactiveEndCss = "";

	this.currentIndex = -1;
	this.activeIndex = -1;
	this.selectedIndex = -1;
	this.delayHideTimer = 500;
	this.delayHideId = -1;
	this.availableWidth = -1;

	this.thirdMenuId = "";
	this.thirdMenuDelayHideId = "";	
	this.delayHideThirdId = -1;
	this.offsetTop = 7;
	this.offsetLeft = 5;
}

vieMenu.prototype = {
	init : function ()
	{
		// name of object variable
		if(arguments.length > 0) {
			this.objectId = arguments[0];
		}
		if(!this.objectId || this.objectId == "")
		{
			alert("The name of menu object must be not null.");
			return;
		}
		
		// Id of element that contains all menu items
		if(arguments.length > 1) {
			this.menuId = arguments[1];
		}
		
		// Id of element that use to display sub-menus
		if(arguments.length > 2) {
			this.subMenuId = arguments[2];
		}
		
		// Id of selected item will be show at first-time
		var selectedId = null;
		if(arguments.length > 3) {
			selectedId = arguments[3];
		}
		
		// prepare menu
		var __m = this;
		$j(document).ready(function () {
			
			// get menu items
			__m.getMenus();	
			
			// assign class and events of all menu items
			for(var index=0; index<__m.menuItems.length; index++)
			{
				if(selectedId && selectedId == __m.menuItems[index]) {
					__m.currentIndex = index;
				}
				__m.setCss(index, index == __m.currentIndex);
				var menuObj = $(__m.menuItems[index]);
				if(menuObj)
				{
					menuObj.writeAttribute("onmouseover", __m.objectId + ".active(this);");
					menuObj.writeAttribute("onmouseout", __m.objectId + ".deactive();");
				}
			}
			
			// assign events of sub-menu
			var subMenuContainer = $(__m.subMenuId);
			if(subMenuContainer)
			{
				subMenuContainer.writeAttribute("onmouseover", __m.objectId + ".clearHide();");
				subMenuContainer.writeAttribute("onmouseout", __m.objectId + ".deactive();");
				subMenuContainer.style.position = "relative";
			}
			
			// show active menu 
			if(__m.currentIndex < 0) {
				__m.currentIndex = 0;
			}
			__m.show(__m.currentIndex);
		});
	}
	,
	
	active : function (obj)
	{
		if(!obj || !obj.id || obj.id == "") {
			return;
		}
		
		var index = 0;
		while (index < this.menuItems.length)
		{
			if(this.menuItems[index] == obj.id) {
				break;
			}
			else {
				index++;
			}
		}
		this.show(index);
	}
	,
	
	deactive : function ()
	{	
		var __m = this;
		this.delayHideId = window.setTimeout(function() { __m.show(__m.currentIndex); }, this.delayHideTimer);	
	}
	,
	
	show : function (index)
	{
		// clear hide timer
		this.clearHide();
		
		// check
		if (index < 0 || this.selectedIndex == index) {
			return;
		}
		
		// get menu objects
		var selectedMenu = $(this.menuItems[this.selectedIndex]);
		var activeMenu = $(this.menuItems[index]);
		
		// set Css
		this.activeIndex = index;
		this.setActive(this.activeIndex);
		this.setInActive(this.selectedIndex);
		this.selectedIndex = index;
		
		// show sub-menus
		var subMenus = null;
		if(selectedMenu)
		{
			subMenus = $(this.subMenuPrefix + selectedMenu.id);
			if(subMenus)
			{
				subMenus.style.visibility = "hidden";
				subMenus.style.display = "none";
			}
		}
				
		subMenus = null;
		if(activeMenu)
		{
			subMenus = $(this.subMenuPrefix + activeMenu.id);
			if(subMenus)
			{
				subMenus.style.position = "absolute";
				subMenus.style.display = "block";
				subMenus.style.visibility = "visible";
				subMenus.style.left = this.getPosition(activeMenu, subMenus) + "px";
			}
		}
	}
	,
	
	getPosition : function(menuObj, subMenuObj)
	{
		// if alignment is "none", then return position is zero
		if(this.subMenuAlignment == "none") {
			return 0;
		}
		
		// get available width
		if(this.availableWidth < 0) {
			this.availableWidth = Element.getWidth(this.subMenuId);
		}

		// initialize position		
		var pos =	menuObj.offsetLeft;
		var width = subMenuObj.getWidth();
		var left = 0;
		
		// computing "left" position		
		if(this.subMenuAlignment == "left")
		{
			left = pos - this.offsetLeft;
			if(left < 0) {
				left = 0;
			}
			else if(left + width > this.availableWidth)
			{
				left = this.availableWidth - width - this.offsetLeft;
				if(left < 0) {
					left = 0;
				}
			}
		}
		
		// computing "center" position	
		else
		{
			pos += menuObj.getWidth() / 2;
			left = pos - (width/2);
			if(left < 0) {
				left = 0;
			}
			else if(left + width > this.availableWidth)
			{
				left = this.availableWidth - width;
				if(left < 0) {
					left = 0;
				}
			}
		}		
		return left;
	}
	,
	
	showSub : function (menuObj)
	{
		if(menuObj) {
			this.showSubMenu(menuObj.id);
		}
	}
	,
	
	hideSub : function (menuObj)
	{
		// get object
		if(!menuObj || menuObj == 'undefined') {
			return;
		}
		
		var subMenuObj = $(this.subMenuPrefix + menuObj.id);
		if(subMenuObj)
		{
			this.thirdMenuDelayHideId = subMenuObj.id;
			var __m = this;
			this.delayHideThirdId = window.setTimeout(function() { __m.hideSubMenu(subMenuObj.id); }, this.delayHideTimer/2);
		}
	}
	,
	
	showMe : function (obj)
	{
		if(obj && obj != 'undefined')
		{
			if(obj.style.display == "none") {
				obj.style.display = "block";
			}
			this.clearHideSub();
			this.clearHide();
		}
	}
	,
	
	hideMe : function (obj)
	{
		this.thirdMenuDelayHideId = obj.id;
		var __m = this;
		this.delayHideThirdId = window.setTimeout(function() { __m.hideSubMenu(obj.id); }, this.delayHideTimer/2);
		this.deactive();
	}
	,
	
	showSubMenu : function (id)
	{
		// get objects
		if(!id || id == '') {
			return;
		}
		var menuObj = $(id);
		if(!menuObj || menuObj == 'undefined') {
			return;
		}
		var subMenuObj = $(this.subMenuPrefix + id);
		if(!subMenuObj || subMenuObj == 'undefined') {
			return;
		}
		
		// prepare position
		var pos =	Element.cumulativeOffset(menuObj);
		var left = pos.left + this.offsetLeft;
		var top = pos.top + this.offsetTop;
		
		if(this.subMenuPosition == "under") {
			top += Element.getHeight(menuObj);
			if(Prototype.Browser.IE) {
				top += 2;
			}
		}
		else if(this.subMenuPosition == "top") {
			top -= Element.getHeight(menuObj) + Element.getHeight(subMenuObj);
		}
		
		// set display
		subMenuObj.style.position = "absolute";
		subMenuObj.style.display = "block";
		subMenuObj.style.left = left + "px";
		subMenuObj.style.top = top + "px";
		subMenuObj.style.visibility = "visible";
		
		// show/hide other sub-menus		
		if(this.thirdMenuDelayHideId == subMenuObj.id) {
			this.clearHideSub();
		}
		
		if(this.thirdMenuId != "" && this.thirdMenuId != subMenuObj.id) {
			this.hideSubMenu(this.thirdMenuId);
		}
		
		// assign Id of currently third menu
		this.thirdMenuId = subMenuObj.id;
	}
	,
	
	hideSubMenu : function (id)
	{
		this.clearHideSub();
		if(!id || id == '') {
			return;
		}
		var menuObj = $(id);
		if(menuObj)
		{
			menuObj.style.display = 'none';
			menuObj.style.visibility = 'hidden';
		}
	}
	,
	
	clearHideSub : function ()
	{
		if(!this.delayHideThirdId || this.delayHideThirdId < 0) {
			return;
		}
		window.clearTimeout(this.delayHideThirdId);
		this.delayHideThirdId = -1;
		this.thirdMenuDelayHideId = "";
	}
	,
	
	setActive : function (index)
	{
		this.setCss(index, true);
	}
	,
	
	setInActive : function (index)
	{
		this.setCss(index, false);
	}
	,
	
	setCss : function (index, isActive)
	{	
		// get object
		if(index < 0 || index >= this.menuItems.length) {
			return;
		}
		var obj = $(this.menuItems[index]);
		if(!obj) {
			return;
		}
		
		// get Css
		var activeCss = this.activeCss;
		var inactiveCss = this.inactiveCss;
		if(index == 0)
		{
			if(this.activeStartCss != "") {
				activeCss = this.activeStartCss;
			}
			if(this.inactiveStartCss != "") {
				inactiveCss = this.inactiveStartCss;
			}
		}
		else if(index == this.menuItems.length - 1)
		{
			if(this.activeEndCss != "") {
				activeCss = this.activeEndCss;
			}
			if(this.inactiveEndCss != "") {
				inactiveCss = this.inactiveEndCss;
			}
		}
		
		// set Css
		if(isActive)
		{
			if(inactiveCss != "") {
				obj.removeClassName(inactiveCss);
			}
			if(activeCss != "") {
				obj.addClassName(activeCss);
			}
		}
		else
		{
			if(activeCss != "") {
				obj.removeClassName(activeCss);
			}
			if(inactiveCss != "") {
				obj.addClassName(inactiveCss);
			}
		}
	}
	,
	
	clearHide : function ()
	{	
		if (!this.delayHideId || this.delayHideId < 0) {
			return;
		}
		window.clearTimeout(this.delayHideId);
		this.delayHideId = -1;
	}
	,
	
	getMenus : function()
	{
		if(!this.menuId || this.menuId == "") {
			return;
		}
		var itemsContainer = $(this.menuId);
		if(!itemsContainer) {
			return;
		}
		
		var __m = this;
		var items = itemsContainer.childElements();
		items.each(function(menu) {
			if(menu.id && menu.id != "") {
				__m.menuItems[__m.menuItems.length] = menu.id;
			}
		});
	}
	,
	
	addMenu : function (id)
	{
		if(id && id != "") {
			this.menuItems[this.menuItems.length] = id;
		}
	}
	,
	
	addMenus : function (menuIds)
	{
		// check
		if(!menuIds || !Object.isArray(menuIds) || menuIds.length < 1) {
			return;
		}
		
		// add objects
		var __m = this;
		menuIds.each(function (id)
		{
			__m.menuItems[__m.menuItems.length] = menu;
		});
	}
};
/* /Skins/Default/Scripts/VIEPortalNG.Rotator.js ---------- */

/* ----------------------------------------------------------------------

	VIE Portal - Rotator Layers Library
	Written by Quynh Nguyen - VIEPortal.net
	
	Notes: using Prototype.js, script.aculo.us effects.js and jQuery (with $j)

-----------------------------------------------------------------------	*/

function vieRotator()
{
	this.rotatorId = "";
	this.containerId = "";
	
	this.pauseTime = 5;					// time to stop effect (in seconds)
	this.duration = 1;					// time to show effect (in seconds)
	
	this.showIndicator = true;
	this.indicatorCss = "";
	this.indicatorSelectedColor = "red";
	this.indicatorHorizontal = "right";
	this.indicatorHorizontalOffset = 7;
	this.indicatorVertical = "bottom";
	this.indicatorVerticalOffset = 5;
	this.indicatorId;
	
	this.showCaptions = true;
	this.captionsSurffix = "_Caption";
	this.captionsCss = "rotatorCaptions";
	this.captionsPosition = "bottom";					// top, bottom, left, right
	this.captionsHeight = 70;
	this.captionsWidth = 150;
	this.captionsVerticalOffset = 0;
	this.captionsHorizontalOffset = 0;
	
	this.autoStart = true;
	this.effect = "random";
	
	this.layers = [];
	this.effects = ["slideDown", "blindDown", "blindRight", "grow", "growUp", "growDown", "growLeft", "opacity"]; 
	
	this.index = -1;
	this.settedIndex = -1;
	this.currentEffect = "";
	
	this.processId = -1;
}

vieRotator.prototype = {

	init : function ()
	{
		// get name of ratator variable
		if(arguments.length > 0) {
			this.rotatorId = arguments[0];
		}
		if(!this.rotatorId || this.rotatorId == "")
		{
			alert("The name of rotator object must be not null.");
			return;
		}
		
		// get Id of container
		if(arguments.length > 1) {
			this.containerId = arguments[1];
		}
		
		// get pause time	
		if(arguments.length > 2) {
			this.pauseTime = arguments[2];
		}
		
		// get state to show indicator
		if(arguments.length > 3) {
			this.showIndicator = arguments[3];
		}
		
		// get CSS of indicator
		if(arguments.length > 4) {
			this.indicatorCss = arguments[4];
		}
		
		// get state to collect layers automatically
		var autoCollect = true;
		if(arguments.length > 5) {
			autoCollect = arguments[5];
		}
		
		// get state to start rotate automatically
		if(arguments.length > 6) {
			this.autoStart = arguments[6];
		}
		
		// automatically get all related layers and start the rotator
		if(autoCollect || this.autoStart)
		{
			var __r = this;
			$j(window).load(function() {
				if(autoCollect) {
					__r.getLayers();
				}
				if(__r.autoStart) {
					__r.start();
				}
			});
		}
	}
	,
	
	start : function ()
	{
		// prepare container, all layers and indicator befor start
		this.prepareRotator();
		
		// check to collection of layers
		if(!this.layers	|| this.layers.length < 1) {
			return;
		}
			
		// show first layer
		this.index = 0;
		this.setIndicator();
		Effect.Appear(this.layers[this.index], {duration: this.duration });
		
		// and wait next
		var __r = this;
		this.processId = window.setTimeout(function() { __r.rotate(); }, this.pauseTime * 1000);
	}
	,
	
	go : function (index)
	{
		this.settedIndex = index - 1;	
		window.clearTimeout(this.processId);
		var __r = this;
		this.processId = window.setTimeout(function() { __r.rotate(); }, 30);
	}
	,
	
	rotate : function()
	{
		// do not rotate when has only one layer
		if(this.layers.length < 2) {
			return;
		}
		
		// hide current
		if(this.index > -1 && this.index != this.settedIndex)
		{
			var layer = this.layers[this.index];
			Effect.Fade(layer, {duration: this.duration });
		}
		
		// computing index of playing layer
		if(this.settedIndex < 0) {
			this.index++;
		}
		else {
			this.index = this.settedIndex;
			this.settedIndex = -1;
		}
		
		if(this.index >= this.layers.length) {
			this.index = 0;
		}
		else if(this.index < 0) {
			this.index = this.layers.length - 1;
		}
	
		// apply effect
		this.applyEffect();
		
		// set indicator and wait for next
		var __r = this;
		window.setTimeout(function() { __r.setIndicator(); }, 500);
		this.processId = window.setTimeout(function() { __r.rotate(); }, this.pauseTime * 1000);
	}
	,
	
	applyEffect : function() 
	{
		// get effect
		if(this.effect == "random") {
			this.currentEffect = (this.effects[Math.floor(Math.random() * this.effects.length)]).strip();
		}
		else {
			this.currentEffect = this.effect;
		}
		
		// get layer and apply effect
		var layer = this.layers[this.index];
		switch (this.currentEffect)
		{
			case "slideDown":
				Effect.SlideDown(layer, { duration: this.duration });
				break;
				
			case "blindDown":
				Effect.BlindDown(layer, { duration: this.duration });
				break;
				
			case "blindRight":
				Effect.BlindRight(layer, { duration: this.duration });
				break;
				
			case "grow":
				Effect.Grow(layer, { duration: this.duration, direction: "top-left" });
				break;
				
			case "growLeft":
				Effect.Grow(layer, { duration: this.duration, direction: "bottom-right" });
				break;
				
			case "growDown":
				Effect.Grow(layer, { duration: this.duration, direction: "top-right" });
				break;
				
			case "growUp":
				Effect.Grow(layer, { duration: this.duration, direction: "bottom-left" });
				break;
				
			// opacity (fade first, then appear)
			default:
				Effect.Appear(layer, {duration: this.duration });
				break;
		}	
	}
	,
	
	prepareRotator : function ()
	{
		// computing position of captions
		var captionTop = Element.getHeight(this.containerId) - this.captionsHeight - this.captionsVerticalOffset;
		var captionLeft = this.captionsHorizontalOffset;
		var captionWidth = Element.getWidth(this.containerId);
		var captionHeight = this.captionsHeight;
		switch (this.captionsPosition)
		{
			case "top":
				captionTop = this.captionsVerticalOffset;
				break;
				
			case "left":
				captionTop = this.captionsVerticalOffset;
				captionWidth = this.captionsWidth;
				captionHeight = Element.getHeight(this.containerId);
				break;
				
			case "right":
				captionLeft = Element.getWidth(this.containerId) - this.captionsWidth - this.captionsHorizontalOffset;
				captionTop = this.captionsVerticalOffset;
				captionWidth = this.captionsWidth;
				captionHeight = Element.getHeight(this.containerId);
				break;
				
			default: // bottom
				break;
		}
		
		// set style of container
		var container = $(this.containerId);
		if(container) {
			container.setStyle( { position: "relative", overflow: "hidden" } );
		}
		
		// prepare all layers
		var __r = this;
		this.layers.each(function(layer) {
			
			// prepare layer
			Element.setStyle (layer, { position: "absolute", overflow: "hidden", top: "0px", left: "0px", display: "none" } );
			
			// prepare all captions
			var captionLayer = $(layer.id + __r.captionsSurffix);
			if(captionLayer)
			{
				if(__r.showCaptions)
				{
					if(__r.captionsCss != "")
						captionLayer.className = __r.captionsCss;
					Element.setStyle (captionLayer, { position: "absolute", display: "block", overflow: "hidden", top: captionTop + "px", left: captionLeft + "px", width: captionWidth + "px", height: captionHeight + "px" } );
				}
				else {
					Element.setStyle (captionLayer, { display: "none" } );
				}
			}
		});
		
		// do not show indicator when has only one layer
		if(this.layers.length < 2) {
			this.showIndicator = false;
		}
		
		// create indicator
		if(this.showIndicator && this.containerId != "")
		{
			this.indicatorId = this.containerId + "Indicators";
			this.createIndicator();
		}	
		else
		{
			this.indicatorId = "";
			this.showIndicator = false;
		}
	}
	,
	
	setIndicator : function ()
	{
		if(this.showIndicator) {
			var aTags = Element.childElements(this.indicatorId);
			for(var i=0; i<aTags.length; i++) {
				if(i == this.index) {
					aTags[i].style.backgroundColor = this.indicatorSelectedColor;
				}
				else {
					aTags[i].style.backgroundColor = '';
				}
			}
		}
	}
	,
	
	createIndicator : function ()
	{
		var html = "";
		for(var index = 1; index <= this.layers.length; index++) {
			html += "&nbsp;<a onclick='" + this.rotatorId + ".go(" + index + ");'>" + index + "</a>";
		}
		
		var indicator = document.createElement("DIV");
		indicator.id = this.indicatorId;
		indicator.innerHTML = html;
		$(this.containerId).appendChild(indicator);
		
		if(this.indicatorCss != "") {
			indicator.className = this.indicatorCss;
		}
		
		var left = 0;
		if(this.indicatorHorizontal.toLowerCase() == "right")
			left = (Element.getWidth(this.containerId) - Element.getWidth(this.indicatorId) - this.indicatorHorizontalOffset);
		else if(this.indicatorHorizontalOffset > 0)
			left = this.indicatorHorizontalOffset;
		
		var top = 0;
		if(this.indicatorVertical.toLowerCase() == "bottom")
			top = (Element.getHeight(this.containerId) - Element.getHeight(this.indicatorId) - this.indicatorVerticalOffset);
		else if(this.indicatorVerticalOffset > 0)
			top = this.indicatorVerticalOffset;
		
		indicator.style.position = "absolute";
		indicator.style.zIndex = 999;
		indicator.style.left = left + "px";
		indicator.style.top = top + "px";
	}
	,
	
	getLayers : function ()
	{
		if(!this.containerId || this.containerId == "") {
			return;
		}
		var container = $(this.containerId);
		if(!container) {
			return;
		}
		
		var __r = this;
		var layers = container.childElements();
		layers.each(function(layer) {
			if(layer.id && layer.id != "") {
				__r.layers[__r.layers.length] = layer;
			}
		});
	}
	,
	
	addLayer : function (id)
	{
		var layer = $(id);
		if(layer) {
			this.layers[this.layers.length] = layer;
		}
	}
	,
	
	addLayers : function (layerIds)
	{
		// check
		if(!layerIds || !Object.isArray(layerIds) || layerIds.length < 1) {
			return;
		}
		
		// set properties
		var __r = this;
		layerIds.each(function(id) {
			__r.addLayer(id);
		});
	}
};
/* /Skins/Default/Scripts/VIEPortalNG.Scroller.js ---------- */

/* --------------------------------------------------------------------------------------

	VIE Portal - Scroll Layers Library
	Written by Quynh Nguyen - VIEPortal.net
	
	Notes: using Prototype ($) and jQuery ($j)

---------------------------------------------------------------------------------------	*/

function vieScroller()
{
	this.scrollerId = "";							// variable name of scroller object
	this.scrollerHeight = -1;					// height of the scroller (in pixels)
	this.scrollerWidth = -1;					// width of the scroller (in pixels)
	
	this.containerId = "";						// Id of DIV element that presents the scroller
	this.container = null;
	this.scrollElementId = "";				// Id of DIV element that will be used to scroll
	this.scrollElement = null;
	this.slideContainerId  = "";			// Id of an element that contains slides (TR for srolling right, TBODY for scrolling down)
	this.slideContainer = null;
	this.slides = [];									// collection of slides (TD for scrolling right, TR for scrolling down)
	
	this.scrollDirection = "left";		// up, left, down, right (only TABLE when scrolling right/down)
	this.scrollPixels = 3;						// pixels to sroll
	this.scrollInterval = 10;					// time to scroll (in miliseconds)
	this.slidePause = 2000;						// time to pause after scrolling a slide (in mileseconds)
	this.pauseOnMouseOver = true;			// if TRUE, the scroller will be stoped when user moves mouse over the scroller
	this.autoStart = true;						// if TRUE, the scrolling process will be started automatically

	this.size;
	this.slidesSize;
	this.position = null;
	
	this.slideIndex = -1;
	this.slideWidth = -1;
	this.slideHeight = -1;
	
	this.processId = -1;
	this.ableToScrollRight = false;
	this.ableToScrollDown = false;
}

vieScroller.prototype = {
	init : function ()
	{
		// get variable name of the scroller 
		if(arguments.length > 0) {
			this.scrollerId = arguments[0];
		}
		if(!this.scrollerId || this.scrollerId == "")
		{
			alert("The variable of of the scroller must be not null and not empty.");
			return;
		}
		
		// get objects		
		if(arguments.length > 1) {
			this.containerId = arguments[1];
		}
		this.container = $(this.containerId);
		if(!this.container)
		{
			alert("The container element with identity '" + this.containerId + "' is not found.");
			return;
		}
		
		if(arguments.length > 2) {
			this.scrollElementId = arguments[2];
		}
		this.scrollElement = $(this.scrollElementId);
		if(!this.scrollElement)
		{
			alert("The scroll element with identity '" + this.scrollElementId + "' is not found.");
			return;
		}
		
		if(arguments.length > 3) {
			this.slideContainerId = arguments[3];
		}
		this.slideContainer = $(this.slideContainerId);
		if(!this.slideContainer)
		{
			alert("The slide container element with identity '" + this.slideContainerId + "' is not found.");
			return;
		}

		// height of the scroller
		if(arguments.length > 4) {
			this.scrollerHeight = arguments[4];
		}
		
		// direction
		if(arguments.length > 5) {
			var direction = arguments[5].toLowerCase();
			if(direction == "left" || direction == "right" || direction == "up" || direction == "down") {
				this.scrollDirection = direction;
			}
		}
		
		// auto start
		if(arguments.length > 6) {
			this.autoStart = arguments[6];
		}

		// collect slides automatically
		var autoCollectSlides = true;
		if(arguments.length > 7) {
			autoCollectSlides = arguments[7];
		}
		
		// prepare scroller when window is loaded
		var __s = this;
		$j(window).load(function() {
		
			// get slide
			if(autoCollectSlides) {
				__s.getSlides();
			}
			
			// prepare style of container
			__s.container.style.position = "relative";
			__s.container.style.overflow = "hidden";
			if(__s.scrollerHeight > 0) {
				__s.container.setStyle( { height : __s.scrollerHeight + "px" } );
			}
			if(__s.scrollerWidth > 0) {
				__s.container.setStyle( { width : __s.scrollerWidth + "px" } );
			}
			
			// prepare style of scroll element
			__s.scrollElement.style.position = "relative";
			__s.scrollElement.style.overflow = "hidden";
			if(__s.scrollerHeight > 0) {
				__s.scrollElement.setStyle( { height : __s.scrollerHeight + "px" } );
			}
			if(__s.scrollerWidth > 0) {
				__s.scrollElement.setStyle( { width : __s.scrollerWidth + "px" } );
			}
			
			// set style of slide container and all slides (when tag name is DVI)
			if(__s.slideContainer.tagName == "DIV") {
				
				// prepare style of slides container
				__s.slideContainer.style.position = "relative";
				if(__s.scrollerHeight > 0) {
					__s.slideContainer.setStyle( { height : __s.scrollerHeight + "px" } );
				}
				if(__s.scrollerWidth > 0) {
					__s.slideContainer.setStyle( { width : __s.scrollerWidth + "px" } );
				}
				
				// prepare style of slides
				__s.slides.each(function(slide)
				{
					slide.style.position = "relative";
					if(__s.scrollDirection == "left") {
						slide.setStyle( { cssFloat : "left" } );
					}
				});
			}
			
			// set event handlers
			if(__s.pauseOnMouseOver)
			{
				__s.container.writeAttribute("onmouseover", __s.scrollerId + ".pause();"); 
				__s.container.writeAttribute("onmouseout", __s.scrollerId + ".resume();");
			}

			// auto-start scroller
			if(__s.autoStart) {
				__s.start();
			}
		});
	}
	,
	
	start : function ()
	{
		// clear time-out
		this.clear();
		
		// get size of container
		this.size = { width : 0, height : 0 };
		this.size.width = this.container.getWidth();
		this.size.height = this.container.getHeight();
		
		// re-position of slide container
		this.rePosition();
		
		// start scroll the slides
		this.position = null;
		this.pickSlide();
		var __s = this;
		this.processId = window.setTimeout(function() { __s.scroll(); }, this.slidePause);
	}
	,
	
	pause : function ()
	{
		this.clear();
	}
	,
	
	resume : function ()
	{
		// continue scroll
		var __s = this;
		this.processId = window.setTimeout(function() { __s.scroll(); }, this.scrollInterval);
	}
	,
	
	left : function ()
	{
		if(this.scrollDirection != "left")
		{
			this.scrollDirection = "left";
			this.change();
		}
	}
	,
	
	right : function ()
	{
		if(this.ableToScrollRight && this.scrollDirection != "right")
		{
			this.scrollDirection = "right";
			this.change();
		}
	}
	,
	
	up : function ()
	{
		if(this.scrollDirection != "up")
		{
			this.scrollDirection = "up";
			this.change();
		}
	}
	,
	
	down : function ()
	{
		if(this.ableToScrollDown && this.scrollDirection != "down")
		{
			this.scrollDirection = "down";
			this.change();
		}
	}
	,
	
	change : function()
	{
		this.pause();
		this.rePosition();
		this.position = null;
		this.pickSlide();
		this.resume();
	}
	,
	
	clear : function ()
	{
		if(this.processId && this.processId > 0)
		{
			window.clearTimeout(this.processId);
			this.processId = -1;
		}
	}
	,

	scroll : function ()
	{
		// clear time-out
		this.clear();
		
		// computing position and size
		var stop = false;
		var pos = this.getPosition();
		var interval = this.scrollInterval;
		switch(this.scrollDirection)
		{
			case "up":
				pos.top -= this.scrollPixels;
				this.slideHight -= this.scrollPixels;
				stop = this.slideHight < 1;
				if(this.slideHight < 15)
					interval = interval * 4;
				break;
				
			case "down":
				pos.top += this.scrollPixels;
				this.slideHight -= this.scrollPixels;
				stop = this.slideHight < 1;
				if(this.slideHight < 15)
					interval = interval * 4;
				break;
				
			case "left":
				pos.left -= this.scrollPixels;
				this.slideWidth -= this.scrollPixels;
				stop = this.slideWidth < 1;
				if(this.slideWidth < 15)
					interval = interval * 4;
				break;
				
			case "right":
				pos.left += this.scrollPixels;
				this.slideWidth -= this.scrollPixels;
				stop = this.slideWidth < 1;
				if(this.slideWidth < 15)
					interval = interval * 4;
				break;
		}
		
		// check rest of height
		if(this.slideHight < this.scrollPixels && (this.scrollDirection == "up" || this.scrollDirection == "down"))
		{
			if(this.scrollDirection == "up") {
				pos.top -= this.slideHight;
			}
			else {
				pos.top += this.slideHight;
			}
			this.slideHight = -1;
			stop = true;
		}
		
		// check rest of width
		if(this.slideWidth < this.scrollPixels && (this.scrollDirection == "left" || this.scrollDirection == "right"))
		{
			if(this.scrollDirection == "left") {
				pos.left -= this.slideWidth;
			}
			else {
				pos.left += this.slideWidth;
			}
			this.slideWidth = -1;
			stop = true;
		}
		
		// set new position to the slide container
		this.scrollElement.style.left = pos.left + "px";
		this.scrollElement.style.top = pos.top + "px";
		
		// continue scroll or stop for showing
		var __s = this;
		if(stop)
		{
			// rorate slides
			this.rotateSlide();
			
			// re-position of slide container
			this.scrollElement.style.left = "0px";
			this.scrollElement.style.top = "0px";
			
			// pick new slide and scroll after waiting
			this.position = null;
			this.pickSlide();
			this.processId = window.setTimeout(function() { __s.scroll(); }, this.slidePause);
		}
		// continue until reach the condition to stop
		else {
			this.processId = window.setTimeout(function() { __s.scroll(); }, interval);
		}
	}
	,
	
	rePosition : function ()
	{
		// get container that contains the slides
		var slideContainer = null;
		var parentContainer = null;
		switch (this.scrollDirection)
		{
			case "left":
				slideContainer = this.slideContainer;
				parentContainer = this.scrollElement.childElements()[0];
				break;
				
			case "up":
				slideContainer = this.slideContainer;
				parentContainer = this.slideContainer.getOffsetParent();
				break;
				
			case "right":
				slideContainer = this.scrollElement.childElements()[0];
				break;
				
			case "down":
				slideContainer = this.slideContainer.getOffsetParent();
				break;
		}
		
		// check to re-position
		if(!slideContainer) {
			return;
		}
		
		// direction is 'right'
		if(this.scrollDirection == "right")
		{
			if(slideContainer.tagName != "TABLE") {
				// change direction if the container of the slides is not TABLE
				this.scrollDirection = "left";
			}
			else
			{
				var availableWidth = this.scrollElement.getWidth();
				var slidesWidth = slideContainer.getWidth();
				slideContainer.style.position = "absolute";
				slideContainer.style.top = "0px";
				if(slidesWidth > availableWidth) {
					slideContainer.style.left = "-" + (slidesWidth - availableWidth) + "px";
				}
				else if (slidesWidth < availableWidth) {
					slideContainer.style.left = (availableWidth - slidesWidth) + "px";
				}
				this.ableToScrollRight = true;
			}
		}
		
		// direction is 'down'
		else if(this.scrollDirection == "down")
		{
			if(slideContainer.tagName != "TABLE") {
				// change direction if the container of the slides is not TABLE
				this.scrollDirection = "up";
			}
			else
			{
				var availableHeight = this.scrollElement.getHeight();
				var slidesHeight = slideContainer.getHeight();
				slideContainer.style.position = "absolute";
				slideContainer.style.left = "0px";
				if(slidesHeight > availableHeight) {
					slideContainer.style.top = "-" + (slidesHeight - availableHeight) + "px";
				}
				else if (slidesHeight < availableHeight) {
					slideContainer.style.top = (availableHeight - slidesHeight) + "px";
				}
				else {
					slideContainer.style.top = "0px";
				}
				this.ableToScrollDown = true;
			}
		}
		
		// direction is 'left' or 'up'
		else
		{
			// re-position
			if(parentContainer)
			{
				parentContainer.style.left = "0px";
				parentContainer.style.top = "0px";
			}
			else if(slideContainer)
			{
				slideContainer.style.left = "0px";
				slideContainer.style.top = "0px";
			}
			
			// check state to see the scroller is able to scroll right/down
			if(parentContainer)
			{
				this.ableToScrollRight = (parentContainer.tagName == "TABLE");
				this.ableToScrollDown = (parentContainer.tagName == "TABLE");
			}
		}
	}
	,
	
	getPosition : function ()
	{
		if(!this.position)
		{
			this.position = { left : 0, top : 0 };
			var pos = this.scrollElement.positionedOffset();
			this.position.left = pos[0];
			this.position.top = pos[1];
		}
		return this.position;
	}
	,
	
	rotateSlide : function ()
	{
		// remove first element and append as last child (using Prototype)
		if(this.scrollDirection == "left" || this.scrollDirection == "up")
		{
			var slide = this.slides[this.slideIndex];
			slide.remove();
			this.slideContainer.appendChild(slide);
		}
		
		// remove the last element and insert as first child (using jQuery)
		else
		{
			var slides = this.slideContainer.childElements();
			var first = $j("#" + slides[0].id);
			var last = $j("#" + slides[slides.length - 1].id);
			if(first && last)
			{
				last.remove();
				last.insertBefore(first);
			}
		}
	}
	,
	
	pickSlide : function ()
	{
		// computing index
		if(this.scrollDirection == "left" || this.scrollDirection == "up")
		{
			this.slideIndex++;
			if (this.slideIndex >= this.slides.length) {
				this.slideIndex = 0;
			}
		}
		else
		{
			this.slideIndex--;
			if (this.slideIndex < 0) {
				this.slideIndex = this.slides.length - 1;
			}
		}
				
		// computing size
		this.slideWidth = this.slides[this.slideIndex].getWidth();
		this.slideHight = this.slides[this.slideIndex].getHeight();
	}
	,
	
	getSlides : function ()
	{
		var slides = this.slideContainer.childElements();
		this.addSlides(slides);
	}
	,
	
	addSlides : function (slides)
	{
		// check
		if(!slides || !Object.isArray(slides) || slides.length < 1) {
			return;
		}
		
		// add objects
		var __s = this;
		slides.each(function(slide) {
			if(slide) {
				__s.slides[__s.slides.length] = slide;
			}
		});
	}
	,
	
	addSlide : function (id)
	{
		// check
		if(!id || id == "") {
			return;
		}
			
		// get and add object
		var slide = $(id);
		if(slide) {
			this.slides[this.slides.length] = slide;
		}
	}
	,
	
	addSlidesById : function (slideIds)
	{
		// check
		if(!slideIds || !Object.isArray(slideIds) || slideIds.length < 1) {
			return;
		}
		
		// add objects
		var __s = this;
		slideIds.each(function (id)
		{
			__s.addSlide(id);
		});
	}
};
/* /Skins/Default/Scripts/VIEPortalNG.TimeCountdown.js ---------- */

/* -----------------------------------------------------------------------------------------------------
	VIE Portal - Time countdown ticking library
	Written by Quynh Nguyen - VIEPortal.net

	Based on original version of Robert Hashemian (http://www.hashemian.com/tools/javascript-countdown.htm)
------------------------------------------------------------------------------------------------------ */

function TimeCountdown(obj)
{
	this.obj						= obj;
	this.Div						= "clock";
	this.TargetDate			= "12/31/2020 5:00 AM";
	this.DisplayFormat	= "%%D%% Days, %%H%% Hours, %%M%% Minutes, %%S%% Seconds.";
	this.CountActive		= true;
	
	this.DisplayStr			= "";
	
	this.StopWhenReach = true;
	this.ProcessFunctionWhenReached = "";	
}

TimeCountdown.prototype = {

	Calcage : function (secs, num1, num2)
	{
		s = ((Math.floor(secs/num1))%num2).toString();
		if (s.length < 2) {
			s = "0" + s;
		}
		return (s);
	}
	,
	
	CountBack : function (secs)
	{
		var tickingCtrl = document.getElementById(this.Div);
		if(!tickingCtrl) {
			return;
		}
		this.DisplayStr = this.DisplayFormat.replace(/%%D%%/g,	this.Calcage(secs,86400,100000));
		this.DisplayStr = this.DisplayStr.replace(/%%H%%/g,		this.Calcage(secs,3600,24));
		this.DisplayStr = this.DisplayStr.replace(/%%M%%/g,		this.Calcage(secs,60,60));
		this.DisplayStr = this.DisplayStr.replace(/%%S%%/g,		this.Calcage(secs,1,60));
		tickingCtrl.innerHTML = this.DisplayStr;
		if(secs==0) {
			this.ProcessWhenReached();
		}
		if(this.CountActive) {
			var __c = this;
			window.setTimeout( function () { __c.CountBack(secs-1); }, 990);
		}
	}
	,
	
	Setup : function ()
	{
		var dthen	= new Date(this.TargetDate);
		var dnow	= new Date();
		ddiff = new Date(dthen-dnow);
		gsecs = Math.floor(ddiff.valueOf()/1000);
		this.CountBack(gsecs);
	}
	,
	
	ProcessWhenReached : function ()
	{
		this.CountActive = !this.StopWhenReach;
		if(this.ProcessFunctionWhenReached!="")
			eval(this.ProcessFunctionWhenReached);
	}
};

