/*var Nicole = {
	require: function(libraryName) {
		document.write('<script type="text/javascript" src="' + libraryName + '"></script>');
	},

	load: function() {
		$A(document.getElementsByTagName("script")).findAll( function(s) {
			return (s.src && s.src.match(/Nicole\.js(\?.*)?$/))
		}).each( function(s) {
			var path     = s.src.replace(/Nicole\.js(\?.*)?$/,'');
			var includes = s.src.match(/\?.*load=([a-z,]*)/);
			(includes ? includes[1] : 'ajax/jquery,ajax/ajaxfunctions,thickbox').split(',').each(
				function(include) { Nicole.require(path + include + '.js') });
		});
	}
}

Nicole.load();
*/

document.write('<script type="text/javascript" src="/data/scripts/ajax/jquery.js"></script>');
document.write('<script type="text/javascript" src="/data/scripts/ajax/ajaxfunctions.js"></script>');
document.write('<script type="text/javascript" src="/data/scripts/thickbox.js"></script>');

function cssPreloadImages() {
	var i, j, img;
	for (i=0; i<document.styleSheets.length; i++) {
		var pos = document.styleSheets[i].href.lastIndexOf("/");
		var cssDir = (pos != -1) ? document.styleSheets[i].href.substring(0, pos + 1) : "";
		var rules = document.styleSheets[i].cssRules ? document.styleSheets[i].cssRules : document.styleSheets[i].rules;
		for (j=0; j<rules.length; j++) {
			var style = rules[j].style;
			if (style && style.backgroundImage.toLowerCase().substr(0,4) == "url(") {
				var filename = style.backgroundImage.substring(4, style.backgroundImage.length - 1);
				if (filename.indexOf("http://") != 0 && filename.indexOf("/") != 0)
					filename = cssDir + filename;
				var img = new Image();
				img.src = filename;
			}
		}
	}
}

if (window.attachEvent) {
	// IE
	window.attachEvent("onload", cssPreloadImages);

} else {
	// DOM
	window.addEventListener("load", cssPreloadImages, false);

}

function confirmedRedirect(question, url) {
    if(confirm(question)) { window.location.href = url; }
}

function init() {
	var loginForm = $('#loginForm');

	if (loginForm.length) {
		loginForm[0].onsubmit = function() {
			ajaxPostUpdate('loginForm', '/belepes', 'TB_window', false);
			return false;
		}
	}
}

window.onload = init;