var glob=Array();
function getAbsolutePos(el)
{
	var r = { x: el.offsetLeft, y: el.offsetTop };
	if (el.offsetParent)
	{
		var tmp = getAbsolutePos(el.offsetParent);
		r.x += tmp.x;
		r.y += tmp.y;
	}
	return r;
}
function windowHeight()
{
	var windowHeight;
	if (self.innerHeight) {    // all except Explorer
	     windowHeight = self.innerHeight;
	 } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
	     windowHeight = document.documentElement.clientHeight;
	 } else if (document.body) { // other Explorers
	     windowHeight = document.body.clientHeight;
	 }
	 return(windowHeight);
}
function include_once( filename )
{
	var headID = document.getElementsByTagName("head")[0];
	var newScript = document.createElement('script');
	newScript.type = 'text/javascript';
	newScript.src = filename;
	headID.appendChild(newScript);
}
function call_user_func (cb, parameters)
{
    var func;
    if (typeof cb == 'string') {
        if (typeof this[cb] == 'function') {
            func = this[cb];
        } else {
            func = (new Function(null, 'return ' + cb))();
        }
    } else if (cb instanceof Array) {
        func = eval(cb[0]+"['"+cb[1]+"']");
    }

    if (typeof func != 'function') {
        throw new Error(func + ' is not a valid function');
    }

    return func.apply(null, Array.prototype.slice.call(arguments, 1));
}
function get_html(tpl,xml) // заменяем в шаблоне (tpl) ::имя_поля:: на значение этого поля из xml=(<field id=имя_поля>значение поля</field>)
{
	var arr=$("field",xml);
	for(var i=0;i<arr.length;i++)
	{
		tpl=tpl.replace(new RegExp("::"+$(arr[i]).attr("id")+"::",'g'),$(arr[i]).html());
	}
	tpl=tpl.replace(new RegExp("::*[A-Za-z0-9.\-_]*::",'g'),""); // убираем пустые поля (::name::)
	return(tpl);
}
function file_del(file)
{
glob['del_id']=file;
	$.post("form.php",{func:"del",file:glob[file]},file_del2);
}
function file_del2(file)
{
	$("#"+glob['del_id']).remove();
}
function find_focus(id,str)
{
	if ($("#"+id).val()==str.replace(new RegExp("_",'g')," "))
	{
		$("#"+id).val('');
	}
}
function find_blur(id,str)
{
	if ($("#"+id).val()=="")
	{
		str=str.replace(new RegExp("_",'g')," ");
		$("#"+id).val(str);
	}
}
