/* Design & Code (c) Devoler */

function switchEl(el) {
    if (document.getElementById(el).style.display == 'none') {
        document.getElementById(el).style.display = '';
    } else {
        document.getElementById(el).style.display = 'none';
    }
}

function getEl(I_id) {
    return document.getElementById(I_id);
}

function hideEl(el) {
    document.getElementById(el).style.display = 'none';
}

function showEl(el) {
    document.getElementById(el).style.display = '';
}

function moreInfo(id) {
    if (document.getElementById(id).style.display == 'none') {
        document.getElementById(id).style.display='';
    } else {
        document.getElementById(id).style.display='none';
    }
}

function setOverClass(I_el) {
    Element.addClassName(I_el, 'over');
}

function setOutClass(I_el) {
    Element.removeClassName(I_el, 'over');
}


function infoHints() {

    var helpers = {
        
        'news-actions-1': {
            'bind': 'title-news',
            'src': '/img/v1/hint-news-arrow.png',
            'width': 35,
            'height': 215,
            'x': 25,
            'y': -210
        },
        'news-actions-2': {
            'bind': 'title-news',
            'src': '/img/v1/hint-news.png',
            'width': 87,
            'height': 43,
            'x': 60,
            'y': -210
        },
        'fence-1': {
            'bind': 'title-news',
            'src': '/img/v1/hint-fence-product.gif',
            'width': 158,
            'height': 103,
            'x': 455,
            'y': -230
        },/*
        'product-block-1': {
            'bind': 'product-block-1',
            'src': '/img/v1/hint-products-block.gif',
            'width': 143,
            'height': 95,
            'x': -160,
            'y': 40
        },
        'product-block-2': {
            'bind': 'product-block-2',
            'src': '/img/v1/hint-products-block-2.gif',
            'width': 146,
            'height': 103,
            'x': -160,
            'y': -40
        },*/
        'page-demo-1': {
            'bind': 'page-demo-1',
            'src': '/img/v1/hint-demo.gif',
            'width': 325,
            'height': 41,
            'x': 400,
            'y': 0
        }
    };

    this.init = function () {
        updateInfo();
        window.onresize = updateInfo.bind(this);
    }
    
    var updateInfo = function () {
        for (i in helpers) {
            displayIfNeed(helpers[i], i);
        }
    };
    
    var displayIfNeed = function(I_help, I_name) {
        el = $(I_help.bind);
        if (!el)
            return;
        pos = Position.cumulativeOffset(el);
        elHint = createImgLayer(I_help, I_name);

        Element.setStyle(elHint, {
            left: (pos[0] + I_help.x + 'px'),
            top: (pos[1] + I_help.y + 'px')
        });

        Element.show(elDiv);
    }
    
    var createImgLayer = function(I_data, I_name) {
        lId = 'hint' + I_name + I_data.bind;
        if ($(lId))
           return $(lId);
        elDiv = document.createElement('div');
        elDiv.id = lId;
        elImg = document.createElement('img');
        Element.setStyle(elDiv, {
            position: 'absolute',
            width: (I_data.width + 'px'),
            height: (I_data.height + 'px'),
            display: 'none'
        });
        
        Element.setStyle(elImg, {
            width: (I_data.width + 'px'),
            height: (I_data.height + 'px')
        });
        elImg.src = I_data.src;
        elDiv.appendChild(elImg);
        document.getElementsByTagName('body').item(0).appendChild(elDiv);
        return elDiv;
    }
    
    this.init();
}

var gInfoHints = 0;

/*
hint-easy-contact
hint-live-brilliant
hint-news-1
hint-news-2
hint-fence
hint-concrete-block
*/

window.onload = function () {
    var gInfoHints = new infoHints();
}
