﻿
//Gives position of an object
//function Controls_Product_ECSProduct_Div_GivObjectPosition(obj) {
//    var curleft = curtop = 0;
//    if (obj.offsetParent) {
//        do {
//            curleft += obj.offsetLeft;
//            curtop += obj.offsetTop;
//        } while (obj = obj.offsetParent);
//    }
//    return [curleft, curtop];
//}

//Shows-hides help DIV tag
function Controls_Product_ECSProduct_Div_ShowHideProductPhoto(positionRefControl, showHideAction, imageUrl) {
    if (showHideAction) {
        var _helpDiv = document.getElementById('ProductPhotoDiv');

        if (_helpDiv == null) {
            _helpDiv = document.createElement('div');
            _helpDiv.id = 'ProductPhotoDiv';
            document.body.appendChild(_helpDiv);
        }

        _helpDiv.style.position = 'absolute';
        _helpDiv.style.width = '160px';
        _helpDiv.style.border = '1px solid #999999';
        _helpDiv.style.padding = '1px';
        //_helpDiv.style.backgroundColor = '#CCCC99';
        _helpDiv.style.left = ECSJSGeneral_GetObjectPosition(positionRefControl)[0] - 180 + 'px';
        _helpDiv.style.top = ECSJSGeneral_GetObjectPosition(positionRefControl)[1] - 100 + 'px';
        //_helpDiv.style.pixelLeft = ECSJSGeneral_GetObjectPosition(positionRefControl)[0] - 180;
        //_helpDiv.style.pixelTop = ECSJSGeneral_GetObjectPosition(positionRefControl)[1] - 100;
        _helpDiv.style.textAlign = 'center';
        _helpDiv.innerHTML = '<img border="0" src="' + imageUrl + '" />';
        _helpDiv.style.visibility = 'visible';

    }
    else {
        var _helpDiv = document.getElementById('ProductPhotoDiv');

        if (_helpDiv != null)
            _helpDiv.style.visibility = 'hidden';

    }
}

function Controls_Product_ECSProduct_Div_ShowHideProductComment(positionRefControl, showHideAction, controlDiv) {
    if (showHideAction) {
        var _helpDiv = document.getElementById(controlDiv);

        if (_helpDiv == null) {
            _helpDiv = document.createElement('div');
            _helpDiv.id = controlDiv;
            document.body.appendChild(_helpDiv);
        }

        _helpDiv.style.position = 'absolute';
        _helpDiv.style.display = 'block';
        _helpDiv.style.width = '400px';
        _helpDiv.style.border = '1px solid #999999';
        _helpDiv.style.pixelLeft = ECSJSGeneral_GetObjectPosition(positionRefControl)[0] - 180;
        _helpDiv.style.pixelTop = ECSJSGeneral_GetObjectPosition(positionRefControl)[1] - 120;
        _helpDiv.style.visibility = 'visible';
    }
    else {
        var _helpDiv = document.getElementById(controlDiv);

        if (_helpDiv != null)
            _helpDiv.style.visibility = 'hidden';

    }
}

function Controls_Product_ECSProduct_Div_ShowHideHelp(positionRefControl, showHideAction, controlDiv, movex, movey) {
    if (showHideAction) {
        var _helpDiv = document.getElementById(controlDiv);

        if (_helpDiv == null) {
            _helpDiv = document.createElement('div');
            _helpDiv.id = controlDiv;
            document.body.appendChild(_helpDiv);
        }

        _helpDiv.style.position = 'absolute';
        _helpDiv.style.display = 'block';
        _helpDiv.style.width = '400px';
        _helpDiv.style.border = '1px solid #999999';
        _helpDiv.style.pixelLeft = ECSJSGeneral_GetObjectPosition(positionRefControl)[0] + movex;
        _helpDiv.style.pixelTop = ECSJSGeneral_GetObjectPosition(positionRefControl)[1] + movey;
        _helpDiv.style.visibility = 'visible';
    }
    else {
        var _helpDiv = document.getElementById(controlDiv);

        if (_helpDiv != null)
            _helpDiv.style.visibility = 'hidden';

    }
}

function Controls_Product_ECSProduct_Edit(eventTarget, windowGuid, productGuid) {
    var _window = openModalWindow("ECSPageGeneric.aspx?WindowGuid=" + windowGuid + "&ControlGuid=499d9a87-6fec-4f30-bfaa-6f8b6eb45d7d&EventTarget=" + eventTarget + "&ProductGuid=" + productGuid + " ");
    _window.setSize(550, 500);
    _window.set_visibleTitlebar(true);
    _window.set_behaviors(Telerik.Web.UI.WindowBehaviors.Move + Telerik.Web.UI.WindowBehaviors.Close);
    _window.center();
}

if (typeof (Sys) !== 'undefined') Sys.Application.notifyScriptLoaded(); 