(function ()
{
    var orenoSimaDir = 'http://fx.hikaku-memo.com/island/app/orenoSima',
        orenoSimaUrl = orenoSimaDir +'/app.html',
        i, d = document, src, m, chi = d.getElementsByTagName ? d.getElementsByTagName('script') : d.childNodes;

    for (i = chi.length-1; -1 < i; i--)
        if (chi[i].src && chi[i].src.indexOf(orenoSimaDir) != -1) { src = chi[i].src; chi = chi[i]; break; }

    if (src && (i = src.indexOf('?')) != -1 &&
        (m = src.substr(i).match(/(?:uid|rsargs|select(?:ed)?Tab)=[^?&'"#\/]+/g)))
    {
        m.push("refresh="+ (new Date()).getTime() +"t");
        orenoSimaUrl += '?'+ m.join('&').replace('selectTab', 'selectedTab');
    }
    else
        orenoSimaUrl += '?argError';

    var op = '<iframe id="orenoSimaFrame" src="'+ orenoSimaUrl +'" width="140" height="178" marginwidth="0" marginheight="0" frameborder="0" scrolling="no"></iframe>',
        frm = document.getElementById('orenoSimaFrame');

    if (frm && frm.src) frm.src = orenoSimaUrl;
    else if (chi.parentNode) chi.parentNode.innerHTML += op;
    else if (chi.getParent && chi.getParent()) chi.getParent().innerHTML += op;
    else try{ d.open(); d.write(op); d.close(); }catch (err){ ;}
})();
