function Login() {
	SetRedirect(true);
	Submit(99, "login");
}

function Logoff() {
	SetReload(true);
	Submit(99, "logoff");
}

function ResendPassword() {
	SetRedirect(true);
}

function OnKeyPressPWD(e) {
	var keynum;

	if (window.event) // IE
	{
		keynum = e.keyCode;
	}
	else if (e.which) // Netscape/Firefox/Opera
	{
		keynum = e.which;
	}
	if (keynum == 13) // cr
		Login();

	return true;
}

function SwitchLanguage(language) {
	var httpRequest,
		xmlRequest;

	xmlRequest = new XmlRequest();
	xmlRequest.ServerPage = applicationPath + "RS/SwitchLanguage.ashx";
	if ((httpRequest = xmlRequest.ExecuteRequest("<language>" + language + "</language>")) != null) {
		if (responseErrors(httpRequest) == 0)
			window.location.reload();
		else
			alert(responseMessage(httpRequest));
	}
}

function ExecuteNextStep(xml) {
	var xmlRequest;

	xmlRequest = new XmlRequest();
	xmlRequest.ServerPage = applicationPath + "ShopServices/NextStep.ashx";
	window.location.href = xmlRequest.ExecuteScalar(xml, document.body);
}

function NextStep(current) {
	ExecuteNextStep("<root current=\"" + current + "\" />");
}

function GotoStep(next) {
	ExecuteNextStep("<root next=\"" + next + "\" />");
}

function ExecuteAndRefresh(serverPage, xml) {
	var xsltDocument,
		httpRequest,
		xmlDocument,
		xmlRequest,
		div;

	if ((div = document.getElementById("shoppingcart_placeholder")) != null) {
		xmlRequest = new XmlRequest(serverPage, applicationPath + "Checkout/IE5.0/Shoppingcart.xsl");
		//xmlRequest.Debug = true;
		try {
			if ((httpRequest = xmlRequest.ExecuteRequest(xml)) != null) {
				if (responseErrors(httpRequest) == 0) {
					if ((xmlDocument = httpRequest.responseXML) != null) {
						if ((xsltDocument = xmlRequest.LoadStyleSheet()) != null) {
							xmlRequest.TransformNodeToElement(div, xmlDocument, xsltDocument);
						}
					}
				}
				else
					alert(pulkError(httpRequest));
			}
		}
		catch (exception) {
			div.innerHTML = exception.message;
		}
	}
}

function DeleteItem(id) {
	ExecuteAndRefresh(applicationPath + "ShopServices/DeleteItem.ashx", "<root id=\"" + id.toString() + "\" />");
}

function sfHover(id) {
	try {
		var sfEls = document.getElementById(id).getElementsByTagName("li");
		for (var i = 0; i < sfEls.length; i++) {
			sfEls[i].onmouseover = function() {
				this._className = this.className;
				this.className += " sfhover";
			}
			sfEls[i].onmouseout = function() {
				this.className = this._className;
			}
		}
	}
	catch (e) {
		alert(e);
	}
}

function keytest(txtbox) {
	if (window.event.keyCode == 13) {
		Search(txtbox);
		window.event.returnValue = false;
	}
}

function Search(control) {
	window.location.href = applicationPath + "searchcatalog.aspx?catalog=veiligheidstechniek" + "&search=" + control.value;
}
