var tempHtml;
var tempStr1;
var tempStr2;
if (section == null)	var section = 0;
if (level1 == null)	var level1 = "";
if (level2 == null)	var level2 = "";
if (level3 == null)	var level3 = "";
if (level4 == null)	var level4 = "";
if (level5 == null)	var level5 = "";
if (level6 == null)	var level6 = "";
var id1 = null;
var id2 = null;
var id3 = null;
var id4 = null;
var id5 = null;
var id6 = null;
var d = document;
if (navUp == null)	var navUp = false;

/*
if (location.search != '')
{
	if (GetParam('level1'))	level1 = GetParam('level1');
	if (GetParam('level2'))	level2 = GetParam('level2');
	if (GetParam('level3'))	level3 = GetParam('level3');
}*/


var levelArray = new Array();
var idArray = new Array();
function checkStr(astr, bstr)
{
	var va = [".", "/", "_", "-"];
	for (var item in va)
		{
			if (astr.indexOf(("/" + bstr + va[item])) > -1)
				{
					return true;
				}
			if (astr.indexOf(("-" + bstr + va[item])) > -1)
				{
					return true;
				}
		}
	return false;
}
function setLevel(obj)
{
	for (var m=0; m<obj.length; m++)
	{
		if ((window['level'+(1+levelArray.length)]==undefined) || (window['level'+(1+levelArray.length)]!=''))
		{
			if (obj[m].id != window['level'+(1+levelArray.length)])
			{					
				continue;
			}
			else
			{
				//alert(obj[m].id);
				while (window['level'+(1+levelArray.length)]!=undefined)
				{
					levelArray.push(window['level'+(1+levelArray.length)]);
				}
				break;
			}
		}
		if (checkStr(link, obj[m].id))
		{
			levelArray.push(obj[m].id);

			if (typeof(obj[m].subSection)!='undefined')
			{
				setLevel(obj[m].subSection);
			}
			break;
		}
	}
}

function setLevelId(obj, index)
{
	for (var m=0; m<obj.length; m++)
		{
			if (levelArray[index] == obj[m].id)
				{
					idArray.push(m);
					if (typeof(obj[m].subSection)!='undefined')
						{
							setLevelId(obj[m].subSection, (1+index));
						}
					break;
				}
		}
}

function getLevel() {
	var obj = sectionArray[section];
	link = location.href.toString();
	setLevel(obj);
	
	for (var i=0; i<levelArray.length; i++)
		{
			window['level'+(1+i)] = levelArray[i];
		}
		
	setLevelId(obj, 0);
	for (var i=0; i<idArray.length; i++)
		{
			window['id'+(1+i)] = idArray[i];
		}
}
getLevel();
//alert(id1 + " : " + id2 + " : " + id3 + " : " + id4 + " : " + id5 + " : " + id6);
//window.status = level1 + " : " + level2 + " : " + level3 + " : " + level4 + " : " + level5 + " : " + level6;
//window.status = id1 + " : " + id2 + " : " + id3 + " : " + id4 + " : " + id5 + " : " + id6;

function genTop()
{
	var obj = sectionArray[0];
	
	if (level1 != "" && section == 0)
	{
		var mc = d.getElementById(('nav_'+level1));
		var img = path + 'img/nav/btn_' + level1 + '_on.png';
		
		mc.src = img;
	}
	
	for (var i in obj)
	{
		var btn = d.getElementById(('nav_'+obj[i].id));		
		btn.className = "pngImg";
		if (isIE && /MSIE (5\.5|6\.)/.test(navigator.userAgent))	btn.style.display = "none";
		btn.hit = false;
		
		if (d.getElementById(('menu_'+obj[i].id)))
		{
			var layer = d.getElementById(('menu_'+obj[i].id));
			layer.style.top = (navUp)?'100px':'-77px';
			layer.tempTop = (navUp)?100:-77;
			layer.hit = false;
		}
	}
}
var topNavHit = false;
function navOver(name, over)
{
	if (level1 == name)	return;
	
	var btn = d.getElementById(('nav_'+name));
	if (d.getElementById(('menu_'+name)))	var layer = d.getElementById(('menu_'+name));
	var mask = d.getElementById(('topNavMenuMask'));
	if (over)
	{
		var img = path + 'img/nav/btn_' + name + '_over.png';
		if (layer)	menuGo(name, 1);
		changeImg(btn, img);
		mask.style.zIndex = 300;
		selectShowHide(false);
		btn.hit = true;
		topNavHit = true;
	}
	else
	{
		var img = path + 'img/nav/btn_' + name + '.png';
		if (layer)
		{
			setTimeout(function() {
				menuGo(name, 0);
				if (!layer.hit && !btn.hit)	changeImg(btn, img);
				if (!topNavHit)	selectShowHide(true);
			}, 200);
		}
		else
		{
			changeImg(btn, img);
			selectShowHide(true);
		}
		if (!isIE)	mask.style.zIndex = 10;
		btn.hit = false;
		topNavHit = false;
	}
	
	//Hide select
	function selectShowHide(isShow)
	{
		
		

		if (checkIEVersion(6) && !navUp)
		{

			setTimeout(function() {
				/*var select = d.getElementsByTagName('select');
				for (var i=0; i<select.length; i++)
				{
					select[i].style.visibility = (isShow)?'visible':'hidden';
				}*/
				if(level1=='shopping')
				{
					var select = d.getElementById('shopSelect');
					if(select)
					{
						select.style.visibility = (isShow)?'visible':'hidden';
					}

				}
				if (frames.length > 0)
				{
					var select = frames[0].document.getElementsByTagName('select');
					for (var i=0; i<select.length; i++)
					{
						select[i].style.visibility = (isShow)?'visible':'hidden';
					}
				}
			}, 100);
		}
	}
}

function changeImg(btn, img)
{
	var f = 'DXImageTransform.Microsoft.AlphaImageLoader';
	if (isIE && /MSIE (5\.5|6\.)/.test(navigator.userAgent))
	{
		btn.style.filter = 'progid:'+f+'(src="'+img+'",sizingMethod="scale")';
	}
	else
	{
		btn.src = img;
	}
}

var timeOutSpeed = 25;
var z = 1;
function menuGo(name, over)
{
	var btn = d.getElementById(('nav_'+name));
	var layer = d.getElementById(('menu_'+name));
	layer.menuMotion = menuMotion;
	
	if (over)
	{
//		if (layer)	layer.style.visibility = 'visible';
		layer.tempTop = 0;
		layer.speed = 5;
		layer.style.zIndex = z++;
		layer.menuMotion(layer);
	}
	else
	{
		if (layer.hit | btn.hit)	return;
		layer.tempTop = (navUp)?100:-78;
		layer.speed = 2;
		layer.menuMotion(layer);
	}
}
	
function menuMotion(layer)
{
	if (isIE)
	{
		layer.objTop = Number(layer.style.pixelTop);
	}
	else
	{
		layer.objTop = Number(layer.style.top.substring(0, (layer.style.top.toString().length-2)));
	}
	layer.goStep = (layer.tempTop - layer.objTop)/layer.speed;
	
	if (!(Math.abs(layer.objTop - layer.tempTop) < 1))
	{
		layer.objTop += layer.goStep;
		var timeOut = setTimeout(function(){layer.menuMotion(layer);}, timeOutSpeed);
	}
	else
	{
		layer.objTop = layer.tempTop;
		clearTimeout(timeOut);
	}
	
//	window.status = layer.objTop;
	layer.style.top = layer.objTop + 'px';
}

function subNavOver(name, i, over)
{
	var btn = d.getElementById(('subNav_'+name+'_'+i));
	if (d.getElementById(('menu_'+name+'_'+i)))	var layer = d.getElementById(('menu_'+name+'_'+i));
	
	if (over)
	{
		btn.className = 'topNavMenuItemOn '+name+'MenuIconOn';
		if (layer)	layer.style.visibility = 'visible';
		btn.hit = true;
	}
	else
	{
		setTimeout(function()
		{
			if (!layer.hit && !btn.hit)
			{
				btn.className = 'topNavMenuItem '+name+'MenuIcon';
				layer.style.visibility = 'hidden';
			}
		}, 200);
		btn.hit = false;
	}
}

function genLeft()
{
	if (level2)
	{
		if (d.getElementById(level2))
		{
			var level2Btn = d.getElementById(level2);
			level2Btn.className += 'On';
		}
		
		//if (obj1[id2].subSection)
		if (d.getElementById(level2 + '_menu'))
		{
			var level2Menu = d.getElementById(level2 + '_menu');
			level2Menu.style.display = 'block';
		}
		
		if (level3)
		{
			if (d.getElementById(level2 + '_' + level3))
			{
				var level3Btn = d.getElementById(level2 + '_' + level3);
				level3Btn.className += 'On';
			}
			
			if (d.getElementById(level2 + '_' + level3 + '_menu'))
			{
				var level3Menu = d.getElementById(level2 + '_' + level3 + '_menu');
				level3Menu.style.display = 'block';
			}
			
			if (level4)
			{
				if (d.getElementById(level2 + '_' + level3 + '_' + level4))
				{
					var level4Btn = d.getElementById(level2 + '_' + level3 + '_' + level4);
					level4Btn.className += 'On';
				}
			}
		}
	}
}

function genRight()
{
	var obj = sectionArray[section];
	
	if (level6)
	{
		if (d.getElementById(level6))
		{
			var level6Btn = d.getElementById(level6);
			level6Btn.className += 'On';
		}
	}
	if (level5)
	{
		if (d.getElementById(level5))
		{
			var level5Btn = d.getElementById(level5);
			level5Btn.className += 'On';
		}
		if (d.getElementById(level5 + '_menu'))
		{
			var level5Menu = d.getElementById(level5 + '_menu');
			level5Menu.style.display = 'block';
		}
	}
	if (level4)
	{
		if (d.getElementById(level4))
		{
			var level4Btn = d.getElementById(level4);
			level4Btn.className += 'On';
		}
		if (d.getElementById(level4 + '_menu'))
		{
			var level4Menu = d.getElementById(level4 + '_menu');
			level4Menu.style.display = 'block';
		}
	}
	if (level3)
	{
		if (d.getElementById(level3))
		{
			var level3Btn = d.getElementById(level3);
			level3Btn.className += 'On';
		}
	}
	if (level1 == "skyclub")
	{
		if (id2 > 2 && d.getElementById(level2))
		{
			var level2Btn = d.getElementById(level2);
			level2Btn.className += 'On';
		}
	}
}

function genBreadcrumbs()
{
	if (level1 == "")	return;
	var obj = sectionArray[section];
	var tempHtml = '';
	
	function genA(name, link, target)
	{
		link=(link=="#")?"javascript:void(0)":link;
		return '<a href="'+genLink(link)+'" target="'+target+'">' + name + '</a>';
	};
	
	tempHtml += genA('Home', 'index.html', '_top');
	tempHtml += ' > ';
	
	tempHtml += genA(obj[id1].name, obj[id1].link, obj[id1].target);	
	
	if (id2 != null)
	{
		tempHtml += ' > ';
		
		var obj1 = obj[id1].subSection;
		tempHtml += genA(obj1[id2].name, obj1[id2].link, obj1[id2].target);
		
		if (id3 != null && obj1[id2].subSection)
		{
			tempHtml += ' > ';
			
			var obj2 = obj1[id2].subSection;
			tempHtml += genA(obj2[id3].name, obj2[id3].link, obj2[id3].target);
			
			if (id4 != null && obj2[id3].subSection)
			{
				tempHtml += ' > ';
				
				var obj3 = obj2[id3].subSection;
				tempHtml += genA(obj3[id4].name, obj3[id4].link, obj3[id4].target);
				
				if (id5 != null && obj3[id4].subSection)
				{
					tempHtml += ' > ';
					
					var obj4 = obj3[id4].subSection;
					tempHtml += genA(obj4[id5].name, obj4[id5].link, obj4[id5].target);
					
					if (id6 != null && obj4[id5].subSection)
					{
						tempHtml += ' > ';
						
						var obj5 = obj4[id5].subSection;
						tempHtml += genA(obj5[id6].name, obj5[id6].link, obj5[id6].target);
					}
				}
			}
		}
	}
	
	d.write(tempHtml);
}

function genWinTitle()
{
	var obj = sectionArray[section];
	var tempHtml = '';
	
	if (level1 != "")
	{
		tempHtml += obj[id1].name;	
		
		if (id2 != null)
		{
			tempHtml += ' - ';
			
			var obj1 = obj[id1].subSection;
			tempHtml += obj1[id2].name;
			
			if (id3 != null && obj1[id2].subSection)
			{
				tempHtml += ' - ';
				
				var obj2 = obj1[id2].subSection;
				tempHtml += obj2[id3].name;
				
				if (id4 != null && obj2[id3].subSection)
				{
					tempHtml += ' - ';
					
					var obj3 = obj2[id3].subSection;
					tempHtml += obj3[id4].name;
					
					if (id5 != null && obj3[id4].subSection)
					{
						tempHtml += ' - ';
						
						var obj4 = obj3[id4].subSection;
						tempHtml += obj4[id5].name;
						
						if (id6 != null && obj4[id5].subSection)
						{
							tempHtml += ' - ';
							
							var obj5 = obj4[id5].subSection;
							tempHtml += obj5[id6].name;
						}
					}
				}
			}
		}
		
		tempHtml += ' - ';
	}
	
	tempHtml += 'Hong Kong International Airport';
	
	window.top.d.title = tempHtml;
	
	
	//Add level2 alt title
	if (level1 == "")	return;
	if (!d.getElementById('secondLevelTitle'))	return;
	var img = path + 'img/spacer.gif';
	var name = obj[id1].name;
	tempHtml = '<img src="'+img+'" alt="'+name+'" width="146" height="29" />';
	d.getElementById('secondLevelTitle').innerHTML = tempHtml;
}

function genLink(i)
{
	if (!(i.indexOf('http') > -1) && !(i.indexOf('javascript') > -1) && i.indexOf('/') != 0)
	{
		var link = path + i;
	}
	else
	{
		var link = i;
	}
	
	return link;
}

var quickLinksHit = false;
function quickLinksOver(over, auto)
{
	var btn = d.getElementById('quickLinks');
	var menu = d.getElementById('quickLinksMenu');
	
	if (over)
	{
		btn.className = 'quickLinksOn';
		menu.style.visibility = 'visible';
		menu.style.display = 'block';
		menuHideSelect(menu, true);
		if (!auto)	quickLinksHit = true;
	}
	else
	{
		btn.className = 'quickLinks';
		menu.style.visibility = 'hidden';
		menu.style.display = 'none';
		menuHideSelect(menu, false);
		quickLinksHit = false;
	}
}

function quickLinksOpen()
{
	quickLinksOver(1, true);
	
	setTimeout(
		function()
		{
			if (!quickLinksHit)	quickLinksOver(0);
		}, 5000
	);
}

function getTitle(i)
{
	var obj = sectionArray[section];
	var obj1 = obj[id1].subSection;
	var img;
	var name;
	var tempHtml = '';
	
	if (level4 && (level3 == 'all' | level3 == 't1' | level3 == 't2' | level3 == 'sp'))
	{
		img = path + 'img/'+level1+'/'+level2+'/'+level3+'/title_'+level4+'.gif';
		name = obj1[id2].subSection[id3].subSection[id4].name;
	}
	else if (level4 && (level3 == 'photo'))
	{

		img = path + 'img/'+level1+'/'+level2+'/title_'+level3+'.gif';
		name = obj1[id2].subSection[id3].subSection[id4].name;

	}
	else if (level3)
	{
		img = path + 'img/'+level1+'/'+level2+'/title_'+level3+'.gif';
		name = obj1[id2].subSection[id3].name;
	}
	else if (level2)
	{
		img = path + 'img/'+level1+'/title_'+level2+'.gif';
		name = obj1[id2].name;
	}
	tempHtml += '<img src="'+img+'" alt="'+name+'" />';
	
	/*var imgCode = document.createElement("img");
	imgCode.src = img;
	imgCode.alt = name;
	
	d.getElementById(i).appendChild(imgCode);*/
	d.getElementById(i).innerHTML = tempHtml;
}
function getUsefulNumbers()
{
	var tempHtml = '';
	if(level1=="passenger" || level1=="transport" || level1=="contact")
	{
		tempHtml += '<a href="'+path+'/'+level1+'/useful-numbers.html">Useful Numbers</a>';
		d.getElementById("quickLinksMenu").style.height = "128px";
		d.getElementById("quickLinksUsefulNumbersLink").innerHTML = tempHtml;
	}
	else
	{
		d.getElementById("quickLinksMenu").style.height = "83px";
		d.getElementById("quickLinksUsefulNumbers").style.display = "none";
	}
}
function genRelatedlinks()
{
	var obj = sectionArray[section];
	var tempHtml = '';
	
	if (id5)
	{
		if (obj[id1].subSection[id2].subSection[id3].subSection[id4].subSection[id5].relatedLinks)
		{
			var obj1 = obj[id1].subSection[id2].subSection[id3].subSection[id4].subSection[id5].relatedLinks;
		}
		else
		{
			return;
		}
	}
	else if (id4)
	{
		if (obj[id1].subSection[id2].subSection[id3].subSection[id4].relatedLinks)
		{
			var obj1 = obj[id1].subSection[id2].subSection[id3].subSection[id4].relatedLinks;
		}
		else
		{
			return;
		}
	}
	else if (id3)
	{
		if (obj[id1].subSection[id2].subSection[id3].relatedLinks)
		{
			var obj1 = obj[id1].subSection[id2].subSection[id3].relatedLinks;
		}
		else
		{
			return;
		}
	}
	else if (id2)
	{
		if (obj[id1].subSection[id2].relatedLinks)
		{
			var obj1 = obj[id1].subSection[id2].relatedLinks;
		}
		else
		{
			return;
		}
	}
	else if (id1)
	{
		if (obj[id1].relatedLinks)
		{
			var obj1 = obj[id1].relatedLinks;
		}
		else
		{
			return;
		}
	}
	
	if (obj1.length > 0)
	{
		for (var i in obj1)
		{
			tempHtml += '<div class="relatedLinksItem">';
			
			tempHtml += '<div class="relatedLinksItemImg"><img src="'+path+obj1[i].img+'" width="58" height="43" alt="'+obj1[i].txt+'" /></div>';
			tempHtml += '<div class="relatedLinksItemContent"><a href="'+genLink(obj1[i].link)+'" target="'+obj1[i].target+'">'+obj1[i].txt+'</a></div>';
			
			tempHtml += '</div>';
		}
		
		d.getElementById('relatedLinksWrapper').style.display = 'block';
		d.getElementById('relatedLinks').innerHTML = tempHtml;
	}
}

function genSpecial()
{
	var obj = sectionArray[section];
	var tempHtml = '';
	
	if (id5 && id5 >= 0)
	{
		if (obj[id1].subSection[id2].subSection[id3].subSection[id4].subSection[id5].specials)
		{
			var obj1 = obj[id1].subSection[id2].subSection[id3].subSection[id4].subSection[id5].specials;
		}
		else
		{
			return;
		}
	}
	else if (id4 && id4 >= 0)
	{
		if (obj[id1].subSection[id2].subSection[id3].subSection[id4].specials)
		{
			var obj1 = obj[id1].subSection[id2].subSection[id3].subSection[id4].specials;
		}
		else
		{
			return;
		}
	}
	else if (id3 && id3 >= 0)
	{
		if (obj[id1].subSection[id2].subSection[id3].specials)
		{
			var obj1 = obj[id1].subSection[id2].subSection[id3].specials;
		}
		else
		{
			return;
		}
	}
	else if (id2 && id2 >= 0)
	{
		if (obj[id1].subSection[id2].specials)
		{
			var obj1 = obj[id1].subSection[id2].specials;
		}
		else
		{
			return;
		}
	}
	else if (id1 && id1 >= 0)
	{
		if (obj[id1].specials)
		{
			var obj1 = obj[id1].specials;
		}
		else
		{
			return;
		}
	}
	else
	{
		return;
	}
	
	if (obj1.length > 0)
	{
		for (var i in obj1)
		{
			tempHtml += '<div class="specialItem">';
			
			tempHtml += '<div class="specialItemImg"><img src="'+path+obj1[i].img+'" alt="'+obj1[i].txt+'" /></div>';
			tempHtml += '<div class="specialItemContent"><a href="'+genLink(obj1[i].link)+'" target="'+obj1[i].target+'">'+obj1[i].txt+'</a></div>';
			
			tempHtml += '</div>';
		}
		
		d.getElementById('specialWrapper').style.display = 'block';
		d.getElementById('specialContent').innerHTML = tempHtml;
	}
}
function getDidYouKnow()
{
	var didYouKnowArray = new Array();
	var didYouKnowGeneralArray = new Array();
	var didYouKnowCSRArray = new Array();

	didYouKnowGeneralArray = [
		"HKIA is located no more than five flying hours from half of the world's population, it is the world's fourth busiest international passenger airport as well as the most active air cargo operation.",
		"HKIA handled more than 46.1  million passengers and moved over 3.35 million tonnes of cargo in 2009.",
		"An average of 750 aircraft take off and land at HKIA every day.",
		"Around 90 airlines operate from HKIA, linking Hong Kong with around 150 locations round the world, including 40 cities on the Chinese Mainland.",
		"Since opening in 1998, HKIA continues to be acclaimed as the world's best airport - over 25 times by 10 entities.",
		"HKIA and the 60,000-strong airport community is an engine of economic growth for Hong Kong and its leading regional aviation and logistics hub.",
		"Some 400 coach trips a day link HKIA with 90 PRD towns and cities.",
		"The SkyPier offers cross-boundary ferry services to eight ports - Macao's Taipa and Maritime Ferry Terminal, Guangzhou Nansha, Shenzhen's Shekou and Fuyong, Dongguan Humen, Zhongshan and Zhuhai Jiuzhou.",
		"HKIA is served by a highly efficient and comprehensive transport network. The Airport Express takes passengers to Central in just 24 minutes. ",
		"HKIA offers more than 3,000 public parking spaces in four car parks, including one covered multi-storey car park.",
		"Since the launch of the Airport Ambassador Programme in 2002, HKIA has already recruited more than 750 youths, student and senior ambassadors, providing immediate assistance to passengers in need.",
		"The SkyPier, a permanent cross-boundary ferry terminal, officially opened in January 2010. The 16,500 m<sup>2</sup> new facility is eight times the size of the temporary pier.",
		"Security is the heart of airport operations and HKIA has employed about 3,000 security staff. "
	];

	didYouKnowCSRArray = [
		"Soon after the airport opened, we planted 350,000 seedlings in a 60-hectare woodland on Tung Chung hill slopes. More recently we supported the creation of a 12-hectare mangrove habitat in Tai O, where about 90,000 mangrove seedlings were planted.",
		"HKIA has been named a Caring Organisation by the Hong Kong Council of Social Service for five consecutive years since 2004 in recognition of our continuous support and contributions to the community.",
		"HKIA has been working with different charity and community organisations to provide care for senior citizens in neighbouring communities such as Tung Chung and Tuen Mun.",
		"The AA raised HK$4.27 million from the airport community to support the rescue and reconstruction works in Sichuan in the wake of the earthquake in May 2008.",
		"HKIA has taken part in many charitable events and activities, such as Walk up Jardine House, MTR Hong Kong Race Walking, Community Chest's New Territories Walk and Dress Special Day, etc, to raise funds for programmes that promote the betterment of our community.",
		"HKIA encourages food and beverage outlets to collect wet wastes and unused food to be used as compost. This is processed in two mechanised food composters which reduce waste volume by up to 90% and produce a residue for airport landscaping projects.",
		"T1 was the first non-government building in Hong Kong to receive indoor air quality certification from the Environmental Protection Department. <br/>T2 has also been certified recently.",
		"HKIA is operating a fleet of four LPG and seven hybrid vehicles. By gradually replacing the current vehicles with environmentally friendly models, HKIA hopes to protect the environment by minimising vehicle emissions.",
		"HKIA has participated in the Hong Kong Environmental Protection Department's Wastewi$e programme since 2003. Wastewi$e sets annual waste reduction and recycling targets and HKIA won the Wastewi$e Gold standard from 2003.",
		"HKIA works hard to identify opportunities to improve energy efficiency and we have been able to maintain the same overall level of energy consumption despite increasing passenger and cargo numbers."
	];
	if (level1 == 'csr')
	{
		didYouKnowArray = didYouKnowCSRArray;
	}
	else
	{
		didYouKnowArray = didYouKnowGeneralArray.concat(didYouKnowCSRArray);
	}

	var tempHtml = '';
	
	var num1 = Math.floor(Math.random()*didYouKnowArray.length);
	//tempHtml += '<div style="border-bottom:1px solid #E5E5E5; padding-bottom:7px; margin-bottom:7px;">';
	tempHtml += didYouKnowArray[num1];
	//tempHtml += '</div>';
	
	/*var tempArray = new Array();
	for (var i=0; i<didYouKnowArray.length; i++)
	{
		if (i != num1)	tempArray.push(didYouKnowArray[i]);
	}
	didYouKnowArray = tempArray;
	
	var num2 = Math.floor(Math.random()*didYouKnowArray.length);
	tempHtml += didYouKnowArray[num2];
	//alert("num1:  "+num1+"  num2:  "+num2);*/
	
	d.getElementById('didYouKnow').innerHTML = tempHtml;
}
var hour = (-1); // this would be assigned as the value of system time
function genHomeBg() {
	var num = Math.round(Math.random() * 2 ) + 1;
	var numNite = Math.round(Math.random() * 1 ) + 1;
	
	tempHtml = '';
	if (hour < 18 & hour >= 6) {
		tempHtml += '<img src="'+path+'img/home/photo/day_'+num+'.jpg" border="0" alt="" />';
	} else {
		tempHtml += '<img src="'+path+'img/home/photo/night_'+numNite+'.jpg" border="0" alt="" />';
	}
	
	document.write(tempHtml);
}
function genWeatherBg() {
	
	if (hour < 18 & hour >= 6) {
		d.getElementById('homeLeftWeather').style.color = '#333333';
		d.getElementById('homeLeftWeather').style.background = 'url('+path+'img/home/weather_day.jpg) no-repeat';
		d.getElementById('homeLeftClock').style.background = 'url('+path+'img/home/clock_day.gif) no-repeat 0px 7px';
		d.getElementById('homeLeftCity').style.background = 'url('+path+'img/home/arrow_day.gif) no-repeat 0px 9px';
		d.getElementById('homeLeftCity').className = 'homeLeftCityDay';
	} else {
		d.getElementById('homeLeftWeather').style.color = '#FFFFFF';
		d.getElementById('homeLeftWeather').style.background = 'url('+path+'img/home/weather_night.jpg) no-repeat';
		d.getElementById('homeLeftClock').style.background = 'url('+path+'img/home/clock_night.gif) no-repeat 0px 7px';
		d.getElementById('homeLeftCity').style.background = 'url('+path+'img/home/arrow_night.gif) no-repeat 0px 9px';
		d.getElementById('homeLeftCity').className = 'homeLeftCityNight';
	}
}
function genWeatherRightBg() {
	
	if (hour < 18 & hour >= 6) {
		d.getElementById('weatherBgTitle').style.color = '#235CA7';
		d.getElementById('weatherBg').style.background = 'url('+path+'img/flight/weather_bg_day.jpg) no-repeat';
		d.getElementById('homeLeftCity').style.background = 'url('+path+'img/home/arrow_day.gif) no-repeat 0px 9px';
		d.getElementById('homeLeftCity').className = 'homeLeftCityDay';
	} else {
		d.getElementById('weatherBgTitle').style.color = '#FFFFFF';
		d.getElementById('weatherBg').style.background = 'url('+path+'img/flight/weather_bg_night.jpg) no-repeat';
		d.getElementById('homeLeftCity').style.background = 'url('+path+'img/home/arrow_night.gif) no-repeat 0px 9px';
		d.getElementById('homeLeftCity').className = 'homeLeftCityNight';
	}
}
