var sysdir, imgdir, isie;
var found = false;

var mooRules = {
	//body' : function(){
//		if (window.ActiveXObject) isie = true;
//		//sysdir = $('sysdir').src;
//		//imgdir = $('imgdir').src;
//		var layout = new Layout(720, 510, 800, 1200, "nofl");
//		if (isie) layout.constrain('head', 'container');
//		if ($('big') && $('small')) layout.change('big', 'small');
//		window.onresize = function() {
//			if ($('big') && $('small')) layout.change('big', 'small');
//			if (isie) layout.constrain('head', 'container');
//		}
//	},
//	
	'#msg' : function(element){
		Element.cleanWhitespace(element);
	},
	'a.hide' : function(element){
		Element.block(element);
		var item = $(element.rel);
		item.MooBlock = new fx.MooBlock(item, element, "show", "hide");
		if (item.offsetHeight == 0) {
			Element.addClassName(element, "show");
			element.title = "show";
		}
		if (item.offsetHeight > 0) item.style.height = "1%";
		element.onclick = function(){
			item.MooBlock.toggle();
		}
	},
	'#WeatherSearchForm' : function(element) {
		element.onkeydown = function(){
			if ($F('city') != "" && $F('city') != null && $F('city').length > 1 ) this.submit;
			else return false;
		}
	},

	'#WeatherSearchForm' : function(form) {
		form.onsubmit = function(){
			var url = this.action + "?ajax=true";
			var parameters = Form.serialize(this);
			new Loader2('sWeather', 'anim_ok', url, parameters);
			return false;
		}
	}
};
Attitude.append(mooRules);

var tableRules = {
		'div.dTreeNode a' : function(element) {
		//if(element.href.indexOf("/ajax") > 0) element.href = element.href.replace("/ajax", "");
		element.onclick = function(){
			if (this.getAttribute("urlid")!=null) {
			var parameters = moo.serializeFilters();
			var url =this.getAttribute("urlid") + "&ajax=true";
			//this.href = "javascript:void(0)";
			new Loader('loader', 'anim_nok ', url, parameters);
			}
		}
	}

};
Attitude.append(tableRules);
//main moo class, to support behaviour rules
var moo = {
	writeMsg: function(message, type){
		if ($('msg').childNodes[0]) {
			Element.niceRemove($('msg').childNodes[0]);
		}
		new Addition('p', message, $('msg'),{cssStyle: type, onComplete: function(){
			$('msg').style.height = $('msg').offsetHeight+"px";
			$('msg').style.overflow = 'hidden';
		}});
	},

	closeMsg: function(){
		$('msg').style.height = "1%";
		if ($('msg').childNodes[0]) {
			Element.niceRemove($('msg').childNodes[0]);
		}
	},

	checkmod: function(element){
		if (element.previousSibling.checked == true){
			element.previousSibling.checked = false;
			Element.removeClassName(element.parentNode, "oneChoiceSel");
		}
		else {
			element.previousSibling.checked = true;
			Element.addClassName(element.parentNode, "oneChoiceSel");
		}
	},

	serializeFilters: function(){
		if ($('filter')) var parameters = Form.serialize($('filter'));
		else var parameters = null;
		return parameters;
	},

	checkBoxes: function(checkboxes, found){
		for (i=0;i<checkboxes.length;i++){
			if (found == false) checkboxes[i].checked = true;
			else checkboxes[i].checked = false;
		}
	},

	ajaxSubmit: function(form, ty){
		var url = form.action + "/?ajax=true";
		var parameters = Form.serialize(form);
		new Loader('loader', ty, url, parameters, form, true);
	}

};