var animate = false;
var l_steps = 30;
var l_timeout = 20;
var current = 0;

function nav_in(id){
    if(!animate && current != id){
        animate = true;
        current = id;
        nav_animation_in(id,0);
    }   
}
function nav_animation_in(id,c){
    c++;
    cr = c/l_steps;
    var e = document.getElementById('subnav_'+id);    
    var opacity = Math.round(cr * 90);
    if(document.all){
        e.filters.alpha.opacity = opacity;
    }else{
        e.style.opacity = opacity / 100;
    }
    if(c < l_steps){
        setTimeout(function() {nav_animation_in(id, c);}, l_timeout);
    }else{
         animate = false;
    }
}

var page_status = true;
var page_animation = false;
var page;
function init_effects(){
    page = document.getElementById('page');
    page.onmousemove = page_fade_in;
    document.getElementById('background').onclick = page_fade_out;
}
function page_fade_in(){
    if(!page_status && !page_animation){
        page_status = true;
        page_animation = true;
        page_fade_in_helper(0);
    }
}
function page_fade_in_helper(c){
    c++;
    var op = 0.1 + (c / 8 * 0.9);
    op = Math.round(op * 100);
    if(document.all){
    page.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity='+(op)+')';
  }else{
    page.style.opacity = op / 100;
  }
    if(c < 8){
        setTimeout(function(){page_fade_in_helper(c);},50);
    }else{
        page_animation = false;
    }
}
function page_fade_out(){
    if(page_status && !page_animation){
        page_status = false;
        page_animation = true;
        page_fade_out_helper(0);
    }
}
function page_fade_out_helper(c){
    c++;
    var op = 1 - (c / 8 * 0.9);
    op = Math.round(op * 100);
    if(document.all){
    page.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity='+(op)+')';
  }else{
    page.style.opacity = op / 100;
  }
    if(c < 8){
        setTimeout(function(){page_fade_out_helper(c);},50);
    }else{
        page_animation = false;
    }
}
