﻿stringformat = function (text) {
    if (arguments.length <= 1) return text;

    for (var i = 0; i <= arguments.length - 2; i++) {
        text = text.replace(new RegExp("\\{" + i + "\\}", "gi"), arguments[i + 1]);
    }

    return text;
}

fn_SendTwitter = function (m, u) {
    var url = "http://twitter.com/home?status=" + encodeURIComponent(m) + " " + encodeURIComponent(u);
    var pop = window.open(url, "SendTwitter", "");
    if (pop) pop.focus();
}

fn_SendFaceBook = function (m, u) {
    var url = "http://www.facebook.com/sharer.php?u=" + u + "&t=" + encodeURIComponent(m);
    var pop = window.open(url, "SendFaceBook", "");
    if (pop) pop.focus();
}

fn_ScrapUrl = function () {
    if (window.clipboardData) {
        window.clipboardData.setData('Text', location.href);
        alert("보고 계신 이벤트의 주소가 복사되었습니다.\nCtrl+V로 붙여 넣으세요...");
    }
}

windowopen = function (u, n, w, h) {
    l = (screen.width) ? (screen.width - w) / 2 : 0;
    t = (screen.height) ? (screen.height - h) / 2 : 0;
    op = stringformat("height={0},width={1},top={2},left={3},scrollbars=yes", h, w, t, l);
    window.open(u, n, op);
}

windowresize = function () { 
    //w = document.body.scrollWidth + 22;
    //h = document.body.scrollHeight + 25;
    w = document.body.scrollWidth + 6;
    h = document.body.scrollHeight + 30;
    window.self.resizeTo(w, h);
}
