function frameset(){
    if (document.getElementById('content') == null) {
        setTimeout(frameset, 100);
    }
    else {
        redirect();
    }
}

function redirect(){
    var realLocation = '/index/';
    if (window.location.hash != '') {
        if (!window.opera) {
            realLocation = window.top.location.toString();
            realLocation = realLocation.substr(realLocation.indexOf('#') + 1);
        }
        else {
            realLocation = parent.location.hash.toString().replace("#", "");
        }
        
        if (realLocation == '/') {
            realLocation = '/index/';
        }
    }
    if (window.opera) {
        parent.content.location = 'http://www.elbosco.ru' + realLocation;
    }
    else {
        document.getElementById('content').contentWindow.location.replace(realLocation);
    }
}


var storedLocation = '';
var contentWindow = null;

window.onload = function(event){
    contentWindow = parent.content;
    storedLocation = window.location.toString();
    window.setInterval(listenLocation, 1000);
}

function listenLocation(){
    var currentLocation = window.location;
    if (storedLocation != currentLocation.toString()) {
        storedLocation = window.location.toString();
        var matches = storedLocation.match(/^(.+?)#(.*)$/);
        if (matches[2] == '/') {
            matches[2] = '/index/';
        }
        contentWindow.location.replace(matches[2]);
    }
    
}

var currentLocation = '';
frameset();
