var $ = jQuery; $(function () { if (!$('body.staging').length!=0 && !showCurtains()) { $(window).resize(showCurtains); } }); function curtainLength() { var curtainBottom = $('.curtain').offset().top + $('.curtain').height(); var gap = $('#footer').offset().top + 20 - curtainBottom; var fullHeight = 768; /*console.log("curtainBottom:"+curtainBottom+" gap:"+gap+" footer:"+$('#footer').offset().top+ " curtain:"+$('.curtain').offset().top+" curtain Top:"+$('.curtain').css('top')+ "curtainHeight:"+$('.curtain').height());*/ if (gap<0) { $('.curtain').css('height', $('.curtain').height()+gap ) } else if (($('.curtain').height() 0) { if ($('.curtain').height()+gap>fullHeight) { $('.curtain').css('height',fullHeight); } else { $('.curtain').css('height', $('.curtain').height()+gap ) } } } function showCurtains() { var curtains = $(window).width() > $('#wrapper').width(); if (curtains) { drawCurtains(); } return curtains } function drawCurtains() { if ($('#leftcurtain').length==0) { $('#wrapper').before("
").after("
"); pullCurtains(); $(window).unbind('resize'); $(window).resize(pullCurtains); /*$(window).scroll(curtainLength);*/ } } function pullCurtains() { var offset = $('#wrapper').offset(); $('#leftcurtain').css('left', offset.left - $('.curtain').width() - 30 ); $('#rightcurtain').css('left', offset.left + $('#wrapper').width()+ 30 ).css('width',offset.left); }