opWindows = new Array();
curWin = 0;
booksearchwin_id=0;
grpwin_id=0;
varer_win_id=0;
id=0;
loaded=false;
order_warning=0;
function time_o(type,time_)
{
	clearTimeout(id);
	id=setTimeout('refresh();', ((time_*1000*60)-30000));
}

function refresh()
{
	document.location='day.php'; 
}

function close_win()
{
	for(i=0; i<opWindows.length; i++)
	if (opWindows[i] && !opWindows[i].closed)
		opWindows[i].self.close();
}

function closeWindows(sek, error, type) 
{	
	close_win();
	document.location='../logout.inc?error='+error+'&amp;S_time=' + sek + '&amp;type=' + type; 
}

function BookWin(urlLoc) 
{
	var count = curWin++;
	booksearchwin_id=opWindows[count]=window.open(urlLoc,"win_1", "toolbar=no, location = no, directories=no,status=yes,menubar=no,scrollbars=yes,resizable=no,dependent,height=400,width=675,left=50,top=50");
	opWindows[count].focus();
}
 
function print_win(popurl)
{
	var count = curWin++;
	opWindows[count]=window.open(popurl,"win_2","width=770,height=200,scrollbars=yes,resizable=yes,toolbar=yes,menubar=yes,status=yes,location=yes")
	opWindows[count].focus();
}	

function newWin(urlLoc) 
{	
	var count = curWin++;
	opWindows[count]=window.open(urlLoc,"win_3", "toolbar=no, location = no, directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,dependent,height=280,width=350,left=100,top=100");
	opWindows[count].focus();
}

function newWinCrit(urlLoc) 
{
	var count = curWin++;
	grpwin_id=opWindows[count]=window.open(urlLoc,"win_4", "toolbar=no, location = no, directories=no,status=yes,menubar=no,scrollbars=yes,resizable=no,dependent,height=500,width=715,left=50,top=10");
	opWindows[count].focus();
}

function NewSearchWin(urlLoc) 
{	
	var count = curWin++;
	opWindows[count]=window.open(urlLoc,"win_5", "toolbar=no, location = no, directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,dependent,height=250,width=500,left=100,top=100");
	opWindows[count].focus();
}

function DiagWin(urlLoc) 
{	
	var count = curWin++;
	opWindows[count]=window.open(urlLoc,"win_6", "toolbar=no, location = no, directories=no,status=no,menubar=no,scrollbars=no,resizable=no,dependent,height=230,width=230,left=100,top=100");
	opWindows[count].focus();
}

function MidWin(urlLoc) 
{
	var count = curWin++;
	opWindows[count]=window.open(urlLoc,"win_7", "toolbar=no, location = no, directories=no,status=yes,menubar=no,scrollbars=no,resizable=no,dependent,height=400,width=600,left=50,top=50");
	opWindows[count].focus();
}

function help_win(popurl)
{
	var count = curWin++;
	opWindows[count]=window.open(popurl,"win_9","width=700,height=500,scrollbars=yes,resizable=yes,toolbar=yes,menubar=yes,status=yes,location=yes")
	opWindows[count].focus();
}	
function _win(urlLoc)
{
	var count = curWin++;
	opWindows[count]=window.open(urlLoc,"ob", "toolbar=no, location = no, directories=no,status=yes,menubar=no,scrollbars=no,resizable=no,dependent,height=400,width=420,left=50,top=50");
	opWindows[count].focus();
}

function NewGrpWin(urlLoc) 
{
	var count = curWin++;
	opWindows[count]=window.open(urlLoc,"win_11", "toolbar=no, location = no, directories=no,status=yes,menubar=no,scrollbars=no,resizable=no,dependent,height=400,width=620,left=50,top=50");
	opWindows[count].focus();
}

function note_win(urlLoc) 
{
	var count = curWin++;
	opWindows[count]=window.open(urlLoc,"wind_12","scrollbars=no,resizable=no,toolbar=no,menubar=no,status=no,location=no,,dependent,height=350,width=400,left=100,top=100")
	opWindows[count].focus();
}

function move_win(urlLoc) 
{
	var count = curWin++;
	opWindows[count]=window.open(urlLoc,"win_13", "toolbar=no, location = no, directories=no,status=yes,menubar=no,scrollbars=no,resizable=no,dependent,height=170,width=350,left=50,top=50");
	opWindows[count].focus();
}

function NewSearchWin2(urlLoc) 
{	
	var count = curWin++;
	opWindows[count]=window.open(urlLoc,"win_14", "toolbar=no, location = no, directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,dependent,height=320,width=500,left=100,top=100");
	opWindows[count].focus();
}

function alarms(urlLoc) 
{
	var count = curWin++;
	opWindows[count]=window.open(urlLoc,"win_15", "toolbar=no, location = no, directories=no,status=yes,menubar=no,scrollbars=no,resizable=no,dependent,height=500,width=700,left=50,top=10");
	opWindows[count].focus();
}

function PassWin(urlLoc) 
{
	var count = curWin++;
	opWindows[count]=window.open(urlLoc,"win_16", "toolbar=no, location = no, directories=no,status=no,menubar=no,scrollbars=no,resizable=no,dependent,height=90,width=250,left=50,top=50");
	opWindows[count].focus();
}

function cal(urlLoc) 
{
	var count = curWin++;
	opWindows[count]=window.open(urlLoc,"win_17", "toolbar=no, location = no, directories=no,status=no,menubar=no,scrollbars=no,resizable=no,dependent,height=200,width=105,left=70%,top=5%");
	opWindows[count].focus();
}

function TlfWin(urlLoc) 
{
	var count = curWin++;
	opWindows[count]=window.open(urlLoc,"win_18", "toolbar=no, location = no, directories=no,status=no,menubar=no,scrollbars=no,resizable=no,dependent,height=90,width=250,left=500,top=500");
	opWindows[count].focus();
}

function cos_hist_win(urlLoc) 
{
	var count = curWin++;
	opWindows[count]=window.open(urlLoc,"wind_19","scrollbars=no,resizable=no,toolbar=no,menubar=no,status=no,location=no,,dependent,height=350,width=400,left=100,top=100")
	opWindows[count].focus();
}


function select_go(_str_form)
{
	document.location.href = _str_form.value;
}

function KeyCheck(e)
{
	var keycode;
	keycode = e.keyCode;
	if (((keycode>47) && (keycode<58) )  || (keycode==8) || (keycode==0)) { return true; }
	else {return false;}
}
//accept floats
function KeyCheckFloat(e)
{
	var keycode;
	keycode = e.keyCode;
	if (((keycode>47) && (keycode<58) )  || (keycode==8) || (keycode==44)) { return true; }
	else {return false;}
}

function set_pers(max_num_pers)
{		
	//find de gamle valgte antal - fx 100 personer valgt
	var index_ = document.forms["book"].pers_index.value-1;
	str=max_num_pers.value;
	array_str = str.split(":");

	//slet først de gamle
	var I = document.forms["book"].num_pers.options.length;

	for(var i=0;i<I;i++)
	{
	    // IE Specific Method
	    if (navigator.appName == 'Microsoft Internet Explorer')
		{document.forms["book"].num_pers.options.remove(I-i-1);}
    	else
        {document.forms["book"].num_pers.options[I-i-1] = null;}
	}

	//læg de nye ind
	I=array_str[2];
	//hvis ingen ledige
	if(I<=1){index_=0;}
	var runs=0;
	for(var i=1;i<=I;i++)
	{
		var NI = document.forms["book"].num_pers.options.length++;

		if(i==1)
		{document.forms["book"].num_pers.options[NI].text= i + ' person';}
		else
		{document.forms["book"].num_pers.options[NI].text= i + ' personer';}
		document.forms["book"].num_pers.options[NI].value=i;  		
		runs++;
	}	 
	if(i<index_)
	{document.forms["book"].num_pers.options.selectedIndex=runs-1;alert('ADVARSEL!\n____________________________________________________\n\nBookingen indeholder flere deltagere end der er kapacitet til.\nDette kan skyldes at kapaciteten er blevet nedsat efter bookingen\ner lavet eller nedjusteret på en specifik dato.\nDeltagerantallet bliver nedjusteret til det nuværende maximum!');}	
	else
	{document.forms["book"].num_pers.options.selectedIndex=index_;}
	//har ikke været i loopet ovenover
	if(I<=0)
	{
		var NI = document.forms["book"].num_pers.options.length++;	
		document.forms["book"].num_pers.options[NI].text= 'Ingen ledige';
		document.forms["book"].num_pers.options[NI].value=0;   
	}
	
	if(order_warning==1)
	{alert("Notere først tidspunkt - herefter antal!");order_warning=0;}
}

function set_warn()
{		
	order_warning=1;
}
