/* GLOBALS */
var imagePath = "images/";
var prevToggleId = "";

/* FUNCTIONS */

function toggleExpand (id, idExpand, idCollapse, expand) {
	if (expand){
		$(id).style.display = "block";
		$(idExpand).style.display = "none";
		$(idCollapse).style.display = "block";
	}else{
		$(id).style.display = "none";
		$(idExpand).style.display = "block";
		$(idCollapse).style.display = "none";
	}
}

function toggleSection (id){
	try{
		Effect.toggle(prevToggleId,'BLIND');
	}catch(e){}
	Effect.toggle(id,'BLIND');
	prevToggleId = id;
}

function getNextSibling(element){
	try{
		while (!element.id) {
			element = element.nextSibling;  // !important. You must have id's for your child nodes.
		}
		return element;
	}catch(e){
		return false;
	}
}


function getQueryStringVal(arg, url) {
    var URL = (url) ? url : document.location.href;
    var qs = URL.substring( URL.indexOf("?"), URL.length );
    var theArg = new String ("?" + arg + "=" );
    var retVal = "";

    if (qs.indexOf(theArg) >= 0 ) {
        var equalIndex = qs.indexOf("=");
        if (qs.indexOf("&") >= 0 )
          retVal = qs.substring( equalIndex+1 , qs.indexOf("&"));
        else
          retVal = qs.substring( equalIndex+1, qs.length );
    } else {
        theArg = new String("&" + arg + "=" );
        var argIndex = qs.indexOf(theArg);
        if ( argIndex  >= 0 ) {
            retVal = qs.substring( argIndex + theArg.length, qs.length);
            var ampIndex = retVal.indexOf("&");
            if ( ampIndex >= 0 ) retVal = retVal.substring( 0, ampIndex );
        }
    }
    return retVal;
}


/***********************************************************************************
// Classes
var CrossFade = Class.create ({
	initialize: function (e1, e2, optObj, ce){
		if (!e1 || !e2) return false;	
		this.e1 = e1;
		this.e2 = e2;
		this.ce = ce;
		this.z = 9999;
		(!optObj.duration) ? this.duration = 2.0 : this.duration = optObj.duration;
		(!optObj.delay) ? this.delay = 5.0 : this.delay = optObj.delay;
		(!optObj.loop) ? this.loop = true : this.loop = optObj.loop;
		
		// Set zindex for animation
		if (this.ce) this.ce.style.zIndex = this.z - 5;
		this.e1.style.zIndex = this.z;
		this.e2.style.zIndex = this.z-1;
		new Effect.Opacity(this.e1, {duration:0, from:0.0, to:1.0});  // Make sure e1 is not faded out.
		new Effect.Opacity(this.e2, {duration:0, from:0.0, to:1.0});  // Make sure e2 is not faded out.
		this.e1.style.display = "block";
		this.e2.style.display = "block";
	}
	},
	
	doFade: function () {
		// Fade
		new Effect.Opacity(this.e1, {
			loop:this.loop,
			delay:this.delay,
			duration:this.duration, 
			from:1.0, to:0.0,
			e1:this.e1,
			e2:this.e2,
			z:this.z,
			afterFinish: function () {
				var cz = this.e2.style.zIndex;
				this.e2.style.zIndex = this.e1.style.zIndex;
				this.e1.style.zIndex = cz;
				this.e1.style.display = "none";
				new Effect.Opacity(this.e1, {duration:0, from:0.0, to:1.0});  // Make sure e1 is not faded out.
			}
		});
	}
});

var CrossFadeSet = Class.create({
	initialize: function(element, duration, delay, loop) {
	if (!element) return false;
    this.element  = element;
    (!duration) ? this.duration = 2.0 : this.duration = duration;
	(!delay) ? this.delay = 5.0 : this.delay = delay;
	(!loop) ? this.loop = true : this.loop = loop;
	
	// Crossfade through the child elements.
	this.cChild = element.firstChild;
	this.nChild = this.nChild;
  },

  doFade: function() {
	this.cChild = getNextSibling(this.cChild);
	this.nChild = getNextSibling(this.cChild.nextSibling);
	if (!this.nChild || this.done) {
		this.nChild = getNextSibling(this.element.firstChild);
		if (!this.loop) return;
	}
	new Effect.Opacity(this.cChild, {
		cChild:this.cChild,
		nChild:this.nChild,
		element:this.element,
		loop:this.loop,
		delay:this.delay,
		doFade:this.doFade,
		done:this.done,
		duration:this.duration, 
		from:1.0, to:0.0,
		beforeStart: function () {
				if (this.done) return;
				var cz = this.cChild.style.zIndex;
				if ( cz < this.nChild.style.zIndex) {
					this.cChild.style.zIndex = this.nChild.style.zIndex;
					this.nChild.style.zIndex = cz;
				}
				this.nChild.style.display = "block";
		},
		afterFinish: function () { 
				var cz = this.nChild.style.zIndex;
				this.nChild.style.zIndex = this.cChild.style.zIndex;
				this.cChild.style.zIndex = cz;
				new Effect.Opacity(this.cChild, {duration:0, from:0.0, to:1.0});
				this.cChild.style.display = "none";
				this.cChild = getNextSibling(this.cChild.nextSibling);
				if (!this.cChild) this.cChild = this.element.firstChild;
				this.doFade(); 
		}
	});
  },
  
});
*/

