<!--

// Major version of Flash required
var requiredMajorVersion = 8;
// Minor version of Flash required
var requiredMinorVersion = 0;
// Minor version of Flash required
var requiredRevision = 0;

var addthis_config = {
	username: "irasia",
	ui_click: true,
	data_track_clickback: true
}

var isFirefox=(window.navigator.userAgent.indexOf("Firefox")!=-1);
var isChrome=(window.navigator.userAgent.indexOf("Chrome")!=-1);
var isSafari=(window.navigator.userAgent.indexOf("Safari")!=-1);

var isWindows=(window.navigator.userAgent.indexOf("Windows")!=-1);
var isMacintosh=(window.navigator.userAgent.indexOf("Macintosh")!=-1);

var isMobile=(window.navigator.userAgent.indexOf("Android")!=-1 || window.navigator.userAgent.indexOf("iPhone")!=-1 || window.navigator.userAgent.indexOf("iPad")!=-1  || window.navigator.userAgent.indexOf("iPod")!=-1 || window.navigator.userAgent.indexOf("BlackBerry")!=-1);
var isIPhone=(window.navigator.userAgent.indexOf("iPhone")!=-1);
var isIPad=(window.navigator.userAgent.indexOf("iPad")!=-1 );
var isIPod=(window.navigator.userAgent.indexOf("iPod")!=-1 );
var isAndroid=(window.navigator.userAgent.indexOf("Android")!=-1);
var isBlackBerry=(window.navigator.userAgent.indexOf("BlackBerry")!=-1);


function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function addFavourites() {
	var curLoc = parent.location.href;
	var docTitle = document.title;

	if(isMacintosh)
	{
		showBookmarkPopup();
	}
	else if(isWindows && isSafari)
	{
		showBookmarkPopup();
	}
	else 
	{
		if (window.sidebar) 
		{
			window.sidebar.addPanel(docTitle, curLoc, "");
		}
		else if (window.external) 
		{
			window.external.AddFavorite(curLoc,docTitle);
		}
	}

}

function printFriendly() {
	var winLink = window.location.href;	
	winLink = winLink.substring(7);
	if(winLink.indexOf("network.php")!=-1)
	{
		winLink = winLink.replace(/network.php/,"network_nonflash.php")
	}
	var url = "../global/printVersion.php?file=" + encodeURIComponent(winLink);
	
	if(winLink.indexOf("network_nonflash.php")!=-1)
	{
		url += "&printaction=0";
	}
	
	if(mainSection == 'home')
	{
		window.print() ;
	}
	else
	{
		openPrintPopup(url);
	}
}

function openPrintPopup(url)
{
	window.open(url, 'printing', 'width=810,height=600,left=50,top=50,scrollbars=yes, menubar=yes');
}

function emailThisPage()
{
	var winLink = window.location.href;	
	winLink = winLink.substring(7);
	var url = "http://www.lifung.com/eng/global/emailpage.php?page=" + encodeURIComponent(winLink);
	window.open(url, 'emailpage', 'width=300,height=300,left=50,top=50,scrollbars=no, menubar=no');
}

function emailCheck(field) {
	var valid = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz@&_-.0123456789";
	var ok = "yes";
	var temp;
	for (var i=0; i<field.value.length; i++) {
		temp = "" + field.value.substring(i, i+1);
		if (valid.indexOf(temp) == "-1") ok = "no";
	}
	hasAt = 0;
	hasDot = false;
	for (var i=0; i<field.value.length-1; i++) {
			if ((i >= 1) && (field.value.substring(i, i+1) == '@') && (field.value.substring(i+1, i+2) != '.')) // return true if it contains @ but not @.
				{
					hasAt = hasAt + 1;
				}
			if ((hasAt == 1) && (field.value.substring(i, i+1) == '.') && (i != field.value.length-1) && (field.value.substring(i+1, i+2) != '.') && (field.value.substring(i-1, i) != '.')) // return true if the pattern contains . after @ but not ..
				{
				hasDot = true;
				}
	}
	if ((hasAt == 1) && (hasDot) && (field.value.substring(field.value.length-1, field.value.length) != '.')) // return true if the pattern is *@*.*
	{
	}
	else 
	{
		ok = "no";
	}
	if (ok == "no") {
		alert("Sorry! Your email address is not valid!");
		field.focus();
		field.select();
		return false;
	}
}

function emailCheckBig5(field) {
	var valid = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz@&_-.0123456789";
	var ok = "yes";
	var temp;
	for (var i=0; i<field.value.length; i++) {
		temp = "" + field.value.substring(i, i+1);
		if (valid.indexOf(temp) == "-1") ok = "no";
	}
	hasAt = 0;
	hasDot = false;
	for (var i=0; i<field.value.length-1; i++) {
			if ((i >= 1) && (field.value.substring(i, i+1) == '@') && (field.value.substring(i+1, i+2) != '.')) // return true if it contains @ but not @.
				{
					hasAt = hasAt + 1;
				}
			if ((hasAt == 1) && (field.value.substring(i, i+1) == '.') && (i != field.value.length-1) && (field.value.substring(i+1, i+2) != '.') && (field.value.substring(i-1, i) != '.')) // return true if the pattern contains . after @ but not ..
				{
				hasDot = true;
				}
	}
	if ((hasAt == 1) && (hasDot) && (field.value.substring(field.value.length-1, field.value.length) != '.')) // return true if the pattern is *@*.*
	{
	}
	else 
	{
		ok = "no";
	}
	if (ok == "no") {
		alert("qla}~I");
		field.focus();
		field.select();
		return false;
	}
}

function changeLanguage(newLanguage) {
   var curLoc = parent.location.href;
   
   var arrlen = 2;
   var arr = new Array(arrlen);
   arr[0] = "eng";
   arr[1] = "big5";
   arr[2] = "gb";

   // Get the new language index in the array first
   var newpos = -1;
   for (i = 0; i < arrlen; i++)
   {
   	if (arr[i] == newLanguage)
   	{
   		newpos = i;
   		break;	
   	}
   }
   
   // Get the old language index second
   var oldpos = -1;
   for (i = 0; i < arr.length; i++)
   {
   	tmplanguage = "/" + arr[i];
   	if (curLoc.indexOf(tmplanguage) > 0)
   	{
   		oldpos = i;
   		break;	
   	}
   }
   
   var tmplen = 0;
   if (oldpos != newpos)
   {
   	tmplanguage = "/" + arr[oldpos];
   	tmplen = tmplanguage.length;
   	var docPos = curLoc.indexOf(tmplanguage);
   }
   
   var pathPart = curLoc.substring(0, docPos+1);
   var docPart = curLoc.substring(docPos+tmplen);
   eval("parent.location='" + pathPart + newLanguage + docPart + "'");
}

//Get href values
function getUrlValue(name)
{
	var str=window.location.search;
	if (str.indexOf(name)!=-1)
	{
		var pos_start=str.indexOf(name)+name.length+1;
		var pos_end=str.indexOf("&",pos_start);
		if (pos_end==-1)
		{
			return str.substring(pos_start);
		}
  		else
  		{
   			return str.substring(pos_start,pos_end);
  		}
 	}
 	else
 	{
		return "NNN";
 	}
}

function subSectionhighlight() { 
	if (subSection != "" && document.getElementById(subSection + '_subnav')) 
	{
		//imgTemp = document.getElementById(subSection + '_subnav').className;
		document.getElementById(subSection + '_subnav').className = 'subNavBtnHover';
		
		if(mainSection == "csr")
		{
			document.getElementById(subSection + '_subnav').className = "csr_"+document.getElementById(subSection + '_subnav').className;
		}
	} 
}

function subSubSectionhighlight() { 
	if (subSubSection != "" && document.getElementById(subSubSection + '_subsubnav')) 
	{
		document.getElementById(subSubSection + '_subsubnav').className = 'subSubNavBtnHover';
		
		if(mainSection == "csr")
		{
			document.getElementById(subSubSection + '_subsubnav').className = "csr_"+document.getElementById(subSubSection + '_subsubnav').className;
		}
	} 
}

function showSubSubNavLayer()
{
	if(document.getElementById(subSection + 'SubNavLayer'))
	{
		$("#"+subSection+'SubNavLayer').show();
	}
}


function docContent(obj)
{
	if (obj != "") 
	{
		if(document.getElementById)
		{
			var el = document.getElementById("P"+obj);
			var ar = document.getElementById("divQs").getElementsByTagName("div");
			for (var i=0; i<ar.length; i++)
			{
				if (ar[i].className=="divA")
				ar[i].style.display = "none";
			}
			el.style.display = "block";
			
			window.location="#" + obj;
		}
	}
}

function switchYear()
{
	var curLoc = parent.location.href;
	
	getLoc = curLoc.split("#");
	
	if (getLoc.length>1)
	{
		pos = getLoc.length-1;
		docContent(getLoc[pos]);	
	}
	else
		docContent(startYear);
}


function back2Top()
{
	window.scrollTo(0,0);
}

//Get href values
function getUrlValue(name)
{
	var str=window.location.search;
	if (str.indexOf(name)!=-1)
	{
		var pos_start=str.indexOf(name)+name.length+1;
		var pos_end=str.indexOf("&",pos_start);
		if (pos_end==-1)
		{
			return str.substring(pos_start);
		}
  		else
  		{
   			return str.substring(pos_start,pos_end);
  		}
 	}
 	else
 	{
		return "NNN";
 	}
}

function addListener(element,e,fn)
{
     if(element.addEventListener)
	 {
          element.addEventListener(e,fn,false);
     } 
	 else 
	 {
          element.attachEvent("on" + e,fn);
     }
}

function removeListener(element,e,fn)
{
     if(element.addEventListener)
	 {
          element.removeEventListener(e,fn,false);
     } 
	 else 
	 {
          element.detachEvent("on" + e,fn);
     }
}

function getElementByClassInId(id,theClass) 
{
	var classArray = new Array(); 
	var allPageTags=document.getElementById(id).getElementsByTagName("*");
	j=0;
	for (i=0; i<allPageTags.length; i++) 
	{
		if (allPageTags[i].className==theClass) 
		{
			classArray[j]=allPageTags[i];
			j++;
		}
	}
	return classArray;
} 

function subNavOn(evt)
{
	evtElement = evt.srcElement || evt.target;
	id = evtElement.getAttribute('id');
	sectionId = id.replace(/_subnav/,'') || id.replace(/_subsubnav/,'');

	if(sectionId != subSection && sectionId != subSubSection )
	{
		document.getElementById(id).src = document.getElementById(id).src.replace(/_off/,'_on');
	}
}

function subNavOff(evt)
{
	evtElement = evt.srcElement || evt.target;
	id = evtElement.getAttribute('id');
	sectionId = id.replace(/_subnav/,'') || id.replace(/_subsubnav/,'');

	if(sectionId != subSection && sectionId != subSubSection )
	{
		document.getElementById(id).src = document.getElementById(id).src.replace(/_on/,'_off');
	}
}

function addSubNavEvent()
{
	var subNavBtnClass = 'subNavBtn'; 
	var subNavArea = 'subNav';
	var subNavBtnArr = new Array();
	
	subNavBtnArr = getElementByClassInId(subNavArea,subNavBtnClass);
	for (i = 0 ; i < subNavBtnArr.length ; i++)
	{
		addListener(subNavBtnArr[i],'mouseover',function(e)
		{
			var evt = window.event || e;
			subNavOn(evt);
		});
		addListener(subNavBtnArr[i],'mouseout',function(e)
		{
			var evt = window.event || e;
			subNavOff(evt);
			//subSectionhighlight();
		});
	}
}

function addSubSubNavEvent()
{
	var subNavBtnClass = 'subSubNavBtn'; 
	var subNavArea = 'subNav';
	var subNavBtnArr = new Array();
	
	subNavBtnArr = getElementByClassInId(subNavArea,subNavBtnClass);
	for (i = 0 ; i < subNavBtnArr.length ; i++)
	{
		addListener(subNavBtnArr[i],'mouseover',function(e)
		{
			var evt = window.event || e;
			subNavOn(evt);
		});
		addListener(subNavBtnArr[i],'mouseout',function(e)
		{
			var evt = window.event || e;
			subNavOff(evt);
			subSubSectionhighlight();
		});
	}
}

function checkFeedTitle(numOfCharsLimit,className,id)
{
	var allClasses = new Array();
	var regex = /[A-Za-z0-9\,\.]/;
	
	numOfCharsLimitTemp = numOfCharsLimit;
	
	allClasses = getElementByClassInId(id,className);
	if(allClasses.length > 0)
	{
		for(i=0; i<allClasses.length;i++)
		{
			innerHtmlTemp = allClasses[i].getAttribute('title'); 
			if(innerHtmlTemp.length > numOfCharsLimitTemp-3)
			{			
				innerHtmlTemp = innerHtmlTemp.substring(0,numOfCharsLimit-3);
				
				if(window.location.href.indexOf('/eng/') != -1)
				{
					innerHtmlTemp = innerHtmlTemp.substring(0,innerHtmlTemp.lastIndexOf(' '));
				}
				else
				{
					while(regex.test(innerHtmlTemp.charAt(innerHtmlTemp.length-1)))
					{
						innerHtmlTemp = innerHtmlTemp.substring(0,innerHtmlTemp.length-1);
					}
				}
				allClasses[i].innerHTML = innerHtmlTemp +' ...';
				innerHtmlTemp = '';
			}
			else
			{
				allClasses[i].innerHTML = innerHtmlTemp;
			}
		}
	}
}

function customFeedTitle()
{
	if(window.location.href.indexOf('/eng/') != -1)
	{
		checkFeedTitle(45,'newsTitle','homeNews');
	}
	else
	{
		checkFeedTitle(45,'newsTitle','homeNews');
	}
	
	
}

function customFeedTitle2()
{
	if(window.location.href.indexOf('/eng/') != -1)
	{
		checkFeedTitle(9999,'newsTitle','homeNews');
	}
	else
	{
		checkFeedTitle(9999,'newsTitle','homeNews');
	}
	
	
}

function selectYear()
{
	var year = getUrlValue('y');
	var yearArr = new Array();
	if(year != 'NNN')
	{
		document.getElementById('y'+year).style.display = 'block';
	}
	else
	{
		yearArr = getElementByClassInId('hiddenContentArea','hiddenContent');
		yearArr[0].style.display = 'block';
	}
}

function loadDisable()
{
	document.getElementById('newsLoading').style.display = 'none';
}

function plantPhotoSwitch(no)
{
	document.getElementById("display_photo").src = "../../eng/images/plants/" + subSection + "/" + no + ".jpg";
}

function globalSearchBlur() {
	var searchID = document.getElementById("q");
	var defaultV = searchID.getAttribute("defaultValue");

	if (searchID.value == "") {
		searchID.value = defaultV;
	}
}

function globalSearchFocus() {
	var searchID = document.getElementById("q");
	var defaultV = searchID.getAttribute("defaultValue");

	if (searchID.value == defaultV) {
		searchID.value = "";
	}
}

function genContentPhoto()
{
	document.getElementById('photoArea').innerHTML = '<img src="../images/global/content_area_photos/'+(Math.round(Math.random()*9)+1)+'.jpg" border="0">';
}

function genShareBtn()
{
	pageTitle = document.getElementsByTagName('title')[0].innerHTML;
	
	pageTitle = pageTitle.replace(/>/,'-'); 
	pageTitle = pageTitle.replace(/&gt;/,'-');
	
	document.write('<div class="shareBtn"><a href="javascript:;" class="addthis_button" addthis:title="'+pageTitle+'"><IMG src="../images/global/share_btn.gif" alt="Share to Friends" border="0"></A></div>');
}

function genHomeShareBtn()
{
	if(mainSection == 'home')
	{
		document.write('<a href="javascript:;" class="addthis_button"><IMG src="../images/global/share_btn.gif" alt="Share to Friends" border="0"></A>');
	}
}

function docOpen(theURL) {
	window.open(theURL,'newswin','left=50,top=50,width=700,height=450,toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1')
}

function genTime()
{
	var ENG_MONTH_NAME = new Array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec");
	
	now = new Date();
	year = now.getFullYear();
	month = now.getMonth();
	day = now.getDate();
	hours = now.getHours();
	minutes = now.getMinutes();
	secound = now.getSeconds();
	
	if(window.location.href.indexOf("/eng/") != -1)
	{
		document.getElementById("headerTime").innerHTML = genTimeValueFormat(day)+" "+ENG_MONTH_NAME[month]+" "+year+" "+genTimeValueFormat(hours)+":"+genTimeValueFormat(minutes);
	}
	else
	{
		document.getElementById("headerTime").innerHTML = year+"&#24180;"+genTimeValueFormat(month+1)+"&#26376;"+genTimeValueFormat(day)+"&#26085; "+genTimeValueFormat(hours)+":"+genTimeValueFormat(minutes);
	}

	setTimeout("genTime()",10);
}

function genTimeValueFormat(value)
{
	value = value.toString();
	if(value.length == 1)
	{
		value = "0" + value;
	}
	return value;
}

function genHomeHighlight()
{
	var highlightLinks = ["http://202.66.146.82/listco/hk/trinity/interim/2010/intpress.pdf","http://www.lifung.com/eng/newsroom/lifung_news/news100720.pdf","http://www.cr-asia.com/eng/newsroom/press/p101104.pdf","http://202.66.146.82/listco/hk/lifung/interim/2010/intpress.pdf"];
	var highlightPhotos = ["../images/home/highlight_02_01.jpg","../images/home/highlight_02_02.jpg","../images/home/highlight_02_03.jpg","../images/home/highlight_02_05.jpg"];
	var ranNum = Math.round(Math.random()*3);
	
	document.write('<a href="'+highlightLinks[ranNum]+'" target="_blank"><img src="'+highlightPhotos[ranNum]+'" border="0" /></a>');
}

//PNG function
function checkIE6()
{	
	if (navigator.appName!="Microsoft Internet Explorer") 	
	{		
		return false;
	}
	else if(navigator.userAgent.indexOf('MSIE 6.0') == -1)
	{
		return false;
	}
	return true;
}

function checkIE7UP()
{	
	if (navigator.appName!="Microsoft Internet Explorer") 	
	{		
		return false;
	}
	return true;
}

function redrawPNG() 
{
	if(checkIE6() || (checkIE7UP() && mainSection == 'home'))
	{
		for(var i=0; i<document.images.length; i++)   
		{	  
			var tarimg = document.images[i];	  
			var iw=tarimg.width;	  
			var ih=tarimg.height;	  
			var tarimgsrc = tarimg.src.toUpperCase();
			if (tarimgsrc.substring(tarimgsrc.length-3, tarimgsrc.length) == "PNG")	  
			{          
				tarimg.style.filter+="progid:DXImageTransform.Microsoft.AlphaImageLoader(src="+tarimg.src+", sizingmethod=scale);"; 
				tarimg.src="../images/global/spacer.gif";         
				tarimg.width=iw;
				tarimg.height=ih;
			}
		}
	}
}

function out_link(url){
	if (url != "") {
		window.open(url);
	}
}

//cookie
function setCookie(theName,theValue,theDay)
{
	if ((theName != null) && (theValue != null))
	{
		expDay = "Wed, 01 Jan 2020 18:56:35 GMT";	// wɫh2020~
		if (theDay != null)
		{
			theDay = eval(theDay);	// prאּƭȡ]oˤOI^
			setDay = new Date();
			setDay.setTime(setDay.getTime()+(theDay*1000*60*60*24));
			expDay = setDay.toGMTString();
		}
		document.cookie = theName + "="+escape(theValue)+";expires="+expDay;
		return true;
	}
	return false;
}

function getCookie(theName)
{
	theName += "=";	// W[=H[tjMʧ@
	theCookie = document.cookie+";";	// wjMɳ̫@-1
	start = theCookie.indexOf(theName);	// jMwW
	if (start != -1)
	{
		end = theCookie.indexOf(";",start);
		return unescape(theCookie.substring(start+theName.length,end));
	}
	return false;
}

/*****************************************************************************/

var tooltip=function()
{
	var id = 'tt';
	var top = 3;
	var left = 3;
	var maxw = 300;
	var speed = 10;
	var timer = 20;
	var endalpha = 95;
	var alpha = 0;
	var tt,t,c,b,h;
	var ie = document.all ? true : false;
	return{
		show:function(v,w){
			if(tt == null){
				tt = document.createElement('div');
				tt.setAttribute('id',id);
				t = document.createElement('div');
				t.setAttribute('id',id + 'top');
				c = document.createElement('div');
				c.setAttribute('id',id + 'cont');
				b = document.createElement('div');
				b.setAttribute('id',id + 'bot');
				tt.appendChild(t);
				tt.appendChild(c);
				tt.appendChild(b);
				document.body.appendChild(tt);
				tt.style.opacity = 0;
				tt.style.filter = 'alpha(opacity=0)';
				document.onmousemove = this.pos;
			}
			tt.style.display = 'block';
			c.innerHTML = v;
			tt.style.width = w ? w + 'px' : 'auto';
			if(!w && ie){
				t.style.display = 'none';
				b.style.display = 'none';
				tt.style.width = tt.offsetWidth;
				t.style.display = 'block';
				b.style.display = 'block';
			}
			if(tt.offsetWidth > maxw){tt.style.width = maxw + 'px'}
			h = parseInt(tt.offsetHeight) + top;
			clearInterval(tt.timer);
			tt.timer = setInterval(function(){tooltip.fade(1)},timer);
		},
		pos:function(e){
			var u = ie ? event.clientY + document.documentElement.scrollTop : e.pageY;
			var l = ie ? event.clientX + document.documentElement.scrollLeft : e.pageX;
			tt.style.top = (u + 90 - h) + 'px';
			tt.style.left = (l + left) + 'px';
		},
		fade:function(d){
			var a = alpha;
			if((a != endalpha && d == 1) || (a != 0 && d == -1)){
				var i = speed;
				if(endalpha - a < speed && d == 1){
					i = endalpha - a;
				}else if(alpha < speed && d == -1){
					i = a;
				}
				alpha = a + (i * d);
				tt.style.opacity = alpha * .01;
				tt.style.filter = 'alpha(opacity=' + alpha + ')';
			}else{
				clearInterval(tt.timer);
				if(d == -1){tt.style.display = 'none'}
			}
		},
		hide:function(){
			clearInterval(tt.timer);
			tt.timer = setInterval(function(){tooltip.fade(-1)},timer);
		}
	};
}();

/*****************************************************************************/

(function($){
 $.fn.extend({
 
 	customStyle : function(options) {
	  if(!$.browser.msie || ($.browser.msie&&$.browser.version>6)){
	  return this.each(function() {
	  
			var currentSelected = $(this).find(':selected');
			$(this).after('<span class="customStyleSelectBox"><span class="customStyleSelectBoxInner">'+currentSelected.text()+'</span></span>').css({position:'absolute', opacity:0,fontSize:$(this).next().css('font-size')});
			var selectBoxSpan = $(this).next();
			var selectBoxWidth = parseInt($(this).width()) - parseInt(selectBoxSpan.css('padding-left')) -parseInt(selectBoxSpan.css('padding-right'));			
			var selectBoxSpanInner = selectBoxSpan.find(':first-child');
			selectBoxSpan.css({display:'inline-block'});
			selectBoxSpanInner.css({width:selectBoxWidth, display:'inline-block'});
			var selectBoxHeight = parseInt(selectBoxSpan.height()) + parseInt(selectBoxSpan.css('padding-top')) + parseInt(selectBoxSpan.css('padding-bottom'));
			$(this).height(selectBoxHeight).change(function(){
				selectBoxSpanInner.text($(this).val()).parent().addClass('changed');
			});
			
	  });
	  }
	}
 });
})(jQuery);


/*****************************************************************************/

var currentDiv;
function swapDiv(d,o,l,t)
{
	$(".swapDiv").css({'z-index':'50',left:'0',top:'0',opacity:o,cursor:'pointer'}).click(function(event){
		if(event.currentTarget.id!=currentDiv)
		{
			$(".swapDiv").css({'z-index':function(index, value){return parseFloat(value) +1;}});
			$('#'+currentDiv).css({'z-index':'50',opacity:o,cursor:'pointer'}).animate({left:'0',top:'0'},d);
			$('#'+event.currentTarget.id).css({'z-index':'100',opacity:'1',cursor:'default'}).animate({left:l,top:t},d);
			currentDiv = event.currentTarget.id;
		}
	});
	currentDiv = $(".swapDiv:last").css({'z-index':'100',left:l,top:t,opacity:'1',cursor:'default'}).attr('id');
}

/*****************************************************************************/

var bannertCount = 1;
var bannerCountTemp = 1;
var bannerChangeTimeout = "";
var bannerEffectSpeed = 500;
var bannerSpeed = 5000;

function showBannerItem(bannerNum)
{
	if(bannerNum != bannertCount)
	{
		clearTimeout(bannerChangeTimeout);
		$(".homeBannerImg:eq("+(bannerNum-1)+")").fadeIn(bannerEffectSpeed);
		$(".homeBannerImg:eq("+(bannertCount-1)+")").fadeOut(bannerEffectSpeed);
		$(".bannerBtn").each(function(index){this.src = this.src.replace(/_on/,"_off")});
		$("#bannerBtn-"+bannerNum+"").attr('src',$("#bannerBtn-"+bannerNum+"").attr('src').replace(/_off/,"_on"));
		bannertCount = bannerNum;
		autoChangeBanner();
	}
}

function autoChangeBanner()
{
	bannerCountTemp = bannertCount+1;
	if(bannerCountTemp > $(".homeBannerImg").size()) bannerCountTemp = 1;
	bannerChangeTimeout = setTimeout(function(){showBannerItem(bannerCountTemp);},bannerSpeed);
}

function genBannerBtn()
{
	btnHtml = "";
	for(i = 1; i <= $(".homeBannerImg").size() ; i++) btnHtml += '<img src="../images/home/banner_btn_off.png" border="0" onClick="showBannerItem('+i+')" id="bannerBtn-'+i+'" class="bannerBtn">';
	return btnHtml;
}

function stopLoop()
{
	clearTimeout(bannerChangeTimeout);
}

function startLoop()
{
	autoChangeBanner();
}

/*****************************************************************************/
function showPhotoInit()
{
	$("a[rel=photogallery]").fancybox({
		'transitionIn'		: 'elastic',
		'transitionOut'		: 'elastic',
		'titlePosition' 	: 'over',
		'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
			return '<span id="fancybox-title-over">' + (title.length ? ' &nbsp; ' + title : '')+ ' (' + (currentIndex + 1) + '/' + currentArray.length + ')</span>';
		}
	});
}

function showEmailPageInit()
{
	var winLink = window.location.href;	
	winLink = winLink.substring(7);
	var url = "http://www.lifung.com/eng/global/emailpage.php?page=" + encodeURIComponent(winLink);
	$("#emailpage").attr("href", url);	
	if(!isMobile)
	{
		$("#emailpage").fancybox({
			'width'				: '3',
			'height'			: '3',
			'autoScale'			: false,
			'transitionIn'		: 'elastic',
			'transitionOut'		: 'elastic',
			'type'				: 'iframe'
		});
	}
}

function showVideoInit()
{
	var url = "";
	//var winLink = window.location.href;	
	//winLink = winLink.substring(7);
	//var url = "../global/emailpage.php?page=" + encodeURIComponent(winLink);
	$("#videoBtn").attr("href", url);	
	if(!isMobile)
	{
		url = "../global/video.php";
		$("#videoBtn").attr("href", url);
		$("#videoBtn").fancybox({
			'width'				: 640,
			'height'			: 360,
			'autoScale'			: false,
			'transitionIn'		: 'elastic',
			'transitionOut'		: 'elastic',
			'type'				: 'iframe',
			'scrolling'         : 'no'
		});
	}
	else if(isBlackBerry)
	{
		url = "../global/video_divx4.avi";
		$("#videoBtn").attr("href", url).attr("target", "_blank");
	}
	else
	{
		url = "../global/video.mp4";
		$("#videoBtn").attr("href", url).attr("target", "_blank");
	}
}

function showReportsInit()
{
	$("a[rel=reportPopup]").fancybox({
		'width'				: '5',
		'height'			: '5',
		'autoScale'			: false,
		'transitionIn'		: 'elastic',
		'transitionOut'		: 'elastic',
		'showNavArrows'     : false,
		'type'				: 'iframe'
	});
}

function showHomePopup()
{
	var html = "";
	
	if(window.location.href.indexOf("/eng/")!=-1)
		html = "<div style='width:400px;height:120px;overflow:auto;'>"
			 + "<p class='homePopupTitle'>Welcome to the new edition of Li & Fung Ltd's website!</p>"
			 + "<p class='homePopupText'>With newly added features, you can now connect to Li & Fung on your mobile devices. "
			 + "Also check out our new interactive functions, news alerts, and many other exciting additions.</p>"
			 + "</div>";			  
	
	$.fancybox(
	html,
	{
		'autoScale'			: true,
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'overlayOpacity'	: 0.3
	});
	
	setCookie("homepopup","1",0.007);
}

function styleBusinessIcon()
{
	$(".businessIcon").css({
		"opacity":0.45
	}).mouseover(function(){
			$("#"+this.id).css({"z-index":20}).animate({"opacity":1},300);
	}).mouseout(function(){
			$("#"+this.id).css({"z-index":10}).animate({"opacity":0.45},300);
	});
}

function showBookmarkPopup()
{
	var html = "";
	
	if(isMacintosh)
	{
		if(window.location.href.indexOf("/eng/")!=-1)
			html = "<div style='width:200px;height:50px;overflow:auto;padding-top:10px;'><p><b>Press 'Command + D' to Add Bookmark</b></p></div>";
		else if(window.location.href.indexOf("/big5/")!=-1)
			html = "<div style='width:200px;height:50px;overflow:auto;padding-top:10px;'><p><b>請按'Command + D'以新增本頁到書籤</b></p></div>";
		else if(window.location.href.indexOf("/gb/")!=-1)
			html = "<div style='width:200px;height:50px;overflow:auto;padding-top:10px;'><p><b>请按'Command + D'以新增本页到书签</b></p></div>";	
	}
	else if(isWindows)
	{
		if(window.location.href.indexOf("/eng/")!=-1)
			html = "<div style='width:200px;height:50px;overflow:auto;padding-top:10px;'><p><b>Press 'Ctrl + D' to Add Bookmark</b></p></div>";
		else if(window.location.href.indexOf("/big5/")!=-1)
			html = "<div style='width:200px;height:50px;overflow:auto;padding-top:10px;'><p><b>請按'Ctrl + D'以新增本頁到書籤</b></p></div>";
		else if(window.location.href.indexOf("/gb/")!=-1)
			html = "<div style='width:200px;height:50px;overflow:auto;padding-top:10px;'><p><b>请按'Ctrld + D'以新增本页到书签</b></p></div>";	
	}
	
	$.fancybox(
	html,
	{
		'autoScale'			: true,
		'transitionIn'		: 'fade',
		'transitionOut'		: 'fade',
		'overlayOpacity'	: 0.6
	});
}

function showOffice(url)
{
	if(!isMobile)
	{
		$.fancybox(url,{
			'width'				: 900,
			'height'			: 600,
			'autoScale'			: false,
			'transitionIn'		: 'fade',
			'transitionOut'		: 'fade',
			'type'				: 'iframe'
		});
	}
	else
	{
		window.open(url);
	}
}

function showNewsVideo(fileName,width,height)
{
	var url = "";
	if(!isMobile)
	{
		url = "../newsroom/video.php?video="+fileName+"&width="+width+"&height="+height;
		$.fancybox(url,{		
			'width'				: width,
			'height'			: height,
			'autoScale'			: false,
			'transitionIn'		: 'elastic',
			'transitionOut'		: 'elastic',
			'type'				: 'iframe',
			'scrolling'         : 'no'
		});
	}
	else if(isBlackBerry)
	{
		url = "../newsroom/lifung_news/"+fileName+".avi";
		window.open(url);
	}
	else
	{
		url = "../newsroom/lifung_news/"+fileName+".mp4";
		window.open(url);
	}
}

function showRSSForm(cat)
{
	var url = "";
	url = "../global/rss.php?rsstype="+cat;
	if(!isMobile)
	{
		$.fancybox(url,{		
			'width'				: 300,
			'height'			: 300,
			'autoScale'			: false,
			'transitionIn'		: 'elastic',
			'transitionOut'		: 'elastic',
			'type'				: 'iframe',
			'scrolling'         : 'no'
		});
	}
	else
	{
		window.open(url);
	}
}


/*****************************************************************************/
function catChange(cat)
{
	/*if (cat=="Others")
	{
		document.getElementById("showCatOtherDiv").style.display = "block";
	}
	
	else
	{
		document.getElementById("showCatOtherDiv").style.display = "none";
	}*/
	
	if (cat!="- - - - - - - - - - Please Select - - - - - - - - - -")
		document.getElementById("category").value = cat;
}

function presetCatChange(cat)
{
	if (cat=="Financial Community")
	{
		document.getElementById("category_a").selectedIndex = 0;
		document.getElementById("category_b").selectedIndex = 0;
		document.getElementById("category_div_a").style.display = "block";
		document.getElementById("category_div_b").style.display = "none";
		document.getElementById("showCatOtherDiv").style.display = "none";
		document.getElementById("category").value = "";
	}
	
	else if (cat=="Media")
	{
		document.getElementById("category_a").selectedIndex = 0;
		document.getElementById("category_b").selectedIndex = 0;
		document.getElementById("category_div_a").style.display = "none";
		document.getElementById("category_div_b").style.display = "block";
		document.getElementById("showCatOtherDiv").style.display = "none";
		document.getElementById("category").value = "";
	}
	
	else if (cat=="Employee")
	{
		document.getElementById("category_a").selectedIndex = 0;
		document.getElementById("category_b").selectedIndex = 0;
		document.getElementById("category_div_a").style.display = "none";
		document.getElementById("category_div_b").style.display = "none";
		document.getElementById("showCatOtherDiv").style.display = "none";
		document.getElementById("category").value = "Employee";
	}
	
	else if (cat=="Others")
	{
		document.getElementById("category_a").selectedIndex = 0;
		document.getElementById("category_b").selectedIndex = 0;
		document.getElementById("category_div_a").style.display = "none";
		document.getElementById("category_div_b").style.display = "none";
		document.getElementById("showCatOtherDiv").style.display = "block";
		document.getElementById("category").value = "Others";
	}
}

/*****************************************************************************/

$(function(){
	$("#nav ul").css({display: "none"}); // Opera fix

	$("#nav li").hover(function(){
	
		$(this).addClass("hover");
		$('ul:first',this).css({display: "block"});
	
	}, function(){
	
		$(this).removeClass("hover");
		$('ul:first',this).css({display: "none"});
	
	});
	
	$("#nav li a").removeAttr('title');
	$("#nav li ul li a").removeAttr('title');
	
	//$("#nav_"+mainSection).addClass("current");
	
	if(mainSection != 'home')
	{
		if(document.getElementById("subNav"))
		{
			subSectionhighlight();
			//showSubSubNavLayer();
			subSubSectionhighlight();
		}
		
		if(subSection == "gallery")
			showPhotoInit();
			
		if(subSection == "reports" && !isMobile)
			showReportsInit();
		
		if(mainSection == "business" && subSection == "index")
		{
			//styleBusinessIcon();
			showVideoInit();
		}
	}
	else
	{
		//bannertCount = Math.round(Math.random()*4+1);
		bannertCount = 1;
		$(".homeBannerImg:eq("+(bannertCount-1)+")").show();
		autoChangeBanner();
		$("#bannerBtnArea").html(genBannerBtn());
		$(".bannerBtn:eq("+(bannertCount-1)+")").each(function(index){this.src = this.src.replace(/_off/,"_on")});
		$(".homeBannerImg").mouseover(function(){stopLoop()}).mouseout(function(){startLoop()});
		
		
		scroller  = new jsScroller(document.getElementById("Scroller"), 340, 80);
		scrollbar = new jsScrollbar (document.getElementById("Scrollbar-Container"), scroller, 'auto');
		
		showVideoInit();
		
		/*if(!getCookie("homepopup"))
		{
			showHomePopup();
		}*/

	}
	
	if(!isMobile)
	{
		if(!(isMacintosh && isFirefox) && !(isWindows && isSafari))
			$('select.styled').customStyle();
	}
	else
	{
		$(".printFriendly").hide();
		$(".addBookmark").hide();
		$(".mobileHide").hide();
	}
	
	if (window.location.href.indexOf("printVersion") != -1)
	{
		$("select").attr("disabled","true");
	}
		
	$("body").noContext();
	document.body.style.webkitTouchCallout='none';

	showEmailPageInit();
	
});

window.onload= function()
{
	
	
}
//-->
