function checkSearchForm(frm, mode) {
	var d = new Date();
	var d2 = d.getMonth();
	d2 += 1;
	var dy = "00" + d2;
	var dy2 = d.getFullYear() + dy.substr((dy.length-2), 2);
	if(mode == 1) {
		if(document.getElementById('st-classification') != null && (document.getElementById('st-classification').value == "FO" || document.getElementById('st-classification').value == "FL" || document.getElementById('st-classification').value == "FR"  || document.getElementById('st-classification').value == "F3") && frm.day.value == d.getDate() && frm.yearmonth.value == dy2) {
			//alert(noJustNu);
			frm.submit();
		} else {
			document.getElementById('waiter').style.display = 'block';
			frm.submit();
		}
	} else {
		return false;
	}
}

function SwitchCheck(frm) {
	for (var i = 0; i < frm.elements.length; i++) {
		var e = frm.elements[i];
		if ((e.name == 'tripdata') && (e.type == 'checkbox')) {
			e.checked = frm.allbox.checked;
		}
	}
}            

function CheckChecked(frm) {
	isTrue = false;
	for (var i = 0; i < frm.elements.length; i++) {
		var e = frm.elements[i];
		if ((e.name == 'tripdata') && (e.type == 'checkbox')) {
			if(e.checked) {
				isTrue = true;
			}
		}
	}
	return isTrue;
}

function ResetExecuter() {
	parent.executer.location.href = "empty.html";
}

function OpenDetailsWindow(action1, action2, action3, action4) {
	var wf = "";	
	wf = wf + "width=" + action3;
	wf = wf + ",height=" + action4;
	wf = wf + ",resizable=yes";
	wf = wf + ",scrollbars=yes";
	wf = wf + ",menubar=yes";
	wf = wf + ",toolbar=no";
	wf = wf + ",search=no";
	wf = wf + ",directories=no";
	wf = wf + ",location=no";
	wf = wf + ",status=no";		
	window.open(action1, action2, wf);
}

function OpenPrintableWindow(action1, action2, action3, action4) {
	var wf = "";
	wf = wf + "width=" + action3;
	wf = wf + ",height=" + action4;
	wf = wf + ",resizable=yes";
	wf = wf + ",scrollbars=yes";
	wf = wf + ",menubar=yes";
	wf = wf + ",toolbar=no";
	wf = wf + ",search=no";
	wf = wf + ",directories=no";
	wf = wf + ",location=no";
	wf = wf + ",status=no";		
	window.open(action1, action2, wf);
}

function OpenHelpWindow(action1, action3, action4) {
	var page = "help.asp?page=" + action1;
	var target = "_help" + action1;
	var wf = "";	
	wf = wf + "width=" + action3;
	wf = wf + ",height=" + action4;
	wf = wf + ",resizable=yes";
	wf = wf + ",scrollbars=yes";
	wf = wf + ",menubar=no";
	wf = wf + ",toolbar=no";
	wf = wf + ",search=no";
	wf = wf + ",directories=no";
	wf = wf + ",location=no";
	wf = wf + ",status=no";		
	window.open(page, target, wf);
}

function OpenAllDetailsWindow(action1, action2, action3, action4) {
	var wf = "";	
	wf = wf + "width=" + action3;
	wf = wf + ",height=" + action4;
	wf = wf + ",resizable=yes";
	wf = wf + ",scrollbars=yes";
	wf = wf + ",menubar=yes";
	wf = wf + ",toolbar=no";
	wf = wf + ",search=no";
	wf = wf + ",directories=no";
	wf = wf + ",location=no";
	wf = wf + ",status=no";		
	window.open(action1, action2, wf);
}

function OpenExternalWindow(action1, action2, action3, action4) {
	var wf = "";	
	wf = wf + "width=" + action3;
	wf = wf + ",height=" + action4;
	wf = wf + ",resizable=yes";
	wf = wf + ",scrollbars=yes";
	wf = wf + ",menubar=yes";
	wf = wf + ",toolbar=no";
	wf = wf + ",search=no";
	wf = wf + ",directories=no";
	wf = wf + ",location=no";
	wf = wf + ",status=no";		
	window.open(action1, action2, wf);
}

function OpenSMSWindow(action1, action2, action3, action4) {
	var wf = "";
	wf = wf + "width=" + action3;
	wf = wf + ",height=" + action4;
	wf = wf + ",resizable=no";
	wf = wf + ",scrollbars=no";
	wf = wf + ",menubar=no";
	wf = wf + ",toolbar=no";
	wf = wf + ",search=no";
	wf = wf + ",directories=no";
	wf = wf + ",location=no";
	wf = wf + ",status=no";		
	window.open(action1, action2, wf);
}

function StoreCaretPos (textEl) {
	if(textEl.createTextRange) {
		textEl.caretPos = document.selection.createRange().duplicate();
	}
}

function InsertAtCaretPos( textEl, text ) {
	if (textEl.createTextRange && textEl.caretPos) {
		var caretPos = textEl.caretPos;
		caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text;
	} else {
		textEl.value  += text;
	}
}

function ModifyRange(cmd, lang) { 
	strSelection = document.selection.createRange().text;
	complex = false;
	switch(lang) {
		case 2:
			mouseOutText = "Resplus - One Ticket Covers the Complete Journey";
			break;
		case 3:
			mouseOutText = "Resplus - die gesamte Reise auf einer Fahrkarte";
			break;
		default:
			mouseOutText = "Resplus - hela resan på en biljett!";
			break;
	}
	switch(cmd) {
		case "table":
			rows = prompt("Ange antal rader i tabellen:", "");
			cols = prompt("Ange antal kolumner i tabellen:", "");
			fullCmd = '<table';
			border = prompt("Ange rambredd i pixels:", "0");
			if(border != "") {
				fullCmd += ' border="' + border + '"';
			}
			cellpadding = prompt("Ange utfyllnad mellan cellerna i pixels:", "0");
			if(cellpadding != "") {
				fullCmd += ' cellpadding="' + cellpadding + '"';
			}
			cellspacing = prompt("Ange mellanrum mellan cellerna i pixels:", "0");
			if(cellspacing != "") {
				fullCmd += ' cellspacing="' + cellspacing + '"';
			}
			width = prompt("Ange tabellens bredd i pixels (Om tom, är bredden beroende på innehållet i tabellen.):", "");
			if(width != "") {
				fullCmd += ' width="' + width + '"';
			}
			height = prompt("Ange tabellens höjd i pixels (Om tom, är höjden beroende på innehållet i tabellen.):", "");
			if(height != "") {
				fullCmd += ' height="' + height + '"';
			}
			style = prompt("Ange parametrar för t ex textformattering (t ex formtext):", "");
			if(style != "") {
				fullCmd += ' class="' + style + '"';
			}
			fullCmd += '>\n';
			r = 0;
			while(r < rows) {
				fullCmd += '\t<tr>\n';
				c = 0;
				while(c < cols) {
					fullCmd += '\t\t<td></td>\n';
					c++;
				}
				fullCmd += '\t</tr>\n';
				r++;
			}
			fullCmd += '</table>';
			complex = true;
			break;
		case "image":
			fullCmd = '<img src="';
			fullCmd += prompt("Skriv in vart bilden ligger och vad den heter:", "");
			fullCmd += '" width="';
			fullCmd += prompt("Ange bildens bredd i pixels:", "");
			fullCmd += '" height="';
			fullCmd += prompt("Ange bildens höjd i pixels:", "");
			fullCmd += '" border="';
			fullCmd += prompt("Ange bildens ram i pixels:", "0");
			fullCmd += '" hspace="';
			fullCmd += prompt("Ange horisontellt tomrum runt bilden i pixels:", "0");
			fullCmd += '" vspace="';
			fullCmd += prompt("Ange vertikalt tomrum runt bilden i pixels:", "0");
			fullCmd += '"';
			align = prompt("Ange bildens justering (right, left, top, middle, bottom):", "");
			if(align != "") {
				fullCmd += ' align="' + align + '"';
			}
			title = prompt("Ange bildtext:", strSelection);
			fullCmd += ' title="' + title + '" alt="' + title + '">';
			complex = true;
			break;
		case "link":
			fullCmd = '<a href="';
			fullCmd += prompt("Skriv in vart länken skall leda:", "");
			fullCmd += '"';
			target = prompt("Ange vilket fönster länken skall öppnas i:\n('_blank' innebär att den öppnas i ett nytt fönster, tomt innebär samma fönster.)", "_blank");
			if(target != "") {
				fullCmd += ' target="' + target + '"';
			}
			title = prompt("Ange länktext:", strSelection);
			fullCmd += ' title="' + title + '" onmouseover="javascript:self.status=';
			fullCmd += "'" + title + "'; return true;";
			fullCmd += '" onmouseout="javascript:self.status=';
			fullCmd += "'" + mouseOutText + "'; return true;";
			fullCmd += '" class="redlink">' + title + '</a>';
			complex = true;
			break;
		case "italic":
			startCmd = '<em>';
			endCmd = '</em>';
			break;
		case "bold":
			startCmd = '<strong>';
			endCmd = '</strong>';
			break;
		case "newline":
			startCmd = '<br>\n';
			endCmd = "";
			break;
		case "paragraph":
			startCmd = '<p>';
			endCmd = '</p>';
			break;
		case "justify":
			startCmd = '<p align="justify">';
			endCmd = '</p>';
			break;
		case "formtext":
			startCmd = '<font class="formtext">';
			endCmd = '</font>';
			break;
		default:
			startCmd = "";
			endCmd = "";
			break;
	}
	if(complex) {
		if(strSelection == "") {
			InsertAtCaretPos(document.editform.text,fullCmd);
			return;
		} else {
			document.selection.createRange().text = fullCmd;
		}
	} else {
		fullCmd = startCmd + endCmd;
		if (strSelection == "") {
			InsertAtCaretPos(document.editform.text,fullCmd);
			return;
		} else {
			document.selection.createRange().text = startCmd + strSelection + endCmd;
			return;
		}
	}
	this.document.editform.text.focus();
}

function MailMyTT() {
	subject = prompt("Ange tidsåtgång:", "");
	email = prompt("Ange din e-postadress:", "");
	if(email != "" && email != null) {
		this.document.postmytt.subject.value = subject;
		this.document.postmytt.email.value = email;
		this.document.postmytt.submit();
	}
}
var alerter = 0;
function makeButton(text, url, onclick, imgS, imgW, imgH, lType, bkgd, inactive, trgt, mode, tW, tH, cls) {
	var retStr = "";
	if(tW == "") {
		var tW = 100;
	} else {
		var tW = tW;
	}
	if(tH == "") {
		var tH = 21;
	} else {
		var tH = tH;
	}
	if(url == "#") {
//		url = "javascript:void(null);";
	}
	switch(mode) {
		case 2:
			if(inactive == 1) {
				retStr += "<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" class=\"buttTable2 " + cls + "\" disabled=\"disabled\" style=\"filter: alpha(opacity=30);\"";
				if(tW > 0) {
					retStr += " width=\"" + tW + "\"";
				}
				if(tH > 0) {
					retStr += " height=\"" + tH + "\"";
				}
				retStr += ">\n";
			} else {
				retStr += "<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" onclick=\"" + onclick + "\" class=\"buttTable2 hand " + cls + "\"";
				if(tW > 0) {
					retStr += " width=\"" + tW + "\"";
				}
				if(tH > 0) {
					retStr += " height=\"" + tH + "\"";
				}
				retStr += ">\n";
			}
			retStr += "<tr>\n";
			retStr += "	<td width=\"3\" height=\"3\" valign=\"top\"><img src=\"/img/" + bkgd + "n_c_ul.gif\" width=\"3\" height=\"3\" alt=\"\"></td>\n";
			retStr += "	<td valign=\"top\" style=\"background: url('/img/n_t.gif') repeat-x;\" height=\"3\"></td>\n";
			retStr += "	<td width=\"3\" height=\"3\" valign=\"top\"><img src=\"/img/" + bkgd + "n_c_ur.gif\" width=\"3\" height=\"3\" alt=\"\"></td>\n";
			retStr += "</tr>\n<tr>\n";
			retStr += "	<td width=\"3\" style=\"background: url('/img/n_l.gif') repeat-y;\"></td>\n";
			retStr += "	<td>\n";
			retStr += "		<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"buttInside2 hand ins" + cls + "\">\n";
			retStr += "			<tr>\n";
			if(imgS != "") {
				retStr += "				<td><img src=\"" + imgS + "\" width=\"" + imgW + "\" height=\"" + imgH + "\" alt=\"\" class=\"buttIcon2\"></td>\n";
			}
			if(inactive == 1) {
				retStr += "				<td><span class=\"buttLink" + lType + "_2 nohand\">" + text + "</span></td>\n";
			} else {
				retStr += "				<td><span><a ";
				if(url != "#" && url != onclick) {
					retStr += "href=\"" + url + "\" ";
				}
				if(trgt != "") {
					retStr += "target=\"" + trgt + "\" ";
				}
				retStr += "class=\"buttLink" + lType + "_2\">" + text + "</a></span></td>\n";
			}
			retStr += "			</tr>\n";
			retStr += "		</table>\n";
			retStr += "	</td>\n";
			retStr += "	<td width=\"3\" style=\"background: url('/img/n_r.gif') repeat-y;\"></td>\n";
			retStr += "</tr>\n";
			retStr += "<tr>\n";
			retStr += "	<td width=\"3\" height=\"3\"><img src=\"/img/" + bkgd + "n_c_ll.gif\" width=\"3\" height=\"3\" alt=\"\"></td>\n";
			retStr += "	<td valign=\"bottom\" height=\"3\" style=\"background: url('/img/n_b.gif') repeat-x;\"></td>\n";
			retStr += "	<td width=\"3\" height=\"3\"><img src=\"/img/" + bkgd + "n_c_lr.gif\" width=\"3\" height=\"3\" alt=\"\"></td>\n";
			retStr += "</tr>\n";
			retStr += "</table>\n";
			break;
		default:
			if(inactive == 1) {
				retStr += "<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" class=\"buttTable" + cls + "\" disabled=\"disabled\" style=\"filter: alpha(opacity=30);\">\n";
			} else {
				retStr += "<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" onclick=\"" + onclick + "\" class=\"buttTable" + cls + "\" onmouseover=\"javascript:toggleButt(this, 'over');\" onmouseout=\"javascript:toggleButt(this, 'out');\" style=\"background-color: #fff;\">\n";
			}
			retStr += "<tr>\n";
			retStr += "	<td width=\"6\" height=\"6\" valign=\"top\"><img src=\"/img/" + bkgd + "c_ul.gif\" width=\"6\" height=\"6\" alt=\"\"></td>\n";
			retStr += "	<td valign=\"top\" style=\"background: url('/img/e_u.gif') repeat-x;\" height=\"6\"></td>\n";
			retStr += "	<td width=\"7\" height=\"6\" valign=\"top\"><img src=\"/img/" + bkgd + "c_ur.gif\" width=\"7\" height=\"6\" alt=\"\"></td>\n";
			retStr += "</tr>\n<tr>\n";
			retStr += "	<td width=\"6\" style=\"background: url('/img/e_l.gif') repeat-y;\"></td>\n";
			retStr += "	<td>\n";
			retStr += "		<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"buttInside" + cls + "\">\n";
			retStr += "			<tr>\n";
			if(imgS != "") {
				retStr += "				<td><img src=\"" + imgS + "\" width=\"" + imgW + "\" height=\"" + imgH + "\" alt=\"\" class=\"buttIcon\"></td>\n";
			}
			if(inactive == 1) {
				retStr += "				<td><span class=\"buttLink" + lType + " nohand\">" + text + "</span></td>\n";
			} else {
				retStr += "				<td><span><a ";
				if(url != "#" && url != onclick) {
					retStr += "href=\"" + url + "\" ";
				}
				if(trgt != "") {
					retStr += "target=\"" + trgt + "\" ";
				}
				retStr += "class=\"buttLink" + lType + "\">" + text + "</a></span></td>\n";
			}
			retStr += "			</tr>\n";
			retStr += "		</table>\n";
			retStr += "	</td>\n";
			retStr += "	<td width=\"7\" style=\"background: url('/img/e_r.gif') repeat-y;\"></td>\n";
			retStr += "</tr>\n";
			retStr += "<tr>\n";
			retStr += "	<td width=\"6\" height=\"8\"><img src=\"/img/" + bkgd + "c_ll.gif\" width=\"6\" height=\"8\" alt=\"\"></td>\n";
			retStr += "	<td valign=\"bottom\" height=\"8\" style=\"background: url('/img/e_b.gif') repeat-x;\"></td>\n";
			retStr += "	<td width=\"7\" height=\"8\"><img src=\"/img/" + bkgd + "c_lr.gif\" width=\"7\" height=\"8\" alt=\"\"></td>\n";
			retStr += "</tr>\n";
			retStr += "</table>\n";
			if(alerter < 1) {
//				alert(retStr);
			}
			alerter++;
			break;
	}
//	document.write("<textarea>" + retStr + "</textarea>");
//	alert(retStr);
	return retStr;
}


function toggleButt(obj, act) {
	switch(act) {
		case "over":
			obj.style.background = '#c8dDf8';
			break;
		case "out":
			obj.style.background = '#FFFFFF';
			break;
		default:
			break;
	}
}


function tblOut(section) {
	var outText = "";
	switch(section) {
		case 1:
			outText = "<table nowrap='nowrap' cellpadding='0' cellspacing='0'><tr><td class='buttonCell'>";
			break;
		case 2:
			outText = "</td><td class='buttonCell'>";
			break;
		default:
			outText = "</td></tr></table>";
			break;
	}
	document.write(outText);
}

