﻿// Função de Fix PNG

var arVersion = navigator.appVersion.split("MSIE")
var version = parseFloat(arVersion[1])

if ((version >= 5.5) && (document.body.filters)) {
    for (var i = 0; i < document.images.length; i++) {
        var img = document.images[i]
        var imgName = img.src.toUpperCase()
        if (imgName.substring(imgName.length - 3, imgName.length) == "PNG") {
            var imgID = (img.id) ? "id='" + img.id + "' " : ""
            var imgClass = (img.className) ? "class='" + img.className + "' " : ""
            var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
            var imgStyle = "display:inline-block;" + img.style.cssText
            if (img.align == "left") imgStyle = "float:left;" + imgStyle
            if (img.align == "right") imgStyle = "float:right;" + imgStyle
            if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
            var strNewHTML = "<span " + imgID + imgClass + imgTitle
         + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
         + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
         + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>"
            img.outerHTML = strNewHTML
            i = i - 1
        }
    }
}

// Função que Valida com Tooltip
function ValidarPagina(validationgroup, target) {

    if (typeof (Page_ClientValidate) == 'function') {
        Page_ClientValidate(validationgroup);
    }

    if (!Page_IsValid) {
        var ErrorMsg = '';
        for (var i = 0; i < Page_Validators.length; i++) {
            if (!Page_Validators[i].isvalid) {
                ErrorMsg = ErrorMsg + '<li>- ' + Page_Validators[i].errormessage + '</li>';
            }
        }
        CriarTooltip('<ul>' + ErrorMsg + '</ul>', target);
    }
}

// Função que cria o Tooltip
function CriarTooltip(conteudo, target) {
    $('#' + target).qtip({
        content: {
            title: 'Aviso',
            text: conteudo
        },
        position: {
            corner: {
                target: 'bottomMiddle',
                tooltip: 'topMiddle'
            }
        },
        style: {
            name: 'cream',
            padding: '7px 13px',
            width: {
                min: 0
            },
            tip: true,
            border: {
                width: 3,
                radius: 5
            },
            classes: {
                content: 'tooltip'
            }
        },
        show: {
            ready: true,
            when: {
                event: 'none'
            },
            effect: {
                type: 'slide'
            },
            solo: true
        },
        hide: {
            effect: {
                type: 'slide'
            },
            delay: 0,
            when: {
                target: $('#' + target),
                event:
                    'unfocus'
            }
        }
    });
}

$(function() {
	$('.ativo').prev().children().attr('style','border: none;');

});
