﻿function resize_fix(){
  document.getElementById('thewindow').style.height = document.body.clientHeight + "px"; 
}
function showWindow() {
end_opacity = 50; //end opacity, 25 = 25%, 50 = 50%, 100 = 100%, etc.
increase_opacity_by = 10; //how much to increase by each time the timeout ends
timeout = 10; //timeout in miliseconds, 0 = instant fade-out

win = document.getElementById('thewindow');
winbackground = document.getElementById('thewindowbackground');
wincontent = document.getElementById('thewindowcontent');
cur_opacity = 0;

resize_fix();

if(document.getElementsByTagName('select')[0] != null){
  document.getElementsByTagName('select')[0].style.display='none';
}
var timer = null;
  if(timeout > 0) {
    cur_opacity = 0;
  
    winbackground.style.opacity = cur_opacity / 100;
    winbackground.style.filter = "alpha(opacity=" + cur_opacity + ")";
    win.style.display = 'block';
    wincontent.style.display = 'none';
    timer = setTimeout("increase_opacity()",timeout);
    
  }
  else {
    winbackground.style.opacity = end_opacity / 100;
    winbackground.style.filter = "alpha(opacity=" + end_opacity + ")";
    win.style.display = 'block';
    wincontent.style.display = 'block';
  }
}

function increase_opacity() {
  cur_opacity += increase_opacity_by;

  winbackground.style.opacity = cur_opacity / 100;
  winbackground.style.filter = "alpha(opacity=" + cur_opacity + ")";
  
  if(cur_opacity < end_opacity) {
    timer = setTimeout("increase_opacity()",timeout);
  }
  else {
    wincontent.style.display = 'block';
  }
}

function hideWindow() {
  if(document.getElementsByTagName('select')[0] != null){
    document.getElementsByTagName('select')[0].style.display='block';
  }
  win.style.display = 'none';
}
function submitForm(){
  if(document.reg.onsubmit()){
    document.getElementById('error_field').style.display="none";
    document.reg.submit();
  }
}

function show_story(name) {
    if (name == "Jian") {
    document.getElementById("Jian").style.display = 'block';
    document.getElementById("Kim").style.display = 'none';
    document.getElementById("Young").style.display = 'none';
    document.getElementById("link_nav_Jian").className = 'link_nav_active';
    document.getElementById("link_nav_Kim").className = 'link_nav';
    document.getElementById("link_nav_Young").className = 'link_nav';
  }
    else if (name == "Kim") {
    document.getElementById("Jian").style.display = 'none';
    document.getElementById("Kim").style.display = 'block';
    document.getElementById("Young").style.display = 'none';
    document.getElementById("link_nav_Jian").className = 'link_nav';
    document.getElementById("link_nav_Kim").className = 'link_nav_active';
    document.getElementById("link_nav_Young").className = 'link_nav';
  }
    else if (name == "Young") {
    document.getElementById("Jian").style.display = 'none';
    document.getElementById("Kim").style.display = 'none';
    document.getElementById("Young").style.display = 'block';
    document.getElementById("link_nav_Jian").className = 'link_nav';
    document.getElementById("link_nav_Kim").className = 'link_nav';
    document.getElementById("link_nav_Young").className = 'link_nav_active';
  }
}

// Search through all <a> links, replace HTTPS with HTTP (use for forms to change navigation links to HTTP)

function onFocusBlur() {
  for (x=0; x< document.getElementsByTagName('a').length; x++) {
    document.getElementsByTagName('a')[x].onfocus = function() { this.blur() };
  }
}

function customPopup(url, features) {
window.open(url, '', features);
}

