/*
Theme Name: HTML5 Menu
Author: Felipe Ortega
Author URI: http://www.graffixdesign.cl/
*/
/*----------------------------------------------------------------------------------------- //-->

<!-- BODY //-->
 
<!-- -------------------------------------------------------------------------------------- //-*/

var iL1 = 1;
var iL1Max = 8;

var iL2 = 1;
var iL2Max = 15;
var il2dir = 1;

var iL3 = 1;
var iL3Max = 15;
var il3dir = 1;

var iL4 = 1;
var iL4Max = 15;
var il4dir = 1;

function iL1Mueve(){
  if(iL1 <= iL1Max){
    var iL1x = -135*iL1;
    if(iL1x < -945){
      iL1x = -945;
    }
    
    if(jQuery('#menu').hasClass('menu')){
      var iL1x = -67*iL1;
      if(iL1x < -469){
        iL1x = -469;
      }
    }
    
    jQuery('#menu .logo_ani').attr('style','background-position:'+iL1x+'px 0px');  
    iL1++;
  
    if(iL1 < iL1Max){
      l1_tempo = 0;
      clearTimeout(l1_tempo);
      l1_tempo = setTimeout("iL1Mueve()", 150);
    }
  }
}

function iL1GO(){
  iL1 = 1;
  iL1Mueve();
}

function iLNMueve(n,y){
  if(this['iL'+n+'dir'] > 0 && !y){
    return;
  }else if(this['iL'+n+'dir'] < 0 && y){
    return;
  }
  if(this['iL'+n] <= this['iL'+n+'Max'] && this['iL'+n] >= 0){
    var iLNy = -40*this['iL'+n];
    
    if(jQuery('#menu').hasClass('menu')){
      iLNy = Math.floor(iLNy/2);
    }
    
    jQuery('#menu .menu'+n+'_ani').attr('style','background-position:0px '+iLNy+'px');  
    
    if(y) this['iL'+n]++;
    else this['iL'+n]--;
    
    if(this['iL'+n] < this['iL'+n+'Max'] && this['iL'+n] >= 0){
      this['l'+n+'_tempo'] = 0;
      clearTimeout(this['l'+n+'_tempo']);
      this['l'+n+'_tempo'] = setTimeout('iLNMueve('+n+','+y+')', 75);
    }
  }
}

function iLNGO(n,y){
  if(y){
    this['iL'+n+'dir'] = 1;
    this['iL'+n] = 1;
    iL1GO();
  }else{
    this['iL'+n+'dir'] = -1;
    this['iL'+n] = 14;
    iL1GO();
  }
  iLNMueve(n,y);
}
