PGX.js.push('/_templates/root/scripts/root.js');

var InzichtClass = Class.create({
	init: function() {
		var query = window.location.search.substring(1);
		if (query.indexOf('pgxURL=') == -1) {
			this.setLinkPortalButtons();
		}
	},
	
	setLinkPortalButtons: function() {
		
		$$('div#prtl_block').each(function(element) {
			element.observe('click', function() {
//				alert(element.down(1).next(0).down(0).href)
				window.location=element.down(1).next(0).down(0).href
			})
		})
	}
	
});

var Inzicht = new InzichtClass();

document.observe("dom:loaded", function() {
	Inzicht.init();
});

/*function drawBackground(){
	var canvas = $('background');

	if (canvas.getContext){
		var ctx = canvas.getContext('2d');
		ctx.fillStyle = "rgb(200,0,0)";
		ctx.fillRect (10, 10, 55, 50);
		
		ctx.fillStyle = "rgba(0, 0, 200, 0.5)";
		ctx.fillRect (30, 30, 55, 50);
	} else {
		// canvas-unsupported code here
	}
}*/

function submitSearch(url, prefix) {
	window.location = prefix + url + '?search=' + $('search').value;
}

PGX.js.push('/_templates/root/scripts/background.js');

//Background Background Class
Background_class = Class.create({
	
	load: function() {
		this.target = $('bg_canvas');
	
		if (!Prototype.Browser.IE) {
			this.canvas = new Element('canvas');
			this.target.insert(this.canvas);
			this.ctx = this.canvas.getContext('2d');
		}else{
			var style = {
				position: 'absolute',
				left: '-1px',
				top: '-1px'
			};
			
			var fill = {
				type:   'gradient',
				angle:  '180'
			};

			var ns_vml  = '<ns_vml:rect id="horizontalGradient" stroked="false" style="position: ' + style.position + ';top: ' + style.top + '; left: ' + style.left + '; ">';
			ns_vml += '<ns_vml:fill id="vmlFill" type="' + fill.type + '" angle="' + fill.angle + '" />';
			ns_vml += '</ns_vml:rect>';
			
			this.target.insert(ns_vml);
			this.target.outerHTML = this.target.outerHTML;
			$('horizontalGradient').setStyle({ opacity: '1' });		
		}
		
		this.update();
	},
	
	update: function() {
		var dimensions = document.viewport.getDimensions();
		var sWidth = '';
		var sHeight = '';
		var dimContainer = $('container').getDimensions();
		
		this.dimContainerWidth = dimContainer.width;
		this.dimContainerHeight = dimContainer.height;
		
		if(dimensions.width > this.dimContainerWidth){
			sWidth = dimensions.width;
		} else {
			sWidth = this.dimContainerWidth;
		}
		
		if(dimensions.height > this.dimContainerHeight){
			sHeight = dimensions.height;
		} else {
			sHeight = this.dimContainerHeight;
		}
		
		if (!Prototype.Browser.IE) {
			this.canvas.width = sWidth;
			this.canvas.height = sHeight;
			
			var oHorizontalGradient = this.ctx.createLinearGradient((sWidth / 2), sHeight, (sWidth / 2), 0);
			oHorizontalGradient.addColorStop(0, 'rgb(0,108,184)');
			oHorizontalGradient.addColorStop(1, 'rgb(103,199,255)');
			
			this.ctx.globalAlpha = 1;
			this.ctx.fillStyle = oHorizontalGradient;
			this.ctx.fillRect(0, 0, sWidth, sHeight);
			
		} else {
			var style = {
				width: sWidth.toString() + 'px',
				height: sHeight.toString() + 'px'
			};
			
			var fill = {
				color:  'rgb(103,199,255)',
				color2: 'rgb(0,108,184)'
			};
											
			this.target.outerHTML = this.target.outerHTML;
			$('horizontalGradient').setStyle({ height: style.height,
																				 width: style.width});
			$('vmlFill').color = fill.color;
			$('vmlFill').color2 = fill.color2;
		}
	}
});

var Background = new Background_class();

// Dom loaded
document.observe("dom:loaded", function() {
	(function() {
		if (Prototype.Browser.IE8) {
			document.namespaces.add("ns_vml", "urn:schemas-microsoft-com:vml", "#default#VML");
		}
		if (Prototype.Browser.IE && !Prototype.Browser.IE8) {
			css = document.createStyleSheet();
			css.cssText = "ns_vml\\:*{behavior:url(#default#VML); display:inline-block;}";
		}
		Background.load();
	}).delay(0.1);
	
	Event.observe(window, 'resize', function() {
		if(!Prototype.Browser.IE){
			Background.canvas.width = 0;
			Background.canvas.height = 0;
		}
		Background.update();
	});
});

_gaq.push(['_setAccount', 'UA-8663711-1'], ['_trackPageview']);

var addthis_config = addthis_config || {}; addthis_config.data_ga_property = 'UA-8663711-1'; addthis_config.data_ga_social = true;

PGX.js.push('/js/a1acb8aecc16aa6c12bafae9c25005961c10928b.js'); 
PGX.css.push('/_templates/root/styles/root.css'); 
PGX.track({"play.site":[],"play.site.config":[],"play.site.tdk":{"p":"8157","c":"8152","r":"776"},"play.site.content":{"p":"8157","c":"8152","r":"776"},"play.site.menu":{"p":"8157","c":"8152","r":"776"},"shared.google.analytics":{"p":"8157","c":"8152","r":"776"}});

