﻿function CallHigh(src) {
    parent.location.href = '/Hamilton/WebSite' + src;
}

function CallMovieSeminario(src) {
    parent.location.href = '/Hamilton/WebSite' + src;
}

function CallSearch(Keyword) {
    if (Keyword.length < 3) {
        alert('A palavra-chave tem que ter pelo menos 3 caracteres.');
    } else {
        parent.location.href = '/Hamilton/WebSite/Search/Default.aspx?key=' + MyUrlEncode(Keyword);
    }
}

function MyUrlEncode(Keyword) {
    Keyword = Keyword.toLowerCase();
    Keyword = escape(Keyword);
    
    while (Keyword.indexOf('%C') >= 0) { Keyword = Keyword.replace('%C', '%c3%8'); }
    while (Keyword.indexOf('%D') >= 0) { Keyword = Keyword.replace('%D', '%c3%9'); }
    while (Keyword.indexOf('%E') >= 0) { Keyword = Keyword.replace('%E', '%c3%a'); }
    while (Keyword.indexOf('%F') >= 0) { Keyword = Keyword.replace('%F', '%c3%b'); }
    
    return Keyword;
}

function ShowPicture(src, label) {
    document.getElementById('ctl00_body_imgPictureAmp').src = '/Hamilton/AppFile' + src;
    document.getElementById('ctl00_body_lblPictureAmp').innerHTML = label;
}

/*****************************************************
*** Masks
*****************************************************/
function MaskPhone(field){
    if(MaskInteger(field)==false){
        event.returnValue = false;
    }    
    return FormatField(field, '(00) 0000-0000', event);
}

function MaskCEP(field){
    if(MaskInteger(field)==false){
        event.returnValue = false;
    }    
    return FormatField(field, '00.000-000', event);
}

function MaskDate(field){
    if(MaskInteger(field)==false){
        event.returnValue = false;
    }    
    return FormatField(field, '00/00/0000', event);
}

function MaskInteger(){
    if (event.keyCode < 48 || event.keyCode > 57){
        event.returnValue = false;
        return false;
    }
    return true;
}

function FormatField(campo, Mascara, evento) { 
    var boleanoMascara; 
    
    var Digitato = evento.keyCode;
    exp = /\-|\.|\/|\(|\)| /g
    campoSoNumeros = campo.value.toString().replace( exp, "" ); 
   
    var posicaoCampo = 0;     
    var NovoValorCampo="";
    var TamanhoMascara = campoSoNumeros.length;
    
    if (Digitato != 8) { // backspace 
        for(i=0; i<= TamanhoMascara; i++) { 
            boleanoMascara  = ((Mascara.charAt(i) == "-") || (Mascara.charAt(i) == ".")
                                || (Mascara.charAt(i) == "/")) 
            boleanoMascara  = boleanoMascara || ((Mascara.charAt(i) == "(") 
                                || (Mascara.charAt(i) == ")") || (Mascara.charAt(i) == " ")) 
            if (boleanoMascara) { 
                NovoValorCampo += Mascara.charAt(i); 
                  TamanhoMascara++;
            } else { 
                NovoValorCampo += campoSoNumeros.charAt(posicaoCampo); 
                posicaoCampo++; 
              }            
          }     
        campo.value = NovoValorCampo;
          return true; 
    } else { 
        return true; 
    }
}

/*****************************************************
*** Font Size
*****************************************************/
var PageFontSize = 3;
function FontSizeMore() {
    if (PageFontSize < 6) {
        PageFontSize += 1;
        document.getElementById('ctl00_body_lblPageText').className = 'PageText' + PageFontSize;
    }
}

function FontSizeLess() {
    if (PageFontSize > 1) {
        PageFontSize -= 1;
        document.getElementById('ctl00_body_lblPageText').className = 'PageText' + PageFontSize;
    }
}

/*****************************************************
*** Send To
*****************************************************/
var BoxWidth;
var BoxHeight;
function SendToFriend(TitleSend, LinkSend) {
    var PageWidth = document.body.offsetWidth;
    var PageHeight = document.getElementById('PageEnd').offsetTop + 20;
    
    document.getElementById('ctl00_body_pnlSendToPage').style.display = 'block';
    document.getElementById('ctl00_body_pnlSendToPage').style.width = PageWidth + 'px';
    document.getElementById('ctl00_body_pnlSendToPage').style.height = PageHeight + 'px';

    document.getElementById('ctl00_body_pnlSendToBox').style.display = 'block';
    BoxWidth = document.getElementById('ctl00_body_pnlSendToBox').offsetWidth;
    BoxHeight = document.getElementById('ctl00_body_pnlSendToBox').offsetHeight;
    document.getElementById('ctl00_body_pnlSendToBox').style.left = parseInt((PageWidth - BoxWidth) / 2) + 'px';
    document.getElementById('ctl00_body_pnlSendToBox').style.top = (parseInt((document.body.offsetHeight - BoxHeight) / 2) + document.documentElement.scrollTop) + 'px';

    document.getElementById('ctl00_body_lblSendToBox').innerHTML = '<iframe id="frmSend" name="frmSend" src="/Hamilton/WebSite/SendTo/Default.aspx?title=' + escape(TitleSend) + '&link=' + escape(LinkSend) + '" height="258" width="500" frameborder="0" scrolling="no"></iframe>';
}

function SendToClose() {
    document.getElementById('ctl00_body_pnlSendToPage').style.display = 'none';
    document.getElementById('ctl00_body_pnlSendToBox').style.display = 'none';
}

/*****************************************************
*** Zoom
*****************************************************/
function ZoomIn() {
    var PageWidth = document.body.offsetWidth;
    var PageHeight = document.getElementById('PageEnd').offsetTop + 20;
    
    document.getElementById('ctl00_body_pnlZoomPage').style.display = 'block';
    document.getElementById('ctl00_body_pnlZoomPage').style.width = PageWidth + 'px';
    document.getElementById('ctl00_body_pnlZoomPage').style.height = PageHeight + 'px';

    document.getElementById('ctl00_body_pnlZoomBox').style.display = 'block';
    BoxWidth = document.getElementById('ctl00_body_pnlZoomBox').offsetWidth;
    BoxHeight = document.getElementById('ctl00_body_pnlZoomBox').offsetHeight;
    document.getElementById('ctl00_body_pnlZoomBox').style.left = parseInt((PageWidth - BoxWidth) / 2) + 'px';
    document.getElementById('ctl00_body_pnlZoomBox').style.top = (parseInt((document.body.offsetHeight - BoxHeight) / 2) + document.documentElement.scrollTop) + 'px';
}

function ZoomClose() {
    document.getElementById('ctl00_body_pnlZoomPage').style.display = 'none';
    document.getElementById('ctl00_body_pnlZoomBox').style.display = 'none';
}