$(function() {
  $("div[id^='DIVTabLabel_']").mouseover(function() {
    selectedDIVTabLabelName = $(this).attr("id");
    selectedDIVContentName = selectedDIVTabLabelName.replace("DIVTabLabel_", "DIVContent_");

    $("div[id^='DIVContent_']").css("display", "none");
    $("div[id^='" + selectedDIVContentName + "']").css("display", "block");

    $("div[id^='DIVTabLabel_'] > div").removeClass("TabLabelSelected");
    $("div[id^='" + selectedDIVTabLabelName + "'] > div").addClass("TabLabelSelected");
    
  });
});

function checkZIPCode(zipCodeFieldName,countryIDFieldName,townFieldName, townSelectPlace, xmasFunctions) {
  
  if ($(zipCodeFieldName).val().length > 3) {
    $.post("/public/ajax/jajax.php",{
      ZIPCode: $(zipCodeFieldName).val(),
      CountryID: $(countryIDFieldName).val(),
      action: "checkZIPCode"
    }, function(xml) {
     
      
      $("select[name='" + townFieldName + "']").children().remove().end();
      
      $(xml).find('Town').each(function(){
        $("select[name='" + townFieldName + "']").append('<option selected value="' + $(this).text() + '">' + $(this).text() + '</option>')
      })
      $("select[name='" + townFieldName + "'] option:first").attr('selected','selected');

      if($("select[name='" + townFieldName + "']").val() == 'Budapest') {
        $("div[id^='xmasalertdiv']").css("display", "none");
      }
      else {
        $("div[id^='xmasalertdiv']").css("display", "");
      }

    });
  }
}
