/************************************************* # CodeTrend slider Developed by CodeTrend(@Kyson Lee) Date: 2014.02 *************************************************/ (function($){ // Pointing slider animation for biz introduction $.fn.pSlider = function() { var element = this; var items = $("#" + element[0].id + " div"); /** SETTING **/ var timeInterval = 150; var widthOpen = 399; var widthClose = 149; /**************/ var prevIdx = 0; items.each(function(i) { $(items[i]).mouseover(function() { if($(items[i]).index() != prevIdx) { $(items[i]).stop().css("background-position", "0px top"); $(items[prevIdx]).stop().css("background-position", "-400px top"); $(items[prevIdx]).animate({width:widthClose}, timeInterval); $(items[i]).animate({width:widthOpen}, timeInterval); prevIdx = $(items[i]).index(); } }); }); $(items[0]).click(function() { window.location.href = "./facility/fm.php?sub=01"; }); $(items[1]).click(function() { window.location.href = "./dispatch/dw.php?sub=01"; }); $(items[2]).click(function() { window.location.href = "./search/search.php?sub=01"; }); $(items[3]).click(function() { window.location.href = "./other/hrdev.php?sub=01"; }); }; // Fading slider animation for banner $.fn.mSlider = function() { var element = this; var subEls = $(".main_banner_el"); //alert(subEls.length); var currentStat = 0; var timeOutFn = null; /** SETTING **/ var timeOut = 4000; var count = 4; /**************/ var showElements = function() { $(subEls[0]).animate({opacity:1}, 1500, function() { $(subEls[1]).animate({opacity:1}, 1500, function() { $(subEls[2]).css("top", "400px"); $(subEls[2]).animate({top:216, opacity:1}, 1000, function() { timeOutFn = setTimeout(slideElChange, timeOut); }); }); }); } var showElements2 = function() { $(subEls[3]).animate({opacity:1}, 1500, function() { $(subEls[4]).css("right", "-290px"); $(subEls[5]).css("right", "-235px"); $(subEls[6]).css("right", "-522px"); $(subEls[4]).animate({right:127, opacity:1}, 1000, function() { $(subEls[5]).animate({right:127, opacity:1}, 1000, function() { $(subEls[6]).animate({right:127, opacity:1}, 1000, function() { timeOutFn = setTimeout(slideElChange, timeOut); }); }); }); }); } var hideElements = function() { subEls.each(function(i) { $(subEls[i]).animate({opacity:0}, (timeOut/6)); }); } var slideElChange = function() { hideElements(); $(element).animate({opacity:0}, (timeOut/6), function() { currentStat += 1; if(currentStat == count) currentStat = 0; $(element).stop().css("background-position", "50% " + -400*currentStat + "px"); slideEl(); }); } var slideEl = function() { $(element).animate({opacity:1}, (timeOut/6), function() { if(currentStat == 0) { showElements(); } else if(currentStat == 1) { showElements2(); } else if(currentStat == 2) { showElements(); } else { showElements2(); } //timeOutFn = setTimeout(slideElChange, timeOut); }); } slideEl(); }; })(jQuery);