var webRoot;
var webRootSeguro;
var webTeste;
var endereco = document.location.href;
var endR = endereco.substr(endereco.indexOf('://')+3,3);
var strAutenticacaoCadastroUnico = "TmluaG9Tb2xlaWw=";
var porta = '';
if(location.port != 80) porta=':' + location.port;

switch (endR) {
    case '10.':
        webDomain='http://10.141.1.17/';
        webRoot='http://10.141.1.17/ninhosoleil/';
        webRootSeguro='https://10.141.1.17/wscadastrounico/';
        webTeste='';
       break;
    case 'sta':
        webDomain='http://staging.nestle.com.br/';
        webRoot = 'http://staging.nestle.com.br/ninhosoleil/';
        webRootSeguro='https://staging.nestle.com.br/wscadastrounico/';
        webTeste='';
       break;
    case 'www':
        webDomain='http://www.nestle.com.br/';
        webRoot = 'http://www.nestle.com.br/ninhosoleil/';
        webRootSeguro='https://www.nestle.com.br/wscadastrounico/';
        webTeste='';
       break;
    case 'loc':
        webDomain='http://10.141.1.17/';
        webRoot='http://localhost' + porta +'/web/';
        webRootSeguro='http://10.141.1.17/wscadastrounico/';
        webTeste='';
       break;
    default:
        webDomain='';
        webRoot='';
        webRootSeguro='';
        webTeste='Teste';
}

function popupPolitica()
{
    args = 'width=660, height=500, location=0, scrollbars=1';
    window.open(webDomain + 'wscadastrounico/Politica/wfPolitica.aspx?sgAreaSite='+strAutenticacaoCadastroUnico,'Politica',args);
}
function popupFaleConosco(){
    args = 'width=660px, height=600, location=0, scrollbars=1';
    window.open(webDomain + '/wscadastrounico/fale/wfFale.aspx?SgAreaSite='+strAutenticacaoCadastroUnico+'&cdAssunto=166', 'FaleCom', args);
}
function popupCadastro()
{
    args = "width=660px,height=600,location=0,menubar=0,resizable=0,scrollbars=1,status=0,titlebar=0,toolbar=0,hotkeys=0,directories=0,copyhistory=0,screenx=100,screeny=100,left=100,top=100";
    window.open(webRootSeguro+'cadastro/wfcadastro.aspx?sgAreaSite='+strAutenticacaoCadastroUnico, 'Cadastro',args);
}
function popupLoginBlog(redir)
{
    args = "width=520,height=520,location=0,menubar=0,resizable=0,scrollbars=no,status=0,titlebar=0,toolbar=0,hotkeys=0,directories=0,copyhistory=0,screenx=100,screeny=100,left=100,top=100";
    //window.open(redir, 'Login', args);
    window.open(webRootSeguro + 'login/wfLogin' + webTeste + '.aspx?SgAreaSite=' + strAutenticacaoCadastroUnico + '&RedirectAfterLogoff=' + webRoot + 'Logoff.aspx' + '&RedirectAfterLogin=' + webRoot + redir, 'Chamyto_Login', args);
}
function executaLogoff()
{
      window.document.location.href = webRoot + 'logoff.aspx';
}

function popupQueroMeCadastrar()
{
    popupCadastro();
    window.close();
}

function logado() 
{
    window.opener.location.href = window.opener.location.href;
    self.close();
}

function LoginPath() {
    return webRootSeguro + 'login/wfLogin' + webTeste + '.aspx?SgAreaSite=' + strAutenticacaoCadastroUnico + '&RedirectAfterLogoff=' + webRoot + 'Logoff.aspx' + '&RedirectAfterLogin=' + webRoot + 'Login.aspx';
    //return webRootSeguro + 'login/wfLogin' + webTeste + '.aspx?SgAreaSite=' + strAutenticacaoCadastroUnico + '&RedirectAfterLogoff=' + webRoot + '&RedirectAfterLogin=' + webRoot;
}

function iframelogin() {
    var dest = LoginPath();
    $("#ifr-login").attr('src', dest);
}

