$(function(){ $(".h").hover(function(){ $(this).addclass("hover") }, function(){ $(this).removeclass("hover") }) }) function hover(obj, classname) { obj.hover(function(){ $(this).addclass(classname) }, function(){ $(this).removeclass(classname) }) } function tab(tabbtn, tabbox) { var tabbl = true; tabbtn.eq(0).addclass("cur") tabbox.eq(0).show() tabbtn.click(function(){ var n = $(this).index(); $(this).addclass("cur").siblings().removeclass("cur") if(tabbox.attr("data-effect") == "true"){ if(!tabbl){ return } tabbl = false; tabbox.eq(n).stop().fadein(800).siblings().stop().fadeout(800, function(){ tabbl = true; }) }else{ tabbox.eq(n).show().siblings().hide() } }) } function fullbg(box, obj){ box.css("background", "none") obj.eq(0).stop().fadein(1000) function resizebg() { obj.removeclass("w-f").removeclass("h-f").css("margin", 0) var boxr = box.outerwidth() / box.outerheight(), objr = obj.width() / obj.height(); if( objr < boxr ) { obj.addclass('w-f').css("margin-top", -(obj.height() - box.outerheight()) / 2); }else{ obj.addclass('h-f').css("margin-left", -(obj.width() - box.outerwidth()) / 2); } } $(window).resize(resizebg).trigger("resize"); } function videofull(obj, width, height){ var $video = obj function resizebg() { $video.attr("width", "").attr("height", "").attr("style", "") var boxr = $('.top-video').outerwidth() / $('.top-video').outerheight(), objr = width / height; if( objr < boxr ) { $video.attr("width", "100%") var videoheight = $video.width() / objr var top = - (videoheight - $('.top-video').outerheight()) / 2 > 0 ? 0 : - (videoheight - $('.top-video').outerheight()) / 2 $video.css("margin-top", top); }else{ $video.attr("height", "100%") var videowidth = $video.height() * objr var left = - (videowidth - $('.top-video').outerwidth()) / 2 > 0 ? 0 : - (videowidth - $('.top-video').outerwidth()) / 2 $video.css("margin-left", left); } } $(window).resize(resizebg).trigger("resize"); } function enter(obj, direction, distance, number, time, delay, callback) { if(direction == "left"){ obj.stop().animate({ left : distance, opacity : 1 }, time) settimeout(function(){ if(obj.next().index() != -1){ enter(obj.next(), direction, distance, number, time, delay, callback) }else{ settimeout(function(){ callback = callback || function(){}; callback (); return }, time - delay) } }, delay) } if(direction == "top"){ obj.stop().animate({ top : distance, opacity : 1 }, time) settimeout(function(){ if(obj.next().index() != -1){ enter(obj.next(), direction, distance, number, time, delay, callback) }else{ settimeout(function(){ callback = callback || function(){}; callback (); return }, time - delay) } }, delay) } if(direction == "x"){ obj.stop().transition({ x : distance, opacity : 1 }, time) settimeout(function(){ if(obj.next().index() != -1){ enter(obj.next(), direction, distance, number, time, delay, callback) }else{ settimeout(function(){ callback = callback || function(){}; callback (); return }, time - delay) } }, delay) } if(direction == "y"){ obj.stop().transition({ y : distance, opacity : 1 }, time) settimeout(function(){ if(obj.next().index() != -1){ enter(obj.next(), direction, distance, number, time, delay, callback) }else{ settimeout(function(){ callback = callback || function(){}; callback (); return }, time - delay) } }, delay) } } function _preloadimg(b,e){var c=0,a={},d=0;for(src in b){d++}for(src in b){a[src]=new image();a[src].onload=function(){if(++c>=d){e(a)}};a[src].src=b[src]}};