function enroll(str,id){
	if(id)
		document.location.href='?str='+str+'&setEnrollment=1&groupID='+id;
}

var sel
function addUser(groupID){
	if(sel)
		sel.close();
	sel=window.open("",hash,"left=200,top=200,resizable=no,width=400,height=100,status=yes,location=no,menubar=no,scrollbars=yes");
	sel.document.write("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n");
	sel.document.write("<html>\n");
	sel.document.write('<head><title>Konservatorio</title>'+"\n");
	sel.document.write('<meta http-equiv="content-type" content="text/html; charset=UTF-8" />'+"\n")
	sel.document.write('<link rel="stylesheet" type="text/css" href="styles.php" media="screen" />'+"\n")		
	sel.document.write('<script  type="text/javascript" ><!--'+"\n") 	
	sel.document.write('var curHash="'+hash+'"'+"\n");
	sel.document.write('function ok(){if(window.opener.hash!=curHash){alert("Error!");window.close();return}'+"\n");
	sel.document.write('window.opener.location.href="?str="+window.opener.str+"&addUser="+document.getElementById("users").value+"&groupID='+groupID+"\"\n");
	sel.document.write('window.close()'+"\n");
	sel.document.write('}'+"\n");	
	
	sel.document.write('function cancel(){window.close()}'+"\n");

	sel.document.write('//--></script>'+"\n");
	sel.document.write("</head><body style='background-color:#f2f2f2' onload='window.focus()'>\n")
	sel.document.write('<br /><br /><select class="txt" id="users" name="users">'+userOptions+"</select>\n")
	sel.document.write('<br /><input type="button" value="OK" onclick="javascript:ok()" class="btn"> <input type="button" value="Cancel" onclick="javascript:cancel()" class="btn">'+"\n")
	sel.document.write('</body></html>'+"\n");
}

function getTop(item){
	var myTarget = item;  
	var top=0;
	while(myTarget!= document.body) {
		top += myTarget.offsetTop;     
		myTarget = myTarget.offsetParent;   
	} 
	return top;
}

function getLeft(item){
	var myTarget = item;  
	var left=0;
	while(myTarget!= document.body) {
		left += myTarget.offsetLeft;     
		myTarget = myTarget.offsetParent;   
	} 
	return left;
}


function ask(){
	if(confirm(delQuest))
		return true;
	else
		return false;
}

function askUpdate(quest){
	if(confirm(quest))
		return true;
	else
		return false;
}

function roomselect(){
	var b=document.getElementById('buildingID')
	var r=document.getElementById('roomID')
	var bID=parseInt(b.value)

	if(bID){
		var c=rooms[bID].length;
		
		r.selectedIndex=0
		r.options.length=c+1;
		

		for(i=0;i<c;i++){
			r.options[i+1].value=rooms[bID][i][0]
			r.options[i+1].text=rooms[bID][i][1]
		}
		return 
	}
	
	r.options.length=1;
	/*else{
		r.options.length=1;
		var c=buildings.length
		var n=1;
		for(i=0;i<c;i++){
			var c2=rooms[buildings[i]].length
			r.options.length+=c2;
			for(j=0;j<c2;j++){
				r.options[n].value=rooms[buildings[i]][j][0]
				r.options[n++].text=rooms[buildings[i]][j][1]
			}
		}
	}*/

}

