var TelemarkSite = TelemarkSite || {}; /** * Set the variable that indicates if JavaScript behaviors should be applied */ TelemarkSite.jsEnabled = document.getElementsByTagName && document.createElement && document.createTextNode && document.documentElement && document.getElementById; /** * Retrieves the absolute position of an element on the screen */ TelemarkSite.absolutePosition = function (el) { var sLeft = 0, sTop = 0; var isDiv = /^div$/i.test(el.tagName); if (isDiv && el.scrollLeft) { sLeft = el.scrollLeft; } if (isDiv && el.scrollTop) { sTop = el.scrollTop; } var r = { x: el.offsetLeft - sLeft, y: el.offsetTop - sTop }; if (el.offsetParent) { var tmp = TelemarkSite.absolutePosition(el.offsetParent); r.x += tmp.x; r.y += tmp.y; } return r; }; // Global Killswitch on the element if (TelemarkSite.jsEnabled) { document.documentElement.className = 'js'; } /** * Toggle the visibility of a fieldset using smooth animations */ TelemarkSite.toggleFieldset = function(fieldset, cls) { if ($(fieldset).is('.collapsed')) { var content = $('> div', fieldset).hide(); $(fieldset).removeClass('collapsed'); $(cls).removeClass('collapsa'); $(cls).addClass('collapsao'); content.slideDown(300, /* function() { // Scroll the fieldset into view TelemarkSite.collapseScrollIntoView(this.parentNode); }, */ function() { // Make sure we open to height auto $(this).css('height', 'auto'); TelemarkSite.collapseScrollIntoView(this.parentNode); this.parentNode.animating = false; } ); } else { var content = $('> div', fieldset).slideUp('medium', function() { $(this.parentNode).addClass('collapsed'); $(cls).removeClass('collapsao'); $(cls).addClass('collapsa'); this.parentNode.animating = false; }); } } /** * Scroll a given fieldset into view as much as possible. */ TelemarkSite.collapseScrollIntoView = function (node) { var h = self.innerHeight || document.documentElement.clientHeight || $('body')[0].clientHeight || 0; var offset = self.pageYOffset || document.documentElement.scrollTop || $('body')[0].scrollTop || 0; var pos = TelemarkSite.absolutePosition(node); var fudge = 55; //if (pos.y + node.offsetHeight + fudge > h + offset) { if ((pos.y + node.offsetHeight + fudge > h + offset)/* && (node.offsetHeight < 150)*/) { if (node.offsetHeight > h) { window.scrollTo(0, pos.y); } else { window.scrollTo(0, pos.y + node.offsetHeight - h + fudge); } } } // Global Killswitch if (TelemarkSite.jsEnabled) { $(document).ready(function() { $('fieldset.collapsible > legend').each(function() { var fieldset = $(this.parentNode); var text = this.innerHTML; $(this).empty().append($(''+ text +'').click(function() { var fieldset = $(this).parents('fieldset:first')[0]; if (!fieldset) fieldset = this; if (!fieldset.animating) { fieldset.animating = true; TelemarkSite.toggleFieldset(fieldset); } return false; })).after($('
').append(fieldset.children(':not(legend)'))); }); var s = $('#slider'); if (s.get(0)) { s.parent().css('width',s.parent().parent().width() + 'px'); s.css('display','').find('span').each(function() { $(this).css('width',s.parent().width() + 'px'); }).find('a').each(function() { $(this).css('width',s.parent().width() + 'px'); });; $('a.c-next').click(function() { var fel = $('#slider > span:first'); fel.animate({ marginLeft: (0 - fel.width()) + 'px' }, 400, function() { $(this).css('margin-left','0').appendTo(fel.parent()); }); }).hover(function() { $(this).addClass('c-next-hover'); }, function() { $(this).removeClass('c-next-hover'); }); $('a.c-prev').click(function() { var fel = $('#slider > span:last'); fel.css('margin-left',(0 - fel.width()) + 'px').prependTo(fel.parent()) fel.animate({ marginLeft: '0px' }, 400); }).hover(function() { $(this).addClass('c-prev-hover'); }, function() { $(this).removeClass('c-prev-hover'); }); } }); $(window).resize(function() { var s = $('#slider'); if (s.get(0)) { s.css('display','none'); s.parent().css('width','auto'); s.parent().parent().css('width','auto'); s.parent().parent().parent().css('width','auto'); s.parent().parent().parent().parent().css('width','auto'); s.parent().parent().parent().parent().parent().css('width','auto'); s.parent().css('width',s.parent().parent().width() + 'px'); s.css('display',''); s.find('span').each(function() { $(this).css('width',s.parent().width() + 'px'); }).find('a').each(function() { $(this).css('width',s.parent().width() + 'px'); }); } }); } function coll(name,cls){ var fieldset = $(name).parents('fieldset:first')[0]; if (!fieldset) fieldset = $(name).get(0); if (!fieldset.animating) { fieldset.animating = true; TelemarkSite.toggleFieldset(fieldset, cls); } }