var initial = true;
var current_page ='/main.html';
function set_current_page(page){
    current_page=page;
    self.location.hash=current_page;
}


function onload_frame(){
    //console.log('load_frame');
    var is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
    if (is_chrome) window.location = 'http://www.mirage-junior.ru/main.html';
    
   if(initial){
   //console.log('initial');
   initial = false;
   var hash = self.location.hash.replace('#','');
        //console.log(hash);
    //if(hash!='' || hash!='/main.html' || hash!='/'){
    if(hash!='' && hash!='/main.html' && hash!='/'){
        //console.log('set');
        /*  
        console.log('set');
        self.frames[0].location.href = hash;
        console.log(self.frames[0]);
        set_current_page(top.frames[0].location.pathname);
        */
    }else{
        //console.log('initial');
        // Initial load 
        var new_page = top.frames[0].location.pathname;
        
        if(current_page != '/video.html' && new_page == '/video.html'){
            top.frames[0].pause(top.frames[1]);
            top.frames[0].document.getElementById('but_play_mute').style.backgroundImage = 'url(/img/ekwalazer.gif)';
        }
        if(current_page == '/video.html' && new_page != '/video.html'){
            top.frames[0].resume(top.frames[1]);
            top.frames[0].document.getElementById('but_play_mute').style.backgroundImage = 'url(/img/s.gif)';
        }
        
        set_current_page(new_page);
        
        //console.log('initial true 2 '+self.location.hash.replace('#',''))
   }
 }
 //else if(current_page!=top.frames[0].location.pathname){
 else {
     // Next load
        //console.log('NOT INITIALLLL!!!!');
        
        var new_page = top.frames[0].location.pathname;
        
        if(current_page != '/video.html' && new_page == '/video.html'){
            top.frames[0].pause(top.frames[1])
            top.frames[0].document.getElementById('but_play_mute').style.backgroundImage = 'url(/img/ekwalazer.gif)'
        }
        if(current_page == '/video.html' && new_page != '/video.html'){
            top.frames[0].resume(top.frames[1])
            top.frames[0].document.getElementById('but_play_mute').style.backgroundImage = 'url(/img/s.gif)'
        }
        set_current_page(new_page)
 }
}


