﻿$(document).ready(function() {

    getLang();
    $("select[id$=wmi_language]").change(getData);
    $("select[id$=wmi_country]").change(getLang);

});

function getData() {
    var lang = $("select[id$=wmi_language]").val();
    $.getJSON("/logic/get_LDAData.aspx", { lang: lang }, displayContent);
}

function displayContent(info) {
    $("div[id$=contPleaseSelect]").html(info.pleaseselect);
    $("div[id$=contOrText]").html(info.ortext);
    $("div[id$=contResponsibility]").html(info.responsibility);
    $("div[id$=contTrademark]").html(info.trademark);
    $("div[id$=contCopyright]").html(info.copyright);
    $("div[id$=contCentury]").html(info.century);
    $("div[id$=contTermsPrivacy]").html(info.termsprivacy);
    $("div[id$=contLDATerms]").html(info.ldaterms);
    $("a[id$=btnSubmitLink]").text(info.ldasubmit);
    $("span[id$=lblBirthDate]").html(info.birthdate);
    $("span[id$=lblLanguage]").html(info.ldalanguage);
    $("span[id$=lblCountry]").html(info.ldacountry);
    $("select[id$=wmi_country]").attr("title", info.wmi_country_error);
    $("select[id$=wmi_birth_month]").attr("title", info.wmi_birth_month_error);
    $("select[id$=wmi_birth_day]").attr("title", info.wmi_birth_day_error);
    $("select[id$=wmi_birth_year]").attr("title", info.wmi_birth_year_error);
    $("#valDate").val(info.wmi_birth_date_error);
    $("select[id$=wmi_birth_year] option").eq(0).html(info.wmi_birth_year_label);
    $("select[id$=wmi_birth_month] option").eq(0).html(info.wmi_birth_month_label);
    $("select[id$=wmi_birth_day] option").eq(0).html(info.wmi_birth_day_label);

}

function displayLang(info) {
    $("select[id$=wmi_language]").html(info.langlist);
    getData();
    if (info.prohibited == "true") {
        window.location.href = "prohibited.aspx?langType=" + $("select[id$=wmi_language]").val();
        $("select[id$=wmi_country]").val('USA');
    
    }
}

function toggleType(selected) {
    if (selected == "rock") {
        $(".ldaLatinoButton").css("color", "#444444");
        $("input[id$=musicType]").val("rock");
        $(".ldaRockButton").css("color", "#CFA54A");
        $(".cover").hide(0);
        $(".openHide").show(0);

        if ($("select[id$=wmi_country]").val() == "USA") {

            $("select[id$=wmi_language]").val("1033").change();
            
            if ($("select[id$=wmi_language] option").length > 1) {
                $("select[id$=wmi_language] option:last").remove();
            }
        }

        
    }
    else if (selected == "latino") {
        $(".ldaRockButton").css("color", "#444444");
        $("input[id$=musicType]").val("latino");
        $(".ldaLatinoButton").css("color", "#CFA54A");
        $(".cover").hide(0);
        $(".openHide").show(0);


        if ($("select[id$=wmi_country]").val() == "USA") {
            if ($("select[id$=wmi_language] option").length == 1) {
                $("select[id$=wmi_language]").append("<option value='21514'>Espa&ntilde;ol (E.U.) [Spanish (U.S.)]</option>");               
            }

            $("select[id$=wmi_language]").val("21514").change();
        }
        
    }

}
    
function getLang() {
    var countryitem = $("select[id$=wmi_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();
}


        