﻿$(document).ready(function() {

    getLang();
    $("select[id$=Language]").change(getData);
    $("select[id$=Country]").change(getLang);

});

function getData() {
    var lang = $("select[id$=Language]").val();
    $.getJSON("/logic/get_LDAData.aspx", { lang: lang }, displayContent);
}

function displayContent(info) {
    $("#lbl_Birthdate").html(info.birthdate);
    $("#lbl_Country").html(info.ldacountry);
    $("#lbl_Language").html(info.ldalanguage);
    $("#ldaLegalText").html(info.formsubmit);
    $("#welcomeContent").html(info.welcome);
    $("div.facebook").html(info.facebook);
    $("div.responsibility").html(info.responsibility);
    $("div.copyright").html(info.copyright);
    $("div.footerNav").html(info.footernav);
    $("#termsPrivacyCentury").html(info.terms);
    $("#btnSubmitImg").html(info.submitButton);
    $("select[id$=Country]").attr("title", info.wmi_country_error);
    $("select[id$=month]").attr("title", info.wmi_birth_month_error);
    $("select[id$=wmi_day]").attr("title", info.wmi_birth_day_error);
    $("select[id$=year]").attr("title", info.wmi_birth_year_error);
    $("#valDate").val(info.wmi_birth_date_error);
    $("select[id$=year] option").eq(0).html(info.wmi_birth_year_label);
    $("select[id$=month] option").eq(0).html(info.wmi_birth_month_label);
    $("select[id$=wmi_day] option").eq(0).html(info.wmi_birth_day_label);
    $("span.ldaIntro").html(info.intro);
    $("#errors ul").html("");
    $("#btnSubmitLink").css("background-image", "url(" + info.submitImgPath + ")");
}

function displayLang(info) {
   
    $("select[id$=Language]").html(info.langlist);
    getData();
    if (info.prohibited == "true") {
        var langval = $("select[id$=Language]").val();
        $("select[id$=Country]").val('USA');
        window.location.href = "prohibited.aspx?langType=" + langval;
        
    
    }
}
    
function getLang() {
    var countryitem = $("select[id$=Country]");
    var country = countryitem.val();
    var countryId = countryitem.attr("id");
    var countrySelect = "#" + countryId;
    if (country == "" || country == null) {
        country = "USA";
    }
    $.getJSON("/logic/get_LDAData.aspx", { country: country }, displayLang);
    
}

function submitForm() {
    $("#aspnetForm").submit();
}


        
