﻿// JScript File
function ChangePage()
{
    var sPath = window.location.pathname;
    //var sPage = sPath.substring(sPath.lastIndexOf('\\') + 1);
    var sPage = sPath.substring(sPath.lastIndexOf('/') + 1);
    if (sPage == 'FirstPage.aspx')
    {
        var sufix = '';
        if (window.location.search.indexOf("PreviewMode") > 0)
            sufix = window.location.search;
        if (sufix != "")
            window.location = "../Pages/ViewArticle.aspx" + sufix + "&ArticleType=1";
        else
            window.location = "../Pages/ViewArticle.aspx?ArticleId=-1&ArticleType=1";
    }
    if (sPath.indexOf('Articole/') > 0)
     {
        window.location = "../Pages/FirstPage.aspx" + window.location.search;
    }
     if (sPage == 'ViewArticle.aspx')
     {
        window.location = "../Pages/FirstPage.aspx" + window.location.search;
    }
    if (sPage == 'Archive.aspx')
     {
        window.location = "../Pages/FirstPage.aspx" + window.location.search;
    }
     if (sPage == 'CalculatorResults.aspx')
     {
        window.location = "../Pages/FirstPage.aspx" + window.location.search;
    }
    if (sPage == 'Contact.aspx')
     {
        window.location = "../Pages/FirstPage.aspx" + window.location.search;
    }
    if (sPage == 'SearchResults.aspx')
     {
        window.location = "../Pages/FirstPage.aspx";
    }
    if (sPage == 'Register.aspx')
     {
        window.location = "../Pages/FirstPage.aspx" + window.location.search;
    }
    if (sPage == 'Terms.aspx')
     {
        window.location = "../Pages/FirstPage.aspx" + window.location.search;
    }
}

function ShowSubscriptionDetails(divId)
{
    var divObj = document.getElementById(divId);

    divObj.style.display = 'block';
}

function HideSubscriptionDetails(divId)
{
    var divObj = document.getElementById(divId);

    divObj.style.display = 'none';
}

function submitForm(e, bntSubmitId)
{
    var keycode;
    if (window.event) 
        keycode = window.event.keyCode;
    else if (e)
        keycode = e.which;
    else
        return true;
    
    if (keycode == 13)
    {
        var btnSubmit = document.getElementById(bntSubmitId);
        btnSubmit.click();
        return false;
    }
    else
       return true;
}

function IsSearchStringEmpty(idTxtSearch)
{
    var txtSearch = document.getElementById(idTxtSearch);
    if (txtSearch != null && txtSearch.value == '')
    {
        alert('Introduceti textul dupa care doriti sa cautati');
        return false;
    }
    return true;
}
