function scrollTop() {
window.scrollTo(0,0)
}


// The following inserts/removes the second choice checkbox for an oral presentation
function posterOK() {
	var row=document.getElementById("q_row_1");
	if (document.getElementById("q_cell_1")==null) {
		var cell=row.insertCell(0);
		cell.id="q_cell_1";
		hidden=document.createElement("INPUT");
		hidden.type="hidden";
		hidden.name="poster_ok";
		hidden.value="left_blank";
		cell.appendChild(hidden);
		input=document.createElement("INPUT");
		input.type="checkbox";
		input.name=input.id="poster_ok";
		input.value="yes";
		//input.checked=true;
		cell.appendChild(input);
		txt=document.createTextNode(" The authors would consider a poster if not selected for an oral presentation");
		cell.appendChild(txt);
  }
 	var row=document.getElementById("q_row_2");
	if (document.getElementById("q_cell_2")==null) {		
		var cell=row.insertCell(0);
		cell.id="q_cell_2";
		hidden=document.createElement("INPUT");
		hidden.type="hidden";
		hidden.name="pdf_ok";
		hidden.value="left_blank";
		cell.appendChild(hidden);
		input=document.createElement("INPUT");
		input.type="checkbox";
		input.name=input.id="pdf_ok";
		input.value="yes";
		//input.checked=true;
		cell.appendChild(input);
		txt=document.createTextNode(" The authors will allow slides of the talk to be posted on this website (in PDF form)");
		cell.appendChild(txt);
	}
}
function removeBox() {
	if (document.getElementById("q_cell_1")!=null) {
		var box1=document.getElementById("q_cell_1");
		box1.parentNode.removeChild(box1);
		var box2=document.getElementById("q_cell_2");
		box2.parentNode.removeChild(box2);		
	}
}

// Multiple Select Limit
 
var selectedOptions = [];
function countSelected(select, maxNumber){
	for (var i=0; i<select.options.length; i++){
		if (select.options[i].selected && !new RegExp(i,'g').test(selectedOptions.toString())){
			selectedOptions.push(i);}
		if (!select.options[i].selected && new RegExp(i,'g').test(selectedOptions.toString())){
			selectedOptions = selectedOptions.sort(function(a,b){return a-b});
			for(var j=0; j<selectedOptions.length; j++){
				if(selectedOptions[j] == i){selectedOptions.splice(j,1);}
			}
		}
		if(selectedOptions.length > maxNumber){
			alert('Please select no more than '+maxNumber+' keywords.');
			select.options[i].selected = false;
			selectedOptions.pop();
			document.body.focus();
		}
	}
}


// Phone Number Auto-Advance

var isNN = (navigator.appName.indexOf("Netscape")!=-1);
function autoTab(input,len, e) {
	var keyCode = (isNN) ? e.which : e.keyCode; 
	var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
	if(input.value.length >= len && !containsElement(filter,keyCode)) {
		input.value = input.value.slice(0, len);
		var idx=getIndex(input);
		var elem=input.form[(idx+1) % input.form.length];
		try {
			elem.focus();
		} catch (e) {
		alert(e.message);
		}
	}
	return true;
}
function containsElement(arr, ele) {
	var found = false, index = 0;
	while(!found && index < arr.length)
	if(arr[index] == ele)
	found = true;
	else
	index++;
	return found;
}
function getIndex(input) {
	var index = -1, i = 0, found = false;
	while (i < input.form.length && index == -1)
	if (input.form[i] == input)index = i;
	else i++;
	return index;
}

