if (!JS_AB) {
var JS_AB = new Object();
}
JS_AB.general = {
debug : false,
init : function() {
JS_AB.general._cookiesEnabled();
JS_AB.general._styleSwitcher();
JS_AB.general._hookLoginInTopBar();
JS_AB.general._hookAccessibilityTooltip();
JS_AB.general._setExternalFavicons();
JS_AB.general._hookModalBoxes();
JS_AB.general.accessibleYoutube();
},
_cookiesEnabled: function() {
// try to grab the property
var cookiesEnabled = (navigator.cookieEnabled) ? true : false;
// unknown property?
if(typeof navigator.cookieEanbled == 'undefined' && !cookiesEnabled) {
// try to set a cookie
document.cookie = 'testcookie';
cookiesEnabled = (document.cookie.indexOf('testcookie') != -1);
}
// show div
if(!cookiesEnabled) $('#noCookies').show();
},
_styleSwitcher: function() {
$('.styleswitch').click(function(){
JS_AB.general._switchStylestyle(this.getAttribute("rel"));
return false;
});
var c = JS_AB.general.readCookie('style');
if (c) JS_AB.general._switchStylestyle(c);
},
_switchStylestyle: function(styleName) {
$('link[@rel*=style][title]').each(function(i) {
this.disabled = true;
if (this.getAttribute('title') == styleName) this.disabled = false;
if (styleName === 'accessibility') $('body').addClass('accessibility');
else $('body').removeClass('accessibility');
});
JS_AB.general.createCookie('style', styleName, 365);
},
_hookAccessibilityTooltip: function() {
if (!$('body').hasClass('accessibility')) {
$('#styleAccessibility a').hover(function(evt) {
$('#styleHelp').fadeIn(250);
}, function(evt) {
$('#styleHelp').fadeOut(250);
});
};
$('#styleAccessibility a').bind('focus', function(evt) {
evt.preventDefault();
evt.stopPropagation();
$('#styleHelp').fadeIn(250);
}).bind('blur mouseout', function(evt) {
evt.preventDefault();
evt.stopPropagation();
$('#styleHelp').fadeOut(250);
});
},
_hookLoginInTopBar: function() {
$('#activateLoginform').bind('click', function(evt) {
evt.preventDefault();
evt.stopPropagation();
$('#topbarLoginForm').toggle();
if ($('#topbarLoginForm').is(':visible')) {
$('#username').focus();
}
});
$('#topbarLoginForm').bind('click', function(evt) {
evt.stopPropagation();
});
$(document.body).bind('click', function(evt) {
if ($('#topbarLoginForm').is(':visible')) {
$('#topbarLoginForm').toggle();
}
});
$(document.body).bind("keypress blur", function(evt) {
if ($('#topbarLoginForm').is(':visible') && (evt.keyCode == 27)) {
$('#topbarLoginForm').toggle();
}
});
$(".tooltipContent input.input-submit").bind("keypress blur", function(evt) {
if ($('#topbarLoginForm').is(':visible')) {
$('#topbarLoginForm').toggle();
}
});
},
_setExternalFavicons: function() {
$('#external-links-list a[href^="http://"]').each(function() {
var faviconIMG = $('').prependTo($(this));
var extImg = new Image();
extImg.src = $(this).attr('href').replace(/^(http:\/\/[^\/]+).*$/, '$1') +'/favicon.ico';
extImg.onload = function() {
faviconIMG.attr('src', extImg.src);
}
extImg.onerror = function() {
faviconIMG.attr('src', '/modules/core/layout/images/externalLink.gif');
}
extImg.onabort = function() {
faviconIMG.attr('src', '/modules/core/layout/images/externalLink.gif');
}
});
},
_hookOverlay: function(show) {
if($('#overlay').length == 0) $('#container').prepend('