(function($) { $.fn.ssnRotate = function(options) { var defaults = { SwitchSpeed: 7000, hideEffect: function(obj) { obj.fadeOut(2500) }, showEffect: function(obj) { obj.fadeIn(2500) } }; options = $.extend(defaults, options); var ssnSelectList = this.ssnSelectList({ hideEffect: options.hideEffect, showEffect: options.showEffect }); Rotate(ssnSelectList, options.SwitchSpeed); return this }; function Rotate(list, time) { setTimeout(function() { list.next(); Rotate(list, time) }, time) } })(jQuery); (function($) { $.fn.ssnSelectList = function(options) { var defaults = { showFirstAndHideOthers: true, hideEffect: function(obj) { obj.hide() }, showEffect: function(obj) { obj.show() } }; var _options = $.extend(defaults, options); if (_options.showFirstAndHideOthers) this.filter(':first').show().end().filter(':gt(0)').hide(); var selectapi = { list: this, selectedID: 0, options: _options, selected: function() { return getSelected(selectapi) }, next: function() { goNext(selectapi); return this }, prev: function() { goPrev(selectapi); return this }, goto: function(id) { gotoID(selectapi, id); return this } }; return selectapi }; function getSelected(selectapi) { return selectapi.list.eq(selectapi.selectedID) } function goNext(selectapi) { var length = selectapi.list.length; var id = selectapi.selectedID + 1; if (id >= length) id = 0; gotoID(selectapi, id) } function goPrev(selectapi) { var length = selectapi.list.length; var id = selectapi.selectedID - 1; if (id < 0) id = length - 1; gotoID(selectapi, id) } function gotoID(selectapi, id) { var length = selectapi.list.length; if (id >= 0 && id < length) { hideSelected(selectapi); selectapi.selectedID = id; showSelected(selectapi) } } function hideSelected(selectapi) { selectapi.options.hideEffect(selectapi.selected()) } function showSelected(selectapi) { selectapi.options.showEffect(selectapi.selected()) } })(jQuery); (function($) { $.ssnSubscription = function(options) { var defaults = { NameID: 'subscribeName', NameHiddenID: '', EmailID: 'subscribeEmail', EmailHiddenID: '', TextNameMissing: 'Navn skal skrivast.', TextEmailMissing: 'Teldupostur skal skrivast.', SubscribeID: 'subscribe', UnsubscribeID: 'unsubscribe', SubscribeProc: function() { }, UnsubscribeProc: function() { }, NameValue: { fo: 'Navn', da: 'Navn', en: 'Name' }, EmailValue: { fo: 'Teldupostur', da: 'E-mail', en: 'E-mail'} }; _options = $.extend(defaults, options); bindEvents() }; var _options; function bindEvents() { var NameIDAndEmailID = $('#' + _options.NameID + ',#' + _options.EmailID); NameIDAndEmailID.each(function() { onDeselecting(this) }).focus(function() { onSelecting(this) }).blur(function() { onDeselecting(this) }); $('#' + _options.SubscribeID).click(function() { if (validate()) _options.SubscribeProc() }); $('#' + _options.UnsubscribeID).click(function() { if (validate()) _options.UnsubscribeProc() }) } function onSelecting(e) { if ($(e).val() == getCurrentValue(e)) $(e).val("") } function onDeselecting(e) { if ($(e).val() == "") $(e).val(getCurrentValue(e)) } function getCurrentValue(e) { if (e.id == _options.NameID) return getText(_options.NameValue); return getText(_options.EmailValue) } function validate() { var name = $('#' + _options.NameID); var email = $('#' + _options.EmailID); if (isEmptyOrHasDefaultValue(name)) { alert(_options.TextNameMissing); return false } else if (isEmptyOrHasDefaultValue(email)) { alert(_options.TextEmailMissing); return false } else { $('#' + _options.NameHiddenID).val(name.val()); $('#' + _options.EmailHiddenID).val(email.val()); return true } } function isEmptyOrHasDefaultValue(elem) { var value = elem.val(); if (value == '' || value == getCurrentValue(elem.get(0))) return true; return false } function getText(obj) { return eval('(obj.' + getLanguage() + ')') } function getLanguage() { return "fo" } })(jQuery); (function($) { $.fn.ssnSameHeight = function() { var maxHeight = 0; return this.each(function() { var height = $(this).height(); if (height > maxHeight) maxHeight = height }).height(maxHeight) } })(jQuery);