
var hd_js_tools_orig_object = new Object();
var jst = hd_js_tools_orig_object;


jst._init = {
    
    apply_anchor: function(section_name) {
        if (typeof hd_js_tools_orig_object[section_name].anchor=="function") {
            hd_js_tools_orig_object[section_name] = hd_js_tools_orig_object.method.object(hd_js_tools_orig_object[section_name].anchor,hd_js_tools_orig_object[section_name]);
        }
    },
    
    apply_anchors: function() {
        for (var ind in hd_js_tools_orig_object) {
            this.apply_anchor(ind);
        }
    }
    
};


jst.data = {
    
    dump: function(data,maxdepth,filter,filter_maxdepth,depth) {
        var temp=[],str="",pre="",tab="       ";
        maxdepth = (typeof maxdepth=="number")?maxdepth:3;
        depth = depth?depth:1;
        if (typeof filter=="string") {
            filter = new RegExp("^"+hd_js_tools_orig_object.text.regex_escape(filter).replace(/\\\*/g,".*").replace(/\\\?/g,".")+"$");
        }
        for (var i=0; i<depth; i++) {
            pre += tab;
        }
        switch (typeof data) {
            case "boolean":
                str += data?"true":"false";
            break;
            case "number":
                str += data;
            break;
            case "string":
                str += "'"+data.replace(/\\/g,"\\\\").replace(/'/g,"\\'")+"'";
            break;
            case "object":
                var element_dump,multiline;
                if (data===null) {
                    str += "null";
                } else if (typeof data==='object' && typeof data.length==='number' && typeof data.splice==='function') {
                    str += "/*array*/ [";
                    temp = [];
                    for (var i=0; i<data.length; i++) {
                        element_dump = this.dump(data[i],maxdepth,filter,filter_maxdepth,depth+1);
                        multiline = (element_dump.indexOf("\n")!=-1);
                        temp[temp.length] = "\n"+(multiline?"\n":"")+pre+tab+"/* "+i+" => */ "+element_dump;
                    }
                    str += temp.join(",")+"\n"+pre+"]";
                } else if (maxdepth>=depth || maxdepth==0) {
                    str += "/*object*/ {";
                    temp = [];
                    for (var index in data) {
                        if (filter && (!filter_maxdepth || depth<=filter_maxdepth) && ((typeof(filter)=="function")? (!filter(index)) : (!filter.test(index)) ) ) {
                            continue;
                        }
                        try {
                            element_dump = this.dump(data[index],maxdepth,filter,filter_maxdepth,depth+1);
                            multiline = (element_dump.indexOf("\n")!=-1);
                            temp[temp.length] = "\n"+(multiline?"\n":"")+pre+tab+"'"+index+"': "+element_dump;
                        } catch (e) {
                            temp[temp.length] = "\n"+pre+tab+"'"+index+"': null /* error! */";
                        }
                    }
                    str += temp.join(",")+"\n"+pre+"}";
                } else {
                    str += "/*object*/ 'rec!'";
                }
            break;
            case "function":
                str += "/*function*/\n\n'";
                str += data[index].toString();
                str += "\n";
            break;
            default:
                str += "null";
        }
        return str;
    },
    
    search: function(obj,value,parents) {
        if (typeof obj!="object") {
            return false;
        }
        parents = parents?parents:[];
        var sub_parents;
        var sub_result;
        for (var ind in obj) {
            sub_parents = parents.concat([ind]);
            if (obj[ind]==value) {
                return sub_parents;
            } else if (sub_result=this.search(obj[ind],value,sub_parents)) {
                return sub_result;
            }
        }
        return false;
    },
    
    search_index: function(obj,index,parents) {
        if (typeof obj!="object") {
            return false;
        }
        parents = parents?parents:[];
        var sub_parents;
        var sub_result;
        for (var ind in obj) {
            sub_parents = parents.concat([ind]);
            if (ind==index) {
                return sub_parents;
            } else if (sub_result=this.search_index(obj[ind],index,sub_parents)) {
                return sub_result;
            }
        }
        return false;
    },
    
    get_sub: function(obj,sub_indexes) {
        var element = obj;
        for (var i=0; i<sub_indexes.length; i++) {
            if (typeof element!="object") {
                break;
            }
            element = element[sub_indexes[i]];
        }
        return element;
    },
    
    flush: function(data,count,type) {
        var data_text = this.dump(data);
        var sep = "\n";
        if (type=="c" || type=="char" || type=="chars") {
            sep = false;
        }
        var splitted = sep?jst.text.cut(data_text,sep,count):jst.text.cut(data_text,count);
        jst.array.each(
            splitted,
            function(item,index,refs){
                if (!confirm(item)) {
                    refs.breaker[0]=true;
                }
            }
        );
    }
    
};


jst.text = {
    
    htmlstrlen: function (str) {
        return str.replace(/&(\w+|#\d+);/g,"_").length;
    },
    
    htmlsubstr: function(str,start_pos,length) { // !!!
        if (typeof length=="undefined") {
            length = str.length-start_pos;
        }
        var result;
        var search_str = str;
        var results = [];
        for (var index,true_pos=0,next; (index=search_str.indexOf("&"))!=(-1); ) {
            true_pos += index;
            search_str = search_str.substr(index);
            next = search_str.replace(/^&(\w+|#\d+);/,"");
            if (search_str==next) {
                search_str = search_str.substr(1);
            } else {
                if (true_pos>=start_pos&&true_pos<start_pos+length) {
                    results[results.length] = [true_pos-start_pos,search_str.substr(0,search_str.length-next.length)];
                }
                search_str = next;
            }
            true_pos++;
        }
        result = str.replace(/&(\w+|#\d+);/g,"_").substr(start_pos,length);
        for (var i=results.length-1; i>=0; i--) {
            result = result.substr(0,results[i][0])+results[i][1]+result.substr(results[i][0]+1);
        }
        return result;
    },
    
    htmlspecialchars: function (str) {
        return str.toString().replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;");
    },
    
    trim: function(str,type) {
        switch (type) {
            case "l":
            case "left":
                return str.replace(/^\s+/g,"");
            break;
            case "r":
            case "right":
                return str.replace(/\s+$/g,"");
            break;
            case "both":
            default:
                return str.replace(/^\s+|\s+$/g,"");
        }
    },
    
    cut: function(str,delim,count) {
        var delim_str = "";
        if (!delim) {
            delim = false;
            count = 1;
        } else if (typeof delim=="number") {
            count = delim;
            delim = false;
        } else if (typeof delim=="string") {
            delim_str = delim;
            delim = new RegExp(hd_js_tools_orig_object.text.regex_escape(delim));
        } else {
            delim_str = "\n";
        }
        if (!count) {
            count = 1;
        }
        var elements = [];
        if (delim) {
            var pieces = str.split(delim);
            var pc = Math.floor(pieces.length/count);
            for (var i=0; i<pc; i++) {
                elements[elements.length] = pieces.slice(i*count,(i+1)*count).join(delim_str);
            }
            if (pieces.length>pc*count) {
                elements[elements.length] = pieces.slice(pc*count).join(delim_str);
            }
        } else {
            var pc = Math.floor(str.length/count);
            for (var i=0; i<pc; i++) {
                elements[elements.length] = str.substring(i*count,(i+1)*count);
            }
            if (str.length>pc*count) {
                elements[elements.length] = str.substring(pc*count);
            }
        }
        return elements;
    },
    
    split: function(str,delim,show_empty,show_matches) {
        if (!show_empty && !show_matches) {
            return str.split(delim);
        }
        if (typeof delim=="string") {
            delim = new RegExp(this.regex_escape(delim),"g");
        }
        var matches = str.match(delim);
        var pieces = [];
        var start_pos = 0;
        var search_text = str;
        for (var i=0,pos; i<matches.length; i++) {
            pos = search_text.indexOf(matches[i]);
            pieces[pieces.length] = search_text.substr(0,pos);
            if (show_matches) {
                pieces[pieces.length] = matches[i];
            }
            search_text = search_text.substr(pos+matches[i].length);
        }
        pieces[pieces.length] = search_text;
        if (!show_empty) {
            for (var i=pieces.length-1; i>=0; i--) {
                if (pieces[i]=="") {
                    pieces.splice(i,1);
                }
            }
        }
        return pieces;
    },
    
    regex_escape: function(str) {
        return str.replace(/([\/\\\.\*\?\-\+\[\]\{\}\(\)])/g,"\\$1");
    }
    
};


jst.array = {
    
    each: function(arr,func,start,end,keep_empty) {
        start = (typeof start=="number")?start:0;
        end = (typeof end=="number")?end:arr.length;
        var result = [];
        var breaker = [false];
        var refs = {breaker:[false],data:{}};
        for (var i=start,res; i<end; i++) {
            refs.breaker[0] = false;
            res = func(arr[i],i,refs);
            if (refs.breaker[0]) {
                break;
            }
            if (!keep_empty || res!==null) {
                result[result.length] = res;
            }
        }
        return result;
    }
    
};


jst.method = {
    
    _start_regex: /^\s*function\s*([a-zA-Z_\$][a-zA-Z_0-9\$]*\s*)?\(((\s*[a-zA-Z_\$][a-zA-Z_0-9\$]*\s*,)*\s*[a-zA-Z_\$][a-zA-Z_0-9\$]*\s*)?\)\s*\{\s*/,
    _end_regex: /\s*\}\s*$/,
    
    code: function(func) {
        var code = func.toString();
        code = code.replace(this._start_regex,"").replace(this._end_regex,"")
        return code;
    },
    
    params: function(func) {
        var code = func.toString();
        var param_list = code.substring(code.indexOf("(")+1,code.indexOf(")")).replace(/ /g,"");
        if (param_list=="") {
            return [];
        }
        return param_list.split(",");
    },
    
    create: function(code,params) {
        params = params?params:[];
        var param_list = params.join('","');
        if (params.length>0) {
            param_list = '"'+param_list+'",';
        }
        var res;
        eval('res = new Function('+param_list+'"'+code.replace(/"/g,'\\"').replace(/\r?\n/g," ")+'");');
        return res;
    },
    
    copy: function(func) {
        var code = this.code(func);
        var params = this.params(func);
        return this.create(code,params);
    },
    
    object: function(func,obj) {
        var res_obj = this.copy(func);
        if (typeof obj=="object") {
            for (var ind in obj) {
                res_obj[ind] = obj[ind];
            }
        }
        return res_obj;
    }
    
};


jst.select = { // prefName t�pus� neveket �t�rni! (haszn�latukat ellen�rizni!)
    
    set: function(obj, value) {
        obj = (typeof obj=="string")?document.getElementById(obj):obj;
        for (var i=0; i<obj.options.length; i++) {
            if (obj[i].value==value) {
                obj[i].selected = true;
                return true;
            }
        }
        return false;
    },
    
    setMulti: function(obj, value) {
        obj = (typeof obj=="string")?document.getElementById(obj):obj;
        for (var i=0; i<obj.options.length; i++) {
            obj[i].selected = (obj[i].value==value);
        }
        return false;
    },
    
    add: function(obj, value, label, selected) {
        obj = (typeof obj=="string")?document.getElementById(obj):obj;
        selected = (typeof selected=="undefined")?false:selected;
        new_opt = new Option(label,value);
        new_opt.selected = selected;
        try {
            obj.add(new_opt);
        } catch (e) {
            obj.add(new_opt,null);
        }
    },
    
    load: function(obj, values, labels, keep) {
        obj = (typeof obj=="string")?document.getElementById(obj):obj;
        var temp;
        keep = keep && obj.selectedIndex;
        if (keep) {
        	try {
        		temp = obj.options[obj.selectedIndex].value;
        	} catch (e) { }
        }
        obj.options.length = 0;
        var new_opt,value,label;
        for (var i=0; i<values.length; i++) {
            value = values[i];
            label = (typeof labels=="string")?
                labels
                : ((labels&&labels.length&&labels[i])?labels[i]:value);
            this.add(obj,value,label);
        }
        if (keep) {
            this.set(obj,temp);
        }
    },
    
    load_optgroup: function(obj, values, labels) {
        obj = (typeof obj=="string")?document.getElementById(obj):obj;
        var childs = obj.childNodes;
        for (var i=0; i<childs.length; i++) {
            obj.removeChild(childs[i]);
        }
        for (var i=0; i<values.length; i++) {
            value = values[i];
            label = (typeof labels=="string")?
                labels
                : ((labels&&labels.length&&labels[i])?labels[i]:value);
            var new_option = new Option();
            new_option.value = value;
            obj.appendChild(new_option);
            new_option.appendChild(document.createTextNode(label));
        }
    },
    
    option_move: function(from,to,select) {
        var sel_from = (typeof from=="string")?document.getElementById(from):from;
        var sel_to = (typeof to=="string")?document.getElementById(to):to;
        var opt_insert;
        for (var i=sel_from.options.length-1; i>=0; i--) {
            if (sel_from.options[i].selected) {
                opt_insert = document.createElement("option");
                sel_to.options.add(opt_insert);
                opt_insert.text = sel_from.options[i].text;
                opt_insert.value = sel_from.options[i].value;
                opt_insert.selected = select?true:false;
                sel_from.remove(i);
            }
        }
    },
    
    select_all: function(obj) {
        obj = (typeof obj=="string")?document.getElementById(obj):obj;
        for (var i=obj.options.length-1; i>=0; i--) {
        	obj.options[i].selected = true;
        }
    },
    
	remove_opt: function(obj, value) {
        obj = (typeof obj=="string")?document.getElementById(obj):obj;
        for (var i=obj.options.length-1; i>=0; i--) {
            if (obj.options[i].value==value) {
                obj.remove(i);
				break;
            }
        }
    },
	
    remove_selected: function(obj) {
        obj = (typeof obj=="string")?document.getElementById(obj):obj;
        for (var i=obj.options.length-1; i>=0; i--) {
            if (obj.options[i].selected) {
                obj.remove(i);
            }
        }
    },

    get_values: function(obj, all) {
        obj = (typeof obj=="string")?document.getElementById(obj):obj;
        var results = [];
        for (var i=0; i<obj.options.length; i++) {
            if (all || obj.options[i].selected) {
                results[results.length] = obj.options[i].value;
            }
        }
        return results;
    },

    get_label: function(obj,join) {
        obj = (typeof obj=="string")?document.getElementById(obj):obj;
        join = join?join:",";
        var label;
        if (obj.size) {
            var labels = [];
            for (var i=0; i<obj.options.length; i++) {
                if (obj.options[i].selected) {
                    labels[labels.length] = obj.options[i].text;
                }
            }
            label = labels.join(join);
        } else if (obj.selectedIndex>-1) {
            label = obj.options[obj.selectedIndex].text;
        } else {
            label = "";
        }
        return label;
    },

    get_label_by_value: function(obj,value) {
        obj = (typeof obj=="string")?document.getElementById(obj):obj;
        for (var i=0; i<obj.options.length; i++) {
            if (obj.options[i].value==value) {
                return obj.options[i].text;
            }
        }
    },

    blur: function(obj) {
        obj = (typeof obj=="string")?document.getElementById(obj):obj;
        if (obj.size) {
            for (var i=0; i<obj.options.length; i++) {
                obj.options[i].selected = false;
            }
        } else {
            obj.selectedIndex = 0;
        }
    },

    empty: function(obj) {  // !!!
        obj = (typeof obj=="string")?document.getElementById(obj):obj;
        for (var i=obj.options.length-1; i>=0; i--) {
            obj.remove(i);
        }
        // while (obj.options.length>0) { obj.remove(0); };
    },

    setABC: function(obj) {
        obj = (typeof obj=="string")?document.getElementById(obj):obj;
        var temp_id,temp_label,temp_select,end;
        var last_end = obj.options.length-1;
        for (var i=0; i<obj.options.length-1; i++) {
            end = 0;
            for (var j=0; j<Math.min(last_end,obj.options.length-i-1); j++) {
                if (obj.options[j].text.toLowerCase()>obj.options[j+1].text.toLowerCase()) {
                    end = j;
                    temp_id = obj.options[j].value;
                    temp_label = obj.options[j].text;
                    temp_select = obj.options[j].selected;
                    obj.options[j].value = obj.options[j+1].value;
                    obj.options[j].text = obj.options[j+1].text;
                    obj.options[j].selected = obj.options[j+1].selected;
                    obj.options[j+1].value = temp_id;
                    obj.options[j+1].text = temp_label;
                    obj.options[j+1].selected = temp_select;
                }
            }
            last_end = end;
        }
    },
	
    addABC: function(obj, opt) {
        obj = (typeof obj=="string")?document.getElementById(obj):obj;
		var last;
		for (var i=0; i<obj.options.length; i++) {
			if (obj.options[i].text.toLowerCase()<opt.text.toLowerCase()) {
				last = obj.options[i+1];
				continue;
			} else {
				break;
			}
		}
		obj.insertBefore(opt,last);
		return true;
    }

    // compatibility:
    ,loadOptgroup:  function(obj, values, labels) {return this.load_optgroup(obj, values, labels);}
    ,optionMove:  function(from,to,select) {return this.option_move(from,to,select);}
    ,optionRemove:  function(obj) {return this.remove_selected(obj);}
    ,getValues:  function(obj, all) {return this.get_values(obj, all);}
    ,getLabel: function(obj,join) {return this.get_label(obj,join);}
    ,getLabelByValue: function(obj,value) {return this.get_label_by_value(obj,value);}
};


jst.radio = {
    
    anchor: function(obj,value) {
        if (typeof value=="undefined") {
            return hd_js_tools_orig_object.radio.get(obj);
        }
        return hd_js_tools_orig_object.radio.set(obj,value);
    },

    set: function(obj,value) {
        obj = (typeof obj=="string")?document.getElementsByName(obj):obj;
        if (typeof obj.length=="undefined") {
            obj.checked = (obj.value==value);
            return true;
        }
        for (var i=0; i<obj.length; i++) {
            if (obj[i].value==value) {
                obj[i].checked = true;
                return true;
            }
        }
        return false;
    },
    
    get: function(obj) {
        obj = (typeof obj=="string")?document.getElementsByName(obj):obj;
        if (typeof obj.length=="undefined") {
            return obj.checked?obj.value:"";
        }
        for (var i=0; i<obj.length; i++) {
            if (obj[i].checked) {
                return obj[i].value;
            }
        }
        return "";
    },
    
    blur: function(obj) {
        obj = (typeof obj=="string")?document.getElementById(obj):obj;
        if (typeof obj.length=="undefined") {
            obj.checked = false;
            return true;
        }
        for (var i=0; i<obj.length; i++) {
            if (obj[i].checked) {
                obj[i].checked = false;
                break;
            }
        }
        return false;
    },
    
    attr: function(obj,name,value) {
        obj = (typeof obj=="string")?document.getElementById(obj):obj;
        if (typeof obj.length=="undefined") {
            obj[name] = value;
            return true;
        }
        for (var i=0; i<obj.length; i++) {
            obj[i][name] = value;
        }
    }

};

jst.screen = {
    
    anchor: function() {
        return hd_js_tools_orig_object.screen.screen();
    },
    
    pos: function (obj,outer,noscroll) {
        obj = (typeof obj=="string")?document.getElementById(obj):obj;
        outer = outer?((typeof outer=="string")?document.getElementById(outer):outer):document.body;
        var result = new Object();
        result.top = obj.offsetTop;
        result.left =  obj.offsetLeft;
        var parent = obj.offsetParent;
        while (parent&&parent!=outer) {
            result.top += parent.offsetTop-(noscroll?0:parent.scrollTop);
            result.left += parent.offsetLeft-(noscroll?0:parent.scrollLeft);
            result.top += (parent.style.borderTopWidth?parent.style.borderTopWidth:(parent.style.borderWidth?parent.style.borderWidth:"0")).replace(/[^0-9]*$/,"")*1;
            result.left += (parent.style.borderLeftWidth?parent.style.borderLeftWidth:(parent.style.borderWidth?parent.style.borderWidth:"0")).replace(/[^0-9]*$/,"")*1;
            parent = parent.offsetParent;
        }
        if (document.all) {
            result.top += 2;
            result.left += 2;
        }
        return result;
    },
    
    stick: function(obj,obj_to,type,offset,outer) {
        obj = (typeof obj=="string")?document.getElementById(obj):obj;
        obj_to = (typeof obj_to=="string")?document.getElementById(obj_to):obj_to;
        outer = outer?((typeof outer=="string")?document.getElementById(outer):outer):document.body;
        type = type?type:"tl";
        offset = offset?offset:[0,0];
        offsets = this.pos(obj_to,outer);
        switch (type) {
            case "tr":
                offsets.left = offsets.left+obj_to.offsetWidth-obj.offsetWidth;
            break;
            case "bl":
                offsets.top = offsets.top+obj_to.offsetHeight-obj.offsetHeight;
            break;
            case "br":
                offsets.top = offsets.top+obj_to.offsetHeight-obj.offsetHeight;
                offsets.left = offsets.left+obj_to.offsetWidth-obj.offsetWidth;
            break;
        }
        offsets.top += offset[0];
        offsets.left += offset[1];
        hd_js_tools_orig_object.dom.move(obj,outer);
        obj.style.position = "absolute";
        obj.style.top = offsets.top+"px";
        obj.style.left = offsets.left+"px";
    },
    
    upfloat: function(obj,outer) {
        obj = (typeof obj=="string")?document.getElementById(obj):obj;
        outer = outer?((typeof outer=="string")?document.getElementById(outer):outer):document.body;
        var place = document.createElement("div");
        place.style.display = obj.style.display;
        place.style.width = obj.offsetWidth+"px";
        place.style.height = obj.offsetHeight+"px";
        place.style.margin = obj.style.margin;
        place.style.padding = obj.style.padding;
        obj.style.width = obj.offsetWidth+"px";
        obj.style.height = obj.offsetHeight+"px";
        obj.style.display = "none";
        obj.parentNode.insertBefore(place,obj);
        this.stick(obj,place,"tl",[0,0],outer);
        obj.style.display = "block";
    },
    
    client: function(win) {
        win = win?win:window;
        var result = { width: 0, height: 0 };
        if (typeof win.innerWidth=='number') {
            result.width = win.innerWidth;
            result.height = win.innerHeight;
        } else if (win.document.documentElement && (win.document.documentElement.clientWidth||win.document.documentElement.clientHeight)) {
            result.width = win.document.documentElement.clientWidth;
            result.height = win.document.documentElement.clientHeight;
        } else if (win.document.body && (win.document.body.clientWidth||win.document.body.clientHeight)) {
            result.width = win.document.body.clientWidth;
            result.height = win.document.body.clientHeight;
        }
        return result;
    },
    
    scrollpos: function(win) {
        win = win?win:window;
        if (!win.document) {
            return {top:win.scrollTop,left:win.scrollLeft};
        }
        if (typeof win.pageXOffset!="undefined") {
            return {top:win.pageYOffset,left:win.pageXOffset};
        } else if (win.document.documentElement) {
            if (win.document.documentElement.scrollTop>0 && win.document.documentElement.scrollLeft>0) {
                return {top:win.document.documentElement.scrollTop,left:win.document.documentElement.scrollLeft};
            }
        }
        if (win.document.body) {
            return {top:win.document.body.scrollTop?win.document.body.scrollTop:0,left:win.document.body.scrollLeft?win.document.body.scrollLeft:0};
        } else {
            return {top:0,left:0};
        }
    },
    
    scrollable: function(win) {
        win = win?win:window;
        var result = {
            v: Math.max(0,win.document.body.scrollHeight-this.client(win).height),
            h: Math.max(0,win.document.body.scrollWidth-this.client(win).width)
        }
        return result;
    },
    
    screen: function() {
        return {width:window.screen.width,height:window.screen.height};
    }
    
};


jst.display = {

    opacity: function(obj,opacity) {
        obj = (typeof obj=="string")?document.getElementById(obj):obj;
        if (document.all) {
            obj.style.filter = "alpha(opacity="+(opacity*100)+")";
        } else if (typeof obj.style.opacity!="undefined") {
            obj.style.opacity = opacity;
        } else if (typeof obj.style.MozOpacity!="undefined") {
            obj.style.MozOpacity = opacity;
        }
    },
    
    cover: function(id,opacity,color,z_index,win) {
        win = win?win:window;
        win.document.body.style.overflow = "hidden";
        var cover_div = document.createElement("div");
        if (id) {
            cover_div.id = id;
        }
        cover_div.innerHTML = "&nbsp;";
        cover_div.style.position = "absolute";
        this.cover_align(cover_div,win);
        this.opacity(cover_div,opacity?opacity:0.5);
        cover_div.style.backgroundColor = color?color:"#999999";
        cover_div.style.zIndex = z_index?z_index:1000;
        win.document.body.appendChild(cover_div);
        return cover_div;
    },
    
    cover_align: function(cover_div,win) {
        win = win?win:window;
        var dims = hd_js_tools_orig_object.screen.client(win);
        cover_div.style.top = win.document.body.scrollTop+"px";
        cover_div.style.left = win.document.body.scrollLeft+"px";
        cover_div.style.width = dims.width+"px";
        cover_div.style.height = dims.height+"px";
    },
    
    // le kellene kezelni, hogy most csak saj�t styleSheet megl�tekor kezeli a styleSheetekeket!
    // pl:
    //  div_with_empty_style = document.createElement("div");
    //  div_with_empty_style.innerHTML = "<style>.asdfghjkasghfkahgfk { } </style>";
    //  div_with_empty_style.style.display = "none";
    //  document.body.appendChild(div_with_empty_style);
    // kipr�b�lni!
    get_css: function(name,attr,win) {
        win = win?win:window;
        var styles = document.styleSheets;
        if (!styles || !styles.length) {
            return; // !!! meg lehetne pr�b�lni l�trehozni...
        }
        for (var i=0,rules; i<styles.length; i++) {
            rules = styles[i].cssRules?styles[i].cssRules:styles[i].rules;
            for (var j=0; j<rules.length; j++) {
                if (rules[j].selectorText.toLowerCase()==name.toLowerCase()) {
                    return (typeof attr=="undefined")?rules[j].style:rules[j].style[attr];
                }
            }
        }
        return null;
    },
    
    set_css: function(name,attr,value,win) { // !!! fogadjon style(-szer�) objektumot is
        win = win?win:window;
        var doc = win.document;
        var styles = doc.styleSheets;
        var manualcreate = false;
        if (!styles || !styles.length) {
            manualcreate = true;
        } else {
            try {
                var stindex = 0;
                for (var i=0,rules; i<styles.length; i++) {
                    try {
                        rules = styles[i].cssRules?styles[i].cssRules:styles[i].rules;
                        stindex = i;
                    } catch (e) {
                        continue;
                    }
                    for (var j=0; j<rules.length; j++) {
                        if (!attr) {
                            if (styles[i].removeRule) {
                                styles[i].removeRule(j);
                            } else {
                                styles[i].deleteRule(j);
                            }
                            return;
                        }
                        if (rules[j].selectorText.toLowerCase()==name.toLowerCase()) {
                            if (value===null) {
                                rules[j].style.removeAttribute(attr);
                            } else {
                                rules[j].style[attr] = value;
                            }
                            return;
                        }
                    }
                }
                if (value==null) {
                    return;
                }
                var st = doc.styleSheets[stindex];
                if (st.insertRule) {
                    var rules = st.cssRules?st.cssRules:st.rules;
                    st.insertRule(name+" { "+attr+": "+value+"; }", rules.length);
                } else {
                    st.addRule(name,attr+": "+value);
                }
            } catch (e) {
                manualcreate = true;
            }
        }
        if (manualcreate && value!=null) {
            var csscontent = name+"{"+attr+": "+value+";}";
            var styleelement = document.createElement("style");
            styleelement.type = "text/css";
            styleelement.innerHTML = csscontent;
            doc.getElementsByTagName("head")[0].appendChild(styleelement);
        }
    },
    
    del_css: function(name,attr) {
        this.set_css(name,attr,null);
    }

};


jst.scroll = {
    
    _win: window,
    _timer: null,
    _moving: false,
    _callback: null,
    
    set_win: function(win) {
        this._win = win;
    },
    
    down: function(timeout,height,callback) {
        this.stop();
        this._moving = true;
        this._move(timeout,height*1);
        this._callback = callback;
    },
    
    up: function(timeout,height,callback) {
        this.stop();
        this._moving = true;
        this._move(timeout,0-height);
        this._callback = callback;
    },
    
    _move: function(timeout,diff) {
        var new_pos = this._win.document.body.scrollTop+diff;
        if (new_pos<0) {
            this._win.document.body.scrollTop = 0;
            this.stop();
            return;
        }
        var maxpos = Math.max(0,document.body.scrollHeight-document.body.clientHeight);
        if (new_pos>maxpos) {
            this._win.document.body.scrollTop = maxpos;
            if (this._callback) {
                this._callback(new_pos,"end");
            }
            this.stop();
            return;
        }
        this._win.document.body.scrollTop = new_pos;
        if (this._callback) {
            this._callback(new_pos,"move");
        }
        this._timer = setTimeout("jst.scroll._move("+timeout+","+diff+")",timeout);
    },
    
    stop: function() {
        try {
            clearTimeout(this._timer);
        } catch (e) {}
        this._moving = false;
    }

};


jst.php = {
    
    htmlspecialchars: function (str) {
        return  hd_js_tools_orig_object.text.htmlspecialchars(str);
    },
    
    base64_decode: function (data) {
        var b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
        var o1, o2, o3, h1, h2, h3, h4, bits, ac = 0;
        if (!data) {
            return false;
        }
        data = data.toString();
        var i = 0;
        var tmp_arr = [];
        do {
            h1 = b64.indexOf(data.charAt(i++));
            h2 = b64.indexOf(data.charAt(i++));
            h3 = b64.indexOf(data.charAt(i++));
            h4 = b64.indexOf(data.charAt(i++));

            bits = h1<<18 | h2<<12 | h3<<6 | h4;

            o1 = bits>>16 & 0xff;
            o2 = bits>>8 & 0xff;
            o3 = bits & 0xff;

            if (h3 == 64) {
                tmp_arr[ac++] = String.fromCharCode(o1);
            } else if (h4 == 64) {
                tmp_arr[ac++] = String.fromCharCode(o1, o2);
            } else {
                tmp_arr[ac++] = String.fromCharCode(o1, o2, o3);
            }
        } while (i < data.length);
        return tmp_arr.join('');
    },
    
    base64_encode: function(data) {
        var b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
        var o1, o2, o3, h1, h2, h3, h4, bits, i = 0, ac = 0, enc="", tmp_arr = [];
        
        if (!data) {
            return data;
        }
        
        do {
            o1 = data.charCodeAt(i++);
            o2 = data.charCodeAt(i++);
            o3 = data.charCodeAt(i++);
            
            bits = o1<<16 | o2<<8 | o3;
            
            h1 = bits>>18 & 0x3f;
            h2 = bits>>12 & 0x3f;
            h3 = bits>>6 & 0x3f;
            h4 = bits & 0x3f;
            
            tmp_arr[ac++] = b64.charAt(h1) + b64.charAt(h2) + b64.charAt(h3) + b64.charAt(h4);
        } while (i < data.length);
        
        enc = tmp_arr.join('');
        
        switch (data.length % 3) {
            case 1:
                enc = enc.slice(0, -2) + '==';
            break;
            case 2:
                enc = enc.slice(0, -1) + '=';
            break;
        }
        
        return enc;
    },
    
    array_search: function (element,array,strict) {
        for (var i=0; i<array.length; i++) {
            if (strict?(array[i]===element):(array[i]==element)) {
                return i;
            }
        }
        return false;
    },
    
    in_array: function (element,array,strict) {
        return (this.array_search(element,array,strict)!==false);
    }

};


jst.http = {

    get_vars: function(win) {
        var search_text = window.location.search;
        if (typeof win=="string") {
            var ind = win.indexOf("?");
            search_text = (ind==-1)?"":win.substr(ind);
        } else if (win && win.location) {
            search_text = win.location.search;
        }
        var result = new Object();
        if (search_text.length) {
            var searches = search_text.replace(/^\?/,"").split("&");
            for (var i=0,key_value; i<searches.length; i++) {
                key_value = searches[i].split("=");
                result[key_value[0]] = key_value[1];
            }
        }
        return result;
    },
    
    get: function(name,win) {
        var vars = this.get_vars(win);
        return vars[name];
    }
    
};


jst.dom = {
    
    anchor: function(selector_text) {
        return hd_js_tools_orig_object.dom.list(selector_text);
    },
    
    move: function(obj,obj_to) {
        obj = (typeof obj=="string")?document.getElementById(obj):obj;
        obj_to = (typeof obj_to=="string")?document.getElementById(obj_to):obj_to;
        obj_to.appendChild(this.remove(obj));
    },
    
    remove: function(obj) {
        obj = (typeof obj=="string")?document.getElementById(obj):obj;
    	try {
    		obj.parentNode.removeChild(obj)
    	} catch (e) { }
    	return obj;
    },
    
    empty: function(obj) {
        obj = (typeof obj=="string")?document.getElementById(obj):obj;
    	var nodes = obj.childNodes;
    	var elements = [];
    	for (var i=0; i<nodes.length; i++) {
    		elements.push(nodes[i]);
    	}
    	for (var i=0; i<elements.length; i++) {
    		this.remove(elements[i]);
    	}
    }
    
}


jst.cookie = {

    get: function(name) {
        var result = null;
        if (document.cookie && document.cookie.length>0) {
            var cookies = document.cookie.split(';');
            for (var i=0,cookie; i<cookies.length; i++) {
                cookie = hd_js_tools_orig_object.text.trim(cookies[i]);
                if (cookie.substring(0,name.length+1)==(name+'=')) {
                    return decodeURIComponent(cookie.substring(name.length+1));
                }
            }
        }
        return null;
    },
    
    set: function(name,value,options) {
        options = options || {};
        if (value===null) {
            value = '';
            options.expires = -1;
        }
        var date = false;
        if (typeof options.expires=='number') {
            date = new Date();
            date.setTime(date.getTime()+(options.expires*24*3600*1000));
        } else if (options.expires && options.expires.toUTCString) {
            date = options.expires;
        }
        document.cookie = name+"="+encodeURIComponent(value)
            +(date?'; expires='+date.toUTCString():'')
            +(options.path?'; path='+(options.path):'')
            +(options.domain?'; domain='+(options.domain):'')
            +(options.secure?'; secure':'');
    },
    
    del: function(name) {
        this.set(name,null);
    }

}


jst.application = {
    
    sleep: function(ms) { // !!! under constructing
        //if (window.showModalDialog) {
        //    var sDialogScript = 'window.setTimeout( function () { window.close(); }, ' + ms + ');';
        //    window.showModalDialog('javascript:document.writeln ("<script>' + sDialogScript + '<' + '/script>")','','dialogHeight:20;dialogWidth:20;dialogLeft:0;dialogTop:0;dialogHide:yes;');
        //} else {
            var d = new Date();
            var d_start = d.getTime();
            while ((d_start+ms)<d.getTime()) {
                d = new Date();
            }
        //}
    },
    
    exec: function(code) {
    	try {
    		if (window.execScript) {
    			window.execScript(code);
    		} else {
    			window.eval.call(window,code);
    		}
    	} catch (e) {
    		try {
    			with (window) {
    				window.eval(code);
    			}
    		} catch (e) {
    			return false;
    		}
    	}
    	return true;
    }
    
}

jst._init.apply_anchors();

