
// '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_1_page0
// ---------------------------------------------------------------------

// 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_1_page0 = {};

// 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_1_page0 = (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 Fancy Intro stack by Tsooj Media.
 * Version 1.1.1.
 *
 * Visit http://www.tsooj.net for more information on how to use this stacks product for RapidWeaver.
 *
 */

/**
 *
 *  Globals.
 *
 */
var atm_strFancyIntroCookieName = 'atm_FancyIntroDays',
	atm_strFancyIntroDays = '',
	atm_blnFancyIntroSkipBrowser = false,
	atm_strFancyIntroLineHeight = '',
	atm_blnFancyIntroAsync = false;
	
/**
 * 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: ((0 == 0) ? -1 : 0),
 		path: '/',
 		domain: document.domain,
 		secure: ((document.location.protocol == 'https:') ? true : false)
 	}
})(jQuery);
 

/** 
 *
 * Main Fancy Intro Function.
 *
 */
function atm_ShowFancyIntro() {

	// Hide normal page elements and add Fancy Intro elements.
	$('iframe').hide();
	$('body').css('overflow-y', 'hidden');
	$('<div class="atmFancyIntroBackground"></div>').appendTo('body');
	$('<div class="atmFancyIntroText atmFancyIntroUpperText"></div>').appendTo('body');
	$('<div class="atmFancyIntroText atmFancyIntroLowerText"></div>').appendTo('body');	
	$('<div class="atmFancyIntroLine"></div>').appendTo('body');
	$('.atmFancyIntroUpperText').html($('.atmFancyIntroUpperTextHolder').html());
	$('.atmFancyIntroLowerText').html($('.atmFancyIntroLowerTextHolder').html());	

	// Opera percentage fix.
	if ($.browser.opera) { $('.atmFancyIntroLine').css('height', '2px'); }
	
	// IE7 margin fix.	
	if (navigator.userAgent.match(/MSIE (\d+(?:\.\d+)+(?:b\d*)?)/) == "MSIE 7.0,7.0") {
		atm_strFancyIntroLineHeight = String(parseInt(100 + parseInt(40))) + '% !important';	
		$('.atmFancyIntroText').css('line-height', atm_strFancyIntroLineHeight);
	} else {
		$('.atmFancyIntroText').css('line-height', '100% !important');
	}
		
	$('.atmFancyIntroBackground').css('visibility', 'visible');
	$('body').css('visibility', 'hidden');
	$('.atmFancyIntroText').css('visibility', 'visible');
	$('.atmFancyIntroLine').css('visibility', 'visible');

	// Fancy the Intro.
	$('.atmFancyIntroLine').delay(300).animate({ width: '+=100%' }, 1500, function() {
		$('.atmFancyIntroLine').animate({ height: '+=100%', top: '-=50%' }, 2000, function() {
			$('body').attr('style','');
			$('body').css('visibility', 'visible');
			$('.atmFancyIntroText').css('visibility', 'hidden');
			$('.atmFancyIntroBackground').css('visibility', 'hidden');

			// IE Filter Fix.
			if ($.browser.msie) { $('.atmFancyIntroLine').css('filter', ''); }

			// Fadeout and remove Fancy Intro elements.
			$('.atmFancyIntroLine').animate({ opacity: 0 }, 2000, function() {
				$('.atmFancyIntroBackground').remove();
				$('.atmFancyIntroText').remove();
				$('.atmFancyIntroLine').remove();
				$('#stacks_in_1_page0').remove();
				$('iframe').show();
				$('body').css('overflow-y', 'visible');
			});
		});
	});
};


/** 
 *
 * Add Hour(s) Function.
 *
 */
Date.prototype.atm_addHours = function(h){
    this.setHours(this.getHours()+h);
    return this;
}



/** 
 *
 * Document Ready Actions.
 *
 */
 
$(document).ready(function() {

	// Skip old IE6 Browser
	if (navigator.userAgent.match(/MSIE (\d+(?:\.\d+)+(?:b\d*)?)/) == "MSIE 6.0,6.0") {
		atm_blnFancyIntroSkipBrowser = true;
	} else {
		atm_strFancyIntroDays = $.cookie(atm_strFancyIntroCookieName);
		if ((atm_strFancyIntroDays == '') || (0 == 0)) {

			// Show the Fancy Intro.
			atm_ShowFancyIntro();
			
			// Hide for given number of Days or Hours.
			if ((false) && (0 != 0)) {
				$.cookie(atm_strFancyIntroCookieName, 0, { expires: new Date().atm_addHours(0)});
			} else {
				$.cookie(atm_strFancyIntroCookieName, 0);
			}
		} else {
			$('.atmFancyIntroBackground').remove();
		}	
	}

});

	return stack;
})(stacks.stacks_in_1_page0);


// Javascript for stacks_in_6_page0
// ---------------------------------------------------------------------

// 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_6_page0 = {};

// 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_6_page0 = (function(stack) {

	// When jQuery is used it will be available as $ and jQuery but only
	// inside the closure.
	var jQuery = stacks.jQuery;
	var $ = jQuery;
	
/* ==== Excellent fade and vanish code by Eric Boo at Cosculture.com ==== */
function slideBackNow() {
	$("#frm").fadeOut(1000);
	$('#mtxform').slideUp(1500);
}

/* 
   ========================================================================== 
         script: morphing text 
         author: Gerard Ferrandez - [Ge1doot] 
           date: 20 September, 2008 
           site: http://www.dhteumeuleu.com 
    inspiration: http://www.pwang.com/blog/archives/2006/04/post_100.html 
          quote: Scott Adams, 'The Dilbert Principle' 
                       ------------ 
        license: CC-BY-NC - please do not remove this notice ! 
   ========================================================================== 
*/ 
 
var mtx = function () { 
	/* ==== private variables & methods ==== */ 
	var stop = false; 
	var frm, lineDelay, charDelay; 
	var colorText, colorMatch, colorGhost, elapsedTime; 
	var lineIndex = 0; 
	var lineChar  = []; 
	var animStack = []; 
	var colorStack = []; 
	/* ==== rgb color ==== */ 
	function colorRGB (c) { 
		return 'rgb(' 
			+Math.round(Math.min(255, Math.max(0, c[0])))+',' 
			+Math.round(Math.min(255, Math.max(0, c[1])))+',' 
			+Math.round(Math.min(255, Math.max(0, c[2])))+')'; 
	} 
	/* ==== Easing functions ==== */ 
	function Ease () {} 
	Ease.prototype = { 
		ease : function () { 
			this.m += this.s; 
			this.x0 += (this.d * this.m * .0025); 
			if (this.m == 20) this.s = -1; 
			return this.x0; 
		}, 
		init : function (x0, x1) { 
			this.m = 0; 
			this.s = 1; 
			this.d = x1 - x0; 
			this.x0 = x0; 
		} 
	} 
 
	/* ==== Load Lines ==== */ 
	function loadLines () { 
		// read text from HTML form 
		text = document.forms.mtxform.text.value.split("\n"); 
		// loop through all lines 
		for (var j = 0; j < text.length; j++) { 
			var t = text[j]; 
			if (t) { 
				var n = t.length; 
				lineChar[j] = []; 
				// first pass: create characters capture RELATIVE offset coordinates 
				for (var i = 0; i < n; i++) 
					lineChar[j][i] = new Character(t.charAt(i), j); 
				// second pass: convert to absolute position 
				for (var i = 0, o; o = lineChar[j][i]; i++) { 
					if (o.c == "|") { 
						// remove spaces 
						lineChar[j].splice(i, 1); 
						frm.removeChild(o.o); 
						i--; 
					} else { 
						// convert to absolute position and render 
						o.o.style.position = "absolute"; 
						o.moveHTML(); 
						// push first line in animation stack 
						if (j == 0) pushAnim (o, charDelay * i); 
					} 
				} 
			} 
		} 
	} 
	/* ==== Character Constructor ==== */ 
	function Character (c, line) { 
		if (c == " ") c = "|"; 
		this.c = c; 
		// create HTML element and append the the container 
		this.o = document.createElement("span"); 
		this.o.innerHTML = c; 
		this.o.style.zIndex = 2; 
		frm.appendChild(this.o); 
		// capture relative offset positions ! 
		this.x0 = this.o.offsetLeft; 
		this.y0 = -this.o.offsetHeight * 1.5; 
		this.x1 = this.x0; 
		this.x2 = this.x0; 
		this.y1 = (line + 1) * this.o.offsetHeight; 
		this.y2 = frm.offsetHeight; 
		this.mx = new Ease(); 
		this.my = new Ease(); 
		this.c0 = [colorText[0], colorText[1], colorText[2]]; 
	} 
	/* ==== Character functions ==== */ 
	Character.prototype = { 
		// ---- character animation ---- 
		anim : function (i) { 
			// temporization 
			if (this.delay > 0) { 
				if (elapsedTime) 
					this.delay -= new Date().getTime() - elapsedTime; 
			} else { 
				// moving 
				this.x0 = this.mx.ease(); 
				this.y0 = this.my.ease(); 
				this.moveHTML(); 
				if (!this.my.m && !this.mx.m) { 
					// remove from stack 
					animStack.splice(i, 1); 
					// remove dead characters 
					if (this.off) frm.removeChild(this.o); 
				} 
			} 
		}, 
		// ----- color fading ------ 
		color : function (i) { 
			this.c0[0] += this.cr[0]; 
			this.c0[1] += this.cr[1]; 
			this.c0[2] += this.cr[2]; 
			this.ci++; 
			this.o.style.color = colorRGB(this.c0); 
			if (this.ci >= this.cs) 
				colorStack.splice(i, 1); 
		}, 
		// ----- HTML positioning ----- 
		moveHTML : function () { 
			this.o.style.left = Math.round(this.x0) + "px"; 
			this.o.style.top  = Math.round(this.y0) + "px"; 
		}, 
		// ----- init color fading ------ 
		colorFade : function (c1, steps) { 
			this.cs = steps; 
			this.cr = [(c1[0] - this.c0[0]) / steps, (c1[1] - this.c0[1]) / steps, (c1[2] - this.c0[2]) / steps]; 
			if (this.cr[0] != 0 || this.cr[1] != 0 || this.cr[2] != 0){ 
				this.ci = 0; 
				colorStack.push (this); 
			} 
		} 
	} 
	/* ==== push character in the animation stack ==== */ 
	function pushAnim (o, delay) { 
		// init ease 
		o.mx.init(o.x0, o.x1); 
		o.my.init(o.y0, o.y1); 
		o.delay = delay; 
		// push stack 
		animStack.push(o); 
	} 
	/* ==== next line ==== */ 
	function nextLine () { 
		if (lineIndex < lineChar.length - 1) { 
			// display shadow text 
			for (var i = 0, o; o = lineChar[lineIndex][i]; i++) { 
				var s = o.o.cloneNode(true); 
				s.style.zIndex = 1; 
				s.style.color = colorRGB(colorGhost); 
				frm.appendChild(s); 
			} 
			// matching next line characters 
			for (var i = 0, t; t = lineChar[lineIndex + 1][i]; i++) { 
				for (var j = 0, o; o = lineChar[lineIndex][j]; j++) { 
					if (o.c == t.c) { 
						// colors 
						t.colorFade(colorMatch, o.match ? 1 : 20); 
						t.match = true; 
						// swap characters 
						t.x0 = o.x0; 
						t.y0 = o.y0; 
						t.moveHTML(); 
						// remove redundant character 
						frm.removeChild(o.o); 
						lineChar[lineIndex].splice(j, 1); 
						break; 
					} 
				} 
			} 
			// take off redundant characters 
			for (var i = 0, o; o = lineChar[lineIndex][i]; i++) { 
				// set target position (off frame) 
				o.y1 = frm.offsetHeight; 
				o.off = true; 
				o.match = false; 
				o.colorFade (colorText, 20); 
				// push in animation stack 
				pushAnim (o, (lineDelay * .8) + charDelay * i); 
			} 
		} 
		// push next line in animation stack 
		lineIndex++; 
		if (lineIndex < lineChar.length) { 
			for (var i = 0, o; o = lineChar[lineIndex][i]; i++) 
				pushAnim (o, lineDelay + charDelay * i); 
		} 
		else {
			slideBackNow();
		}
	} 
 
	/* ==== main animation loop ==== */ 
	function main() { 
		//  characters 
		var n = animStack.length; 
		if (n) { 
			var i = n; 
			while (i--) 
				animStack[i].anim(i); 
		} else nextLine (); 
		// colors 
		var i = colorStack.length; 
		while (i--) 
			colorStack[i].color(i); 
		// get elapsed time and loop 
		elapsedTime = new Date().getTime(); 
		setTimeout(main, 32); 
	} 
 
	/* //////////// ==== public methods ==== //////////// */ 
	return { 
		/* ==== initialize script ==== */ 
		init : function (cont, t1, t2, c1, c2, c3) { 
			// container 
			frm = document.getElementById(cont); 
			lineDelay = t1; 
			charDelay = t2; 
			colorText = c1; 
			colorMatch = c2; 
			colorGhost = c3; 
			loadLines(); 
			main(); 
		}, 
		changeText : function () { 
			document.getElementById("show").className = ""; 
			document.getElementById("inputext").className = "hidden"; 
			lineChar  = []; 
			animStack = []; 
			colorStack = []; 
			frm.innerHTML = ""; 
			lineIndex = 0; 
			elapsedTime = 0; 
			loadLines(); 
			frm.focus(); 
		}, 
		show : function () { 
			document.getElementById("show").className = "hidden"; 
			document.getElementById("inputext").className = ""; 
			document.getElementById("text").focus(); 
		} 
	} 
}(); 
 
 
/* ==== init text ==== */ 
onload = function () { 
 
//	mtx.init( el, linesDelay, charsDelay, cText, cMatch, cGhost); 
	mtx.init("frm", 1500, 150, [255,255,255], [0,0,0], [102,102,102]); 
} 
	return stack;
})(stacks.stacks_in_6_page0);



