function $(id){
	return document.getElementById(id);
}

function dumpProps(obj, obj_name){
	var result = "";
	for (var i in obj){
		var val="-------";
		try{
			if(typeof obj[i] == 'function')
				val = "F u n c t i o n - " + i;
			else{
				if(typeof obj[i] == 'object')
					val =i+":"+"O b j e c t";
				else
					val = obj[i];
			}
		}catch(ex){ }
		result+=obj_name + "." + i + " = " + val + "\n";
	}
	result+="\n";
	return result;
}
String.prototype.trim=function(){
	return this.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
}

function Form(form){
  this.form = form;
}

Form.prototype={
	// функция init принимает 3 входных параметра;
	// validate - функция, срабатывющая по событию формы onsubmit;
	// submit - функция вызываемая из validate, если все норм	
	// onerror - функция вызываемая если не все норм: при ошибке.
	init: function(validate, submit, onerror){
		this.validate = validate;
		this.submit = submit;
		this.onerror = onerror;

		this.enabled = true; // включена
		
		var _this = this, listener = function(){			
			_this.process();
			var ev = arguments[0] || window.event;
			ev.preventDefault ? ev.preventDefault() : ev.returnValue = false;
		};
		if(this.form.addEventListener)
			this.form.addEventListener('submit', listener, false);
		// для IE
		//@cc_on this.form.attachEvent('onsubmit', listener);
	},
	
	process: function(){
		if(this.enabled){
			this.enabled = false;
			this.validate();
		}
	},
	message: function(text){
		//alert(text);
	}
};

function getXMLDoc(path){
	var xmlDoc=null;
	try //Internet Explorer
	{
		xmlDoc=new ActiveXObject("Microsoft.XMLDOM");		
	}
	catch(e)
	{
		try //Firefox, Mozilla, Opera, etc.
		{
			xmlDoc=document.implementation.createDocument("","",null);			
		}
		catch(e)
		{
			alert(e.message);
			return null;
		}
	}
	xmlDoc.async=false;
	xmlDoc.load(path);
	return xmlDoc;
}