﻿$(document).ready(function () {

    if ($(".Carrocel").length > 0) {
        $(".Carrocel").each(function () {
            $(this).jcarousel({
                visible: 6,
                scroll: 1,
                animation: 500,
                wrap: 'last',
                initCallback: mycarousel_initCallback,
                // This tells jCarousel NOT to autobuild prev/next buttons
                buttonNextHTML: null,
                buttonPrevHTML: null
            });
        });
    }

    if ($(".Carrocel1").length > 0) {
        $(".Carrocel1").each(function () {
            $(this).jcarousel({
                visible: 3,
                scroll: 1,
                animation: 500,
                wrap: 'last',
                initCallback: mycarousel_initCallback,
                // This tells jCarousel NOT to autobuild prev/next buttons
                buttonNextHTML: null,
                buttonPrevHTML: null
            });
        });
    }

    if ($(".Carrocelx").length > 0) {
        $(".Carrocelx").jcarousel({
            visible: 5,
            scroll: 1,
            animation: 500,
            wrap: 'last',
            initCallback: mycarousel_initCallbackXx,
            // This tells jCarousel NOT to autobuild prev/next buttons
            buttonNextHTML: null,
            buttonPrevHTML: null
        });
    }

    //	if($(".pnlPopup").length > 0)
    //	{
    //		if($(".pnlPopup").css('height') == "0px")
    //			$(".fundoFaixa").css('height','620px');
    //	}

});

var X = "";
val = new Array();

function mycarousel_initCallback(carousel) {
    $('.Carrocel_next').bind('click', function () {
        carousel.next();
        return false;
    });

    $('.Carrocel_prev').bind('click', function () {
        carousel.prev();
        return false;
    });
    val[X] = 'defined';
};

function mycarousel_initCallbackXx(carousel) {
    $('.Carrocel_next').bind('click', function () {
        carousel.next();
        return false;
    });

    $('.Carrocel_prev').bind('click', function () {
        carousel.prev();
        return false;
    });
};

function mycarousel_initCallbackX(carousel) {
    $('.Carrocel_next_' + X).bind('click', function () {
        carousel.next();
        return false;
    });

    $('.Carrocel_prev_' + X).bind('click', function () {
        carousel.prev();
        return false;
    });
    val[X] = 'defined';
};

function Carr() {
    X = arguments[0];
    if (val[X] == undefined) {
        $(".Carrocelx_" + X).each(function () {
            $(this).jcarousel({
                visible: 3,
                scroll: 1,
                animation: 500,
                wrap: 'last',
                initCallback: mycarousel_initCallbackX,
                // This tells jCarousel NOT to autobuild prev/next buttons
                buttonNextHTML: null,
                buttonPrevHTML: null
            });
        });
    }
 }
 
 function Redimenciona()
 {
	//$(".fundoFaixa").css('height','620px');
 }

jQuery(function ($) {
    $.mask.definitions['~'] = '[_ 0-9]';
    $(".Cnpj").mask("99.999.999/9999-99");
    $(".Cpf").mask("999.999.999-99");
    $(".Ddd").mask("999");
    $(".Telefone").mask("(99) 999~-9999", { placeholder: "_" });
    $(".Cep").mask("99999-999");
    $(".Data").mask("99/99/9999");
    $(".Num").keydown(function () {
        Mascara(this, Numero);
    });
    $(".Valor").keydown(function () {
        Mascara(this, Valor);
    });
    $(".Valorx").keydown(function () {
        Mascara(this, Valorx);
    });
    $(".Peso").keydown(function () {
        Mascara(this, Peso);
    });

    $("#DvBoxImg").bind("sortstop", function (event, ui) {
        var result = $("#DvBoxImg").sortable('toArray');
        camp.value = "";
        for (var i in result) {
            camp.value += (i > 0 ? ',' : '') + result[i];
        }
    });

    if ($('._ChkV').length > 0) {
        $('._ChkV:checked"').click(function () {
            var id = $(this).val();
            if (eval($(this).attr('checked'))) {
                $('#ex_' + id).val('');
            }
            else
                $('#ex_' + id).val(id);
        });
    }
})

function Selec() {
    var Inp = document.getElementById('tblListagem').getElementsByTagName('input');
    for (var i in Inp) {
        if (Inp[i].getAttribute("type") == "checkbox")
            Inp[i].checked = arguments[0].checked;
    }
}

$(function () {
    if ($("#sortable").length > 0) {
        $("#sortable").sortable();
        $("#sortable").disableSelection();
        $("#sortable").bind("sortstop", function (event, ui) {
            var result = $("#sortable").sortable('toArray');
            var ord = "";
            for (var i in result) {
                ord += (i > 0 ? ',' : '') + result[i];
            };
            $("#ImgOrdem").val(ord);
        });

        $("._ImgQuest").click(function () {
            if ($("._chkDelImagem:checked").length > 0)
                return confirm("Há imagen(s) selecionada(s), deseja excluila(s) ?");
            else
                return true;

        });
    }

    if ($("._Quest").length > 0) {
        $("._Quest").click(function () {
            if ($("._Delete:checked").length > 0)
                return confirm("Há imagen(s) selecionada(s), deseja excluila(s) ?");
            else
                return true;

        });
    }
});
        
