// <SCRIPT language="JavaScript">
//window.name="show_page";
function set_window_name (name) {
	window.name=name;
}
function selReserve(req) {
		if(req != 'int') selContract('int');
		if (document.calendar_entry.all_day.checked) ac = 0;
		else ac = 1;	
		if (document.calendar_entry.book_adm[1].checked) on = 1;
		else {
			on = 0;
			ac = 0;
		}
		toggleBox('idTime', on);
		toggleBox('stId', ac);
		toggleBox('etId', ac);
}

function selContract(oper) {
	if(oper != 'int') selReserve('int');
	if (oper=='on' || oper=='del' || oper=='new') {
		if (document.calendar_entry.book_adm[0].checked) {
alert('xxx');
			on = true;
		}
		else on = false;
		if (oper=='on') document.calendar_entry.book_adm[1].checked = on;
		tobbleBox('idContract', on);

	}
	else {
		if (document.calendar_entry.book_adm[0].checked) on = 1;
		else on = 0;
		if (on==0) document.calendar_entry.end_date_sel.checked = false;
	}
}
function setZIndex(id, z_index) {
	document.getElementById(id).style.zIndex = z_index;
}
function contractTime() {
	var notim = document.calendar_entry.end_date_sel.checked;
	if(notim) toggleBox('idContract_end', 0);
	else toggleBox('idContract_end', 1);
}

function popUp(nr, win) {
	if (win=='view') props=window.open(nr, 'poppage', 'toolbars=0, scrollbars=1, location=0, statusbars=0, menubars=0, resizable=1, width=800, height=300, left = 70, top = 70');
	else props=window.open(nr, 'pop_page', 'toolbars=0, scrollbars=1, location=0, statusbars=0, menubars=0, resizable=1, width=815, height=525, left = 70, top = 70');
	props.focus();
}

function showAdr(url) {
	props=window.open(url, 'pop_page', 'toolbars=0, scrollbars=0, location=0, statusbars=0, menubars=0, resizable=0, width=400, height=380, left = 300, top = 200');
	props.focus();
}

function show_(url) {
// alert('url=' + url);
	window.location.href = url
	return false;
}
function ret_true() {
	return 1;
}
function upd_inpField() {
//	name = document.bookconf.user_sel.options[document.bookconf.user_sel.selectedIndex].value;
	name = document.calendar_entry.user_sel.options[document.calendar_entry.user_sel.selectedIndex].value;
//	document.bookconf.user.value = name;
	document.calendar_entry.user.value = name;
}
function refresh_main(url) {
	window.opener.location.href = url
	setTimeout('window.close()', 500);
	return false;	//???? 051008
}
function subAdr(oper, url) {
	var f_name = document.upd_contact.f_name.value;
	var l_name = document.upd_contact.l_name.value;
	if ((f_name != "") || (l_name != "")) {
		if (oper !='yes') {
			if (oper == 'upd') {
				document.upd_contact.target = "_self";	//??
				window.document.upd_contact.submit();
				return false;
			}
			else {
				document.upd_contact.target = "_self";
				document.upd_contact.operation.value = oper;
				document.upd_contact.s_target.value = "pop";
				window.document.upd_contact.submit();
			}
//			setTimeout('window.close()', 400);
		}
		else {
			document.upd_contact.target = "_self";
			document.upd_contact.s_target.value = "pop";
		}
		return true; 
	}
	else {
		alert('Kontakten måste ha något namn');
		return false;
	}
}
function confirmAct(msg) {
	var agree=confirm(msg);
	if (agree) return true;
	else return false;
}

function chkLogin() {
	var pwd = document.login.pwd.value;
	var name = document.login.user.value;
	if (!name) {
		alert('Användarnamn saknas');
		return false;
	}
	if (!pwd) {
		alert('Lösenord saknas');
		return false;
	}
	return true;
}
function toggleBox(szDivID, iState) // 1 visible, 0 hidden
{
    if(document.layers)	   //NN4+
    {
       document.layers[szDivID].visibility = iState ? "show" : "hide";
    }
    else if(document.getElementById)	  //gecko(NN6) + IE 5+
    {
        var obj = document.getElementById(szDivID);
        obj.style.visibility = iState ? "visible" : "hidden";
    }
    else if(document.all)	// IE 4
    {
        document.all[szDivID].style.visibility = iState ? "visible" : "hidden";
    }
}
function sub_conf(msg, status) {
	document.upd_contact.operation.value = status;
	document.upd_contact.target = "_self";
	document.upd_contact.s_target.value = "pop";
	if (confirmAct(msg)) document.upd_contact.submit();
}
function time_tggl() {
	if(document.calendar_entry.all_day.checked) { 
		toggleBox('stId', 0);
		toggleBox('etId', 0);
	}
	else {
		toggleBox('stId', 1);
		toggleBox('etId', 1);
	}
}
function rep_tggl() {
	if(document.calendar_entry.repeat_act.checked) { 
		toggleBox('idRep_op', 1);
		toggleBox('idWeek', 1);
		document.calendar_entry.repeat.value = 'week';
	}
	else {
		toggleBox('idRep_op', 0);
		toggleBox('idWeek', 0);
		toggleBox('idDay',0);
	}
}
function repSel() {
	var sel = document.calendar_entry.repeat.value;
	if (sel=='day') {
		toggleBox('idDay',1);
		toggleBox('idWeek',0);
	}
	else if (sel=='week') {
		toggleBox('idDay',0);
		toggleBox('idWeek',1);

	}
	else {
		toggleBox('idDay',0);
		toggleBox('idWeek',0);
	}
}
function set_day(forms_no, month_el_no, empty) {
	var day_el_no = parseInt(month_el_no) +1;
	var month = document.forms[forms_no].elements[month_el_no].value;
	var days = document.forms[forms_no].elements[day_el_no].options.length;
	var last = days-1;
	if (empty) {
		days = days-1;
		v28 = 29;
		v29 = 30;
		v30 = 31;
	}
	else {
		v28 = 28;
		v29 = 29;
		v30 = 30;
	}
// alert('month=' + month);
	if (month == '01' || month == '03' || month == '05' || month == '07' || month == '08' || month == '10' || month == '12') {
		if (days == 31) return "";
		if (days == 28) {
			document.forms[forms_no].elements[day_el_no].options[document.forms[forms_no].elements[day_el_no].options.length] = new Option('29','29');
			document.forms[forms_no].elements[day_el_no].options[document.forms[forms_no].elements[day_el_no].options.length] = new Option('30','30');
		}
		document.forms[forms_no].elements[day_el_no].options[document.forms[forms_no].elements[day_el_no].options.length] = new Option('31','31');
	}
	else if (month == '02')  {
		document.forms[forms_no].elements[day_el_no].options[v30] = null;
		document.forms[forms_no].elements[day_el_no].options[v29] = null;
		document.forms[forms_no].elements[day_el_no].options[v28] = null;
	}
	else {
		if (days == 30) return "";
		if (days == 31) {
//			document.forms[forms_no].elements[day_el_no].options[30] = null;
			document.forms[forms_no].elements[day_el_no].options[last] = null;
		}
		else {
			document.forms[forms_no].elements[day_el_no].options[document.forms[forms_no].elements[day_el_no].options.length] = new Option('29','29');
			document.forms[forms_no].elements[day_el_no].options[document.forms[forms_no].elements[day_el_no].options.length] = new Option('30','30');
		}
	}
}
function submit_adm(act)
{
//	alert('oper=' + act);
	document.calendar_entry.action.value=act;
  	document.calendar_entry.submit();
}

// </script>

