/*
* Add by John Mu
*/
var ifInMenu = false; // If click menu
var ifInNavMenu = false; // If click menu
var ifInSelect = false; // If click login select
var intervalId;
/*
* Init Header
*/
jlib.initHeader = function () {
// init search box
$("#searchBox")
.focus(function(){
if($(this).val()=="Search"){
$(this).val("");
$(this).removeClass("searchIcon");
}
})
.focusout(function(){
if($(this).val()==""){
$(this).val("Search");
$(this).addClass("searchIcon")
}
})
.val("Search")
.addClass("searchIcon");
// init login select
jlib.initSelect("loginSelect","loginSelect","My AIA Login","");
$("#loginImgBtn")
.click(function(){
var url = $("#loginSelect div.selectValue").attr("val");
jlib.loadURL(url,"_blank");
});
/* Below codes are for native select
$("#loginSelect")
.change(function(){
if($('#loginSelect')[0].selectedIndex>=0){
$(this).removeClass("noSelected");
}else{
$(this).addClass("noSelected");
}
})
$("#loginSelect").addClass("noSelected");
$('#loginSelect')[0].selectedIndex = -1;
*/
/* Main Menu Control Start */
var fixFlag = false; // fix switch
$("#maindropmenu li.menuHead").each(function(){
$(this)
.click(function () {
$("#maindropmenu li ul.menuBox").hide();
$("#maindropmenu li.active").removeClass("active");
$(this).addClass("active");
$(this).children("#maindropmenu ul.menuBox").show();
fixFlag = true;
})
.mouseover(function () {
if(!$(this).hasClass("active")){
fixFlag = false;
}
$("#maindropmenu li.active").children("ul.menuBox").hide();
$("#maindropmenu li.active").removeClass("active");
$(this).addClass("active");
//if(!fixFlag){
$(this).children("ul.menuBox").show();
//}
ifInMenu = true;
})
.mouseout(function () {
if(!fixFlag){
$("#maindropmenu li.active").removeClass("active");
$(this).children("ul.menuBox").hide();
}else{
if($(this).children("ul.menuBox").css("display")=='none')
$(this).removeClass("active");
}
ifInMenu = false;
});
});
$("#maindropmenu li.menuHead>ul.menuBox").each(function(){
$(this)
.click(function () {
$(this).show();
$("#maindropmenu li.active").removeClass("active");
$(this).parent().addClass("active");
$(this).show();
fixFlag = true;
});
});
/* Main Menu Control End */
/* Nav Menu Control start */
var navFixFlag = false; // fix switch
$("#maindropmenu2 li.menuHead").each(function(){
$(this)
.click(function () {
$("#maindropmenu2 li ul.menuBox").hide();
$("#maindropmenu2 li.active").removeClass("active");
$(this).addClass("active");
$(this).children("#maindropmenu2 ul.menuBox").show();
navFixFlag = true;
})
.mouseover(function () {
if(!$(this).hasClass("active")){
navFixFlag = false;
}
$("#maindropmenu2 li.active").children("ul.menuBox").hide();
$("#maindropmenu2 li.active").removeClass("active");
$(this).addClass("active");
//if(!navFixFlag){
$(this).children("ul.menuBox").show();
//}
ifInNavMenu = true;
})
.mouseout(function () {
if(!navFixFlag){
$("#maindropmenu2 li.active").removeClass("active");
$(this).children("ul.menuBox").hide();
}else{
if($(this).children("ul.menuBox").css("display")=='none')
$(this).removeClass("active");
}
ifInNavMenu = false;
});
});
$("#maindropmenu2 li.menuHead>ul.menuBox").each(function(){
$(this)
.click(function () {
$(this).show();
$("#maindropmenu2 li.active").removeClass("active");
$(this).parent().addClass("active");
$(this).show();
navFixFlag = true;
});
});
/* Nav Menu Control End */
};
/*
* Create Video Player
*/
jlib.createVideo = function(curImg){
var playType = "flv";
var flashVars;
var playerHeight = 300;
var playerWidth = 720;
var pageWidth = 1080;
var playerLeft = (pageWidth-playerWidth)/2 + $('div.bg').offset().left;
var closePlayerLeft = playerLeft + playerWidth + 5;
var playerMovie = homeImages[curImg].movie;
if(playerMovie.toLowerCase().indexOf(".swf")>0) playType = "swf";
if(playType=="swf"){
flashVars="";
}
if(playType=="flv"){
flashVars = "mySource="+playerMovie+"&mySkin="+playBar;
if(flashVars.length>0) playerMovie = playShell + "?" + flashVars;
}
var playerHtml = "";
$("#moviePlayer").html(playerHtml);
$("#moviePlayer")
.css("left",playerLeft)
.show();
$("#closeMoviePlayer")
.css("left",closePlayerLeft)
.show();
$(window).resize(function(){
var playerLeft = (pageWidth-playerWidth)/2 + $('div.bg').offset().left;
var closePlayerLeft = playerLeft + playerWidth + 5;
$('#moviePlayer').css({
left:playerLeft
});
$('#closeMoviePlayer').css({
left:closePlayerLeft
});
});
$(window).scroll(function(){
var playerLeft = (pageWidth-playerWidth)/2 + $('div.bg').offset().left;
var closePlayerLeft = playerLeft + playerWidth + 5;
$('#moviePlayer').css({
left:playerLeft
});
$('#closeMoviePlayer').css({
left:closePlayerLeft
});
});
};
/*
* Init Homepage
*/
jlib.home = function () {
if (!$('body').hasClass('home')) {
return;
}
ifShow("Open",false);
jlib.initContentC2();
var curImg = 0,
imgCount = 0,
pageCount = 0,
PI = Math.PI,
duration = 1000,
delay = 3000,
imgs,
pages,
play_status = 'play', // 'play','stop','pause'
link_status = 'N', // 'Y','N'
curTab;
// images
// from http://www.robertpenner.com/easing/
// t - current time (from 0)
// b - start value (begin)
// c - end value - start value (change)
// d - duration
function easeInOutSine(t, b, c, d) {
return -c/2 * (Math.cos(PI * t / d) - 1) + b;
}
function fadeIn() {
$("#loading").css("visibility",'hidden');
ifShow(homeImages[curImg].show,showFlag);
var cur = imgs[curImg], start = (new Date()).getTime(), d = duration;
var curContentId = homeImages[curImg].contentId;
// load flash
if(homeImages[curImg].src_typ=='swf'){
imgs[curImg].html(getFlashHtml(homeImages[curImg].src_swf,"",475,1080));
}
cur.css({
opacity: '0',
zIndex: '1',
visibility: 'visible'
});
$("#"+curContentId).css({
opacity: '0',
zIndex: '1',
visibility: 'visible'
});
(function () {
if(play_status=='play'){
var t = (new Date()).getTime() - start;
if (t >= d) {
initPlayMovie();
initPages();
initFadeOut();
return;
}
if(imgCount>1){
$("div.pages").css("visibility",'visible');
// Init Content Device > first load : hidden
$("#contentA").css("visibility",'hidden');
}
var op = easeInOutSine(t, 0, 1, d);
cur.css('opacity', op);
$("#"+curContentId).css('opacity', op);
}
setTimeout(arguments.callee, 0);
})();
}
var instance; // singleton
function initFadeOut() {
instance = true;
var cur = imgs[curImg], next = imgs[(parseInt(curImg) + 1)%imgCount];
var curContentId = homeImages[curImg].contentId, nextContentId = homeImages[(parseInt(curImg) + 1)%imgCount].contentId;
cur.css({
visibility: 'visible',
zIndex: '1',
opacity: '1'
});
next.css({
visibility: 'visible',
zIndex: '',
opacity: '0'
});
$("#"+curContentId).css({
visibility: 'visible',
zIndex: '1',
opacity: '1'
});
$("#"+nextContentId).css({
visibility: 'visible',
zIndex: '',
opacity: '0'
});
// Init Content Device > Has content:show; No content:hidden;
if($.trim($("#"+curContentId).html()).length==0){
$("#contentA").css("visibility",'hidden');
}else{
$("#contentA").css("visibility",'visible');
}
// "fix" white dots
if ($.browser.msie) {
cur[0].style.removeAttribute('filter');
next[0].style.removeAttribute('filter');
}
link_status = "Y";
if(play_status=='play'){
delay = homeImages[curImg].src_delay*1000;
if(delay==""||delay==0) delay= 3000;
setTimeout(fadeOut, delay);
}
}
function fadeOut() {
instance = false;
link_status = "N";
var cur = imgs[curImg], start = (new Date()).getTime(), d = duration;
var curContentId = homeImages[curImg].contentId,nextContentId = homeImages[(parseInt(curImg) + 1)%imgCount].contentId;
// reload flash
if(homeImages[curImg==0?imgCount-1:curImg-1].src_typ=='swf'){
imgs[curImg==0?imgCount-1:curImg-1].html("");
}
if(homeImages[(parseInt(curImg) + 1)%imgCount].src_typ=='swf'){
imgs[(parseInt(curImg) + 1)%imgCount].html(getFlashHtml(homeImages[(parseInt(curImg) + 1)%imgCount].src_swf,"",475,1080));
}
// Init Content Device > Both current and next device have content:show; Others:hidden;
if($.trim($("#"+curContentId).html()).length==0&&$.trim($("#"+nextContentId).html()).length==0){
$("#contentA").css("visibility",'hidden');
}else if($.trim($("#"+curContentId).html()).length>0&&$.trim($("#"+nextContentId).html()).length==0){
$("#contentA").css("visibility",'hidden');
}else if($.trim($("#"+curContentId).html()).length==0&&$.trim($("#"+nextContentId).html()).length>0){
$("#contentA").css("visibility",'hidden');
}else{
$("#contentA").css("visibility",'visible');
}
(function () {
if(play_status=='play'){
var t = (new Date()).getTime() - start, nextImg;
if (t >= d) {
nextImg = (curImg + 1) % imgCount;
imgs[nextImg].css('z-index', '1');
cur.css({
visibility: 'hidden',
zIndex: '',
opacity: '1'
});
$("#"+curContentId).css({
visibility: 'hidden',
zIndex: '',
opacity: '1'
});
curImg = nextImg;
initPlayMovie();
initPages();
ifShow(homeImages[curImg].show,showFlag);
initFadeOut();
return;
}
nextImg = (curImg + 1) % imgCount;
/*
imgs[nextImg].css({
visibility: 'visible',
zIndex: '',
opacity: '1'
});
$("#"+nextContentId).css({
visibility: 'visible',
zIndex: '',
opacity: '1'
});
*/
var op = easeInOutSine(t, 1, -1, d);
var op2 = easeInOutSine(t, 0, 1, d);
cur.css('opacity', op);
imgs[nextImg].css('opacity', op2);
$("#"+curContentId).css('opacity', op);
$("#"+nextContentId).css('opacity', op2);
setTimeout(arguments.callee, 0);
}
})();
}
function initPlayMovie(){
$("#playMovie").removeClass("playMovieActive");
$("#playMovie").addClass("playMovie");
if (homeImages[curImg].movie != 'blank'&&homeImages[curImg].movie != '') {
$("#playMovie").show();
}else
{
$("#playMovie").hide();
}
}
function initPages(){
$("#pages div.highlight").attr('class','general');
$("#pageNo"+curImg).attr('class','highlight');
}
function getFlashHtml(src,vars,height,width){
var playerHeight = height;//475;
var playerWidth = width;//1080;
var flashVars = vars;
var playerMovie = src;
return "";
}
/* Feature B & C Max/Min begin*/
var showFlag = false;
var closeFlag = false;
function ifShow(show,flag){
if(flag) return;
clearInterval(intervalId);
//
if(show.toLowerCase()=="close") closeFlag=true;
if(closeFlag&&!showFlag) show="close";
var contentHeight,contentOffset;
if(show.toLowerCase()=="close"){
$("#mainContent").hide();
$("#mainContentMin").show();
intervalId = setInterval('jlib.aotuScroll("#newsMin","-15px")',3000);
contentHeight = $("#mainContentMin").css("height");
contentOffset = -75;
contentHeight = parseInt(jlib.getNumber(contentHeight,"px"))- parseInt(contentOffset)+"px";
}else if(show.toLowerCase()=="open"){
$("#mainContent").show();
$("#mainContentMin").hide();
clearInterval(intervalId);
contentOffset = 69;
contentHeight = $("#mainContent").css("height");
contentHeight = parseInt(jlib.getNumber(contentHeight,"px"))- parseInt(contentOffset)+"px";
}else{
// do nothing
clearInterval(intervalId);
contentHeight = $("#blankDIV").css("height");
}
$("#blankDIV").css("height",contentHeight);
};
/* Feature B & C Max/Min end*/
var imgNum = 0; // Image count
var imgIdx = 0; // Image index
for(o in homeImages){
if(ifSupportFlash){
if(homeImages[o].src_swf.toLowerCase().indexOf(".swf")>0){
}else{
if(homeImages[o].src_img.toLowerCase().indexOf(".jpg")>0){
imgNum++;
}
}
}else{
imgNum++;
}
}
imgs = $.map(homeImages, function (o) {
var aHtml = "";
if(ifSupportFlash){
if(o.src_swf.toLowerCase().indexOf(".swf")>0){
homeImages[imgCount].src_typ = 'swf';
}else{
if(o.src_img.toLowerCase().indexOf(".jpg")>0){
// aHtml = "
";
aHtml = $('
')
.load(function () {
imgIdx++;
if(imgIdx==imgNum&&homeImages.length>1) fadeIn();
})
.attr({
src: o.src_img,
alt: o.alt
});
homeImages[imgCount].src_typ = 'img';
}
}
}else{
//aHtml = "
";
aHtml = $('
')
.load(function () {
imgIdx++;
if(imgIdx==imgNum&&homeImages.length>1) fadeIn();
})
.attr({
src: o.src_img,
alt: o.alt
});
homeImages[imgCount].src_typ = 'img';
}
imgCount++;
return $('
')
.load(function () {
})
.css('visibility', 'hidden')
.click(function () {
if (homeImages[curImg].link != 'blank'&&homeImages[curImg].link != ''&&link_status == "Y") {
if(homeImages[curImg].target.indexOf("_self")>0){
window.location.href = homeImages[curImg].link;
}else{
window.open(homeImages[curImg].link);
}
}
})
.mouseover(function () {
if (homeImages[curImg].link != 'blank'&&homeImages[curImg].link != '') {
$(this).css('cursor','pointer');
}else
{
$(this).css('cursor','default');
}
/*
if (homeImages[curImg].movie != 'blank'&&link_status == "Y") {
$("#playMovie").css('display','block');
}else
{
$("#playMovie").css('display','none');
}
*/
})
.mouseout(function () {
if (homeImages[curImg].link != 'blank'&&homeImages[curImg].link != '') {
$(this).css('cursor','pointer');
}else
{
$(this).css('cursor','default');
}
/*
$("#playMovie").css('display','none');
*/
})
.mouseup(function () {
if (homeImages[curImg].link != 'blank'&&homeImages[curImg].link != '') {
$(this).css('cursor','pointer');
}else
{
$(this).css('cursor','default');
}
})
.append(aHtml);
});
/* paging control start */
// Init Homepage - Feature A - pages
pages = $.map(homeImages, function (o) {
pageCount++;
return $('')
.load(function () {
})
.click(function () {
var cur = imgs[curImg], next = imgs[(curImg + 1) % imgCount];
var curContentId = homeImages[curImg].contentId,nextContentId = homeImages[(parseInt(curImg) + 1)%imgCount].contentId;
cur.css({
visibility: 'hidden',
zIndex: '',
opacity: '1'
});
next.css({
visibility: 'hidden',
zIndex: '',
opacity: '1'
});
$("#"+curContentId).css({
visibility: 'hidden',
zIndex: '',
opacity: '1'
});
$("#"+nextContentId).css({
visibility: 'hidden',
zIndex: '',
opacity: '1'
});
play_status = 'stop';
$("div.highlight").attr('class','general');
$(this).attr('class','highlight');
curImg = $(this).attr('pageNo');
// load flash
if(homeImages[curImg].src_typ=='swf'){
imgs[curImg].html(getFlashHtml(homeImages[curImg].src_swf,"",475,1080));
}
// Init Content Device > Current Device has content:show; No content:hidden;
if($.trim($("#"+homeImages[curImg].contentId).html()).length==0){
$("#contentA").css("visibility",'hidden');
}else{
$("#contentA").css("visibility",'visible');
}
initPlayMovie();
ifShow(homeImages[curImg].show,showFlag);
initFadeOut();
})
.attr("id", function() { return "pageNo"+(pageCount - 1)})
.attr("pageNo", function() { return pageCount - 1})
.attr("class", function() { return pageCount - 1 == curImg?"highlight":"general"});
});
// Init Homepage - Feature A - Pre Button
$('div.pre')
.click(function () {
play_status = 'stop';
var cur = imgs[curImg], next = imgs[(parseInt(curImg) + 1) % imgCount];
var curContentId = homeImages[curImg].contentId,nextContentId = homeImages[(parseInt(curImg) + 1)%imgCount].contentId;
// load flash
if(homeImages[curImg].src_typ=='swf'){
imgs[curImg].html("");
}
if(homeImages[curImg==0?imgCount-1:curImg-1].src_typ=='swf'){
imgs[curImg==0?imgCount-1:curImg-1].html(getFlashHtml(homeImages[curImg==0?imgCount-1:curImg-1].src_swf,"",475,1080));
}
// Init Content Device > Previous Device has content:show; No content:hidden;
if($.trim($("#"+homeImages[curImg==0?imgCount-1:curImg-1].contentId).html()).length==0){
$("#contentA").css("visibility",'hidden');
}else{
$("#contentA").css("visibility",'visible');
}
cur.css({
visibility: 'hidden',
zIndex: '',
opacity: '1'
});
next.css({
visibility: 'hidden',
zIndex: '',
opacity: '1'
});
$("#"+curContentId).css({
visibility: 'hidden',
zIndex: '',
opacity: '1'
});
$("#"+nextContentId).css({
visibility: 'hidden',
zIndex: '',
opacity: '1'
});
curImg = (curImg==0?imgCount-1:curImg-1);
$("div.highlight").attr('class','general');
$("#pageNo"+curImg).attr('class','highlight');
initPlayMovie();
ifShow(homeImages[curImg].show,showFlag);
initFadeOut();
})
// Init Homepage - Feature A - Next Button
$('div.next')
.click(function () {
play_status = 'stop';
var cur = imgs[curImg], next = imgs[(parseInt(curImg) + 1) % imgCount];
var curContentId = homeImages[curImg].contentId,nextContentId = homeImages[(parseInt(curImg) + 1)%imgCount].contentId;
// load flash
if(homeImages[curImg].src_typ=='swf'){
imgs[curImg].html("");
}
if(homeImages[(parseInt(curImg) + 1) % imgCount].src_typ=='swf'){
imgs[(parseInt(curImg) + 1) % imgCount].html(getFlashHtml(homeImages[(parseInt(curImg) + 1) % imgCount].src_swf,"",475,1080));
}
// Init Content Device > Next Device has content:show; No content:hidden;
if($.trim($("#"+homeImages[(parseInt(curImg) + 1) % imgCount].contentId).html()).length==0){
$("#contentA").css("visibility",'hidden');
}else{
$("#contentA").css("visibility",'visible');
}
cur.css({
visibility: 'hidden',
zIndex: '',
opacity: '1'
});
next.css({
visibility: 'visible',
zIndex: '',
opacity: '1'
});
$("#"+curContentId).css({
visibility: 'hidden',
zIndex: '',
opacity: '1'
});
$("#"+nextContentId).css({
visibility: 'visible',
zIndex: '',
opacity: '1'
});
curImg = ((parseInt(curImg) + 1) % imgCount);
$("div.highlight").attr('class','general');
$("#pageNo"+curImg).attr('class','highlight');
initPlayMovie();
ifShow(homeImages[curImg].show,showFlag);
initFadeOut();
})
/* paging control end */
if (homeImages.length>1){
$('div.fadeimgs').append($.map(imgs, function (o) { return o[0]; }));
$('#pages').append($.map(pages, function (o) { return o[0]; }));
//fadeIn();
}else{
var aHtml = "";
if(ifSupportFlash){
if(homeImages[0].src_swf.toLowerCase().indexOf(".swf")>0){
aHtml = getFlashHtml(homeImages[0].src_swf,"",475,1080);
homeImages[0].src_typ = 'swf';
}else{
if(homeImages[0].src_img.toLowerCase().indexOf(".jpg")>0){
aHtml = "
";
homeImages[0].src_typ = 'img';
}
}
}else{
aHtml = "
";
homeImages[0].src_typ = 'img';
}
$('div.fadeimgs').append($('')
.css({opacity: '1',
zIndex: '1',
visibility: 'visible'
})
.load(function () {
})
.click(function () {
if (homeImages[0].link != 'blank'&&homeImages[0].link != '') {
if(homeImages[curImg].target.indexOf("_self")>0){
window.location.href = homeImages[curImg].link;
}else{
window.open(homeImages[curImg].link);
}
}
})
.mouseover(function () {
if (homeImages[0].link != 'blank'&&homeImages[0].link != '') {
$(this).css('cursor','pointer');
}else
{
$(this).css('cursor','default');
}
})
.mouseup(function () {
if (homeImages[0].link != 'blank'&&homeImages[0].link != '') {
$(this).css('cursor','pointer');
}else
{
$(this).css('cursor','default');
}
})
.append(aHtml));
$('div.pages')
.css({opacity: '1',
zIndex: '1',
visibility: 'hidden'
});
$("#"+homeImages[0].contentId).css({
visibility: 'visible',
zIndex: '1',
opacity: '1'
});
$("#loading").css("visibility",'hidden');
}
//========== Feature A Play Movie Start ==========//
//Close Movie Player
$('#closeMoviePlayer')
.click(function () {
$("#moviePlayer").html("");
$("#moviePlayer").hide();
$(this).hide();
jlib.hideMask();
});
// Init play button
$('#playMovie')
.click(function () {
jlib.createVideo(curImg);
jlib.createMask();
jlib.showMask();
play_status='stop';
})
.mouseover(function () {
$("#playMovie").removeClass("playMovie");
$("#playMovie").addClass("playMovieActive");
if(play_status=='play'){
play_status = 'pause';
}
})
.mouseout(function () {
$("#playMovie").removeClass("playMovieActive");
$("#playMovie").addClass("playMovie");
if(play_status!='stop'){
play_status='play';
if(!instance){
initFadeOut();
}
$("div.highlight").attr('class','general');
$("#pageNo"+curImg).attr('class','highlight');
}
});
//========== Feature A End Start ==========//
//========== Feature A Content Device Start ==========//
$('#contentA')
.click(function () {
play_status = 'stop';
if(link_status == "N") return false;
})
.mouseover(function () {
if(!instance&&homeImages.length>1){
initFadeOut();
}
$("div.highlight").attr('class','general');
$("#pageNo"+curImg).attr('class','highlight');
if(play_status=='play'){
play_status = 'pause';
}
})
.mouseout(function () {
if(play_status!='stop'){
play_status = 'play';
if(!instance&&homeImages.length>1){
initFadeOut();
}
$("div.highlight").attr('class','general');
$("#pageNo"+curImg).attr('class','highlight');
}
});
//========== Feature A Content Device Start ==========//
//========== Feature Min/Max Start ==========//
$("div.contentMin")
.click(function(){
homeImages[curImg].show = 'Close';
showFlag = true;
ifShow("Close",false);
})
.mouseover(function () {
$(this).removeClass("contentMin");
$(this).addClass("contentMinHighlight");
})
.mouseout(function () {
$(this).removeClass("contentMinHighlight");
$(this).addClass("contentMin");
});
$("div.contentMax")
.click(function(){
homeImages[curImg].show = 'Open';
showFlag = true;
ifShow("Open",false);
})
.mouseover(function () {
$(this).removeClass("contentMax");
$(this).addClass("contentMaxHighlight");
})
.mouseout(function () {
$(this).removeClass("contentMaxHighlight");
$(this).addClass("contentMax");
});
//========== Feature Min/Max End ==========//
//========== Feature B1 Start ==========//
/* Featrue B auto height begin*/
function autoHeight(){
var height = 290;
var heightBL = jlib.getNumber($("#contentBL").css("height"),"px");
var heightBC = jlib.getNumber($("#contentBC").css("height"),"px");
var heightBR = jlib.getNumber($("#contentBR").css("height"),"px");
if(height0){
scroll_offset = $("#li1").attr("offsetTop");
scroll_offset1 = $("#li1").attr("offsetTop");
}
$.extend({
// scroll up
scollU:function(){
scroll_offset = scroll_offset + scroll_speed;
if(scroll_offsetscroll_space-scroll_offset1){
$("#newsList").scrollTop(scroll_offset);
scollId = setTimeout("$.scollD()",scroll_delay);
}else{
$("#newsList").scrollTop(scroll_space-scroll_offset1);
clearTimeout(scollId);
}
},
// scroll bar
scollBar:function(){
if(scroll_page<=1) return;
var first,last;
if(scroll_no!=1&&scroll_no==scroll_page){
last = scroll_len;
first = last-scroll_size+1;
}else{
last = ((scroll_no-1)*scroll_count+scroll_size)>scroll_len?scroll_len:((scroll_no-1)*scroll_count+scroll_size);
first = (scroll_no-1)*scroll_count+1;
}
$("#num").html(""+first+" - "+last+" of "+scroll_len+"
");
if(scroll_no==1){
$("#downbtn").attr("disabled","disabled");
$("#downbtn").removeClass("downbtnActive");
$("#downbtn").addClass("downbtn");
}else{
$("#downbtn").removeAttr("disabled");
$("#downbtn").removeClass("downbtn");
$("#downbtn").addClass("downbtnActive");
}
if(scroll_no==scroll_page){
$("#upbtn").attr("disabled","disabled");
$("#upbtn").removeClass("upbtnActive");
$("#upbtn").addClass("upbtn");
}else{
$("#upbtn").removeAttr("disabled");
$("#upbtn").removeClass("upbtn");
$("#upbtn").addClass("upbtnActive");
}
}
});
// init up button
$("#upbtn")
.click(function(){
if(scroll_no>=scroll_page) return;
scroll_no++;
scroll_space = $("#li"+((scroll_no-1)*scroll_count+1)).attr("offsetTop");
setTimeout("$.scollU()",scroll_delay);
$.scollBar();
});
// init down button
$("#downbtn")
.click(function(){
if(scroll_no<=1) return;
scroll_no--;
scroll_space = $("#li"+((scroll_no-1)*scroll_count+1)).attr("offsetTop");
setTimeout("$.scollD()",scroll_delay);
$.scollBar();
});
// init scroll bar
$.scollBar();
/* scroll control end */
//========== Feature B1 End ==========//
$("#newsMin")
.click(function(){
})
.mouseover(function () {
clearInterval(intervalId);
})
.mouseout(function () {
intervalId = setInterval('jlib.aotuScroll("#newsMin","-15px")',3000);
});
};
/*
* Init login select
*/
jlib.initSelect = function(s1,s2,defaultText,defaultValue){
var ifShow = false;
var value,text;
$("#"+s2)
.click(function(){
ifShow = !ifShow;
if(ifShow||$("#"+s2+" ul li.active").hasClass("group")){
$(this).children("div.selectList").css("visibility","visible");
}else{
$(this).children("div.selectList").css("visibility","hidden");
}
})
.mouseover(function(){
ifInSelect = false;
})
.mouseout(function(){
ifInSelect = true;
});
if($("#"+s2+" div.selectValue").children().is("nobr")){
value = $.trim($("#"+s2+" div.selectValue").attr("val"));
text = $.trim($("#"+s2+" div.selectValue").children("nobr").text());
$("#"+s2+" div.selectValue").addClass("default");
}else{
value = $.trim($("#"+s2+" ul li:first").attr("val"));
text = $.trim($("#"+s2+" ul li:first").text());
$("#"+s2+" div.selectValue").html("");
}
$("#"+s2+" div.selectValue")
.attr("val",value==""?defaultValue:value);
$("#"+s2+" div.selectValue")
.children("nobr").text(text==""?defaultText:text);
$("#"+s2+" ul li").each(function(){
$(this)
.click(function () {
if($(this).hasClass("group")){
return;
}
$("#"+s2+" div.selectValue").removeClass("default");
$("#"+s2+" div.selectValue").attr("val",$(this).attr("val"));
$("#"+s2+" div.selectValue nobr").text($(this).text());
})
.mouseover(function () {
if(!$(this).hasClass("group")){
$("#"+s2+" ul li.active").removeClass("active");
$(this).addClass("active");
}
})
.mouseout(function () {
});
});
};
/*
* Auto height 4 Common Tab
*/
function autoHeight4Tab(tabId,height){
var $tabContents = $("#"+tabId+" .tabBoxTabMain div.contentTab");
var len = $tabContents.length;
var h;
for(var i=0;i0) $($tabs.get(i)).children("div.left").addClass("hasPre");
}
// init tab content
$($tabs.get(0)).children("div.center").addClass("first");
var fisrtWidth = jlib.getNumber($($tabs.get(0)).children("div.center").css("width"),"px");
if(fisrtWidth>250) $($tabs.get(0)).children("div.center").addClass("textWrap"); // for text wrap
$($tabContents).css('visibility', 'hidden');
$($tabContents.get(0)).css('visibility', 'visible');
$tabs
.click(function(){
var index = $tabs.index($(this));
// clear active tab
$tabs.removeClass("active");
$tabs.children("div.right").removeClass("hasActiveNext");
$tabs.children("div.center").children("h2").children("a").removeClass("active");
$tabContents.css('visibility', 'hidden');
// init active tab
$(this).addClass("active");
if(index!=0) $($tabs.get(index-1)).children("div.right").addClass("hasActiveNext");
$(this).children("div.center").children("h2").children("a").addClass("active");
$($tabContents.get(index)).css('visibility', 'visible');
});
autoHeight4Tab(tabId,100);
};
jlib.faqList = function (tabId,height) {
var askIdSelect = "";
$("div.questions").each(function(){
$(this)
.click(function () {
var displayStatus = $("#"+$(this).attr("id")+"question").css("display");
if(displayStatus == "none"){
if(askIdSelect!=""){
$("#"+askIdSelect+"display").html("[+]");
$("#"+askIdSelect+"title").removeClass("active");
$("#"+askIdSelect+"question").hide();
}
askIdSelect = $(this).attr("id");
$("#"+askIdSelect+"display").html("[-]");
$("#"+askIdSelect+"title").addClass("active");
$("#"+askIdSelect+"question").show();
}else{
$("#"+askIdSelect+"display").html("[+]");
$("#"+askIdSelect+"title").removeClass("active");
$("#"+$(this).attr("id")+"question").hide();
}
autoHeight4Tab(tabId,height);
});
});
};
/*
* Your Needs
*/
jlib.yourNeeds = function () {
var tabMaxSize = 5;
var fixTab = false;
var $tabHead = $("ul.tab>li");
var $tabHidden = $("div.tabHidden");
var $tabContent = $("div.steps");
//var $step1cols = $("div.step1cols");
var $step1,$step2,$step3,$step1box,$step2box,$step3box;
var $tabCoverStick = $("div.coverStick");
var activeIdx = 0;
var nextIdx = -1;
var $nextStep;
var tabSize = $tabHead.length;
// init tooltip : 1 tab hide, more than 1 tab align center
if(tabSize<=1) $("div.toolTip").hide();
if(tabSize>1){
if(tabSize>tabMaxSize) tabSize = tabMaxSize;
var tabHeadWidth = 154;
var tabHeadMargin = 8;
var toolTipWidth = 332;
var offsetLeft = 9;
var toolTipMarginLeft = (tabHeadWidth*tabSize+tabHeadMargin*(tabSize-1)-toolTipWidth)/2+offsetLeft;
toolTipWidth += "px";
$("div.toolTip").css("margin-left",toolTipMarginLeft);
}
// Init step items & step1 height
var minHeight = 194+8*2+30;
for(var s1=0;s1<$tabContent.length;s1++){
$step1 = $($tabContent.get(s1)).children("div.step1");
$step2 = $($tabContent.get(s1)).children("div.step2");
for(var s2=0;s2<$step2.length;s2++){
$step1.children("div.step1box").children("div.boxMiddle").children("div.col1").children("ul").append($("#li_"+$($step2.get(s2)).attr("id")));
$nextStep = $($step2.get(s2)).next();
while($nextStep.hasClass("step3")){
$($step2.get(s2)).children("div.step2box").children("div.boxMiddle").children("div.col1").children("ul").append($("#li_"+$nextStep.attr("id")));
$nextStep = $nextStep.next();
}
}
//$step1.children("div.step1box").children("div.boxMiddle").append($($step1cols.get(s1)).html());
// Init step1 height
$step1box = $step1.children("div.step1box");
$step1box.children("div.boxHeader").children("div.col1").append($($tabHidden.get(s1)).children("div.step1Col1Title").children());
$step1box.children("div.boxHeader").children("div.col2").append($($tabHidden.get(s1)).children("div.step1Col2Title").children());
$step1box.children("div.boxHeader").children("div.col3").append($($tabHidden.get(s1)).children("div.step1Col3Title").children());
$step1box.children("div.boxMiddle").children("div.col2").append($($tabHidden.get(s1)).children("div.step1Col2Text").children());
$step1box.children("div.boxMiddle").children("div.col3").append($($tabHidden.get(s1)).children("div.step1Col3Text").children());
$step2box = $($tabContent.get(s1)).find("div.step2box");
$step2box.children("div.boxHeader").children("div.col1").append($($tabHidden.get(s1)).children("div.step2Col1Title").children());
$step3box = $($tabContent.get(s1)).find("div.step3box");
$step3box.children("div.boxHeader").children("div.col1").append($($tabHidden.get(s1)).children("div.step3Col1Title").children());
$($tabHidden.get(s1)).remove();
var minMidHeight = minHeight - jlib.getNumber($step1box.children("div.boxHeader").css("height"),"px") - jlib.getNumber($step1box.children("div.boxBottom").css("height"),"px");
var midHeight = jlib.getNumber($step1box.children("div.boxMiddle").css("height"),"px")
if(minMidHeight0&&index<$tabHead.length-1) $($tabCoverStick.get(index)).addClass("coverStickActivedMiddle");
if(index>0&&index==$tabHead.length-1&&$tabHead.length0&&index<$tabHead.length-1) $($tabCoverStick.get(index)).addClass("coverStickActivedMiddle");
if(index>0&&index==$tabHead.length-1&&$tabHead.length1) $("div.toolTip").show();
}
});
// Open step2
$("div.step1 .step1box div.col1 ul li").each(function(){
$(this)
.click(function () {
var index = $(this).parents("ul").children("li").index($(this));
// Update Step1
$(this).parents(".step1box").children("div.boxBottom").addClass("arrowDown");
$(this).parents("ul").children("li").removeClass("active");
$(this).addClass("active");
// Hide Old Step2 & Step3
$(this).parents(".steps").children(".step2").children(".step2box").children("div.boxHeader").removeClass("arrowRight");
$(this).parents(".steps").children(".step2").children(".step2box").children("div.boxMiddle").children("div.col1").children("ul").children("li").removeClass("active");
$(this).parents(".steps").children(".step2").hide();
$(this).parents(".steps").children(".step3").hide();
// Show New Step2
var id = $(this).attr("id");
var $step2 = $("#"+id.replace("li_",""));
$step2.show();
// Aoto Step2 Height
var minHeight = 161+8*2;
var minMidHeight = minHeight - jlib.getNumber($step2.children("div.step2box").children("div.boxHeader").css("height"),"px") - jlib.getNumber($step2.children("div.step2box").children("div.boxBottom").css("height"),"px");
var midHeight = jlib.getNumber($step2.children("div.step2box").children("div.boxMiddle").css("height"),"px");
if(minMidHeightgridH+gridOT){
backTop = gridH+gridOT;
}else{
backTop = document.documentElement.scrollTop+document.body.scrollTop+document.documentElement.clientHeight-50;
}
backLeft = gridW + gridOL + 5;
var backToTop = $('#_backToTop_')
.css({
zIndex: 9,
position: 'absolute',
top:backTop,
left:backLeft
})
.appendTo('body');
$(window).resize(function(){
if(document.documentElement.scrollTop+document.body.scrollTop+document.documentElement.clientHeight-50>gridH+gridOT){
backTop = gridH+gridOT;
}else{
backTop = document.documentElement.scrollTop+document.body.scrollTop+document.documentElement.clientHeight-50;
}
$('#_backToTop_').css({
top:backTop,
left:backLeft
});
});
$(window).scroll(function(){
if(document.documentElement.scrollTop+document.body.scrollTop+document.documentElement.clientHeight-50>gridH+gridOT){
backTop = gridH+gridOT;
}else{
backTop = document.documentElement.scrollTop+document.body.scrollTop+document.documentElement.clientHeight-50;
}
$('#_backToTop_').css({
top:backTop,
left:backLeft
});
});
};
/*
* Homepage - Init Content C2
*/
jlib.initContentC2 = function(){
var $imgDiv = $("div.contentC2 div.imagediv");
var count = 0;
$imgDiv.each(function(){
if($(this).children("img").length==0){
$(this).css("background","none");
count++;
}
});
if(count==$imgDiv.length) $("div.contentC2").hide();
};
/*
* Remove Division
*/
jlib.removeDivision = function(){
var $gridBoxRow = $("div.gridBoxMainContent div.gridBoxRow");
$gridBoxRow.each(function(){
if($(this).children().length==0){
$(this).prev().hide();
$(this).hide();
}
});
};
/*
*
*/
jlib.attachToThePreviousImg = function(){
var $attachToThePreviousImg = $("a.attachToThePreviousImg");
$attachToThePreviousImg.each(function(){
$(this).append($(this).prev());
});
};
/*
*
*/
jlib.autoSetFirstAndLastCSSClass = function(){
$("ul.autoSetFirstAndLastCSSClass li:first-child").addClass("first");
$("ul.autoSetFirstAndLastCSSClass li:last-child").addClass("last");
};
/*
*
*/
jlib.getLocalName = function (key) {
var localNames = [{key:'PrintName', en:'Print Page', zh_hk:'列印本頁', kr:'Print Page kr', id:'Cetak halaman ini', th:'พิมพ์หน้านี้', vn:'In trang nà', zh_tw:'列印本頁'}];
var localName = '';
var lang = jlib.getLang();
lang = lang.replace("-","_");
for(var i=0; i=1080) {
$("div.bg").css({ paddingLeft:38,paddingRight:38});
}
if ($('body').hasClass('version2_0')) {
$("div.header").css({ marginLeft:0,paddingLeft:0});
$("div.fp").css({ paddingLeft:0,paddingRight:0});
if(window.screen.width>=1080){
$("div.bg").width(1004).css({ paddingLeft:38,paddingRight:38});
}else{
$("div.bg").width(1004).css({ paddingLeft:0,paddingRight:0});
}
}else{
jlib.home();
}
jlib.initHeader();
jlib.attachToThePreviousImg();
jlib.autoSetFirstAndLastCSSClass();
body = null;
});