function embedPlayer(url, type)
{
   var objContentType = (navigator.userAgent.toLowerCase().indexOf("windows") != -1) ? "application/x-mplayer2" : "audio/mpeg";
   var height = (type == 'audio') ? 69 : 270;

   document.writeln("<div>");
   document.writeln("<object width='280' height='" + height + "'>");
   document.writeln("<param name='type' value='" + objContentType + "'>");
   document.writeln("<param name='src' value='" + url + "'>");
   document.writeln("<param name='autostart' value='0'>");
   document.writeln("<param name='showcontrols' value='1'>");
   document.writeln("<param name='showstatusbar' value='1'>");
   document.writeln("<embed src ='" + url + "' type='" + objContentType + "' autoplay='false' autostart='0' width='280' height='" + height + "' controller='1' showstatusbar='1' bgcolor='#ffffff'></embed>");
   document.writeln("</object>");
   document.writeln("</div>");
   document.close();
}

function embedFile(id, mediatype)
{
    var url = 'getfile.php?id=' + id;

    if(arguments[2])
    {
        url += '&amp;preview=' + arguments[2];
    }

    if(mediatype == 'Image')
    {
        document.writeln("<img src='" + url + "'>");
    }
    else if(mediatype == 'Audio')
    {
        embedPlayer(url, 'audio');
    }
    else if(mediatype == 'Video')
    {
        embedPlayer(url, 'video');
    }
}

function incrementCount(id)
{
    if(!id)
    {
        return;
    }

    obj = document.getElementById(id + 'Count');

    if(!obj)
    {
        return;
    }

    if(obj.innerHTML == '0')
    {
        objTitle = document.getElementById(id + 'Title');
        objTitle.innerHTML = "<a href='#' onClick=\"toggleDisplay('" + id + "'); return false;\"><img id='" + id + "Image' border='0' src='images/plus.gif'> " + objTitle.innerHTML;
    }

    obj.innerHTML = parseInt(obj.innerHTML) + 1;
}

function toggleDisplay(id)
{
    if(!id)
    {
        return;
    }

    objResults = document.getElementById(id + 'Results');
    objImg = document.getElementById(id + 'Image');

    if(!objResults)
    {
        return;
    }

    objResults.style.display = ((objResults.style.display == '') ? 'none' : '');

    if(objImg)
    {
       objImg.src = (objResults.style.display == '') ? 'images/minus.gif' : 'images/plus.gif';
    }
}

