/* Altura da tela aonde começa o conteúdo */
var bodyContent_Top  = 420; // px
var bodyContent_Time = 500; // ms
/* ----- */

/*
 * listLog
 */
function listLogInit (number) {
    var divWidth = $('#listLog div').css('width');
    $('#listLog div div').css('width', parseInt(divWidth) * number);
    $('#listLog div').scrollTo(0);
}

function listLogScroll (signal) {
    $('#listLog div:first').scrollTo(signal + '=' + $('#listLog div').css('width'), 500);
}
/* END - listLog */


/*
 * bodyTop - Ir para o topo do site
 */
function bodyTop (value) {
    $(document).scrollTo(value, 500);
}
/* END - bodyTop */


/*
 * outrasNot
 */
function outrasNotInit (number) {
    var divHeight = $('#outrasNot').css('height');
    $('#outrasNot div').css('height', parseInt(divHeight) * number);
    $('#outrasNot').scrollTo(0);
}

function outrasNotScroll (signal) {
    $('#outrasNot').scrollTo(signal + '=' + $('#outrasNot').css('height'), 500);
}
/* END - outrasNot */

/*
 * setLightBox
 */
$(document).ready(function () {
    setLightBox('a[rel="lightbox"]');
});

function setLightBox (elem) {
    if (elem) {
        $(elem).lightBox({
            imageLoading: 'img/lightbox/loading.gif',
            imageBtnClose: 'img/lightbox/close.gif',
            imageBtnPrev: 'img/lightbox/prev.gif',
            imageBtnNext: 'img/lightbox/next.gif',
            imageBlank: 'img/lightbox/blank.gif',
            txtImage: 'Imagem',
            txtOf: 'de'
        });
    }
}
// END - setLightBox

/*
 * galeriasList
 */
function galeriasListInit (number) {
    var divWidth = $('#galeriasList div').css('width');
    $('#galeriasList div div').css('width', parseInt(divWidth) * number);
    $('#galeriasList div').scrollTo(0);
}

function galeriasListScroll (signal) {
    $('#galeriasList div:first').scrollTo(signal + '=' + $('#galeriasList div').css('width'), 500);
}
/* END - galeriasList */

/*
 * fileUpPreview
 */
function inputFileImageChange (elem, field) {
    if (elem && field) {
        fileUpPreview(elem, document.getElementById('IMG_' + field));
    }
}

function inputFileImageClear (field) {
    if (field) {    
        $('#IMG_' + field).html('');
        $('input[name="' + field + '"]').val('');
        $('input[name="FILE_' + field + '"]').val('');
    }
}

function fileUpPreview (objFile, previewer) {
    if(!/(\.gif|\.jpg|\.jpeg|\.png)$/i.test(objFile.value)) {
        alert("Arquivo inválido.");
        objFile.value = null;
        return;
    }
    if (window.navigator.userAgent.indexOf("MSIE 7") != -1) {
        previewer.innerHTML = "";
        previewer.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='file://" + String(objFile.value) +"', sizingMethod='scale')";
    }
    else {
        previewer.innerHTML = "";
        var W = previewer.offsetWidth - 2;
        var H = previewer.offsetHeight - 2;
        var tmpImage = document.createElement('img');
        previewer.appendChild(tmpImage);
        tmpImage.onerror = function () {
            alert("Erro.");
            previewer.innerHTML = "";
            return;
        }
        tmpImage.onload = function () {
            if (this.width > W) {
                this.height = this.height / (this.width / W);
                this.width = W;
            }
            if (this.height > H) {
                this.width = this.width / (this.height / H);
                this.height = H;
            }
        }
        if (window.navigator.userAgent.indexOf("Firefox/3") != -1) {
            var picData = objFile.files.item(0).getAsDataURL();
            tmpImage.src = picData;
            // tmpImage.writeAttribute("title", "ImageSize: "+ objFile.files.item(0).fileSize +" byte");
        }
        else {
            tmpImage.src = "file://" + objFile.value;
        }
    }
}
/* END - fileUpPreview */

/*
 * Mapa
 */
function mapa () {
	var PopUp_W = 1000;
    var PopUp_H =  590;
    var PopUp_L = (screen.width - PopUp_W) / 2;
    var PopUp_T = ((screen.height - PopUp_H) / 2) - 50;
    PopUp_T = (PopUp_T > 0 ? PopUp_T : 0);
    var PopUp_Win = (window.open('mapa.php', 'Farol_Shopping_Mapa', 'width=' + PopUp_W + ', height=' + PopUp_H + ', left=' + PopUp_L + ', top=' + PopUp_T + ', resizable=no, scrollbars=no, toolbar=no, location=no, directories=no, status=no, menubar=no, copyhistory=no'));
    if (parseInt(navigator.appVersion) >= 4) {
        PopUp_Win.window.focus();
    }
}
/* END - Mapa */
