﻿function showHtmlPopup(pTitle, pMessage, pWidth, pHeight, pCustomPage, pOnClosedJavascript) {
    pMessage = '<strong>Mensagem:</strong><br /><br />' + pMessage;

    if (pCustomPage == '') {
        $.fancybox(
		    pMessage,
		    {
		        'title': pTitle,
		        'showCloseButton': true,
		        'autoDimensions': true,
		        'centerOnScroll': true,
		        'scrolling': 'no',
		        'transitionIn': 'elastic',
		        'transitionOut': 'elastic',
		        'easingIn': 'easeOutBack',
		        'easingOut': 'easeInBack',
		        'opacity': true,
		        onClosed: function() {
		            if (pOnClosedJavascript != '') {
		                eval(pOnClosedJavascript);
		            }
		        }
		    }
	    );
    }
    else {
        $.fancybox(
		    {
		        'width': parseInt(pWidth),
		        'height': parseInt(pHeight),
		        'title': pTitle,
		        'centerOnScroll': true,
		        'transitionIn': 'elastic',
		        'transitionOut': 'elastic',
		        'easingIn': 'easeOutBack',
		        'easingOut': 'easeInBack',
		        'type': 'iframe',
		        'href': pCustomPage,
		        'opacity': true,
		        onClosed: function() {
		            if (pOnClosedJavascript != '') {
		                eval(pOnClosedJavascript);
		            }
		        }
		    }
	    );
    }
}

function showPopupImage(pUrl) {
    $.fancybox(
		    {
		        'title': pTitle,
		        'href': pUrl,
		        'showCloseButton': true,
		        'autoDimensions': true,
		        'centerOnScroll': true,
		        'scrolling': 'no',
		        'transitionIn': 'elastic',
		        'transitionOut': 'elastic',
		        'easingIn': 'easeOutBack',
		        'easingOut': 'easeInBack',
		        'opacity': true
		    }
	    );
}

function validaData(data) {
    //    if(!data)
    //    {
    //     return false;
    //    }
    //    data = data.replace('/', '');
    //    data = data.replace('/', '');
    //    data = data.replace('/', '');

    //    var er = /^(([0][1-9]|[12][0-9])02(19|20)([13579][26]|[02468][048])|
    //      ([0][1-9]|[12][0-8]|[19])02(19|20)([02468][1235679]|[13579][01345789])|
    //      ((([0][1-9]|[12][0-9]|30)(0[469]|11)|
    //      ([0][1-9]|[12][0-9]|3[01])(0[13578]|1[02]))((19|20)[0-9][0-9])))$/;

    //    return (!data.match(er));

    //TODO: corrigir function, foi comentada pois está gerando erro nas páginas
}

function BeginRequestHandler(sender, args) {
    if (args.get_postBackElement().id.toLowerCase().indexOf('avoidblockui') == -1) {
        blockUI();
    }
}

function blockUI() {
    $('#loading_progress').show();
}

function EndRequestHandler(sender, args) {
    unBlockUI();
}

function unBlockUI() {
    $('#loading_progress').hide();
}

function onLeavingPage() {
    blockUI();
}

function applyImageRenderOnText() {
    Cufon.replace('h3,.gillSans', { fontWeight: '300', letterSpacing: '2px', color: '#1a1a1a' });
    Cufon.replace('.gillSansGr', { fontWeight: '200', color: '#D00F6E' });
    Cufon.replace('.gillSansPr', { fontWeight: '200', color: '#515154' });
    Cufon.replace('.gillSansLetterNone', { fontWeight: '300' });
    Cufon.replace('.gillSansBlock', { fontSize: "16px", fontWeight: '300', letterSpacing: '2px', lineHeight: "24px" });
    Cufon.replace('.gillSansBlock a', { fontSize: "16px", fontWeight: '300', letterSpacing: '2px', color: "#D00F6E" });
    Cufon.replace('.gillSans15', { fontSize: "15px", fontWeight: 'light', color: "#D00F6E" });
    Cufon.replace('.gillSans13', { fontSize: "13px", fontWeight: 'light', color: "#1a1a1a" });
    Cufon.replace('.gillSans15', { fontSize: "15px", fontWeight: 'light', color: "#D00F6E" });
    Cufon.replace('.gillSansPrBold', { fontWeight: '400', color: '#515154' });
    Cufon('div#main-nav-sub ul li a', {
        fontWeight: '300',
        hover: { fontWeight: '400' }
    });
    Cufon('h3 a', {
        fontWeight: '300'
    });
}

