Sos = function() {
return {
/**
* Returns a prefixed class name from an element without the prefix
* (ie returns "dynamicData" from .value-holder-dynamicData).
* Can be used for specifying settings etc in class names.
* @param {Object} el
* @param {Object} prefix
*/
getClassNameValue: function(el, prefix) {
var ret = new RegExp(".*" + prefix + "(.*?)(?:\\s|$).*").exec(el.className);
if (ret) {
return ret[1];
}
return null;
},
init: function() {
/*@cc_on
if (@_jscript_version==5.6 ||
(@_jscript_version==5.7 &&
navigator.userAgent.toLowerCase().indexOf("msie 6.") != -1)) {
try {
document.execCommand("BackgroundImageCache", false, true);
} catch (e) {}
}
@*/
// Always check if window is active (ie is in foreground and not in inactive tab etc)
window.isActive = true;
$(window).live("focus", function() { this.isActive = true; });
$(window).live("blur", function() { this.isActive = false; });
// Init functions
Sos.print.init();
Sos.addAnchors.init([
{ element: ".teaser", include: ["P", "IMG"], add: false }
]);
Sos.slideshow.init();
Sos.sponsorForm.init();
Sos.carousel.init([
{ element: ".shop-teasers UL", navigation: true, autoplay: true, delay: 800 }
]);
Sos.startpage.init();
}
};
}();
/**
* Add print functionality
*/
Sos.startpage = function() {
return {
init: function() {
$(".featured-projects LI").live("click", function(e) {
e.preventDefault();
$self = $(this);
$(".featured-projects LI").removeClass("selected");
$self.addClass("selected");
var n = Sos.getClassNameValue(this, "toggle-");
$(".featured-projects .teaser").hide();
$("#featured-project-" + n).show();
});
}
};
}();
/**
* Add print functionality
*/
Sos.print = function() {
return {
init: function() {
var tools = $("ul.article-tools");
if (tools.length > 0) {
$li = $("
";
for (var i = 0, l = el.data("noOfItems"); i < l; i++) {
content += "
" + (i+1) + "";
}
content += "";
$("#" + el.attr("id") + " .slideshow-navigation a").live("click", function(e) {
if (!el.data("busy")) {
el.data("busy", true);
var target = parseInt($(this).html()) - 1;
goTo(el.attr("id"), target);
$("#" + el.attr("id") + " .slideshow-navigation a").removeClass("current");
$("#" + el.attr("id") + " .slideshow-navigation a::nth-child(" + (target + 1) + ")").addClass("current");
} else {
this.blur();
}
e.preventDefault();
});
el.append(content);
$("#" + el.attr("id") + " .slideshow-navigation a:first").addClass("current");
}
};
var DOMReady = function() {
$(".slideshow").each(function() {
var el = $(this);
var lis = el.find("li");
var noOfItems = lis.length;
el.attr("id", idPrefix + no++);
el.data("itemNo", 0);
el.data("noOfItems", noOfItems);
el.data("autoplay", el.hasClass("autoplay"));
el.data("showNavigation", el.hasClass("show-navigation"));
el.data("busy", false);
el.css("overflow", "hidden");
if (noOfItems > 0) {
lis[0].style.display = "block";
}
if (noOfItems > 1) {
var ul = lis[0].parentNode;
$(ul).attr("id", el.attr("id") + listSuffix);
var img = $(lis[0]).find("img")[0];
if (!img.complete) {
$(img).load(function() {
construct(el, ul, lis, img);
});
} else {
construct(el, ul, lis, img);
}
}
});
};
return {
init: function() {
$(document).ready(DOMReady);
},
autoplayStart: function(id) {
var el = $("#" + id);
timer[id] = setInterval("Sos.slideshow.autoplay('" + id + "')", autoplayInterval);
},
autoplayStop: function(id) {
if (typeof timer[id] != "undefined") {
clearInterval(timer[id]);
}
},
autoplay: function(id) {
next(id);
}
};
}();
/**
* Adds anchors (using the first found anchor in the element as a source) around an
* element's inner elements when hovered. Also Sets a class of "hover" on the
* parent element when its children are being hovered.
* @param {object} An associative array of elements and their inner items to anchor
* element (mandatory) The parent element.
* include (mandatory) The inner element to be anchored.
* add (optional, default is true) Makes the included elements clickable instead of added anchors.
*/
Sos.addAnchors = (function() {
var selectors = "";
return {
init: function(settings) {
if (settings) {
var i;
for (i = 0, ln = settings.length; i < ln; i++) {
if (settings[i].element) {
if (settings[i].include) {
var selector = settings[i].element;
selectors += (selectors.length > 0 ? "," : "") + selector;
var j;
for (j = 0, ln2 = settings[i].include.length; j < ln2; j++) {
if (settings[i].add === false) {
$(selector + " " + settings[i].include[j]).live("click", function() {
var $self = $(this);
window.location = $self.closest(selectors).find("a").attr("href");
return false;
});
} else {
$(selector + " " + settings[i].include[j]).live("mouseover", function() {
var $self = $(this);
var $linkParent = $self.data("linkParent");
if (!$linkParent || typeof($linkParent) === "undefined") {
$linkParent = $self.closest(selectors);
if ($linkParent.length > 0) {
$self.data("linkParent", $linkParent);
var href = $linkParent.find("a").attr("href");
if (href !== null && typeof href !== "undefined") {
$a = $("
");
if (!this.innerHTML) {
if (this.parentNode.tagName !== "A") {
$self.before($a);
$a.wrapInner($self);
}
} else {
$self.contents().each(function() {
if (this.tagName !== "A") {
$self = $(this);
if (jQuery.trim($self.text()).length > 0) {
$self.wrap($a);
}
}
});
}
}
}
}
if ($linkParent) {
$linkParent.addClass("hover");
}
});
$(selector + " " + settings[i].include[j]).live("mouseout", function() {
var $linkParent = $(this).data("linkParent");
if ($linkParent !== null) {
$linkParent.removeClass("hover");
}
});
}
}
}
}
}
}
}
};
}());
Sos.init();