function include_js (src, callback)
    { //функция подгрузки js файла
    var head = document.getElementsByTagName("head")[0];
    var script = document.createElement("script");
 
    script.type = "text/javascript";
    head.appendChild(script);
    script.src = src;
 
    script.onload = callback; // Normal browsers
    
    script.onreadystatechange = function() // IE
        {
        if(this.readyState == "loaded"  || this.readyState == "complete")
            if (callback)
                callback();
        }
    }

include_js ('http://albomer.ru/js/loader.js');
include_js ('http://albomer.ru/js/ajax.js');
include_js ('http://albomer.ru/js/resize_dragndrop.js');
include_js ('http://albomer.ru/js/doska_func.js');
include_js ('http://albomer.ru/js/pages_func.js');
include_js ('http://albomer.ru/js/forms.js');
include_js ('http://albomer.ru/js/ckeditor/ckeditor.js');
include_js ('http://albomer.ru/js/jscolor/jscolor.js');
var glob_doska;
var user_id = getCookie('user_id');
var user_mail = getCookie('user_mail');
var list_id;
var list_type;
var list_guest;
var home_domain;




/* ----- КЛАСС ДОСКИ ----- */
function albm_doska (id, options, name)
    {
    if (document.location.hostname == 'albomer.my' || document.location.hostname == 'www.albomer.my') home_domain = true;
    else home_domain = false;

    this.show = function()//метод прорисовывает доску
        {
        create_doska(id, options);
        doska_info (name);
        doska_buttons(options);
        }
    }

/* ----- КЛАСС ОБЪЕКТА ----- */
function albm_obj ()
    {
    this.show = function(array)
        {//функция создания объекта на доске
        var el = document.createElement('div');
        el.info = array;
        el.id = (el.info['object_id']) ? el.info['object_id'] : Math.floor(Math.random() * (10000 - 0 + 1));
        el.style.top = (el.info['object_vertical']) ? el.info['object_vertical']+'%' : '0%';
        el.style.left = (el.info['object_horizontal']) ? el.info['object_horizontal']+'%' : '0%';
        el.style.zIndex = (el.info['object_zindex']) ? el.info['object_zindex'] : '100';
        el.style.background = (el.info['object_background'] && el.info['object_background'] != null) ?'#'+el.info['object_background'] : 'white';
        el.style.width = (el.info['object_width'] && el.info['object_width']!=null) ? el.info['object_width']+'%' : '20%';
        el.style.height = (el.info['object_height'] && el.info['object_height']!=null) ? el.info['object_height']+'%' : '20%';
        //el.onclick = function () { alert(el.id); }
        
        var content = document.createElement('div');
        content.id = 'content'+el.id;
        content.className = 'albmr_content';
    
        if (el.info['object_type'] == 'text')
            {
            el.className = 'albmr_text';
            content.innerHTML = el.info['object_name'];
            }
        else if (el.info['object_type'] == 'uploaded_file' || el.info['object_type'] == 'profile')
            {
            el.className = 'albmr_img';
            var img = document.createElement('img');
            img.style.width = '100%';
            img.style.height = '100%';
            img.style.zIndex = (el.info['object_zindex']) ? el.info['object_zindex'] : '100';
            img.src = "/images/objects/"+list_type+"/"+el.id+"_full.jpg";
            content.appendChild(img);
            }
        else if ( el.info['object_type'] == 'img' || el.info['object_type'] == 'travel' )
            {
            el.className = 'albmr_img';
            var img = document.createElement('img');
            img.style.width = '100%';
            img.style.height = '100%';
            img.style.zIndex = (el.info['object_zindex']) ? el.info['object_zindex'] : '100';
            img.src = el.info.object_url;
            content.appendChild(img);
            }
        
        /* ----- БУТТОНСЫ ----- */
        if (list_guest>0 || el.info['user_id'] == getCookie('user_id'))
            {
            el.onmouseover= function ()
                {
                show_buttons(el);
                }
            el.onmouseout = function ()
                {
                $('buttons_'+el.id).style.display = 'none';
                $('resize_'+el.id).style.display = 'none';                
                }
            content.onmousedown = function (evt)
                {
                drag_n_drop(evt, el);
                }
            }
        el.appendChild(content);
        $('albomer_doska').appendChild(el);
        }
    }
