External Jquery script not working in Joomla template. Below I pasted script for reference. Any help greatly appreciated
function ShowLayer() {
var layer = $(this).attr("layer-id");
if (!$("#" + layer).is(":visible")) {
var zindex = $("#" + layer).css("z-index");
$("#" + layer).removeClass("zIndex");
$("#" + layer).css("z-index", zindex + 1);
//$("#" + layer).slideIn();
SlideIn($("#" + layer));
}
}
function SlideIn(current) {
var scope = $('.outer');
current.css("left", $(scope).width());
current.show();
current.animate({ left: 0 }, 700, "linear", function () {
});
}
function SlideOut(current) {
var scope = $('.outer');
current.animate({ left: $(scope).width() }, 700, "linear", function () {
current.css("z-index", "")
current.addClass("zIndex");
current.hide();
});
}
function CloseLayer() {
var layer = $(this).attr("layer-id");
SlideOut($("#" + layer));
}
$(document).ready(function () {
$('.show-layer').click(ShowLayer);
$('.close-layer').click(CloseLayer);
$('.scrollerview').css("opacity", "0");
$(window).scroll(function () {
$('.scrollerview').each(function (i) {
var factor = -250;
if ($(this).hasClass("PckHdOtr")) {
factor = 250;
}
var bottom_of_object = $(this).offset().top + $(this).outerHeight();
var bottom_of_window = $(window).scrollTop() + $(window).height() - factor;
if (bottom_of_window > bottom_of_object) {
$(this).animate({ 'opacity': '1' }, 900);
if ($(this).hasClass("PckHdOtr")) {
$('.outer').animate({ 'opacity': '1' }, 900);
}
}
});
});
});
</head>
. Please also look at @fruppel's answer