(function() {
	
	if (document.getElementById) window.onerror = function(eee) {
		 //return true;
	};
	
	// Checks if MooTools library is loaded successfully and works!
	if ("undefined" === typeof MooTools) {
		alert("Error!\n\n\tThe page could not load javascript core library.\n\tPlease reload the page and try again.");
		return;
	}
	
	//if(window.ie6) window.addEvent('domready', fixPNG);
	window.addEvent("domready", initTemplate);
	
	function initTemplate() {
		// Adds analytic's event tracker for rajman.org links:
		document.getElements("a[href=http://rajman.org]").addEvent("click", function() {
			_gaq.push(
					['rajman._trackEvent', 'Customers` Portals', 'click', 'abfakhorasan.ir clicks']
			);
		});
		
		// Removes rss wrapper in top menu if there is no content in it:
		if($("TDW_rss_wrapper") && $("TDW_rss_wrapper").get("html").trim() == "") {
			$("TDW_rss_wrapper").dispose();
		}
		
		// Removes extra <br/> tags in blog pagination:
		if(document.getElement(".TDW_blogPagination")) {
			document.getElement(".TDW_blogPagination").getAllNext().dispose();
		}
		
		// Loads header image after page load:
		new Asset.image(template_url + "/images/header.jpg", {
			onload: function(img) {
				$$("#TDW_header_wrapper, #TDW_container_wrapper").set({
					"style": "background-image: url('" + img.get("src") + "')"
				});
				
				$("TDW_topMenu_wrapper").set({
					"opacity": 0.0,
					"morph": {duration: 1000}
				}).morph({"opacity": 1, "margin-top": 0});
			}
		});
		
		if(isRemote) {
			var src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
			new Asset.javascript(src);
		}
	}

})();
