/* * Author: tenten Creative | ten2.tw */ // Speed of the automatic slideshow var slideshowSpeed = 7000; // Variable to store the images we need to set as background // which also includes some text and url's. var photos = [ { "title" : "New identity puts ADATA brand back on top.", "image" : "assets/images/home/1920x1030_adata.jpg", "url" : "works/adata", "firstline" : "嶄新的識別設計,幫助ADATA重登領導行列。", "pos" : "left" }, { "title" : "GKB’s strategic repositioning leads to immediate growth in its branded business. ", "image" : "assets/images/1920x1030_GKB-2.png", "url" : "works/gkb", "firstline" : "重新定位的GKB成功轉型,憑藉品牌事業締造大幅成長,邁向更大利基。", "pos" : "left" }, { "title" : "Ozaki rebrand triples sales!", "image" : "assets/images/home/1920x1030_Ozaki-3.jpg", "url" : "works/ozaki", "firstline" : "品牌再造 OZAKI 銷售成長300%!", "pos" : "left" }, { "title" : "Renewed corporate communications voice eMemory’s leading position.", "image" : "assets/images/home/homepage_ememory.jpg", "url" : "works/ememory", "firstline" : "力旺電子創新企業識別與溝通,穩站國際領導地位。", "pos" : "left" }, { "title" : "New communication strategy creates a globally competitive brand for Nova Design.", "image" : "assets/images/homepage_bg/1920x1030_Nova-Design_4.jpg", "url" : "works/novadesign", "firstline" : "品牌溝通策略之再造 為浩漢設計創造出更強大的國際競爭力", "pos" : "right" } ]; $(document).ready(function() { var interval; var activeContainer = 1; var currentImg = 0; var animating = false; var navigate = function(direction) { // Check if no animation is running. If it is, prevent the action if(animating) { return; } // Check which current image we need to show if(direction == "next") { currentImg++; if(currentImg >= photos.length + 1) { currentImg = 1; } } else { currentImg--; if(currentImg <= 0) { currentImg = photos.length; } } $('.trail-text').removeClass('ammon-rocks').eq(currentImg-1).addClass('ammon-rocks'); // Check which container we need to use var currentContainer = activeContainer; if(activeContainer == 1) { activeContainer = 2; } else { activeContainer = 1; } showImage(photos[currentImg - 1], currentContainer, activeContainer); }; var currentZindex = -1; // ********* showImage var showImage = function(photoObject, currentContainer, activeContainer) { animating = true; // Make sure the new container is always on the background currentZindex--; // Set the background image of the new active container $("#headerimg" + activeContainer).css({ "background-image" : "url(" + photoObject.image + ")", "display" : "block", "z-index" : currentZindex }); // Hide the header text $("#headertxt").css({"display" : "none"}); $("#headertxt").removeClass("left right").addClass(photoObject.pos); // Set the new header text $("#firstline").html(photoObject.title); $("#pictureduri").attr("href", photoObject.url); $("#pictureduri2").attr("href", photoObject.url); $("#secondline").html(photoObject.firstline); // Fade out the current container // and display the header text when animation is complete $("#headerimg" + currentContainer).fadeOut(function() { setTimeout(function() { $("#headertxt").css({"display" : "block"}); animating = false; }, 100); }); }; var stopAnimation = function() { // Clear the interval clearInterval(interval); }; // We should statically set the first image navigate("next"); // Start playing the animation interval = setInterval(function() { navigate("next"); }, slideshowSpeed); // Hover Effect (Ammons' Code) var li = $('.btn-work').hover(function(){ stopAnimation(); $('#headerimg1,#headerimg2').stop().each(function(){clearTimeout($(this).data('timeout'));}) .css('opacity',1).hide(); animating = false; currentImg = li.index(this); $('.trail-text').removeClass('ammon-rocks').eq(currentImg).addClass('ammon-rocks'); var photoObject = photos[currentImg++]; $("#headertxt").removeClass("left right").addClass(photoObject.pos); $("#firstline").html(photoObject.title); $("#pictureduri").attr("href", photoObject.url); $("#pictureduri2").attr("href", photoObject.url); $("#secondline").html(photoObject.firstline); $('#headerimg'+activeContainer).css({ "background-image" : "url(" + photoObject.image + ")" }).fadeIn(); },function(){ clearInterval(interval); interval = setInterval(function() { navigate("next"); }, slideshowSpeed); }); //Home Thinkg Before you Brand LightBox $('.think-brand-btn').click(function(){ $('#grayShade3').hide(); $('#think-brand').hide(); $('#header').css('position','fixed'); }); // Sub Menu On Hover Over function megaHoverOver3(){ $("#grayShade4").stop().fadeTo('fast', 1).show(); $('#think-brand').fadeTo('slow', 1).show(); $('.think-brand-btn, .brand-text a').hide(); $('#headertxt').hide(); stopAnimation(); } //On Hover Out function megaHoverOut3(){ $("#think-brand").stop().fadeTo('fast', 0, function() { //Fade to 0 opactiy $('#grayShade4, #think-brand').hide(); $('#headertxt').show(); navigate("next"); interval = setInterval(function() { navigate("next"); }, slideshowSpeed); }); } var config3 = { sensitivity: 7, // number = sensitivity threshold (must be 1 or higher) interval: 100, // number = milliseconds for onMouseOver polling interval over: megaHoverOver3, // function = onMouseOver callback (REQUIRED) timeout: 30, // number = milliseconds delay before onMouseOut out: megaHoverOut3 // function = onMouseOut callback (REQUIRED) }; $("#home-btn").hoverIntent(config3); });//End of Document Ready $(document).ready(function(){ if (!$.cookie('welcome')){ var d = new Date(new Date().getTime()+1000*60*600) $.cookie('welcome','true',{path:'/',expires: d}); $('#header').css('position','absolute'); $('#grayShade3').show(); $('#think-brand').show(); } });