// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults

function slice_background_on(e) {
  $(e + '_slice').style.backgroundImage =
      'url(images/top_' + e + '.png)';
}

function slice_background_on2(e) {
  $(e + '_slice').style.backgroundImage =
      'url(../images/top_' + e + '.png)';
}

function slice_background_off(e) {
  $(e + '_slice').style.backgroundImage =
      'none';
}

function works_hidden() {
    $('works').style.color = 'white';
    $('works_ex').style.visibility = 'hidden';
}

function about_hidden() {
    $('about').style.color = 'white';
    $('about_ex').style.visibility = 'hidden';
}

function popupex(e) {
  if (e != 'blog'){
    $(e + '_ex').style.visibility = 'visible';
  }
  if (e == 'about'){
    $(e).style.color = 'red';
    works_hidden();
  }else if (e == 'works'){
    $(e).style.color = 'red';
    about_hidden();
  } else {
    works_hidden();
    about_hidden();
  }
}

function popoutex(e) {
  $(e + '_ex').style.visibility = 'hidden';
}

function popupmenu() {
   $('menus').style.color = 'red';
   $('menus_ex').style.visibility = 'visible';
}

function popoutmenu() {
   $('menus').style.color = 'white';
   $('menus_ex').style.visibility = 'hidden';
}

function appear() {
  new Effect.Appear('globalWrapper',{ duration: 2 });
}

function open_window(window_url,winname,size) {
  window.open(window_url,winname,size);
}

function popimage(e) {
  for(var i=1;i<=5;i++){
    if(i == e){
      $('image'+ i + '_thumb').style.visibility = 'hidden';
      new Effect.Appear(('image' + i) ,{ duration: 2 });
    }else{
      $('image'+ i + '_thumb').style.visibility = 'visible';
      $('image'+ i).style.display = 'none';
    }
  }
}

function chain_pop_images() {
  var elements = $$.apply(null, $A(arguments));
  var kick = function() {
    if(elements.length == 0) return;
    new Effect.Appear(elements.shift(), { duration: 1, afterFinish: kick });
  };
  kick();
}
