
var topSearch_expanded=false;var topSearch_openTime=480;var topSearch_openTime_de=10;var topSearch_closeTime=420;var topSearch_closeTime_de=40;var topSearch_expanded=false;var topSearchEx_H=127;var LAYOUT_ID="home";var PORTFOLIO_RANDOM_STATE='is_random';var SHOW_PAGER=0;var content_H;var pager_H=9999;var rPanelWidth=0;var renderBoxesMax=50;function getHref(moduleId,pageName,param,pageGoing,ajaxMode){var output='';if(ajaxMode){output="javascript:pageRequest("+moduleId+",'"+pageName+"','"+param+"','"+pageGoing+"');";}else{output=SITE_DOMAIN+DOCUMENT_FRONT_ROOT+INDEX_FILE+"?moduleId="+moduleId+"&pageName="+pageName;output+=(param=='')?"":"&"+param;}
return output;}
function getMaxBoxes(){var returnNum=renderBoxesMax;var deviceBoxes=(Math.floor(screen.width/94)+1)*(Math.floor(screen.height/94)+1);if(deviceBoxes>returnNum){returnNum=deviceBoxes;}
var broswerBoxes=(Math.floor($("body").width()/94)+1)*(Math.floor($("body").height()/94)+1);if(broswerBoxes>returnNum){returnNum=broswerBoxes;}
return returnNum;}
function setUpScrollBar(){if($("#mainDiv_scrollContent").height()!=null){if(IS_IPAD==1||IS_MOBILE==1){setScrollerForIPAD("content");}else{$("#mainDiv_scrollContent").jScrollPane({wheelSpeed:40});if($(".separator").width()!=null){$("#mainDiv_scrollContent img").css("padding","0");}}}
adjustTwitterScroll();if($("#twitter_update_list").height()!=null){if(IS_IPAD==1||IS_MOBILE==1){}else{}}
return false;}
function setScrollerForIPAD(_case){switch(_case){case"content":var scrollPane=$(".scroll-pane");if(scrollPane.width()!=null){scrollPane.jScrollTouch();}
break;case"twitter":var twit=$("#twitter_update_list");if(twit.width()!=null){twit.jScrollTouch();}
break;}
return false;}
function adjustTwitterScroll(){var twit=$("#twitter div:eq(0)");if(twit.height()!=null){twit.width(150);twit.height($("#ContentPanel").height()-60);}}
function expandTopActivite(){if(topSearch_expanded!=true){expandTopSearch();}else{collapseTopSearch();}}
function expandTopSearch(){if(topSearch_expanded==true){return false;}
topSearch_expanded=true;$("#btn_SearchOpen").find("img").attr({src:CURRENT_FRONT_THEME_PATH+"images/search_up_open.gif"});$("#Search_ex").stop().delay(topSearch_openTime_de).animate({height:topSearchEx_H},topSearch_openTime);animateContentH(content_H-127,topSearch_openTime,topSearch_openTime_de);}
function collapseTopSearch(){if(topSearch_expanded==false){return false;}
topSearch_expanded=false;var btn_searchOpen=$("#btn_SearchOpen");var search_ex=$("#Search_ex");btn_searchOpen.find("img").attr({src:CURRENT_FRONT_THEME_PATH+"images/search_up.gif"});search_ex.stop().delay(topSearch_closeTime_de).animate({height:0},topSearch_closeTime,function(){setTimeout(repositionAlertbox,150);});animateContentH(content_H,topSearch_closeTime,topSearch_closeTime_de);}
function windowResizeActions(){var contentTb=$("#ContentTable");var contentLeft=$("#ContentLeft");var contentMain=$("#Content");var container=$("#Container");var white_Alertbox=$("#White_Alertbox");var contentLoader=$("#ContentLoader");var contentCrop=$("#ContentCrop");var white_AB_msg=$("#White_Alertbox .message");var contentPanel=$("#ContentPanel");var details=$("#Details");var client=$("#Client");var staticPage=$("#StaticPage");contentLeft.css("width","auto");contentMain.stop().height(container.height()-$("#Header").height()-$("#Search").height()-$("#Search_ex").height()-120-10);if(contentTb.width()!=null){contentTb.stop().height(contentMain.height());}
if(white_Alertbox.width()!=null){white_Alertbox.stop().height(contentMain.height());}
contentLoader.stop().width(contentMain.width()-170-30+94);if(BROWSE_TYPE=='MSIE'&&Number(BROWSE_VERSION)==6){contentCrop.stop().width(contentMain.width()-170-45);onlyDisplayOneImgOnIE6();setSearchEx_ul_marginLeft(BROWSE_TYPE+BROWSE_VERSION);}else{setSearchEx_ul_marginLeft(BROWSE_TYPE+BROWSE_VERSION);contentCrop.stop().width(contentMain.width()-170-30);}
setTimeout(setWhiteBoxPos,200);if(contentTb.width()!=null){contentTb.stop().width(contentMain.width()-170-30);}
repositionAlertbox();setTimeout(repositionAlertbox,500);updateContentH();setPagerPos();setTimeout(function(){resizeTwitterBox(contentPanel.height()-170);},15);if(details.width()!=null){details.stop().animate({"padding-top":(content_H-details.height())*0.42},0);}
if(details.width()!=null){var makOf=$("#MakingOf");makOf.stop().animate({"padding-top":(content_H-makOf.height())*0.45},0);}
if(client.width()!=null){var __top=(contentPanel.height()+$("#Search_ex").height()-396)*0.4;var __left=(contentLeft.width()-840)*0.35;if(BROWSE_TYPE+BROWSE_VERSION=="MSIE7"){__top-=$("body").height()*0.1;}
client.css("top",__top+"px");if(__left<0){__left=0;}
client.css("left",__left+"px");}
if(staticPage.width()!=null){var __top=(contentPanel.height()+$("#Search_ex").height()-396)*0.4;var __left=(contentLeft.width()-840)*0.35;staticPage.css("top",__top+"px");if(__left<0){__left=0;}
staticPage.css("left",__left+"px");}
if(LAYOUT_ID=="home"){checkForUpdateOnProjectIndex();}
if(LAYOUT_ID=="contact"){layoutContactsDiv();}
adjustTwitterScroll();setTimeout(setUpScrollBar,3000);checkForCrazyRes();}
function checkForCrazyRes(){if($("body").width()>2200||$("body").height()>1200){$("#Background").css({"width":"100%","height":"100%"});if($("#Background2").width()!=null){$("#Background2").css({"width":"100%","height":"100%"});}}else{$("#Background").css({"width":"2200px","height":"1200px"});if($("#Background2").width()!=null){$("#Background2").css({"width":"2200px","height":"1200px"});}}
if(IS_MOBILE==1||IS_IPAD==1){$("#Background").css({"width":"1692px","height":"923px"});}
if(IS_MOBILE==1||IS_IPAD==1){addSlideIcon();}}
function repositionAlertbox(){var white_Alertbox=$("#White_Alertbox");var contentMain=$("#Content");if(white_Alertbox.width()!=null){white_Alertbox.stop().width(contentMain.width()-170-30);setWhiteBoxPos();}}
function setWhiteBoxPos(){white_AB_msg=$("#White_Alertbox .message");if(white_AB_msg.width()==null){return;}
var contentCrop=$("#ContentCrop");var __w=(contentCrop.height()-white_AB_msg.height())*0.48;var __h=(contentCrop.width()-white_AB_msg.width())*0.52;white_AB_msg.animate({"padding-left":positiveNumber(__h),"padding-top":positiveNumber(__w)},1);}
function addSlideIcon(){$(".holder").addClass("slideDown");}
function setPagerPos(){var pager=$("#Pager");var contentLeft=$("#ContentLeft");if(pager_H>=9999){pager_H=pager.height();}
if(content_H!=undefined){pager.css({top:content_H+(4*pager_H)+47+"px",left:"10px"});}
pager.width(contentLeft.width());}
function showPager(){var pager=$("#Pager");pager.css("display","block");if(content_H!=undefined){pager.clearQueue();pager.stop().animate({height:pager_H},500);}
return false;}
function hidePager(_isQuick){var pager=$("#Pager");if(_isQuick==true){if(pager>=9999){pager_H=pager.height();}
pager.clearQueue();if(pager.height()==0){return}
pager.stop().animate({height:0},5,function(){pager.css("display","none")});}else{if(pager.height()==0){return false;}
pager.clearQueue();pager.stop().animate({height:0},300,function(){pager.css("display","none")});}
return false;}
function hidePagerQuick(){hidePager(true);return false;}
var _orgLeft;function animatePanel_hide(){var conFrom=$("#ContactForm");var conPan=$("#ContentPanel");if(conFrom.width()==null||conPan.width()==null){return}
_orgLeft=conFrom.css("left");conFrom.css("left",$("#Container").width()).hide();conPan.clearQueue().animate({"width":0},550,function(){$(this).hide();setTimeout(animatePanel_hide_cont,1000);});return false;}
function animatePanel_hide_cont(){var conFrom=$("#ContactForm");if(conFrom.width()==null){return}
conFrom.show();conFrom.animate({"left":_orgLeft},700);return false;}
function animatePanel_show(){var conPan=$("#ContentPanel");if(conPan.width()==null){return}
if(rPanelWidth==conPan.width()){return false;}
conPan.clearQueue().show().animate({"width":rPanelWidth},550,function(){windowResizeActions();});return false;}
function layoutContactsDiv(){var contactForm=$("#ContactForm");var formHeader=$("#formHeader");if(contactForm.width()==null||formHeader.width()==null){return false;}
var container=$("#Container");var contentLeft=$("#ContentLeft");var _broswerWidth=container.width();contentLeft.width(_broswerWidth);$("#ContentCrop").width(_broswerWidth);$("#ContentLoader").width(_broswerWidth);contactForm.width(_broswerWidth-380);var _left=-1*(2792-contactForm.width())+11;formHeader.width(contactForm.width()+10);formHeader.css("background-position",_left+"px 0px");var content_height=$("#Content").height();contactForm.stop().height(content_height);$("#ContactMap").stop().height(content_height);var _marginTop=((content_H-406)*0.39)+1;formHeader.css("margin-top",_marginTop);$("#ContactMap .header").css("margin-top",_marginTop);return false;}
function updateContentH(){content_H=$("#Container").height()-170-30+10-$("#Search").height();if(IS_MOBILE==1){var _body=$("body");_body.css("min-height","900px");_body.css("max-height","900px");_body.height(900);content_H=$("#Background").width()*0.6;}
if(IS_IPAD==1){content_H+=15;}}
function fixForIPAD(){var _body=$("body");_body.css("min-height","692px");_body.height(692);}
function animateContentH(_targetH,_time,_delay){$("#Content").stop().delay(_delay).animate({height:_targetH},_time);var contentTb=$("#ContentTable");var white_alertbox=$("#White_Alertbox");var twit=$("#twitter");var contactForm=$("#ContactForm");if(contentTb.width()!=null){contentTb.stop().delay(_delay).animate({height:_targetH},_time);}
if(white_alertbox.width()!=null){white_alertbox.stop().delay(_delay).animate({height:_targetH},_time);}
if(BROWSE_TYPE+BROWSE_VERSION=="MSIE7"){twit.stop().delay(_delay).animate({height:_targetH-171},_time);}else{twit.stop().delay(_delay).animate({height:_targetH-153},_time);}
if(contactForm.width()!=null){contactForm.stop().delay(_delay).animate({height:_targetH},_time);$("#ContactMapPanel").stop().delay(_delay).animate({height:_targetH},_time);}}
function resizeTwitterBox(h){h+=17;if(BROWSE_TYPE+BROWSE_VERSION=="MSIE7"){$("#twitter").stop().height(h-18);return;}
$("#twitter").stop().height(h);}
function onlyDisplayOneImgOnIE6(){}
function setSearchEx_ul_marginLeft(_broswer){var _totalUL;for(var i=0;i<=12;i++){if($("#Search_ex ul:last").html()==$("#Search_ex ul:eq("+i+")").html()){_totalUL=Number(1+i);}}
switch(_broswer){case"MSIE6":$("#Search_ex ul:first").css("margin-left",-12+(0.44*($("#Container").width()-20-(_totalUL*166))));break;case"MSIE7":$("#Search_ex ul:first").css("margin-left",-64+$("#Container").width()-20-(_totalUL*166));break;default:$("#Search_ex ul:first").css("margin-left",$("#Container").width()-20-(_totalUL*166)-4);break;}}
function loadGoogleMap(src){var g_html='<iframe  id="iframeID" src="'+src+'" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:330px; height:250px;"></iframe>';$("#tyaGoogleMap").html(g_html);}
var currentItemAry=new Array();function getItemsID_inside40Boxes(){var _numForNonRandom;var _outputAryLength=NUMOFBOX+1;if(PORTFOLIO_RANDOM_STATE=='not_random'){_outputAryLength=MAX_SEARCH+1;}
_numForNonRandom=0;var _currentItemAry;_currentItemAry=new Array();do{var aNum=Math.floor(Math.random()*40)+1;if(!array_exist(_currentItemAry,aNum)){if(PORTFOLIO_RANDOM_STATE=='is_random'){_currentItemAry.push(aNum);}else{_currentItemAry.push(_numForNonRandom);_numForNonRandom++;}}}while(_currentItemAry.length<_outputAryLength);return _currentItemAry;}
function drawIcons(_centreIDsAry){if(PORTFOLIO_RANDOM_STATE!="settle"){currentItemAry=getItemsID_inside40Boxes();PORTFOLIO_RANDOM_STATE="settle";}
if(DRAW_ICON){var array=[];var aRand=0;var aHtml="";var boxCount=0;array.push(aHtml);for(var i=1;i<=renderBoxesMax;i++){if(array_exist(_centreIDsAry,i)==true){aRand++;if(array_exist(currentItemAry,aRand)&&PROJECT_IMG[boxCount]!=undefined){var href=(PROJECT_ID[boxCount]!=0)?getHref(DEFAULT_MODULE,DEFAULT_PAGE,'pid='+PROJECT_ID[boxCount]+'&action=detail&mId='+MENU_PORTFOLIO,'detail',AJAX_MODE):getHref(DEFAULT_MODULE,DEFAULT_PAGE,'action=index&rid='+rand(100000),'home',AJAX_MODE);var img_path=(PROJECT_ID[boxCount]!=0)?CONTENT_IMG_DIR:CURRENT_FRONT_THEME_PATH+'images/';if(IS_IPAD==1){href=href.replace('javascript:',"");aHtml='<a id="box_'+boxCount+'" href="javascript:'+href+';"   onmouseover="'+href+'" onmouseout="'+href+'" ><div class="projIcon_hl" name="'+PROJECT_ID[boxCount]+'" style="background-image: url('+img_path+PROJECT_IMG[boxCount]+');" id="'+PROJECT_ID[boxCount]+'"  /></div></a>';array.push(aHtml);}else{aHtml='<a id="box_'+boxCount+'" href="'+href+'" ><div class="projIcon_hl" name="'+PROJECT_ID[boxCount]+'" style="background-image: url('+img_path+PROJECT_IMG[boxCount]+');" id="'+PROJECT_ID[boxCount]+'"  /></div></a>';array.push(aHtml);}
boxCount++;}else{aHtml="<div class='projIcon' ></div>";array.push(aHtml);}}else{aHtml="<div class='projIcon' ></div>";array.push(aHtml);}}}
return array;}
var currentRow;var currentCol;function checkForUpdateOnProjectIndex(){var contentLeft=$("#ContentLeft");if(contentLeft.width()==null){return false;}
var itemEachRow=Math.ceil((contentLeft.width()+1)/94);var itemEachCol=Math.ceil(contentLeft.height()/94);if(itemEachRow!=currentRow||itemEachCol!=currentCol){currentRow=itemEachRow;currentCol=itemEachCol;}else{return false;}
var limitLf=Math.floor((itemEachRow-8)/2)+1;var limitRg=limitLf+8-1;var limitUp=Math.floor((itemEachCol-5)/2)+1;var limitDn=limitUp+5-1;var centreIDsAry=new Array();for(var col=1;col<=itemEachCol+1;col++){for(var row=1;row<=itemEachRow;row++){if(limitLf<=row&&row<=limitRg){if(limitUp<=col&&col<=limitDn){centreIDsAry.push(row+((col-1)*itemEachRow));}}}}
if(centreIDsAry.length!=40){for(var k=0;k<8;k++){centreIDsAry.push((itemEachRow*4)+k+limitLf);}}
var ary=drawIcons(centreIDsAry);$("#ContentLoader").html(ary.join(''));$(".projIcon_hl").hover(iconOver,iconOut);setUpFollower();}
function iconOver(){var pId=$(this).attr("name");if(pId!=0){showFollower();ajaxRequest(AJAX_REQUEST_PATH+'action.php','action=brief&pId='+pId+'&moduleId=1',parseJSON,'Follower','POST');}
var _img_src=CURRENT_FRONT_THEME_PATH+"images/icon_over_block.gif";var _img_src_shuffle=CURRENT_FRONT_THEME_PATH+"images/btn_shuffle_r.gif";$(this).append("<a href=\""+$(this).parent().attr("href")+"\"><img class='iconAnimatedGif' src='"+CURRENT_FRONT_THEME_PATH+"images/spacer.gif' /></a>");var iconAniGif=$(".iconAnimatedGif");iconAniGif.attr('src',"");if($(this).attr("id")==0){iconAniGif.attr('src',_img_src_shuffle);}else{iconAniGif.attr('src',_img_src);}}
function iconOut(){clearFollower();$(this).html("");}
function setUpFollower(){var follower=$("#Follower");if(IS_IPAD==1||IS_MOBILE==1){follower.css("display","none");return false;}
follower.hide();$(document).mousemove(function(e){if(follower.width()==null){return;}
follower.css({top:(e.pageY+15)+"px",left:(e.pageX+15)+"px"});});}
var COMPUTER_IS_FAST=false;function checkSpeed(animateCase,delays){var _delayed=delays;switch(animateCase){case"Follower":if(_delayed>=35){COMPUTER_IS_FAST=false;}
if(_delayed<=10){COMPUTER_IS_FAST=true;}
break;case"Content_FadeIn":if(_delayed>=1200){COMPUTER_IS_FAST=false;}
if(_delayed<=950){COMPUTER_IS_FAST=true;}
break;case"Content_MoveIn":repositionAlertbox();if(_delayed>=1100){COMPUTER_IS_FAST=false;}
if(_delayed<=900){COMPUTER_IS_FAST=true;}
break;}}
function showFollower(){if(IS_IPAD==1||IS_MOBILE==1){return false;}
var follower=$("#Follower");var spTimer1_f=new Date();follower.stop().clearQueue().show();follower.html('<img src="'+CURRENT_FRONT_THEME_PATH+'images/small_loading.gif" />');follower.css({opacity:1,width:"0px",height:"0px"});follower.animate({opacity:1,width:"150px",height:"150px"},400,function(){var spTimer2_f=new Date();checkSpeed("Follower",spTimer2_f-spTimer1_f-400);});}
function clearFollower(){if(IS_IPAD==1||IS_MOBILE==1){return false;}
$("#Follower").stop().clearQueue().hide();}
function followerClick(){if(IS_IPAD==1){return false;}}
function setUpTwitterBox(){$("#twitter").getTwitter({userName:"tya_hongkong",numTweets:50,loaderText:"Loading tweets...",slideIn:true,slideDuration:600,showHeading:false,headingText:"TYA@twitter",showProfileLink:false,showTimestamp:true});}
function startLoading(){clearFollower();$("#Loading").css("display","block");}
function stopLoading(isQuick){clearFollower();if(isQuick==true){$("#Loading").css("display","none")}else{setTimeout(function(){$("#Loading").css("display","none");},100);}
setTimeout(clearFollower,800);}
function fixTopMenuHeight(_menuH,_itemTop){$("#Menu li").stop().animate({"top":_itemTop+"px"},5);$("#Menu").height(_menuH);}
function animateProjIcon(){return;for(var k=0;k<20;k++){$(".projIcon_hl:eq("+k+")").animate({opacity:0},5).delay(Math.random()*1600).animate({opacity:1},300);}
for(k=0;k<120;k++){$(".projIcon:eq("+k+")").animate({opacity:0},5).delay(Math.random()*1600).animate({opacity:0.7},300);}}
function searchMouseEvent(){$("#Search").hover(searchOver,searchOut);}
function searchOver(){$(this).css("background-color","#444");}
function searchOut(){$(this).css("background-color","#000");}
function navHighlight(mId,wrapper){if(document.getElementById(mId)==null){return;}
var m=document.getElementById(wrapper);if(m==null){return;}
var lis=m.getElementsByTagName("li");for(i=0;i<lis.length;i++){li=lis[i];var a=li.getElementsByTagName('a')[0];if(mId==a.id){li.className='highlight';}else{li.className='';}}}
function searchHighlight(mId,wrapper){var m=document.getElementById(wrapper);if(m==null){return;}
var as=m.getElementsByTagName('a');for(i=0;i<as.length;i++){var tag=as[i];if(tag!=undefined){if(mId==tag.id){tag.className='highlight';}else{tag.className='';}}}}
function setTestFunt(){testFunt();}
function testFunt(){}
function setTwitterScrollButton(){$("#BarUP").hover(barUpOver,barUpOut);$("#BarDN").hover(barDnOver,barDnOut);}
var barUpIsOver=false;var barDnIsOver=false;var barLoopT=50;var barLoopSp=11;function barUpOver(){setTimeout(barScrollUp,barLoopT);barUpIsOver=true;}
function barUpOut(){barUpIsOver=false;}
function barDnOver(){setTimeout(barScrollDown,barLoopT);barDnIsOver=true;}
function barDnOut(){barDnIsOver=false;}
function barScrollUp(){if(barUpIsOver==false)return;var _tweets=$("#twitter_update_list");var _tweetsTop=_tweets.position().top;if(_tweetsTop>-8)return;_tweets.css("top",_tweetsTop+barLoopSp+"px");setTimeout(barScrollUp,barLoopT);}
function barScrollDown(){if(barDnIsOver==false)return;var _tweets=$("#twitter_update_list");var _tweetsTop=_tweets.position().top;if(_tweetsTop<-1*(_tweets.height()-$("#twitter").height())-10)return;_tweets.css("top",_tweetsTop-barLoopSp+"px");setTimeout(barScrollDown,barLoopT);}
$(document).ready(function(){if(IS_IPAD==1){fixForIPAD();}
renderBoxesMax=getMaxBoxes();var contentPan=$("#ContentPanel");rPanelWidth=contentPan.width();$(window).resize(windowResizeActions);stopLoading(true);$("#Search_ex").height(0);resizeTwitterBox(contentPan.height()-170);setTimeout(setUpTwitterBox,250);if(BROWSE_TYPE=='Firefox'&&BROWSE_VERSION<3.3){fixTopMenuHeight(28,0);}
if(BROWSE_TYPE=='MSIE'&&Number(BROWSE_VERSION)==6){fixTopMenuHeight(28,5);}
setPagerPos();setTimeout(hidePagerQuick,50);setTimeout(setTwitterScrollButton,50);});
