var ITWebControl = {
    AlinearPrecioColumnas: function () {
        $(document).ready(function () {
            $('div.grupoPrecio').map(function () {
                var h = $(this).height();
                $(this).parent().addClass('align');
                $(this).parent().css('padding-bottom', h + 'px');
            });
        });
    },
    MouseDisable: function () {
        $(document).ready(function () {
            $(document)[0].oncontextmenu = function () { return false; }
        });
    },
    CopyDisable: function () {
        $(document).ready(function () {
            $(document)[0].oncopy = function () { return false; }
            $(document)[0].ondrag = function () { return false; }
            $(document)[0].onselectstart = function () { return false; }
        });
    },
    CarritoCantidad: function () {
        this.AddEventSubmitOnPressEnter($('input[name^=Cantidad_]:text'), 'Actualizar');
    },
    CarritoPago: function () {
        this.AddEventSubmitOnchange($('input[name=IDFormaPago]:radio'), 'Actualizar');
        //        this.AddEventSubmitOnchange($('select[name=IDFormaPago]'), 'Actualizar');
    },
    CarritoEnvio: function () {
        this.AddEventSubmitOnchange($('input[name=IDFormaEnvio]:radio'), 'Actualizar');
        //        this.AddEventSubmitOnchange($('select[name=IDFormaEnvio]'), 'Actualizar');
    },
    //3.1.30#dieteticagirasol
    CarritoPagoEnvioOk: function () {
        if($('input[name=IDFormaPago]').length == 0 || $('input[name=IDFormaEnvio]').length == 0) return true;
        else if ($('input[name=IDFormaPago]:radio:checked').attr('value') != undefined && $('input[name=IDFormaEnvio]:radio:checked').attr('value') != undefined) return true;
        //else if ($('select[name=IDFormaPago]').attr('value') != undefined && $('select[name=IDFormaEnvio]').attr('value') != undefined) return true;
        else return false;
    },
    InputTextSubmit: function (strTextName, strButtonName) {
        this.AddEventSubmitOnPressEnter($('input[name=' + strTextName + ']:text'), strButtonName);
    },
    AddThis: function () {
        $(document).ready(function () {
            $('a.addthis_button_facebook_like').map(function () {
                $(this).attr('fb:like:layout', 'button_count');
                $(this).attr('fb:like:width', '100');
            });

            $('a.addthis_button_google_plusone').map(function () {
                $(this).attr('g:plusone:size', 'medium');
            });

            var itAddThis = document.createElement('script'); itAddThis.type = 'text/javascript'; itAddThis.async = true;
            itAddThis.src = 'http://' + 's7.addthis.com/js/250/addthis_widget.js?domready=1';
            var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(itAddThis, s);
        });
    },
    AddFormCampoAltInfo: function (idParentDiv, idFieldName, textInfo) {
        $(document).ready(function () {
            $('#' + idParentDiv).append('<div id="info' + idFieldName + '">' + textInfo + '</div>');
            $('#' + idParentDiv).attr('style', 'position: relative');
            $('#info' + idFieldName).attr('class', 'infoCampo');
            if (document.activeElement.id != idFieldName) {
                $('#info' + idFieldName).attr('style', 'display: none;');
            }
            $('#' + idFieldName).focus(function () {
                $('#info' + idFieldName).attr('style', 'display: block;');
            });
            $('#' + idFieldName).blur(function () {
                $('#info' + idFieldName).attr('style', 'display: none;');
            });
        });
    },
    AddEventSubmitOnPressEnter: function (objInput, strButtonSubmit) {
        objInput.live('keypress', function (e) {
            var code = (e.keyCode ? e.keyCode : e.which);
            if (code == 13) { //Enter keycode
                e.preventDefault(); // Stop form submit event
                $(this).closest('form').find('input[name=' + strButtonSubmit + ']').click();
            }
        });
    },
    AddEventSubmitOnchange: function (objInput, strButtonSubmit) {
        objInput.live('change', function (e) {
            //3.1.30#dieteticagirasol
            blnPagoEnvioOk = ITWebControl.CarritoPagoEnvioOk();
            if ($(this).attr('value') != undefined && blnPagoEnvioOk) {
                $(this).closest('form').find('input[name=' + strButtonSubmit + ']').click();
            }
        });
    }
}
