// <SCRIPT language="JavaScript">
//window.name="show_page";
var page_width;
function set_window_name (name) {
	window.name=name;
}
function do_nothing() {
	return true;
}
function radio_input(url) {
	// Re-direct the browser to the url value
	window.location.href = url
}
function selReserve(req) {
		if(req != 'int') selContract('int');
//		if (document.calendar_entry.all_day.checked) ac = 0;
		if (document.bookconf.all_day.checked) ac = 0;
		else ac = 1;
//		if (document.calendar_entry.book_adm[1].checked) on = 1;
		if (document.bookconf.book_adm[1].checked) on = 1;
		else {
			on = 0;
			ac = 0;
		}
		toggleBox('idTime', on);
		toggleBox('stId', ac);
		toggleBox('etId', ac);
}
function setClass(id, newclass) {
	if (newclass=='') return "";
// alert('tgl:newclass=' + newclass + ' id:' + id);
	elId = document.getElementById(id);
	if(elId){
		elId.className = newclass;
	}
	else alert('noid');
}

var classTgl = new Array();
function tglClass(id, newclass, forceclass) {
	if (newclass=='') return "";
	elId = document.getElementById(id);
	if(elId){
		if (!isIndex(classTgl,id)) {
			classTgl[id] = elId.className;
			elId.className = newclass;
		}
		else {
			if (forceclass && forceclass != classTgl[id]) return;	// 080406
			elId.className = classTgl[id];
			delete classTgl[id];
		}
	}
	else alert('noid');
}
function isIndex(arr, ix) {
	for (var i in arr) {
		if (i == ix) return true;
	}
	return false;
}

var aid = null;
function set_actLnk(id, act_tc, norm_tc) {
	xId = document.getElementById(id);
	xId.className=act_tc;
	if (aid && aid != xId) aid.className=norm_tc;
	aid = xId;
//	changeCol('#cc0000', id);
}

var DHTML = (document.getElementById || document.all || document.layers);

function getObj(name)
{
  if (document.getElementById)
  {
  	this.obj = document.getElementById(name);
	this.style = document.getElementById(name).style;
  }
  else if (document.all)
  {
	this.obj = document.all[name];
	this.style = document.all[name].style;
  }
  else if (document.layers)
  {
   	this.obj = document.layers[name];
   	this.style = document.layers[name];
  }
}

function changeCol(col, id)
{
	if (!DHTML) return;
	var x = new getObj(id);
	curc = x.fontStyle.color;
	curc1 = x.color;
alert('color=' + curc + ' c2=' + curc1);
	x.color = col;

}
function setZIndex(id, z_index) {
	document.getElementById(id).style.zIndex = z_index;
}
function browser_type() {
	app = navigator.appName;
	if (app == 'Microsoft Internet Explorer') return 'IE';
	else if (app == 'Netscape') return 'Netscape';
	else return 'other';
}
function popUp(url, win, width, scroll, height, rz) {
//	alert('popUp' + height);
	if (win=='view') popw=window.open(url, 'poppage', 'toolbars=0, scrollbars=0, location=0, statusbars=0, menubars=0, resizable=1, width=740, height=400, left = 70, top = 70');
	else {
//		top = yPos();
//		left = xPos();
		var top = 100;
		var left = 100;
		if (!width) var width = 740;
		if (!height) var height = 650;
		if (!rz) rz = 1;
//		if (scroll) width = parseInt(width) +18;
		width = parseInt(width) +18;
		if (!win) win = 'pop';
		popw=window.open(url, win, "toolbars=0, scrollbars=" + scroll + ", location=0, statusbars=0, menubars=0, resizable=" + rz + ", width=" + width + ", height=" + height + ",left = 100, top = 100");
//		popw=window.open(url, win, "toolbars=0, scrollbars=1" + ", location=0, statusbars=0, menubars=0, resizable=1, width=" + width + ", height=" + height + ",left = 100, top = 100");

	}
	popw.focus();
}

function showAdr(url) {
//	alert('url=' + url);
//	props=window.open(url, 'pop_page', 'toolbars=0, scrollbars=0, location=0, statusbars=0, menubars=0, resizable=0, width=430, height=400, left = 300, top = 200');	// changed name 20071121
	props=window.open(url, 'cWpop', 'toolbars=0, scrollbars=0, location=0, statusbars=0, menubars=0, resizable=0, width=430, height=400, 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,close) {
	if (close) window.opener.location.href = url;
	else popUp(url, 'show_page');
	setTimeout('window.close()', 700);
	return false;	//???? 051008
}
function subMail() {
	
	window.document.mail_contacts.submit();
	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
//	alert('sxDivID=' + szDivID + ', state=' + iState);
    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 toggleLayer(whichLayer, target, url, open) {
	if (!document.getElementById) return;
	var which = document.getElementById(whichLayer);
	if (which.style.display && which.style.display !="none") {
		if (!open) {
			which.style.display="none";
		}
	}
	else {
		which.style.display="block";
	}
	go_nav(url,target);
}
function go_nav(url,target) {
// alert('url=' + url + 'target=' + target);
	if (url) {
		if (target) top.frames[target].location.href = url;
		else window.location.href = url;
	}
	return false;
}
function sel_img(picName,imgName) {
   if (document.images)
    {
      imgOn=eval(imgName + ".src");
      document[picName].src= imgOn;
    }	
}

function sub_conf(msg, status) {
	document.upd_contact.action.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) {
	if(document.bookconf.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) {
	if(document.bookconf.repeat_act.checked) {
		toggleBox('idRep_op', 1);
		toggleBox('idWeek', 1);
//		document.calendar_entry.repeat.value = 'week';
		document.bookconf.repeat.value = 'week';
	}
	else {
		toggleBox('idRep_op', 0);
		toggleBox('idWeek', 0);
		toggleBox('idDay',0);
	}
}
function repSel() {
//	var sel = document.calendar_entry.repeat.value;
	var sel = document.bookconf.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)
{
	document.bookconf.action.value=act;
  	document.bookconf.submit();
}
// </script>

