window.onload = function() {
  document.body.classList.remove("preload");
};


let sa_hamburger = document.getElementsByClassName("sa_hamburger")[0];
sa_hamburger.addEventListener("click", sa_toggle_hamburger);

let sa_menu_items = document.getElementsByClassName("sa_half_menu_item");

for(let i = 0; i < sa_menu_items.length; i++){
    sa_menu_items[i].addEventListener("mouseover", sa_hover_item, false);
}

for(let i = 0; i < sa_menu_items.length; i++){
    sa_menu_items[i].addEventListener("mouseout", sa_hover_out_item, false);
}


function sa_toggle_hamburger(){
	if(sa_hamburger.classList.contains("sa_hamburger_active")){
		sa_hamburger.classList.remove("sa_hamburger_active");
	}else{
		sa_hamburger.classList.add("sa_hamburger_active");
	}
}

function sa_hover_item(event){
    let sa_image_items = document.getElementsByClassName("sa_half_menu_image");
    for(let x = 0; x < sa_image_items.length; x++){
        if(sa_image_items[x].classList.item(1) == event.currentTarget.classList.item(1)){
            sa_image_items[x].classList.add("sa_half_menu_images_active"); 
        }
    }    
}

function sa_hover_out_item(event){
    let sa_image_items = document.getElementsByClassName("sa_half_menu_image");
    for(let x = 0; x < sa_image_items.length; x++){
        if(sa_image_items[x].classList.item(1) == event.currentTarget.classList.item(1)){
            sa_image_items[x].classList.remove("sa_half_menu_images_active"); 
        }
    }    
}