// 'stacks' is the Stacks global object.
// All of the other Stacks related Javascript will
// be attatched to it.
var stacks = {};
// this call to jQuery gives us access to the globaal
// jQuery object.
// 'noConflict' removes the '$' variable.
// 'true' removes the 'jQuery' variable.
// removing these globals reduces conflicts with other
// jQuery versions that might be running on this page.
stacks.jQuery = jQuery.noConflict(true);
// Javascript for stacks_in_325_page20
// ---------------------------------------------------------------------
// Each stack has its own object with its own namespace. The name of
// that object is the same as the stack's id.
stacks.stacks_in_325_page20 = {};
// A closure is defined and assigned to the stack's object. The object
// is also passed in as 'stack' which gives you a shorthand for referring
// to this object from elsewhere.
stacks.stacks_in_325_page20 = (function(stack) {
// When jQuery is used it will be available as $ and jQuery but only
// inside the closure.
var jQuery = stacks.jQuery;
var $ = jQuery;
/*
*
* RapidWeaver Multi Language Enclosure stack by Tsooj Media
* Version 1.1.0
*
* Visit http://www.tsooj.net for more information on how to use this stacks product for RapidWeaver.
*
*/
/**
* Based on the Cookie plugin
*
* Copyright (c) 2006 Klaus Hartl (stilbuero.de)
* Dual licensed under the MIT and GPL licenses:
*
*/
/**
* Create a cookie with the given name and value and other optional parameters.
*
* @example $.cookie('the_cookie', 'the_value');
* @desc Set the value of a cookie.
* @example $.cookie('the_cookie', 'the_value', { expires: 7, path: '/', domain: 'jquery.com', secure: true });
* @desc Create a cookie with all available options.
* @example $.cookie('the_cookie', 'the_value');
* @desc Create a session cookie.
* @example $.cookie('the_cookie', null);
* @desc Delete a cookie by passing null as value. Keep in mind that you have to use the same path and domain
* used when the cookie was set.
*
* @param String name The name of the cookie.
* @param String value The value of the cookie.
* @param Object options An object literal containing key/value pairs to provide optional cookie attributes.
* @option Number|Date expires Either an integer specifying the expiration date from now on in days or a Date object.
* If a negative value is specified (e.g. a date in the past), the cookie will be deleted.
* If set to null or omitted, the cookie will be a session cookie and will not be retained
* when the the browser exits.
* @option String path The value of the path atribute of the cookie (default: path of page that created the cookie).
* @option String domain The value of the domain attribute of the cookie (default: domain of page that created the cookie).
* @option Boolean secure If true, the secure attribute of the cookie will be set and the cookie transmission will
* require a secure protocol (like HTTPS).
* @type undefined
*
* @name $.cookie
* @cat Plugins/Cookie
* @author Klaus Hartl/klaus.hartl@stilbuero.de
*/
/**
* Get the value of a cookie with the given name.
*
* @example $.cookie('the_cookie');
* @desc Get the value of a cookie.
*
* @param String name The name of the cookie.
* @return The value of the cookie.
* @type String
*
* @name $.cookie
* @cat Plugins/Cookie
* @author Klaus Hartl/klaus.hartl@stilbuero.de
*/
(function($){
$.cookie = function(key, value, options) {
if(arguments.length > 1) {
var o = $.extend({}, $.cookie.defaults, options);
if (value === null || value === undefined) {
value = '';
o.expires = -1;
}
if (o.expires.constructor != Date) {
var today = new Date();
today.setDate(today.getDate() + o.expires);
o.expires = today;
}
// Create the cookie string
document.cookie =
key + '=' + value +
'; expires=' + o.expires.toUTCString() +
(o.path? '; path=' + (o.path) : '') +
(o.domain? '; domain=' + (o.domain) : '') +
(o.secure? '; secure' : '');
} else {
if(result = new RegExp(key+"=(.*?)(?:;|$)").exec(document.cookie))
return decodeURIComponent(result[1]);
return false;
}
};
$.cookie.defaults = {
expires: ((135 == 0) ? -1 : 135),
path: '/',
domain: document.domain,
secure: ((document.location.protocol == 'https:') ? true : false)
}
})(jQuery);
// Try to correct possible usage of special characters.
function atm_decodeHTMLEntities (strString) {
return $('').html(strString).val();
}
// Text Equals to function.
$.fn.textEquals = function(strText) {
return $(this).text() == strText;
}
// fadeIn fix for IE :(
jQuery.fn.fadeIn = function(speed, callback) {
return this.animate({opacity: 'show'}, speed, function() {
if (jQuery.browser.msie)
this.style.removeAttribute('filter');
if (jQuery.isFunction(callback))
callback();
});
};
// Global Vars.
stacks.atm_gstrRwmlCurrentLanguage = '';
// Local Vars.
var atm_strRwmlDefaultLanguage = 'EN';
var atm_strRwmlCookieName = 'rwml_preferred_language';
var atm_strRwmlCurrentLanguage = '';
var atm_blnRwmlHanldeRedirects = false;
var atm_blnRwmlMenuItemsSpanBased = false;
function atm_rwmlShowLanguage(strLanguage, blnDocumentReady) {
/** Hide all language content, note that a lot of RW Themes come with a wrong html xml declaration.
For example: .
This is wrong because the language could be something else and the RW users should be able to
set the correct Language(s) themself by using RW in our opinion.
So therefore we are using the specific document.body target for the Lang(uage) selection,
otherwise the entire document content could be hidden by the RWML script.
*/
// Only perform actions when a different Language is chosen.
if (atm_strRwmlCurrentLanguage != strLanguage) {
$('[lang]', document.body).hide();
// Show Selected Language, fade in when Switching from Language.
$('[lang]', document.body).each(function() {
if (($(this).attr('lang') == strLanguage) && blnDocumentReady) {
$(this).show();
}
else if (($(this).attr('lang') == strLanguage) && !blnDocumentReady) {
//if ($.browser.msie && $.browser.version=='8.0' && $(this).get(0).tagName=='DIV') {
// $(this).css('position', 'relative').fadeIn(3295);
//} else {
$(this).fadeIn(3295);
//}
}
else {
$(this).hide();
}
});
// Show all RWML system (rwml-sys) contained Language content items.
if (blnDocumentReady) {
$('.rwml-sys').show();
}
// Set the Active Language;
atm_strRwmlCurrentLanguage = strLanguage;
// Make sure the Cookie is renewed.
$.cookie(atm_strRwmlCookieName, null);
// Set the Active Language;
atm_strRwmlCurrentLanguage = strLanguage;
// Store used Language in RWML Cookie.
$.cookie(atm_strRwmlCookieName, strLanguage);
// Handle Redirects when needed.
if (atm_blnRwmlHanldeRedirects) {
// setTimeout(atm_rwmlRedirect(atm_strRwmlCurrentLanguage), 500);
setTimeout(function(){atm_rwmlRedirect(atm_strRwmlCurrentLanguage)}, 500);
}
}
}
// Hide the Language Content items that belong to the RWML system (rwml-sys) during page load.
// This prevents that the Content comes available during page loading.
document.write("");
// Perform all actions on Document Ready.
$(document).ready(function() {
// Replace Menu Items.
$('div[class="rwml-menu-item"]').each(function() {
var atm_strMenuItemTitle = atm_decodeHTMLEntities($(this).attr('TITLE'));
var atm_strMenuItemHTML = $(this).html();
// Menu Items Text or Span based.
if (atm_blnRwmlMenuItemsSpanBased == false) {
//$('a:contains('+atm_strMenuItemID+')').html(atm_strMenuItemHTML); // Working fine but not Unique Text match.
$('a').each(function() {
if (atm_decodeHTMLEntities($(this).text()) == atm_strMenuItemTitle) { $(this).html(atm_strMenuItemHTML); }
});
// Span based.
} else {
$('.'+atm_strMenuItemTitle).replaceWith(atm_strMenuItemHTML);
}
$(this).remove();
});
// Remove Imported Menu Definitions
$('div[class="rwml-menu-imported"]').each(function() {
$(this).remove();
});
// Create Switch Links based on the RWML Switch Stack(s).
$('a[rel="rwml"]').click(function() {
var atm_strHrefLang = $(this).attr('HREFLANG');
atm_rwmlShowLanguage(atm_strHrefLang, false);
return false; // Disable default behaviour.
});
// Create Switch Links based on the Toolbar aka Menu Items.
$('a[href*="rwml-sys"]').click(function() {
var atm_strHrefLang = $(this).text();
atm_rwmlShowLanguage(atm_strHrefLang, false);
return false; // Disable default behaviour.
});
// Handle Redirects.
$('#rwml-redirect').each(function() {
atm_blnRwmlHanldeRedirects = true;
});
// Show the 'Selected' Language based on Autoselect.
atm_rwmlShowLanguage(($.cookie(atm_strRwmlCookieName)) ? $.cookie(atm_strRwmlCookieName) : atm_strRwmlDefaultLanguage, true);
});
return stack;
})(stacks.stacks_in_325_page20);