//var path = 'http://localhost:4188/Sentimental2010.Site';
var path = 'http://www.sentimentalfilmes.com.br/site/';

function AbreSite() {
    $('#site').show();
    $('#site').addClass('portugues');
    $('.bt-linguas').attr('title', 'en-US');
    $('.bt-linguas').live('click', function() {
        if ($(this).attr('title') === 'en-US') {

            $(this).attr('title', 'pt-BR');
            $('#site').addClass('english');
            $('#site').removeClass('portugues');

        } else {
            $(this).attr('title', 'en-US');
            $('#site').addClass('portugues');
            $('#site').removeClass('english');
        }
    });
}

var Site = {
    Init: function() {
        window.setInterval('AbreSite()', 700);
    },

    Diretorespt: function(idDiretores) {
        if (idDiretores == '') {
            idDiretores = '1';
        }

        $('.hide').show();
        $.ajax({
            type: 'GET',
            url: 'sentimental.asmx/GetDirectors?idDirector=' + idDiretores,
            dataType: 'xml',
            success: parseXML1,
            complete: function() { $('#pane .loading').remove(); }
        });

        function parseXML1(data) {

            var html = ' ';
            var nome = $(data).find('Name').text();
            var conteudo = $(data).find('Bio_ptBR').text();
            //var picture = $(data).find('PictureFileName').text();

            html += '<span>' + nome + '</span><p>' + conteudo + '</p>';
            $('#biografia' + idDiretores).html(html);
            $('#biografia' + idDiretores).show();
        }

        //videos
        $.ajax({
            type: 'GET',
            url: 'sentimental.asmx/ListMoviesByDirector?idDirector=' + idDiretores,
            dataType: 'xml',
            success: parseXML,
            complete: function() { $('#pane .loading').remove(); }
        });

        function parseXML(data) {
            var html2 = ' ';
            $(data).find('Movie').each(function() {
                var nome1 = $(this).find('Name').text();
                var imagem1 = $(this).find('ThumbName').text();
                var filme1 = $(this).find('FileName').text();
                filme1 = path + '/Video.aspx?video=' + filme1;
                html2 += '<li><a href=\"javascript:openModal(\'' + filme1 + '\');\" title=\"' + nome1 + '\"><img src="' + path + '..\/Admin\/userfiles\/movies\/' + imagem1 + '" /></a>';
            });
            $('#pane ul').html(html2);
            setTimeout(function() { $('#pane').jScrollPane({ showArrows: false, scrollbarWidth: 7, arrowSize: 16, dragMinHeight: 54, dragMaxHeight: 54 }); }, 1000);
        }



    },

    Diretoresen: function(idDiretores) {
        if (idDiretores == '') {
            idDiretores = '1';
        }

        $('.hide').show();

        $.ajax({
            type: 'GET',
            url: 'sentimental.asmx/GetDirectors?idDirector=' + idDiretores,
            dataType: 'xml',
            success: parseXML1,
            complete: function() { $('#pane .loading').remove(); }
        });

        function parseXML1(data) {
            var html = ' ';
            var nome = $(data).find('Name').text();
            var conteudo = $(data).find('Bio_enUS').text();
            //var picture = $(data).find('PictureFileName').text();

            html += '<span>' + nome + '</span><p>' + conteudo + '</p>';

            $('#biografia' + idDiretores).html(html);
            $('#biografia' + idDiretores).show();
        }

        //videos

        $.ajax({
            type: 'GET',
            url: 'sentimental.asmx/ListMoviesByDirector?idDirector=' + idDiretores,
            dataType: 'xml',
            success: parseXML,
            complete: function() { $('#pane .loading').remove(); }
        });

        function parseXML(data) {
            var html2 = ' ';
            $(data).find('Movie').each(function() {
                var nome1 = $(this).find('Name').text();
                var imagem1 = $(this).find('ThumbName').text();
                var filme1 = $(this).find('FileName').text();
                filme1 = path + '/Video.aspx?video=' + filme1;
                html2 += '<li><a href=\"javascript:openModal(\'' + filme1 + '\');\" title=\"' + nome1 + '\"><img src="' + path + '..\/Admin\/userfiles\/movies\/' + imagem1 + '" /></a>';
            });
            $('#pane ul').html(html2);
            setTimeout(function() { $('#pane').jScrollPane({ showArrows: false, scrollbarWidth: 7, arrowSize: 16, dragMinHeight: 54, dragMaxHeight: 54 }); }, 1000);
        }
    },

    NewsEN: function() {
        $.ajax({
            type: 'GET',
            url: 'sentimental.asmx/ListNews',
            data: 'languageName=en-US',
            dataType: 'xml',
            success: parseXML
        });

        function parseXML(data) {

            var html = ' ';
            $(data).find('New').each(function() {
                var data = $(this).find('Title').text();
                var conteudo = $(this).find('Content').text();
                var imagem = $(this).find('ThumbFile').text();
                var video = $(this).find('VideoFile').text();
                var htmlImage;

                if (imagem != '') {
                    var caminhoImagem = "Video.aspx?imagem=../Admin/userfiles/image/" + imagem;
                    htmlImage = "<a hreft='#' onclick='openModal(\"" + caminhoImagem + "\");'><img src='" + "../Admin/userfiles/image/" + imagem + "'/></a>";

                    if (video != 'nulo') {
                        if (video != '') {
                            video = path + '/Video.aspx?video=' + video;
                            htmlImage = "<a href=\"#\" onclick='openModal(\"" + video + "\");'><img src='" + "../Admin/userfiles/image/" + imagem + "'/></a>";
                        }
                    }
                }
                else {
                    htmlImage = "<img src='" + "../Admin/userfiles/image/imgnaodisponivel.jpg'/>";
                }

                if (imagem == 'nulo') {
                    htmlImage = ' ';
                }

                conteudo = conteudo.replace('<p>', '');
                conteudo = conteudo.replace('</p>', '');

                if (imagem == '5304ea51-5348-4617-9b24-2125d26333ba.jpg') {
                    html += '<div><p>' + '<span class="sp-img">' + htmlImage + '</span>' + '<span style="float:left;">' + data + '</span><br />' + conteudo + '<br /><a class=\"leia-mais-talentos repfl\" href=\"javascript:openModalTalentosPromissores(\'talentos\', \'Talentos.aspx\', \'753\', \'662\');\" title=\"Leia mais\">Leia mais</a></p>' + '</div>';
                } else {

                    if (imagem != '') {
                        html += '<div><p>' + '<span class="sp-img">' + htmlImage + '</span>' + '<span style="float:left;">' + data + '</span><br />' + conteudo + '</p>' + '</div>';
                    }
                    else {
                        html += '<div><p>' + '<span style="float:left;">' + data + '</span><br />' + conteudo + '</p>' + '</div>';
                    }
                }
            });

            $('.news').html(html);

            setTimeout(function() { $('#pane2').jScrollPane({ showArrows: false, scrollbarWidth: 7, arrowSize: 16, dragMinHeight: 54, dragMaxHeight: 54 }); }, 150);
        }
    },

    NewsPT: function() {
        $.ajax({
            type: 'GET',
            url: 'sentimental.asmx/ListNews',
            data: 'languageName=pt-BR',
            dataType: 'xml',
            success: parseXML
        });

        function parseXML(data) {
            var html = ' ';

            $(data).find('New').each(function(e) {
                var data = $(this).find('Title').text();
                var conteudo = $(this).find('Content').text();
                var imagem = $(this).find('ThumbFile').text();
                var video = $(this).find('VideoFile').text();
                var htmlImage;

                if (imagem != '') {
                    var caminhoImagem = "Video.aspx?imagem=../Admin/userfiles/image/" + imagem;
                    htmlImage = "<a hreft='#' onclick='openModal(\"" + caminhoImagem + "\");'><img src='" + "../Admin/userfiles/image/" + imagem + "'/></a>";

                    if (video != 'nulo') {
                        if (video != '') {
                            video = path + '/Video.aspx?video=' + video;
                            htmlImage = "<a href=\"#\" onclick='openModal(\"" + video + "\");'><img src='" + "../Admin/userfiles/image/" + imagem + "'/></a>";
                        }
                    }
                }
                else {
                    htmlImage = '';
                }

                if (imagem == 'nulo') {
                    htmlImage = ' ';
                }

                conteudo = conteudo.replace('<p>', '');
                conteudo = conteudo.replace('</p>', '');

                if (imagem == '5304ea51-5348-4617-9b24-2125d26333ba.jpg') {
                    html += '<div><p>' + '<span class="sp-img">' + htmlImage + '</span>' + '<span style="float:left;">' + data + '</span><br />' + conteudo + '<br /><a class=\"leia-mais-talentos repfl\" href=\"javascript:openModalTalentosPromissores(\'talentos\', \'Talentos.aspx\', \'753\', \'662\');\" title=\"Leia mais\">Leia mais</a></p>' + '</div>';
                } else {

                    if (imagem != '') {
                        html += '<div><p>' + '<span class="sp-img">' + htmlImage + '</span>' + '<span style="float:left;">' + data + '</span><br />' + conteudo + '</p>' + '</div>';
                    }
                    else {
                        html += '<div><p>' + '<span style="float:left;">' + data + '</span><br />' + conteudo + '</p>' + '</div>';
                    }
                }
            });

            $('.news').html(html);
            setTimeout(function() { $('#pane2').jScrollPane({ showArrows: false, scrollbarWidth: 7, arrowSize: 16, dragMinHeight: 54, dragMaxHeight: 54 }); }, 150);
        }
    }
}

$(document).ready(function(){
    Site.Init();
    
    $('#pane').jScrollPane({
        showArrows:false, 
        scrollbarWidth:7, 
        arrowSize:16,
        dragMinHeight:54, 
        dragMaxHeight:54
    });

    
    
    /*vertical*/
	var elHeight = $('#site').height();
	var bodyHeight = $(document).height();
	var mathCount = bodyHeight - elHeight ;
	
	$('#site').css('top',mathCount/2);
});
  
  
