
var qlSource = '<div id="ql_footer">  <div id="footer-inner">    <div id="quick_launch_bar">      <div id="balk_openen">        <div class="intro">Klik deze balk open en bekijk ook alles over onze producten en onlinetools.</div>        <div class="dl_logo"><img src="http://quicklaunch.deltalloyd.campaign.alion.nl/images/deltalloyd.gif" alt="deltalloyd" width="75" height="12" border="0" /></div>        <div id="openen">Openen</div>      </div>      <div id="balk_sluiten">        <div class="intro">Lees meer over onze producten en online tools</div>        <div class="dl_logo"><img src="http://quicklaunch.deltalloyd.campaign.alion.nl/images/deltalloyd.gif" alt="deltalloyd" width="75" height="12" border="0" /></div>        <div id="sluiten">Sluiten</div>      </div>      <div id="flow">		<object width="100%" height="250">		  <param name="movie" value="http://quicklaunch.deltalloyd.campaign.alion.nl/ql.swf"></param>		  <param name="allowscriptaccess" value="always"></param>		  <param name="FlashVars" value="xmlurl=http://quicklaunch.deltalloyd.campaign.alion.nl/xml/content.xml"></param>          <param name="expressinstall" value="http://quicklaunch.deltalloyd.campaign.alion.nl/Scripts/expressInstall.swf" />          <param name="quality" value="high" />		  <embed src="http://quicklaunch.deltalloyd.campaign.alion.nl/ql.swf" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" FlashVars="xmlurl=http://quicklaunch.deltalloyd.campaign.alion.nl/xml/content.xml" width="100%" height="250"></embed>		</object>      </div>    </div>  </div></div>';
// JavaScript Document
var qlBaseURL = 'http://quicklaunch.deltalloyd.campaign.alion.nl/';
window.fix_wmode2transparent_swf = function  () {
	if(typeof (jQuery) == "undefined") {
		window.setTimeout('window.fix_wmode2transparent_swf()', 200);
		return;
	}
	if(window.noConflict)jQuery.noConflict();
	// For embed
	jQuery("embed").each(function(i) {
		var elClone = this.cloneNode(true);
		elClone.setAttribute("WMode", "Transparent");
		jQuery(this).before(elClone);
		jQuery(this).remove();
	});	
	// For object and/or embed into objects
	jQuery("object").each(function (i, v) {
	var elEmbed = jQuery(this).children("embed");
	if(typeof (elEmbed.get(0)) != "undefined") {
		if(typeof (elEmbed.get(0).outerHTML) != "undefined") {
			elEmbed.attr("wmode", "transparent");
			jQuery(this.outerHTML).insertAfter(this);
			jQuery(this).remove();
		}
		return true;
	}
	var algo = this.attributes;
	var str_tag = '<OBJECT ';
	for (var i=0; i < algo.length; i++) str_tag += algo[i].name + '="' + algo[i].value + '" ';	
	str_tag += '>';
	var flag = false;
	jQuery(this).children().each(function (elem) {
		if(this.nodeName == "PARAM") {
			if (this.name == "wmode") {
				flag=true;
				str_tag += '<PARAM NAME="' + this.name + '" VALUE="transparent">';		
			}
			else  str_tag += '<PARAM NAME="' + this.name + '" VALUE="' + this.value + '">';
		}
	});
	if(!flag)
		str_tag += '<PARAM NAME="wmode" VALUE="transparent">';		
	str_tag += '</OBJECT>';
	jQuery(str_tag).insertAfter(this);
	jQuery(this).remove();	
	});
};
(function() {

// Localize jQuery variable
var jQuery;
var $;

/******** Load jQuery if not present *********/
if (window.jQuery === undefined) {
    var script_tag_c = document.createElement('script');
    script_tag_c.setAttribute("type","text/javascript");
    script_tag_c.setAttribute("src",qlBaseURL+"jquery.cookie.js");
	
    var script_tag = document.createElement('script');
    script_tag.setAttribute("type","text/javascript");
    script_tag.setAttribute("src",qlBaseURL+"jquery-1.4.2.min.js");
    script_tag.onload = scriptLoadHandler;
    script_tag.onreadystatechange = function () { // Same thing but for IE
        if (this.readyState == 'complete' || this.readyState == 'loaded') {
            scriptLoadHandler();
        }
    };
    // Try to find the head, otherwise default to the documentElement
    (document.getElementsByTagName("head")[0] || document.documentElement).appendChild(script_tag);
} else {
    // The jQuery version on the window is the one we want to use
    $ = jQuery = window.jQuery;
	
    main();
}

/******** Called once jQuery has loaded ******/
function scriptLoadHandler() {
    // Restore $ and window.jQuery to their previous values and store the
    // new jQuery in our local jQuery variable
	$ = jQuery = window.jQuery.noConflict(true);
    // Call our main function
    main(); 
}

/******** Load jQuery.cookies *********/
function loadJQueryCookies(){
	if ($.fn.cookie) {
	} else {
		jQuery.cookie = jQuery.fn.cookie = function(name, value, options) {
			if (typeof value != 'undefined') { // name and value given, set cookie
				options = options || {};
				if (value === null) {
					value = '';
					options.expires = -1;
				}
				var expires = '';
				if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
					var date;
					if (typeof options.expires == 'number') {
						date = new Date();
						date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
					} else {
						date = options.expires;
					}
					expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
				}
				// CAUTION: Needed to parenthesize options.path and options.domain
				// in the following expressions, otherwise they evaluate to undefined
				// in the packed version for some reason...
				var path = options.path ? '; path=' + (options.path) : '';
				var domain = options.domain ? '; domain=' + (options.domain) : '';
				var secure = options.secure ? '; secure' : '';
				document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
			} else { // only name given, get cookie
				var cookieValue = null;
				if (document.cookie && document.cookie != '') {
					var cookies = document.cookie.split(';');
					for (var i = 0; i < cookies.length; i++) {
						var cookie = jQuery.trim(cookies[i]);
						// Does this cookie string begin with the name we want?
						if (cookie.substring(0, name.length + 1) == (name + '=')) {
							cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
							break;
						}
					}
				}
				return cookieValue;
			}
		};
	}
}

/******** Our main function ********/
function main() { 
	
	/**************** Get the max z-index in the DOM ***************/
	$.maxZIndex = $.fn.maxZIndex = function(opt) {
		/// <summary>
		/// Returns the max zOrder in the document (no parameter)
		/// Sets max zOrder by passing a non-zero number
		/// which gets added to the highest zOrder.
		/// </summary>    
		/// <param name="opt" type="object">
		/// inc: increment value, 
		/// group: selector for zIndex elements to find max for
		/// </param>
		/// <returns type="jQuery" />
		var def = { inc: 10, group: "*" };
		$.extend(def, opt);
		var zmax = 0;
		$(def.group).each(function() {
			var cur = parseInt($(this).css('z-index'));
			zmax = cur > zmax ? cur : zmax;
		});
		if (!this.jquery)
			return zmax;
	
		return this.each(function() {
			zmax += def.inc;
			$(this).css("z-index", zmax);
		});
	}

	/**************** Load cookie plugin ***************/
	loadJQueryCookies();

	/**************** try to fix wmode in flash in DOM in order to overlay wioth our QuickLaunch bar ***************/
	window.fix_wmode2transparent_swf();

	/**************** open & close functions for the QuickLaunch bar ***************/
	var closeQL = function(){$("#balk_openen").show();$("#balk_sluiten").hide();$("#flow").slideUp('slow');}
	var openQL = function(){$("#flow").hide();$("#balk_openen").hide();$("#balk_sluiten").show();$("#flow").height(250);$("#flow").slideDown('slow');}

    $(document).ready(function($) { 
		$.fx.off = false;
		/**************** Wrap existing content in our own layout incorporating QuickLaunch bar ***************/
		$('head').append('<link href="http://quicklaunch.deltalloyd.campaign.alion.nl/ql_css.asp" rel="stylesheet" type="text/css" />');
		//$("body").wrapInner('<div id="outer"><div id="contain-all"><div id="site"></div></div></div>');
		$('body').append(qlSource);
		//$("#flow,#balk_sluiten").hover(function() {
				//openQL();
		//	});
		$("#balk_openen").click(function() {
				openQL();
			});
		$("#balk_sluiten").click(function() {
				closeQL();
			});
		
		$("#ql_footer, #footer-inner, #quick_launch_bar").maxZIndex();
		/* default states */
		if($.cookie('qldisplayed')=='true'){
			$("#balk_openen").show();
			$("#balk_sluiten").hide();
			$("#flow").height(1);
		}else{
			$("#balk_openen").hide();
			$("#balk_sluiten").show();
			$("#flow").show();
			setTimeout(function(){closeQL()}, 2000);
			$.cookie('qldisplayed','true');
		}
    });
}
})()

