function addEvent(o,e,f){
    if (o.addEventListener){ o.addEventListener(e,f,true); return true; }
    else if (o.attachEvent){ return o.attachEvent("on"+e,f); }
    else { return false; }
}

function createMp3Frames(mainUrl){
    if (!top.frames.length) {
        document.cookie = "screen_width="+ screen.width;
        //alert(mainUrl);
        document.write(
            '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">' +
            '<html>' +
            '<head>' +
            '</head>' + 
            '<frameset id="frameset" cols="30,*" border="0">' +
                '<frame src="' + WEBROOT + '/mp3-empty.php" frameborder="0" marginwidth="0" marginheight="0" noresize="noresize" scrolling="no" />' +
                '<frame src="' + WEBROOT + '/mp3frame.php?url=' + mainUrl + '" frameborder="0" marginwidth="0" marginheight="0" noresize="noresize" scrolling="auto" />' +
            '</frameset>' +
            '</html>'
        );
    }
    else
    {
        top.document.title = top.frames[1].document.title;
        addEvent(top.frames[1],'load',function ()
        {
            if (top.frames[0].location.href.indexOf('mp3.php') == -1)
            {
                top.frames[0].location.href = WEBROOT + '/mp3.php';
            }
        });
    }
}
createMp3Frames(location.href);