function confirmit(question, target) {
	if (confirm(question)) document.location.href=target;
}

function confirmthisform(question) {
	if (confirm(question)) return true;
	else return false;
}

function displayinfo(header, title, message) {
	text = "<html>\r\n<head><link rel='stylesheet' type='text/css' HREF='"+document.styleSheets[0].href+"'></head>\r\n<title>";
	text += header;
	text += "</title>\r\n<body class='infowin'>\r\n<div class=\"subtitle\">";
	text += title;
	text += "</div>\r\n<div class='simple' style='text-align:justify;padding:5px'>";
	text += message;
	text += "</div>\r\n</body>\r\n</html>";
	
	newWindow = window.open('', '', 'scrollbars,resizable,width=400,height=200,left=100,top=100');
	newWindow.document.write(text);
}

function openremarkwin(lid, errmess){
	if (!(remarkwin=window.open("", "remarkwin", "scrollbars,resizable,width=400,height=200,left=100,top=100"))) alert(errmess);
	else {
		remarkwin.location="./engine.php?load=myweb&todo=showrem&listid="+lid;
		remarkwin.focus();
	}
}

var left, timeout, explain

function clock(maxsecs, timemess, timemess2, exp) {
	if (exp) explain=exp;
	if (maxsecs) left=maxsecs;
	if (timemess) timeout=timemess;
	if (timemess2) timeoutsoon=timemess2;
	minute=Math.floor(left/60);
	second=left%60;
	if (minute < 10) {
		minute = "0" + minute;
	}
	if (second < 10) {
		second = "0" + second;
	}
	if (left==-1) {
		top.window.location='./engine.php?load=logout';
		alert(timeout);
	} else {
		if (left==300) {
			var now = new Date ();
			alert(timeoutsoon);
			var then = new Date ();
			left=left-(Math.floor(then.getTime()/1000)-Math.floor(now.getTime()/1000));
			if (left<0) {
				top.window.location='./engine.php?load=logout';
				alert(timeout);
				return;
			}
			setTimeout("clock()", 1000);
		}
		else {
			window.status = explain + ": " + minute + ":" + second;
			setTimeout("clock()", 1000);
		}
	}
	left--;
}


function insertAtCursor(myField, myValue) {
	if (document.selection) {
		myField.focus();
		var str = document.selection.createRange().text;
		sel = document.selection.createRange();
		sel.text = "<"+myValue+">"+str+"</"+myValue+">";
	}
	else if (myField.selectionStart || myField.selectionStart == '0') {
		var startPos = myField.selectionStart;
		var endPos = myField.selectionEnd;
		myField.value = myField.value.substring(0, startPos)
		+ "<"+myValue+">" +myField.value.substring(startPos, endPos)+ "</"+myValue+">" 
		+ myField.value.substring(endPos, myField.value.length);
	} else {
		myField.value += myValue;
	}
	return(false);
}

function insertonceAtCursor(myField, myValue) {
	if (document.selection) {
		myField.focus();
		var str = document.selection.createRange().text;
		sel = document.selection.createRange();
		sel.text = myValue;
	}
	else if (myField.selectionStart || myField.selectionStart == '0') {
		var startPos = myField.selectionStart;
		var endPos = myField.selectionEnd;
		myField.value = myField.value.substring(0, startPos) + myValue + myField.value.substring(endPos, myField.value.length);
	} else {
		myField.value += myValue;
	}
	return(false);
}

var gone;
function doubleclickprotect(){
	if (gone) return false;
	gone='nomore!';
}

function strikeit(elemid){
	if (document.all) document.all(elemid).style.textDecoration="line-through";
	else if (document.getElementById) document.getElementById(elemid).style.textDecoration="line-through";
	else if (document.layers) document.layers[elemid].style.textDecoration="line-through";
}
function unstrikeit(elemid){
	if (document.all) document.all(elemid).style.textDecoration="none";
	else if (document.getElementById) document.getElementById(elemid).style.textDecoration="none";
	else if (document.layers) document.layers[elemid].style.textDecoration="none";
}

var formchange=false;
