/* Paricida, sacrilege, diva amabilis... */
function killChildren(whose)
{
    while (whose.childNodes.length > 0) {
        whose.removeChild(whose.childNodes[0]);
    }
}

/* Ad meliorem, in aeternum */
function getText(node)
{
    var result = '';
    for (var i=0; i<node.childNodes.length; ++i) {
        var n = node.childNodes[i];
        if (3 == n.nodeType) {  //Text node
            result += n.nodeValue;
        }
        else if (1 == n.nodeType && 'script' != n.nodeName.toLowerCase()) { //Element node
            result += getText(n);
        }
    }
    return result;
}


function popup(path,winname,W,H,M,S,b,f)
{
    var brd = b||0;
    var tsz = 20;
    f = f||0;
    var c=(document.all&&navigator.userAgent.indexOf("Win")!=-1)?1:0
    var w=window.screen.width / 2; var h=window.screen.height / 2;
    var W=W||w; W=(typeof(W)=='string'?Math.ceil(parseInt(W)*w/100):W); W+=(brd*2+2)*c; W += f;
    var H=H||h; H=(typeof(H)=='string'?Math.ceil(parseInt(H)*h/100):H); H+=(tsz+brd+2)*c; H += f;
    var X=X||Math.ceil((w-W/2))
    var Y=Y||Math.ceil((h-H/2))
    
    var hPopup = window.open(path, null, "left="+X+",top="+Y+",width="+W+",height="+H+",menubar="+M+",toolbar=0,scrollbars="+S+",resizable=0"); 
    hPopup.focus();
}


function showMySpace(id)
{
    var url = base_href + 'myspace.php?id=' + id
    popup(url, 'MySpace', 700, 375);
}


function share(id)
{
    var url = base_href + 'share.php?id=' + id
    popup(url, 'ShareWithFriend', 400, 400);
}

function bookMark(id)
{
    xajax_bookmark(id);
    return void(0);
}

function checkType()
{
    var name = document.uf.img.value;
    var md   = document.getElementById('upmes');

    if (name == '')
    {
        return false;
    }

    var t = name.split('.');
    var extention = t[(t.length - 1)];
    var check = false;

    for (i in allowed)
    {
        if (allowed[i] == extention.toLowerCase())
        {
            check = true;
        }
    }

    if (!check)
    {
        md.innerHTML = 'This file has an unsupported type';
    }
    else
    {
        md.innerHTML = '';
    }
    return check;
}