var previmg;
function showImage(url,caption)
{
hideImage();
document.getElementById('loading').style.display='';
document.getElementById('largeimage').style.display = 'none';
document.getElementById('largeimage').src = url;
document.getElementById('imgtxt').innerHTML = caption;
document.getElementById('imgcontainer').style.display = 'block';

}

function show()
{
    document.getElementById('loading').style.display='none';
    document.getElementById('largeimage').style.display = '';
}
function hideImage()
{
    html = "<b id=\"imgtxt\"></b>&nbsp;&nbsp;<a href=\"javascript:hideImage();\">[close]</a><br><img id='loading' src='/images/loading.gif'><img onload='show();' id='largeimage' src=''>";
    document.getElementById('imgcontainer').innerHTML = html;
    document.getElementById('imgcontainer').style.display = 'none';
}


function showVideo(html,caption)
{
hideImage();
document.getElementById('largeimage').style.display = 'none';
document.getElementById('loading').style.display='none';

//html =  '<object width="425" height="344"><param name="movie" value="'+url+'"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="'+url+'" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object>';
document.getElementById('imgcontainer').innerHTML += html;
document.getElementById('imgtxt').innerHTML = caption;
document.getElementById('imgcontainer').style.display = 'block';

}

function hideVideo()
{
    document.getElementById('imgcontainer').style.display = 'none';
}

function showImageUploadForm()
{
hideAllDivs();
document.getElementById('uploadImageContainer').style.display='block';
}

function hideImageUploadDiv()
{
document.getElementById('uploadImageContainer').style.display='none';
}

function imgUploadValidate()
{
    docF = document.forms.imgUploadForm;
    if(!(docF.image.value.lastIndexOf(".jpg") != -1 || docF.image.value.lastIndexOf(".jpeg") != -1 || docF.image.value.lastIndexOf(".png") != -1 || docF.image.value.lastIndexOf(".gif") != -1 ))
    {
        alert("Please upload a JPG / PNG / GIF image only");
        docF.image.focus();
        return false;
    }
    if(docF.image.value == '')
    {
        alert("Please select an image to upload");
        docF.image.focus();
        return false;
    }
    if(docF.caption.value == '')
    {
        alert("Please enter an image caption");
        docF.caption.focus();
        return false;
    }
    
    return true;
}

function showVideoUploadForm()
{
hideAllDivs();
document.getElementById('uploadVideoContainer').style.display='block';
}

function hideVideoUploadDiv()
{
document.getElementById('uploadVideoContainer').style.display='none';
}

function vidUploadValidate()
{
    docF = document.forms.vidUploadForm;
   
    if(docF.vid.value == '')
    {
        alert("Please enter a video ID. For Example:\n In the URL \"http://www.youtube.com/watch?v=tXOk5vHkGms\", the Video ID is \"tXOk5vHkGms\"");
        docF.image.focus();
        return false;
    }
    if(docF.caption.value == '')
    {
        alert("Please enter a video caption");
        docF.caption.focus();
        return false;
    }
    
    return true;
}

function showLinkUploadForm()
{
hideAllDivs();
document.getElementById('uploadLinkContainer').style.display='block';
}

function hideLinkUploadDiv()
{
document.getElementById('uploadLinkContainer').style.display='none';
}

function linkUploadValidate()
{
    docF = document.forms.linkUploadForm;
  
    if(docF.link.value == '')
    {
        alert("Please enter a Link URL");
        docF.link.focus();
        return false;
    }
    if(docF.caption.value == '')
    {
        alert("Please enter a link caption");
        docF.caption.focus();
        return false;
    }
    
    return true;
}

function hideAllDivs()
{
    document.getElementById('uploadLinkContainer').style.display='none';
    document.getElementById('uploadImageContainer').style.display='none';
    document.getElementById('uploadVideoContainer').style.display='none';
}
