function GoPage(page) {
	pager.p.value = page;
	pager.submit();
}

function SelectorName() {
	if (selector.selid.length) {
		for (i=0;i<selector.selid.length;i++) {
			if (selector.selid[i].checked){
				return(selector.selid[i].value.substr(selector.selid[i].value.indexOf("|")+1));
			}		
		}
	} else {
		if (selector.selid.checked){
			return(selector.selid.value.substr(selector.selid.value.indexOf("|")+1));
		}		
	}
	return "";
}

function SelectorId() {
	if (selector.selid.length) {
		for (i=0;i<selector.selid.length;i++) {
			if (selector.selid[i].checked){
				return(selector.selid[i].value.substr(0,selector.selid[i].value.indexOf("|")));
			}		
		}
	} else {
		if (selector.selid.checked){
			return(selector.selid.value.substr(0,selector.selid.value.indexOf("|")));
		}			
	}
	return "";
}

function dropFile(btn){
	if(document.getElementById) {
		tr = btn;
		while (tr.tagName != 'TR') tr = tr.parentNode;
		tr.parentNode.removeChild(tr);
		checkForLast();
	}
}
function addFile(btn){
	if(document.getElementById) {
		tr = btn;
		while (tr.tagName != 'TR') tr = tr.parentNode;
		var idSuffix = Math.round(Math.random()*1000);
		var newTr = tr.parentNode.insertBefore(tr.cloneNode(true),tr.nextSibling);
		thisChilds = newTr.getElementsByTagName('td');
		for (var i = 0; i < thisChilds.length; i++){
			if (thisChilds[i].className == 'header') thisChilds[i].innerHTML = '';
			if (thisChilds[i].className == 'files') thisChilds[i].innerHTML = '<input type="hidden" id="bookid'+idSuffix+'" name="bookid[]" value=""><input class="admintxt" id="book'+idSuffix+'" type="text" name="book'+idSuffix+'" value="" readonly>&nbsp;<input type="button" onclick="window.open(\'/selector/book/'+idSuffix+'/\',\'new\',\'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=720,height=520\');" class="btn2" value="Select">';
		}
		checkForLast();
	}
}

function checkForLast(){
	btns = document.getElementsByName('drop');
	for (i = 0; i < btns.length; i++){
		btns[i].disabled = (btns.length == 1) ? true : false;
	}
}
