function callOnLoaded () {
  var quicklink_large_windowopen = document.getElementById('quicklink_large_windowopen');
  var quicklink_small_windowopen = document.getElementById('quicklink_small_windowopen');
  if (quicklink_large_windowopen != null) {
    quicklink_large_windowopen.style.display = 'block';
  }
  if (quicklink_small_windowopen != null) {
    quicklink_small_windowopen.style.display = 'block';
  }
}
window.onload = callOnLoaded;

function handleQuicklinkWindow(size,window){
  var quicklink = document.getElementById('quicklink_'+size+'_window');
  
  if(window == 1){
    quicklink.style.display = 'block';
    if(document.getElementById('main_company_inquiry')){
      document.getElementById('main_company_inquiry').style.display = 'none';
    }
  }
  else if(window == 0){
    quicklink.style.display = 'none';
    if(document.getElementById('main_company_inquiry')){
      document.getElementById('main_company_inquiry').style.display = 'block';
    }
  }
}

function changeQuicklinkWindow(size,window){
  var quicklink_code = document.getElementById('quicklink_'+size+'_brandlist_code');
  var quicklink_char = document.getElementById('quicklink_'+size+'_brandlist_char');
  
  if(window == 1){
    quicklink_char.style.display = 'block';
    quicklink_code.style.display = 'none';
  }
  else if(window == 0){
    quicklink_code.style.display = 'block';
    quicklink_char.style.display = 'none';
  }
}

function changeBrandlistSort(window){
  var brandlist_code = document.getElementById('main_general_brandlis_code');
  var brandlist_char = document.getElementById('main_general_brandlis_char');
  
  if(window == 0){
    brandlist_code.style.display = 'block';
    brandlist_char.style.display = 'none';
  }
  else if(window == 1){
    brandlist_char.style.display = 'block';
    brandlist_code.style.display = 'none';
  }
}


function selectPodcastType(action){
  var podcast_sound_tab = document.getElementById('select_sound');
  var podcast_movie_tab = document.getElementById('select_movie');
  var podcast_sound_list = document.getElementById('main_general_podcast_sound');
  var podcast_movie_list = document.getElementById('main_general_podcast_video');
  
  if(action == 0){
    podcast_sound_tab.style.zIndex = 1;
    podcast_movie_tab.style.zIndex = -1;
    podcast_sound_list.style.display = "block";
    podcast_movie_list.style.display = "none";
  }
  else if(action == 1){
    podcast_sound_tab.style.zIndex = -1;
    podcast_movie_tab.style.zIndex = 1;
    podcast_sound_list.style.display = "none";
    podcast_movie_list.style.display = "block";
  }
}

function selectInquiry(preset){
  var select = document.getElementById('main_company_inquiry_select_selected');
  var selected = null;
  if(select != null){
    selected = select.value;
  }
  var exp_regist = document.getElementById('main_company_inquiry_explain_toregist');
  var exp_import = document.getElementById('main_company_inquiry_explain_toimport');
  // var exp_brand  = document.getElementById('main_company_inquiry_explain_tobrand');
  var exp_site   = document.getElementById('main_company_inquiry_explain_tosite');
  var inq_regist = document.getElementById('main_company_inquiry_toregist');
  var inq_import = document.getElementById('main_company_inquiry_toimport');
  // var inq_brand  = document.getElementById('main_company_inquiry_tobrand');
  var inq_site   = document.getElementById('main_company_inquiry_tosite');
  var inq_submit = document.getElementById('main_company_inquiry_submit');
  
  if(preset){
    selected = preset;
    if(select != null){
      select.value = preset;
    }
  }
  
  exp_regist.style.display = "none";
  exp_import.style.display = "none";
  // exp_brand.style.display = "none";
  exp_site.style.display = "none";
  inq_regist.style.display = "none";
  inq_import.style.display = "none";
  // inq_brand.style.display = "none";
  inq_site.style.display = "none";
  
  if(selected == "toregist"){
    exp_regist.style.display = "block";
    inq_regist.style.display = "block";
  }
  else if(selected == "toimport"){
    exp_import.style.display = "block";
    inq_import.style.display = "block";
  }
  // else if(selected == "tobrand"){
  //   exp_brand.style.display = "block";
  //   inq_brand.style.display = "block";
  // }
  else if(selected == "tosite"){
    exp_site.style.display = "block";
    inq_site.style.display = "block";
  }
  else{
    exp_regist.style.display = "block";
    exp_import.style.display = "block";
    // exp_brand.style.display = "block";
    exp_site.style.display = "block";
  }
}

function documentWindowOpen (brand_seqid, document_url) {
    var url_data_file = '^http(s)?://.*/contents/data_file.php\?.*$';
    var url_data_url = '^(http(s)?://.*/contents/data_url.php\?.*)&url=(.*)$';
    if (document_url.match (url_data_file)) {
        window.open ('/en/document.php?brand=' + brand_seqid + '&document_url=' + escape (document_url) + '&url=' + escape (window.location.href), '_blank');
    }
    else {
        var reg_exp = new RegExp (url_data_url, '');
        var result = reg_exp.exec (document_url);
        if (result) {
            document_url = result[1] + '&url=' + escape (result[3]);
        }
        window.open (document_url, '_blank');
    }
}

