var W3CDOM = (document.createElement && document.getElementsByTagName);

function initFileUploads() {
	if (!W3CDOM) return;
	var fakeFileUpload = document.createElement('div');
	fakeFileUpload.className = 'fakefile';
    var fakeInput = document.createElement('input');
    fakeInput.type = 'text';
	fakeFileUpload.appendChild(fakeInput); //document.createElement('input'));
	//var image = document.createElement('img');
	//image.src='pix/button_select.gif';
	//fakeFileUpload.appendChild(image);
	var x = document.getElementsByTagName('input');
	for (var i=0;i<x.length;i++) {
		if (x[i].type != 'file') continue;
		if (x[i].parentNode.className != 'fileinputs') continue;
		x[i].className = 'file hidden';
		var clone = fakeFileUpload.cloneNode(true);
		x[i].parentNode.appendChild(clone);
		x[i].relatedElement = clone.getElementsByTagName('input')[0];
		x[i].onchange = x[i].onmouseout = function () {
			this.relatedElement.value = this.value;
		}
	}
}

function showNextInput(id) {
    document.getElementById(id).style.display='block';   
}

function fillIn(where,what) {
    var oldvalue = document.getElementById(where).value;
    var already = oldvalue.indexOf(what);

    if (oldvalue.length>0) {
        if (already==-1)
            document.getElementById(where).value = oldvalue+','+what;
    }
    else {
        document.getElementById(where).value = what;
    }

}

function sort() {       
    document.location.href=document.getElementById('projectsort').value;
}


