var $e;
var engine = new Class({
	
	Implements: [Events, Options],

	options: {
		browser: {
			name: Browser.Engine.name,
			version: Browser.Engine.version
		}
	},
	
	initialize: function(options) {
		this.setOptions(options);
        
        if ($chk($('validationImageSrc'))) {
            refreshCaptcha();
        }
		
		this.css();
		this.add();
	},
	
	css: function() {
		
		switch(this.options.browser.name) {
			case 'trident':
				switch(this.options.browser.version) { // IE version -2 (next time, just name it 8 for IE8 Microsoft.
					case 4: // IE6
						new Element('link', {
							'rel': 'stylesheet',
							'type': 'text/css',
							'href': '/content/default/templates/content_wd/dutch/style/style.ie.css'
						}).inject(document.head);
						break;
					case 5: // IE7 
						new Element('link', {
							'rel': 'stylesheet',
							'type': 'text/css',
							'href': '/content/default/templates/content_wd/dutch/style/style.ie.css'
						}).inject(document.head);
						break;
					case 6: // I think you got it by now.
					
						break;
				}
				break;
		}
	},
	
	add: function() {
		$(document.body).getElements('input').each(function(i) {
			if ($chk(i.get('title'))) {
				new OverText(i, {
					poll: true,
					pollInterval: 1000
				});
			}
		});
		
		switch(this.options.browser.name) {
			case 'webkit':
			case 'gecko':
				$(document.body).getElements('div[class*=roundedCorners]').each(function(el) {
					var $radius = el.get('class').match(/radius\[\'([0-9]{1,2})\'\]/i);
					
					if ($chk($radius)) {
						el.setStyles({'-webkit-border-radius': $radius[1] + 'px', '-moz-border-radius': $radius[1] + 'px', '-khtml-border-radius': $radius[1] + 'px', 'border-radius': $radius[1] + 'px'});
					} else {
						el.setStyles({'-webkit-border-radius': '3px', '-moz-border-radius': '3px', '-khtml-border-radius': '3px', 'border-radius': '3px'});
					}
				});
				break;
		}
	}
	
});

window.addEvent('domready', function() {
	$e = new engine();
});

// Analytics
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-3768916-1']);
_gaq.push(['_trackPageview']);

(function() {
  var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
  ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
  var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
