﻿	
	// CREATIONAL
	
	// COPYRIGHT  : 2005-2010 : CREATIONAL : WWW.CREATIONAL.NL : ALL RIGHTS RESERVED
	
	// JAVASCRIPT : General Scripts
	
	
	// JAVASCRIPT : ADD OR REMOVE EVENTS
	function addEvent(obj,evType,fn,useCapture) { if (obj.addEventListener) { obj.addEventListener(evType,fn,useCapture); return true; } else if (obj.attachEvent) { var r = obj.attachEvent("on"+evType,fn); return r; } else { alert("Handler could not be attached"); } }
	function removeEvent(obj,evType,fn,useCapture) { if (obj.removeEventListener){ obj.removeEventListener(evType,fn,useCapture); return true; } else if (obj.detachEvent){ var r = obj.detachEvent("on"+evType,fn); return r; } else { alert("Handler could not be removed"); } }	
	
	// JAVASCRIPT : E-MAIL OBFUSCATION
	function CL_emailExpand(t,e) { if (t === null || typeof t == 'undefined') { return ''; } if (t.indexOf('@') > -1 || t.indexOf('&#64;') > -1) { var p, pe, es; p = t.indexOf('&#64;'); if (p == -1) { p = t.indexOf('@'); } pe = t.indexOf('<',p); if (pe == -1) { pe = t.indexOf(' ',p); } if (pe == -1) { pe = t.indexOf('%20',p); } if (pe == -1) { pe = t.length; } es = t.substring(0,p); p = es.lastIndexOf('>'); if (p == -1) { p = es.lastIndexOf(' '); } if (p == -1) { p = es.lastIndexOf('%20'); if (p > -1) { p = p+2; } } else { p = p+1; } if (p == -1) { p = 0; } es = t.substring(p,pe); t = t.replace(es,e); } return t; }
	function rot13init() { var m = []; var s = "abcdefghijklmnopqrstuvwxyz",i; for (i = 0 ; i < s.length ; i++) { m[s.charAt(i)] = s.charAt((i+13)%26); } for (i = 0 ; i < s.length ; i++) { m[s.charAt(i).toUpperCase()] = s.charAt((i+13)%26).toUpperCase(); } return m; }
	function str_rot13(a,m) { var s = ""; for (var i = 0 ; i < a.length ; i++) { var b = a.charAt(i); s += (b>='A' && b<='Z' || b>='a' && b<='z' ? m[b] : b); } return s; }
	function CL_emailObfuscation() { if (!document.getElementsByTagName) { return false; } var lnks = document.getElementsByTagName('a'); var m = rot13init(), i = 0; function geo_decode(a) { var href = a.getAttribute('href'); var d = href.replace(/.*geo=([a-z0-9._%\-]+)\+([a-z0-9._%\-]+)\+([a-z.]+)/i, '$1' + '@' + '$2' + '.' + '$3'); if (href != d) { var p, s = '', e = d, l, t; p = d.indexOf('&'); if (p > -1) { e = d.substr(0,p); s = d.substr(p+1); s = s.replace('geo_s=','?subject='); } e = str_rot13(e,m); s = CL_emailExpand(s,e); a.setAttribute('href','mailto:' + e +s); l = a.innerHTML; a.innerHTML = CL_emailExpand(l,e); t = a.getAttribute('title'); if (t) { t = CL_emailExpand(t,e); a.setAttribute('title',t); } } } for (i; i < lnks.length ; i++) { var href = lnks[i].getAttribute('href'); if (href && href.indexOf('geo=') > -1) { geo_decode(lnks[i]); } } }

	// JAVASCRIPT : CLEAR AND SET SEARCH INPUT
	// ClassNames: 'search_input_active' and 'search_input'
	function CL_searchInputFocus() { if (document.searchForm.searchInput.value == searchInitialValue) { document.searchForm.searchInput.value = ""; document.searchForm.searchInput.className = "search_input_active"; } }
	function CL_searchInputFocusModule() { if (document.searchFormModule.searchInputModule.value == searchInitialValueModule) { document.searchFormModule.searchInputModule.value = ""; document.searchFormModule.searchInputModule.className = "search_input_active"; } }
	function CL_searchInputSet() { if (document.searchForm || document.searchFormModule) { var m1 = '', m2 = '', v = ''; if (arguments[0] === true) { m1 = 'Module'; m2 = '_module'; v = searchInitialValueModule; } else { v = searchInitialValue; } var d = navigator.userAgent.toLowerCase(); if (d.indexOf('safari') > -1) { var s = document.getElementById('searchInput'+m1); s.type = 'search'; s.setAttribute('results','0'); s.setAttribute('placeholder',v); s = document.getElementById('searchSubmit'+m1); s.style.display = 'none'; s = document.getElementById('search'+m2); s.style.background = 'none'; } 
		else { if (m1 == 'Module' && document.searchFormModule.searchInputModule) { if (document.searchFormModule.searchInputModule.value == "") { document.searchFormModule.searchInputModule.value = v; document.searchFormModule.searchInputModule.className = "search_input"; } } else if (document.searchForm.searchInput) { if (document.searchForm.searchInput.value == "") { document.searchForm.searchInput.value = v; document.searchForm.searchInput.className = "search_input"; } } } } }
	function CL_searchInputSetModule() { CL_searchInputSet(true); }
	// addEvent(window,'load',CL_searchInputSet);

	// JAVASCRIPT: DROPDOWN
	// ClassName: 'over'
	var menuname = "languages";
	function CL_startList() { if (document.getElementById(menuname)) { var r = document.getElementById(menuname); for (var i=0; i<r.childNodes.length; i++) { var n = r.childNodes[i]; if (n.nodeName=="LI") { n.onmouseover=function() { this.className+=" over"; }; n.onmouseout=function() { this.className=this.className.replace("over", ""); }; } } } }
	//addEvent(window,'load',CL_startList);
	
	// JAVASCRIPT : TOOLTIP
	// Based on code by Craig Erskine (grayg.com), Multi-tag support by James Crooke (www.cj-design.com), Inspired by code from Travis Beckham (www.squidfingers.com / www.podlob.com)
	var tt_tags = "a,label,div,img", tt_x = 0, tt_y = 15, tt_s = null, tt_e = null;	
	CL_tooltip = { name : "tooltip", offsetX : tt_x, offsetY : tt_y, tip : null };	
	CL_tooltip.init = function () { if (!document.getElementById) { return; } if (tt_s !== null) { return; } tt_s = true; var tu = "http://www.w3.org/1999/xhtml"; var tc = document.getElementById(this.name); 
		if (!tc) { tc = document.createElementNS ? document.createElementNS(tu, "div") : document.createElement("div"); tc.setAttribute("id", this.name); document.getElementsByTagName("body").item(0).appendChild(tc); } this.tip = document.getElementById(this.name); if (this.tip) { document.onmousemove = function(event) { CL_tooltip.move(event); }; } var a, tt, e; var el = tt_tags.split(","); for(var j = 0; j < el.length; j++) { if (tt_e === null) { e = document.getElementsByTagName(el[j]); } else { e = document.getElementById(tt_e).getElementsByTagName(el[j]); } if(e) { for (var i = 0; i < e.length; i ++) { a = e[i]; tt = a.getAttribute("title"); if(tt) { a.setAttribute("tiptitle", tt); a.removeAttribute("title"); a.removeAttribute("alt"); a.onmouseover = function() { CL_tooltip.show(this.getAttribute('tiptitle')); }; a.onmouseout = function() { CL_tooltip.hide(); }; } } } } };
	CL_tooltip.move = function (e) { var x=0, y=0; if (document.all) { x = (document.documentElement && document.documentElement.scrollLeft) ? document.documentElement.scrollLeft : document.body.scrollLeft; y = (document.documentElement && document.documentElement.scrollTop) ? document.documentElement.scrollTop : document.body.scrollTop; x += window.event.clientX; y += window.event.clientY; } else { x = e.pageX; y = e.pageY; } this.tip.style.left = (x + this.offsetX) + "px"; this.tip.style.top = (y + this.offsetY) + "px"; };
	CL_tooltip.show = function (t) { if (!this.tip) { return; } t = t.replace('[','<strong>'); t = t.replace(']','</strong>'); t = t.replace(/ - /g,'<br />'); this.tip.innerHTML = t; this.tip.style.display = "block"; };
	CL_tooltip.hide = function () { if (!this.tip) { return; } this.tip.innerHTML = ""; this.tip.style.display = "none"; };
	CL_tooltipStart = function () { CL_tooltip.init (); };
	// addEvent(window,'load',CL_tooltipStart);
		
	// JAVASCRIPT : EXPAND / COLLAPSE
	// ClassNames: 'expandcollapse', 'expand' and 'expanded'
	// Required: Prototype.js
	function CL_expandCollapse() { var ttls = $$('#content .expandcollapse'); var txts = $$('#content .expand'); txts.each (function(txt){ txt.hide(); }); ttls.each (function(ttl) { ttl.onclick = function(ttl)	{ var obj = this; if (this.tagName == "SPAN") { obj = this.parentNode; } if (obj.next('.expand')) { var nt = obj.next('.expand'); if (nt.getStyle('display') == 'none' || nt.getStyle('display') === null) { nt.show(); this.addClassName('expanded'); } else { nt.hide(); this.removeClassName('expanded'); } } }; }); }
	// addEvent(window,'load',CL_expandCollapse);
	
	// JAVASCRIPT : MODULE TOGGLE LIST	
	// Required: Prototype.js
	function CL_moduleToggleList(obj) { var l = $(obj).next('ul'); if ($(l)) { if ($(l).getStyle('display') == 'none') { $(l).setStyle({display:'block'}); $(obj).update('-'); } else { $(l).hide(); $(obj).update('+'); } } }


	// JAVASCRIPT : GET WINDOW DIMENSIONS

	function getViewportHeight() {
		if (window.innerHeight!=window.undefined) { return window.innerHeight; }
		if (document.compatMode=='CSS1Compat') { return document.documentElement.clientHeight; }
		if (document.body) { return document.body.clientHeight; }
		return window.undefined; 
	};
	
	function getViewportWidth() {
		if (window.innerWidth!=window.undefined) { return window.innerWidth; }
		if (document.compatMode=='CSS1Compat') { return document.documentElement.clientWidth; }
		if (document.body) { return document.body.clientWidth; }
		return window.undefined; 
	};
	
	
	// JAVASCRIPT : RESIZE CONTENT
	if (!window.resize) { var resize = true; }
	function CL_resizeContent() {
		if (resize === true && document.getElementById('page') && document.getElementById('content') && document.getElementById('content_inner')) {
			var ciH = document.getElementById('content_inner').offsetHeight+54;
			var cN = Math.ceil(ciH/121);
			if (cN > 3) {
				var cH = (cN*121)-20;
				document.getElementById('content').style.height = cH+'px';
			} else {
				if (document.getElementById('page_tools')) { document.getElementById('page_tools').style.display = 'none'; }
			}
		}	
	}
	
	addEvent(window,'load',CL_resizeContent);
