$(function () { function getObjID(string, str) { //console.log(string + "+" + str) if (string.indexOf(str) >= 0) { var str_before = string.split(str)[0]; var str_after = "#" + string.split(str)[1]; } else { var str_after = "#fristConts"; } return str_after; } function dectPO(i,pcTop,mobTop) { changPO_obj.each(function (index, element) { if (index === changPO_obj.length) { if ($(window).width() > 769) { var p = $($(this).attr("href")).offset().top - pcTop; } else { var p = $($(this).attr("href")).offset().top - mobTop; } if (i > p) { changPO_obj.removeClass("active"); $(this).addClass("active"); } } else { var p1obj = getObjID(changPO_obj.eq(index).attr("href"), "#"); //var p2obj = getObjID($(".NavList_a1 a").eq(index+1).attr("href"),"#"); if ($(window).width() > 769) { var p1 = $(p1obj).offset().top - pcTop; } else { var p1 = $(p1obj).offset().top - mobTop; } //console.log(p1); //var p2 = $(p2obj).offset().top; if (i > p1) { changPO_obj.removeClass("active"); $(this).addClass("active"); } } }); } if ($("#fristConts").length > 0) { var pcTop = 160; var mobTop = 0; var changPO_obj = $(".NavList_a1 a"); var outSideWrap = $(".c_portalResIntro_category-01001009"); var fixedObj = $(".NavList_a1"); $(".NavList_a1").css({ 'top': outSideWrap.offset().top }) $(window).scroll(function () { var setW = outSideWrap.width(); //var setW2 = $(".c_portalResIntro_category-01001009").width(); if ($(window).scrollTop() > (outSideWrap.offset().top - 0)) { if ($(window).width() > 769) { fixedObj.css({ 'position': 'fixed', 'top': 100, 'width': setW }) } else { fixedObj.css({ 'position': 'fixed', 'top': '80px' }) } fixedObj.addClass("fixed"); fixedObj.parents().css({ "animation": "none" }) } else { if ($(window).width() > 769) { fixedObj.css({ 'position': 'relative', 'top': 0 }) } else { fixedObj.css({ 'position': 'relative', 'top': 0 }) } fixedObj.removeClass("fixed"); } /* if($(window).scrollTop()>($(".c_portalResIntro_category-01001009").offset().top)){ $("#c_portalResProduct_relatedlist-16137275184472450").css({'position':'fixed','top':80, 'width':setW2, 'z-index':10}) }else{ $("#c_portalResProduct_relatedlist-16137275184472450").css({'position':'relative','top':0}) }*/ dectPO($(window).scrollTop(),pcTop,mobTop); }) $(changPO_obj).each(function (index, element) { var pos = getObjID($(this).attr("href"), "#"); $(this).click(function () { event.preventDefault(); if ($(window).width() > 769) { $("html,body").animate({ "scrollTop": $(pos).offset().top - 150 }) } else { $("html,body").animate({ "scrollTop": $(pos).offset().top - 20 }) } }) }); } var otherFixed = "#w_grid-1649153522293,#w_grid-1649149265815,#w_grid-1649322793726,#w_grid-1650418646822,#w_grid-1649143438646,#w_grid-1649152085297,#w_grid-1649153057702,#w_grid-1649150056706,#w_grid-1649150659527,#w_grid-1649150936447,#w_grid-1649151225245,#w_grid-1649151493104"; if($(otherFixed).length > 0){ $(window).scroll(function () { var Oparent = $(otherFixed).parent(); var setW = Oparent.width(); //var setW2 = $(".c_portalResIntro_category-01001009").width(); if ($(window).scrollTop() > (Oparent.offset().top - 100)) { if ($(window).width() > 769) { $(otherFixed).css({ 'position': 'fixed', 'top': 100, 'width': setW ,'z-index':8}) } else { $(otherFixed).css({ 'position': 'fixed', 'top': '80px','z-index':8 }) } $(otherFixed).addClass("fixed"); $(otherFixed).parents().css({ "animation": "none" }) } else { if ($(window).width() > 769) { $(otherFixed).css({ 'position': 'relative', 'top': 0 }) } else { $(otherFixed).css({ 'position': 'relative', 'top': 0 }) } $(otherFixed).removeClass("fixed"); } /* if($(window).scrollTop()>($(".c_portalResIntro_category-01001009").offset().top)){ $("#c_portalResProduct_relatedlist-16137275184472450").css({'position':'fixed','top':80, 'width':setW2, 'z-index':10}) }else{ $("#c_portalResProduct_relatedlist-16137275184472450").css({'position':'relative','top':0}) }*/ //dectPO($(window).scrollTop()); }) } });