// JScript source code
function doCopy(i)
{
	var elem = document.getElementById(i);
	if(elem!=null){
	    if(document.body.createTextRange){
	        var r = document.body.createTextRange();
	        if(r!=null){
	            r.moveToElementText(elem);
	            r.select();
    	        document.execCommand("Copy");
    	    }
	    }
   	    else{
            alert("Your browser does not support this function.\r\n" + 
            "We recommend using MS Internet Explorer.\r\n" + 
            "The link you need to copy is:\r\n" + elem.innerHTML);    	
            return;
	    }
    }
    elem = document.getElementById("f"+i);
	if(elem!=null){
	    r = document.body.createTextRange();
	    if(r!=null){
	        r.moveToElementText(elem);
	        r.select();
    	}
	}
	alert('The filename has been copied to the clipboard.\r\nYou many now paste it as a link into any field.');
}
/************************************************************/
function doOK()
{
    var nf = document.getElementById("fileName");
    var nh = document.getElementById("fileUploaded");
    var n1 = document.getElementById("alignLeft");
    var n2 = document.getElementById("alignRight");
    var na = "none";
    var nfval = nf.value.trim();
    var nhval = nh.innerHTML.trim();
    if(nfval==""){
        var index = nhval.lastIndexOf("\\");
        if(index<0) index = nhval.lastIndexOf("/");
        if(index>0) nfval = nhval.substring(index+1);
        else nfval=nhval;
    }
    if(n1.checked) na="left";
    else if(n2.checked) na="right";
    window.returnValue=nhval + '|' + nfval + '|' + na;
    window.close()    
}
/**************************************************/
String.prototype.trim = function () 
{
    return this.replace(/^\s*/, "").replace(/[\s\\\/]*$/, "");
}
var vImg = null;
var vImgName = null;
var vTop = null;
var vPreview = null;
var op = 0;
var timer = null;
function imagePreview(e, img, imgName) {
    if (img != null) {
        vImg = img;
        vImgName = imgName;
        vTop = document.getElementById('picPreview');
        vPreview = null;
        clearInterval(timer);
        if (e.type == 'mouseover')
            setTimeout(showPreview, 300);
        else
            showPreview();
    }
}
function hidePreview() {
    if (vTop && vTop.style.visibility != 'hidden') {
        vPreview = null;
        clearInterval(timer);
        vTop.style.visibility = 'hidden';
    }
}
function showPreview() {
    var location = Sys.UI.DomElement.getLocation(vImg);
    vTop.style.visibility = 'visible';
    vTop.style.position = 'absolute';
    vTop.style.display = 'block';
    vTop.style.top = location.y + 'px';
    vTop.style.left = location.x + 'px';
    vTop.innerHTML = "<img id=\"picPreview1\" name=\"picPreview1\" style=\"opacity: 0; alpha(opacity=0);\" src='" + vImg.src +
    "' onmouseout='hidePreview();' onclick='hidePreview()' /><div style=\"width:100%;color:#fff\">" + vImgName + "</div>";
    op = 0;
    vPreview = document.getElementById('picPreview1');
    timer = setInterval(fadeIn, 10);
}
function fadeIn() {
    if (vPreview) {
        op += 0.01;
        if (op <= 1) {
            vPreview.style.opacity = op;
            vPreview.style.filter = 'alpha(opacity=' + (op * 100) + ')';
        }
        else {
            clearInterval(timer);
        }
    }
    else
        clearInterval(timer);
}


