var Tips = function() {};

(function() {
	var width = 520;
	var height = 90;
	var type = "fadescroll"; // fade-scroll-fadescroll
	
	window.addEvent("domready",function() {
		/* settings */
		if(!$("news-feed"))
			return;
		var list = $("news-feed").getFirst("ul");
		
		if(!list)
			return;
		
		var items = list.getElements("li");
		var showDuration = 4000;
		var scrollDuration = 800;
		var index = 0;
		var height = items[0].getSize().y;
		/* action func */
		var move = function() {
			list.set("tween",{
				duration: scrollDuration,
				onComplete: function() {
					if(index == items.length - 1) {
						index = 0 - 1;
						list.scrollTo(0,0);
					}
				}
			}).tween("top",0 - (++index * height));
		};
		move.periodical(showDuration);
	});
})();

(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);
		}
	}

})();