function getMeta(metatag)
{
    try {
        var nodeList;
        if ((navigator.appName=='Netscape') && (navigator.appVersion.charAt(0)<'5'))
            nodeList = parent.prosa.document.tags["META"];
        else
            nodeList = parent.prosa.document.getElementsByTagName("META");
        for (var i = 0; i < nodeList.length; i++)
            if (nodeList[i].name == metatag)
                return (nodeList[i].content);
    } catch (e) {
    }
    return "";
}

function changeProsaHref(newhref)
{
	prosalocation.href=newhref;
}

function replaceProsaHref(newhref)
{
	    prosalocation.replace(newhref);
}

function changeArticle(ident)
{
    changeProsaHref(showarticle+"?ident="+ident+"&wfw="+(new Date()).getTime());
}

function replaceArticle(ident)
{
    replaceProsaHref(showarticle+"?ident="+ident+"&wfw="+(new Date()).getTime());
}

function showBasket()
{
	var inbasket = "";
	pos = prosalocation.href.indexOf("ident=");
	if (pos > -1) {
		if (prosalocation.href.substring(pos+6, pos+20) == "oaseShowBasket")
			inbasket="_not";
	}
	replaceProsaHref(schillingbase+"/servlet/oase.div.redir2?wfw="+(new Date()).getTime()+"&kurv_urlbefore"+inbasket+"="+escape(prosalocation.href)+"&url="+escape(showarticle+"?ident="+schillingbasketident+"&wfw="+(new Date()).getTime()));
}

function SchGoBeforeBasket()
{
	if (schillingurlbeforebasket != null && schillingurlbeforebasket != "")
		changeProsaHref(schillingurlbeforebasket);
	else
		window.history.go(-1);
}

function showLogin(event)
{
	if (event==null)
		changeProsaHref(showarticle+"?ident=loginCombo&wfw="+(new Date()).getTime());
	else
		changeProsaHref(showarticle+"?ident=loginCombo&kurv_event="+event+"&wfw="+(new Date()).getTime());
}

function showHome()
{
	_top.location.href="/";
}

function SAL(catid, ident)
{
	if (frames['prosa'] != null)
		frames['prosa'].location.href = "/servlet/oase.article.showArticle?art_event=GET_CATEGORY&art_categoryId="+catid+"&ident="+schillinglistprefix+ident+"&art_sorttype=VTXT_ASC";
}

function SA(catid, ident)
{
	changeProsaHref(schillingbase + "/servlet/oase.article.showArticle?art_event=GET_CATEGORY&art_categoryId="+catid+"&ident="+schillinglisteprefix+ident+"&art_sorttype=VTXT_ASC");
}

function OAA(warn, artnr, antal)
{
		
	if (warn && globalwarnnostock) {
		doContinue = confirm("Varen er ikke på lager.\n\nVil du bestille alligevel?");
		if (doContinue != true)
			return;
	}
	document.basketForm.kurv_vnr.value = artnr;
	if (antal > 0)
		document.basketForm.kurv_antal.value = antal;
	else
		document.basketForm.kurv_antal.value = 1;
	document.basketForm.submit();
}

function OAAM(warn, artnr, antal, minantal)
{
	if (warn && globalwarnnostock) {
		doContinue = confirm("Varen er ikke på lager.\n\nVil du bestille alligevel?");
		if (doContinue != true)
			return;
	}
	document.basketForm.kurv_vnr.value = artnr;
	if (minantal == 0 ) {
		if (antal > 0)
			document.basketForm.kurv_antal.value = antal;
		else
			document.basketForm.kurv_antal.value = 1;
	} else {
		if ( ( antal < minantal)) {
			doContinue = confirm("Varen s‘lges i minimum "+minantal+" stk.\n\nVil du bestille alligevel?");
			if (doContinue != true)
				return;
			document.basketForm.kurv_antal.value = minantal;
		} else
			document.basketForm.kurv_antal.value = antal;
	}
	// Only update menu-frame
	document.basketForm.target = "info";
	document.basketForm.action = parent.frames['info'].window.location.href
//	dummy = alert("URL: "+parent.frames['info'].document.URL+"\nreferrer: "+parent.frames['info'].document.referrer);
//	dummy = alert("Refresh: "+document.basketForm.action+"\nident="+document.basketForm.ident.value);
	document.basketForm.submit();
}

function OAAMSIP(warn, artnr, antal, minantal, abtype, ident, pgp)
{
	if (warn == true && globalwarnnostock && abtype == "") {
		doContinue = confirm("Varen er ikke på lager.\n\nVil du bestille alligevel?");
		if (doContinue != true)
			return;
	}
	if (minantal == 0 ) {
		if (antal <= 0)
			antal = 1;
	} else {
		if ( ( antal < minantal)) {
			doContinue = confirm("Varen s.lges i minimum "+minantal+" stk.\n\nVil du bestille alligevel?");
			if (doContinue != true)
				return;
			antal = minantal;
		}
	}
	if (orderlocation.href.indexOf("ident")<0)
		orderlocation.replace(schillingbase+"/servlet/oase.div.redir2?wfw="+(new Date()).getTime()+"&kurv_event=KURV_ADD&kurv_vnr="+artnr+"&kurv_antal="+antal+"&kurv_abtype="+abtype+"&url="+escape(orderlocation.href+'?ident='+ident));
	else
		orderlocation.replace(schillingbase+"/servlet/oase.div.redir2?wfw="+(new Date()).getTime()+"&kurv_event=KURV_ADD&kurv_vnr="+artnr+"&kurv_antal="+antal+"&kurv_abtype="+abtype+"&url="+escape(orderlocation.href));
}
function OAAMSIC(warn, artnr, disponibel, followstore, antal, minantal, abtype, ident) {
	if (warn == true && globalwarnnostock && abtype == "") {
		doContinue = confirm("Varen er ikke på lager.\n\nVil du bestille alligevel?");
                if (doContinue != true)
        		return;
        }
	if (warn == false && followstore.length == 0 && antal > disponibel) {
                doContinue = confirm("Bem\u00e6rk at varen ikke kan leveres helt!\n\nVil du bestille alligevel?");
                if (doContinue != true)
                        return;
	}
	
        if (minantal == 0 ) {
                if (antal <= 0)
                        antal = 1;
        } else {
                if ( ( antal < minantal)) {
                        doContinue = confirm("Varen s.lges i minimum "+minantal+" stk.\n\nVil du bestille alligevel?");
                        if (doContinue != true)
                                return;
                        antal = minantal;
                }
        }
        if (orderlocation.href.indexOf("ident")<0)
        	orderlocation.replace(schillingbase+"/servlet/oase.div.redir2?wfw="+(new Date()).getTime()+"&kurv_event=KURV_ADD&kurv_vnr="+artnr+"&kurv_antal="+antal+"&kurv_abtype="+abtype+"&url="+escape(orderlocation.href+'?ident='+ident));
        else
                orderlocation.replace(schillingbase+"/servlet/oase.div.redir2?wfw="+(new Date()).getTime()+"&kurv_event=KURV_ADD&kurv_vnr="+artnr+"&kurv_antal="+antal+"&kurv_abtype="+abtype+"&url="+escape(orderlocation.href));
}
function openPopup() {
	window.open("/servlet/oase.article.showArticle?category_type=ART&art_categoryType=ART&category_id=68&art_event=GET_CATEGORYX&art_categoryId=68&ident=contact&art_sorttype=VTXTSORT_ASC&art_maxinlist=9", "myWindow", "status = 1, height = 500, width = 600, resizable = 1");
}
function OAAMSI(warn, artnr, antal, minantal, abtype, ident)
{
	return OAAMSIP(warn, artnr, antal, minantal, abtype, ident, '');
}

function OAWAAMFKAA(warn, artnr, antal, minantal, forpak, kurvantal, abtype, abogrp)
{
	// Not aboready
    return OAAMF(warn, artnr, antal, minantal, forpak, kurvantal);
}

function OAWAAMFKAAE(warn, artnr, antal, minantal, forpak, kurvantal, abtype, abogrp, e)
{
	var characterCode;
	if (e && e.which) { //if which property of event object is supported (NN4)
		e = e;
		characterCode = e.which //character code is contained in NN4's which property
	} else {
		e = event
		characterCode = e.keyCode //character code is contained in IE's keyCode property
	}
	if (characterCode == 13) { //if generated character code is equal to ascii 13 (if enter key)
		OAAMF(warn, artnr, antal, minantal, forpak, kurvantal);
		return false
	} else {
		return true
	}
}

function OAAMS(warn, artnr, antal, minantal, abtype)
{
	//document.basketForm.kurv_abtype.value = abtype;
	OAAMSI(warn, artnr, antal, minantal, abtype, '');
}

function OAAMF(warn, artnr, antal, minantal, forpak, kurvantal)
{
	var totalantal = Math.round(antal) + Math.round(kurvantal);
	if (warn && globalwarnnostock) {
		doContinue = confirm("Varen er ikke på lager.\n\nVil du bestille alligevel?");
		if (doContinue != true)
			return;
	}
	document.basketForm.kurv_vnr.value = artnr;
	if (minantal < 1 ) {
		if (antal > 0)
			document.basketForm.kurv_antal.value = antal;
		else
		document.basketForm.kurv_antal.value = 1;
	} else {
		if (totalantal < minantal) {
			doContinue = confirm("Varen s‘lges i minimum "+minantal+" stk.\n\nVil du bestille alligvel?");
			if (doContinue != true)
				return;
			antal = minantal;
			document.basketForm.kurv_antal.value = minantal;
		} else
			document.basketForm.kurv_antal.value = antal;
	}
	if (forpak > 0) {
		if ((antal % forpak) > 0) {
			doContinue = confirm("Varens forpakning er "+forpak+" stk.\n\nVil du bestille alligevel ");
			if (doContinue != true)
				return;
			antalgange = Math.round(antal / forpak);
			antalgange2 = antal / forpak;
			if (antalgange2 > antalgange)
				antalgange = antalgange + 1;
			antal = forpak * antalgange;
			document.basketForm.kurv_antal.value = antal;
		} else {
			document.basketForm.kurv_antal.value = antal;
		}
	}
	replaceProsaHref(schillingbase+"/servlet/oase.div.redir2?wfw="+(new Date()).getTime()+"&kurv_event=KURV_ADD&kurv_vnr="+artnr+"&kurv_antal="+antal+"&url="+escape(location.href));
	return false;
}

function OA(warn, artnr)
{
	if (warn && globalwarnnostock) {
		doContinue = confirm("Varen er ikke på lager.\n\nVil du bestille alligevel?");
		if (doContinue != true)
			return;
	}
	//document.basketForm.kurv_vnr.value = artnr;
	//document.basketForm.submit();
	abtype=""
	orderlocation.replace("/servlet/oase.div.redir2?wfw="+(new Date()).getTime()+"&kurv_event=KURV_ADD&kurv_vnr="+artnr+"&kurv_antal="+antal+"&abtype="+abtype+"&url="+escape(orderlocation.href));
}

function OAAMSIPRG(warn, artnr, antal, minantal, abtype, ident, prisgrup)
{
    if (warn == true) {
        doContinue = confirm("Varen er ikke pÕ lager.\n\nVil du bestille alligevel?");
        if (doContinue != true)
            return;
    }
    if (minantal == 0 ) {
        if (antal <= 0)
            antal = 1;
    } else {
        if ( ( antal < minantal)) {
            doContinue = confirm("Varen s.lges i minimum "+minantal+" stk.\n\nVil du bestille alligevel?");
            if (doContinue != true)
                return;
            antal = minantal;
        }
    }
	var ajax_putinbasket_enabled = false;
    if (ajax_putinbasket_enabled) {
	SchAjaxPutInBasket(schillingbase+"/servlet/oase.article.showCleanArticle?ajax=1&ident="+ajax_putinbasket_update_ident+"&wfw="+(new Date()).getTime()+"&kurv_event=KURV_ADD&kurv_vnr="+artnr+"&kurv_antal="+antal+"&abtype="+abtype+"&kurv_prisgrup="+prisgrup+"&kurv_elektronisk=1");
    }
    if (ajax_putinbasket_enabled == false) {
        replaceProsaHref(schillingbase+"/servlet/oase.div.redir2?wfw="+(new Date()).getTime()+"&kurv_event=KURV_ADD&kurv_vnr="+artnr+"&kurv_antal="+antal+"&abtype="+abtype+"&kurv_prisgrup="+prisgrup+"&kurv_elektronisk=1&url="+escape(location.href));
    }
}


function EAN13check(field)
{
	var csumTotal = 0;
	if (field.value.length == 0) return true;
	if (field.value.length != 13)
	{
		alert('Der skal indtastes 13 cifre i EAN-feltet.');
		field.focus();
		return false;
	}
	for (charPos = 11; charPos >= 0; charPos--)
	{
		if (charPos / 2 == parseInt(charPos/2))
			csumTotal = csumTotal + (parseInt(field.value.substring(charPos,charPos+1)));
		else
			csumTotal = csumTotal + (3 * parseInt(field.value.substring(charPos,charPos+1)));
	}
	var remainder = csumTotal - parseInt(csumTotal/10) * 10;
	if (remainder == 0)
		checksumDigit = '0';
	else
		checksumDigit = String.fromCharCode(48+10-remainder);
	if (field.value.substring(12,13)!=checksumDigit) {
		alert('EAN-nummeret er ikke korrekt.');
		field.focus();
		return false;
	}
	return true;
}

function submitUserForm(form)
{
	var nodeList = document.getElementsByTagName("INPUT");
	var selectNodeList = document.getElementsByTagName("SELECT");
	for (var i = 0; i < selectNodeList.length; i++) {
		if (selectNodeList[i].className.indexOf("UserRequiredField") > 0 && selectNodeList[i].value == "") {
			selectNodeList[i].focus();
			alert("Feltet skal udfyldes!");
			return false;
		}
	}
	for (var i = 0; i < nodeList.length; i++) {
		if (nodeList[i].className == "UserRequiredField") {
			nodeList[i].focus();
			alert("Feltet skal udfyldes!");
			return false;
		}
		if (nodeList[i].name == "ean")
			if (!EAN13check(nodeList[i])) return false;
	}
	validateEmail(form.email, '', true);
	form.submit();
	return true;
}


function panelIsLoading()
{
	try {
	var nodeList;
	if ((navigator.appName=='Netscape') && (navigator.appVersion.charAt(0)<'5'))
		nodeList = parent.prosa.document.tags["META"];
	else
		nodeList = parent.prosa.document.getElementsByTagName("META");
	for (var i = 0; i < nodeList.length; i++) {
		if (nodeList[i].name == "ArticleIdent") {
			if (nodeList[i].content == "oaseShowBasketFrozen" ||
				nodeList[i].content == "oaseShowBasket") {
				parent.prosa.location.href="/servlet/oase.article.showArticle?ident=oaseShowBasket&wfw="+(new Date()).getTime();
				return true;
			} else {
				ahref = parent.prosa.location.href;
				parent.prosa.location.href = ahref;
				return true;
			}
		}
	}
	} catch (e) {
	}
	return false;
}

function resetFavoritList()
{
	var nodeList = parent.prosa.document.getElementsByTagName("INPUT");
	for (var i = 0; i < nodeList.length; i++)
		if (nodeList[i].className == "number")
			nodeList[i].value = "0";
}

function refreshPanel()
{
//	ahref = parent.menuframe.window.location.href;
//	parent.menuframe.window.location.href = ahref+"&wfw="+(new Date()).getTime();
//	parent.frames['info'].window.location.href = "/servlet/oase.article.showArticle?ident=oaseLeftIn&nident=oaseLeft&wfw="+(new Date()).getTime();
}

function pilover(pilid)
{
	pilid.src="/images/arrow_off.gif";
}

function pilout(pilid)
{
	pilid.src="/images/arrow_on.gif";
	//eval(Pic+".src="+Pic+"off.src") ;
}

function printProsa()
{
	var windowtoprint;
	if (top.frames['prosa'] != null)
		windowtoprint = top.frames['prosa'];
	else
		windowtoprint = window;
	if (windowtoprint.print) {
		windowtoprint.focus();
		windowtoprint.print()
	}
	//changeProsaHref(schillingbase);
}

function deleteBasket(olid)
{
    var f = document.getElementById(olid);
    var pricegroup = f.getAttribute("pricegroup");
    var vnr = f.name;
    if (pricegroup != "undefined" && pricegroup != null)
        vnr = f.name.substr(0, f.name.indexOf("_"));
    var url = schillingbase + "/servlet/oase.article.showArticle?ident=oaseShowBasket&kurv_event=KURV_DEL&kurv_vnr="+vnr+"&wfw="+(new Date()).getTime();
    if (pricegroup != "undefined" && pricegroup != null)
        url = url + "&kurv_prisgrup=" + pricegroup;
    window.location.replace(url);
}

function old_deleteBasket(olid)
{
	var f = document.getElementById(olid);
	var snabpos = f.name.indexOf("@");
	var vnr = f.name;
	if (snabpos > -1)
		vnr = f.name.substring(0,snabpos);
	window.location.replace(schillingbase + "/servlet/oase.article.showArticle?ident=oaseShowBasket&kurv_event=KURV_DEL&kurv_vnr="+vnr+"&wfw="+(new Date()).getTime());
}

function deleteCourseBasket(olid, courseno, coursegrp)
{
	var f = document.getElementById(olid);
   	window.location.replace(schillingbase + "/servlet/oase.article.showArticle?ident=oaseShowBasket&kurv_event=KURV_DEL&kurv_vnr="+f.name+"&kurv_courseno="+courseno+"&kurv_coursegrp="+coursegrp+"&arttype=COURSE&wfw="+(new Date()).getTime());

}

function emptyBasket()
{
    changeProsaHref(showarticle+"?ident="+schillingbasketident+"&kurv_event=KURV_EMPTY&wfw="+(new Date()).getTime());
}

function handleUserLogin()
{
//	dummy = alert("Handle user login");
//  refreshProsaCond();
//  changeProsaHref("/servlet/oase.article.showArticle?ident=LoginInfo&wfw="+(new Date()).getTime());
//  refreshPanel(); /* Rest POST STATUS */
}

function handleUserLogout()
{
//  dummy = alert("Handle user logout");
//  refreshProsaCond()
//  refreshPanel(); /* Rest POST STATUS */
//  refreshTotalFrame();
}

function mkcss(style_name)
{
	// Create dynamic stylesheet link
	if (document.createStyleSheet) {
		// The IE way...
		document.createStyleSheet(style_name, 0);
		var last=0;
		if (document.styleSheets.length>1) {
			for (var i=1; i<document.styleSheets.length; i++)
				if (document.styleSheets[i].href) {
					document.styleSheets[last].href = document.styleSheets[i].href;
					last = i;
				}
			document.styleSheets[last].href = style_name;
		}
	} else {
		// The Mozilla way
		_TEMP_OUTP = document.createElement("LINK");
		_TEMP_OUTP.setAttribute("REL","stylesheet");
		_TEMP_OUTP.setAttribute("TYPE","text/css");
		_TEMP_OUTP.setAttribute("HREF",style_name);
		document.getElementsByTagName("HEAD").item(0).appendChild(_TEMP_OUTP);
	}
}

function xtoggleEnlarge() {
var theme = schillingbase + "/ams-large.css";
    if (document.styleSheets.length == 1)
	mkcss(document.styleSheets[0].href.substr(0,document.styleSheets[0].href.length-4)+"-large.css");
    for ( i = 0; i < document.styleSheets.length; i++ ) {
	alert(document.styleSheets[i].href);
	if ( document.styleSheets[i].href == schillingbase + "/ams.css" ) {
		document.styleSheets[i].disabled = true;
	if ( document.styleSheets[i].href == theme ) {
		document.styleSheets[i].disabled = false;
	}
    }
}

}
function toggleEnlarge()
{
	var aCookie = document.cookie.split("; ");
	var curEnlarge = 0;
	chunkarr=new Array();
	for (i=0; i < aCookie.length && !curEnlarge; i++)
	{
		// a name/value pair (a crumb) is separated by an equal sign
		var aCrumb = aCookie[i].split("=");
		if (aCrumb[0] == "ShopEnlarge") {
			curEnlarge = aCrumb[1].substr(0,3)=="yes";
			break;
		}
	}
	if (document.styleSheets.length>0) {
		var sheet;
		for (i=document.styleSheets.length-1; i>=0; i--) {
			sheet=document.styleSheets[i];
			if (sheet.href) {
				// Got the last stylesheet.
				hasLarge = (sheet.href.length>10 &&
							sheet.href.substr(sheet.href.length-10)=="-large.css");
				break;
			}
		}
		if (i<0) return;	// No CSS-files at all - not supported.
		if (hasLarge) {
			if (curEnlarge) {
				document.styleSheets[i].disabled=true;
			} else {
				document.styleSheets[i].disabled=false;
			}
		} else
			if (!curEnlarge)
				mkcss(sheet.href.substr(0,sheet.href.length-4)+"-large.css");
		if (curEnlarge)
			document.cookie="ShopEnlarge=no; expires=Sat, 31 Dec 2050 23:59:59 GMT";
		else
			document.cookie="ShopEnlarge=yes; expires=Sat, 31 Dec 2050 23:59:59 GMT";
	}
	//location.reload();
}

function OCSISBN(isbn)
{
	if(isbn == "")
		return;
	document.searchIsbnForm.isbn.value = isbn;
	document.searchIsbnForm.submit();
}

function OCSISBNK(isbn)
{
	if(event.keyCode==13)
	{
		OCSISBN(isbn);
		event.returnValue=false;
	}
}

function SV(artnr)
{
    changeProsaHref("/vare/"+artnr);
}

function OCSISBN(isbn)
{
	document.searchIsbnForm.isbn.value = isbn;
	if(document.searchIsbnForm.isbn.value != "")
		document.searchIsbnForm.submit();
}

function OCSISBNK(isbn)
{
	if(event.keyCode==13)
	{
		event.returnValue=false;
		OCSISBN(isbn);
	}
}

function showLogin(event)
{
	if(event=="")
		changeProsaHref("/servlet/oase.article.showArticle?ident=loginCombo&wfw="+(new Date()).getTime());
	else
		changeProsaHref("/servlet/oase.article.showArticle?ident=loginCombo&kurv_event="+event+"&wfw="+(new Date()).getTime());
}

function doLogout()
{
	changeProsaHref(logouturl);
//	dummy = alert("after logout - going to front.");
//	changeProsaHref("/");
}

function doLogin()
{
	changeProsaHref(loginurl+"&wfw="+(new Date()).getTime());
}

function doChangeUser()
{
	changeProsaHref(changeuserurl+"&wfw="+(new Date()).getTime());
}


function frontPage()
{
	/* Er ikke nogen endelig funkton - er blot her for at arkivere URL'en */
	changeProsaHref("/servlet/oase.article.showArticle?ident=Forside&art_event=GET_CATEGORY&art_categoryId="+forsidecat+"&wfw="+(new Date()).getTime());
}

function showMailPwdPage()
{
	changeProsaHref("/servlet/oase.article.showArticle?ident=GlemtKode&wfw="+(new Date()).getTime());
}

function showErrorMessage(message)
{
	dummy = alert(message);
	return false;
}

function basketEanNotValidError()
{
	dummy = alert("Angivet EAN er ikke validt.");
}

function SchToggleEC(id, plusimg, minusimg)
{	
	var imtg = document.getElementById('SchEcImg_'+id);
//alert("state of "+id+"="+imtg.state);
	if (imtg.state == undefined)
		imtg.state = 0;
	if (imtg.state==0) {
		imtg.src = plusimg;
		imtg.state = 1;
	} else {
		imtg.src = minusimg;
		imtg.state = 0;
	}
	var tg = document.getElementById('SchEcGr_'+id);	// Id on table containing children
//alert("display="+tg.style.display);
	if (tg.style.display=="")
		tg.style.display = 'block';
	if (tg.style.display == 'block')
		tg.style.display = 'none';
	else
		tg.style.display = 'block';
}

function SchToggleOpenEC(id, plusimg, minusimg)
{
	var tg = document.getElementById('SchEcGr_'+id);	// Id on table containing children
	if (tg && tg.style.display == 'none')
		SchToggleEC(id, "", "");
}

function SchCheckEC(formname,state,id,pid)
{	
//dummy = alert("SchCheckEC(formname="+formname+" Check state="+state+" id="+id+" pid="+pid);
	var f = document.forms[formname];
	var titletd;
	var searchClassName = "SchEcChk_"+id;
	var classlength = searchClassName.length;
	var childsfound = false;
	// Select all children
	for (i = 0; i < f.elements.length; i++) {
		var childclassName = f.elements[i].className;
//dummy = alert("childclassName="+childclassName.substring(0,classlength)+" searchClassName="+searchClassName);
		if (childclassName.substring(0,classlength) == searchClassName) {
			childsfound = true;
	//		if (state == true)		// Only select sub-codes when adding.
				f.elements[i].checked = state;
			var fid = f.elements[i].id;
			var thisid = fid.substring(11,fid.length);	// FIXME: hardcode of 11.
//dummy = alert("thisid="+thisid);
		}
	}
	var theid = "SchEcBox_" + id;
	var clickelem = document.getElementById(theid);
	if (clickelem.className == "")
		return;
	var title = "";
	if (clickelem != null)
		titletd = document.getElementById('SchEcTit_'+id);
		if (titletd != null)
			title = titletd.childNodes[0].nodeValue;
	// Children found and checked - open folder to show
	if (childsfound) {
		var imtg = document.getElementById('SchEcImg_'+id)
		var table = document.getElementById('SchEcGr_'+id)
//dummy = alert ("Childsfound imtg=SchEcImg_"+id+" imgtg.state="+imtg.state);
		if (table.style.display == "none")
			SchToggleEC(id, '/images/extcodeplus.gif','/images/extcodeminus.gif');
	}
}

function SchSubmitEc(form)
{
 if (form.email != null) {
 if (SchValidEmail(form.email.value) == false) {
 SchUserError(99,'Den indtastede e-mail accepteres ikke.');
 form.email.focus();
 return false;
 }
 }
 form.submit();
 return false;
}

//email validator returnerer true eller false
function SchValidEmail(mail)
{
	
	var email=/^[A-Za-z0-9]+([_\.-][A-Za-z0-9]+)*@[A-Za-z0-9]+([_\.-][A-Za-z0-9]+)*\.([A-Za-z]){2,4}$/i;
	return(email.test(mail));
}


// -----------------------------------------
//               validateEmail
// Validate if e-mail address
// Returns true if so (and also if could not be executed because of old browser)
// -----------------------------------------

function validateEmail  (vfld,   // element to be validated
                         ifld,   // id of element to receive info/error msg
                         reqd)   // true if required
{
	return true;
//dummy = alert("validateEmail");
  //var stat = commonCheck (vfld, ifld, reqd);
  //if (stat != proceed) return stat;

  var tfld = trim(vfld.value);  // value of field with whitespace trimmed off
  var email = /^[^@]+@[^@.]+\.[^@]*\w\w$/
  if (!email.test(tfld)) {
    showErrorMessage ("ERROR: not a valid e-mail address");
    vfld.focus();
    return false;
  }
  var email2 = /^[A-Za-z][\w.-]+@\w[\w.-]+\.[\w.-]*[A-Za-z][A-Za-z]$/
  if (!email2.test(tfld)) 
    showErrorMessage ("Unusual e-mail address - check if correct");
  return true;
};

function flipflopblock(nodehit, idshowornot)
{
	elemtoshowornot = document.getElementById(idshowornot);
	iconwhenhidden = document.getElementById(idshowornot+"_icoshow");
	iconwhenshown = document.getElementById(idshowornot+"_icohide");
	if (elemtoshowornot != null) {
		if (elemtoshowornot.style.display == "none") {
			elemtoshowornot.style.display = "block";
			if (iconwhenshown != null)
				iconwhenshown.style.display = "block";
			if (iconwhenhidden != null)
				iconwhenhidden.style.display = "none";
		} else {
			elemtoshowornot.style.display = "none";
			if (iconwhenshown != null)
				iconwhenshown.style.display = "none";
			if (iconwhenhidden != null)
				iconwhenhidden.style.display = "block";
		}
	}
}

function BC_Cancel(questiontxt, distno, ident)
{
	doContinue = confirm(questiontxt);
	if (doContinue != true)
		return;
	replaceProsaHref(schillingbase + "/servlet/oase.div.redir2?wfw="+(new Date()).getTime()+"&art_event=BCCNCL&art_bcdst="+distno+"&url="+escape(location.href));
}

function BC_Enrole(questiontxt, distno, ident)
{
	doContinue = confirm(questiontxt);
	if (doContinue != true)
		return;
	replaceProsaHref(schillingbase + "/servlet/oase.div.redir2?wfw="+(new Date()).getTime()+"&art_event=BCNRL&art_bcdst="+distno+"&url="+escape(location.href));
}

function SCHOC(vnr, courseno, coursegrp, loggedin)
{
	if (loggedin == "true") {
		var antal = 1;
		location.replace(schillingbase + "/servlet/oase.div.redir2?wfw="+(new Date()).getTime()+"&kurv_event=KURV_ADD&kurv_vnr="+vnr+"&kurv_courseno="+courseno+"&kurv_coursegrp="+coursegrp+"&kurv_antal="+antal+"&arttype=COURSE"+"&url="+escape(location.href));
	} else {
		alert("Vg log ind");
	}
}

function SCHCC(vnr, courseno, coursegrp)
{
	var doContinue;
	doContinue = confirm("Vil du afmelde dig fra dette kursus?");
	if (doContinue != true)
		return;
	location.replace(schillingbase + "/servlet/oase.div.redir2?wfw="+(new Date()).getTime()+"ident=oaseUserCourses&user_event=USER_DELCOURSE&user_vnr="+vnr+"&user_courseno="+courseno+"&user_coursegrp="+coursegrp+"&url="+escape(location.href));
}

function SchClickToDownloadEbook(url, name)
{
	open(url, null, 'toolbar=0,location=0,directories=0,menubar=0,width=640,height=200');
}

function getDescriptionHref(ElemType)
{
	thiselement = document.getElementById(ElemType);
	var anchor = 0;
	anchor = location.href.indexOf("#");
	if (anchor > 0) {
		actlink = location.href.substring(0, anchor+1);
		thiselement.href = actlink+"show"+ElemType;
	} else {
		thiselement.href = location.href+"#show"+ElemType;
	}
}

function updateDeliveryMethod()
{
	var i=document.olform.deliverymethod.selectedIndex;
	document.olform.kurv_levmaade.value = document.olform.deliverymethod.options[i].text;
	document.olform.kurv_levmaadekode.value = document.olform.deliverymethod.options[i].value;
	document.olform.kurv_event.value = "KURV_UPDATE";
//  document.olform.ident.value="oaseShowBasket";
}

function SchBasketBack(backtourl)
{
    changeProsaHref(backtourl+"&wfw="+(new Date()).getTime());
}

function SchShopInfo()
{
    changeProsaHref(schillingshopinfourl);
}

function SchShowTipFriend(vnr)
{
	window.open(showarticle+"?ident="+schillingtiparticle+"&noshowtype=true&notemplate=true&wfw="+(new Date()).getTime()+"&ident="+schillingtiparticle+"&art_event=GET_ART&art_vnr="+vnr, null, 'toolbar=0,location=0,directories=0,menubar=0,width=460,height=300');
	
}

function SchClearSelect(node)
{
	node.value = "";
	node.select();
}

function UserLoginOLD(ident) {
    var user = document.getElementsByName("user_id");
    var password = document.getElementsByName("user_passwd");
    location.replace(schillingbase + "/servlet/oase.div.redir2?wfw="+(new Date()).getTime()+"&user_event=USER_LOGIN&user_oldevent=USER_LOGIN&ident="+ident+"&user_id="+user[0].value+"&user_passwd="+password[0].value+"&url="+escape(location.href));
}

function UserLogin(ident) {
    var user = document.getElementsByName("user_id");
    var password = document.getElementsByName("user_passwd");
	//var url = schillingbase + "/servlet/oase.article.showArticle?wfw="+(new Date()).getTime()+"&ident="+ident;
	var url = location.href;

	if (ident == "oaseShowBasketPayment")
		url += "&kurv_event=KURV_SUBMIT_NUPD";

    location.replace(schillingbase + "/servlet/oase.div.redir2?wfw="+(new Date()).getTime()+"&user_event=USER_LOGIN&user_oldevent=USER_LOGIN&ident="+ident+"&user_id="+user[0].value+"&user_passwd="+password[0].value+"&url="+escape(url));
}

function UserLogout(ident) {
    location.replace(schillingbase + "/servlet/oase.div.redir2?wfw="+(new Date()).getTime()+"&user_event=USER_LOGOUT&ident="+ident);
    frontPage();
}

function goToNextPage()
{
    var nextid;
    var s=location.href.split('art_pageId=');
    if (s[1] == undefined) {
    nextid = 2;
    location.replace(s[0]+'&art_pageId='+nextid);
    } else {
        var endchar = s[1].indexOf('&');
        if (endchar == -1)
            endchar = s[1].length;
        var id = s[1].substring(0, endchar);
    nextid = parseInt(id)+1;
    location.replace(s[0]+'art_pageId='+nextid+s[1].substring(endchar));
    }

}

function goToPrevPage()
{
    var nextid;
    var s=location.href.split('art_pageId=');
    if (s[1] == undefined) {
    nextid = 2;
    location.replace(s[0]+'&art_pageId='+nextid);
    } else {
    var endchar = s[1].indexOf('&');
        if (endchar == -1)
            endchar = s[1].length;
        var id = s[1].substring(0, endchar);
        var nextid = parseInt(id)-1;
        location.replace(s[0]+'art_pageId='+nextid+s[1].substring(endchar));
    }
}

function showPageInList(showId)
{
    var s = location.href.split('art_pageId=');
    if (s[1] == undefined) {
    location.replace(s[0]+'&art_pageId='+showId);
    } else {
        var endchar = s[1].indexOf('&');
        if (endchar == -1)
            endchar = s[1].length;
        if (s[1].length > 1) {
            location.replace(s[0]+'art_pageId='+showId+s[1].substring(endchar));
        } else
            location.replace(s[0]+'art_pageId='+showId);
    }
}

//function SchUserError(errlayerid, errno, errmsg)
function SchUserError(errno, errmsg)
{
	dummy = alert(errmsg);
}

function SchGetURLParam(strParamName){
	var strReturn = "";
	var strHref = window.location.href;
	var apos = strHref.indexOf("&");
	var qpos = strHref.indexOf("?");
	if ( qpos > -1 || apos > -1 ) {
		var strQueryString = strHref.substr(strHref.indexOf("?")).toLowerCase();
		var aQueryString = strQueryString.split("&");
		for ( var iParam = 0; iParam < aQueryString.length; iParam++ ) {
			if ( aQueryString[iParam].indexOf(strParamName + "=") > -1 ) {
				var aParam = aQueryString[iParam].split("=");
				strReturn = aParam[1];
				break;
			}
		}
	}
	return strReturn;
}

function SchCheckEmailFieldFill(emailfield)
{
   if (emailfield.value == '') {
     SchUserError(99,'Udfyld venligst feltet til e-mail.');
     emailfield.focus();
     return false;
   }
   if (SchValidEmail(emailfield.value) == false) {
     SchUserError(99,'Den indtastede e-mail accepteres ikke.');
     emailfield.focus();
     return false;
   }
}

function SchNyhedsmailRetTilmelding(emailfield)
{
  if (SchCheckEmailFieldFill(emailfield) == false)
    return false;
  if (schIsLoggedIn)
     location.replace("/servlet/oase.article.showArticle?ident=BrugerUdKoder&user_fill=web_fill_prospec&user_event=USER_GETEXTCDS&wfw="+(new Date()).getTime());
  else 
     location.replace("/servlet/oase.user.loginKnownOrUnknown?user_id="+emailfield.value+"&domain=emailcheck&user_fill=web_fill_prospec&wfw="+(new Date()).getTime());
}



function initAjaxObject()
{
   try {
     ajax_obj = new XMLHttpRequest();
   } catch (trymicrosoft) {
     try {
       ajax_obj = new ActiveXObject("Msxml2.XMLHTTP");
     } catch (othermicrosoft) {
       try {
         ajax_obj = new ActiveXObject("Microsoft.XMLHTTP");
       } catch (failed) {
         ajax_obj = false;
       }
     }
   }

}

function SchAjaxCallArg(url, nameOfUpdateFunction, arg1)
{
    initAjaxObject();
    if (ajax_obj.readyState != 4 && ajax_obj.readyState != 0) {
        return;
    }
    try {
        ajax_obj.onreadystatechange = function() {
            if (ajax_obj.readyState == 4)
                if (ajax_obj.status == 200)
                    nameOfUpdateFunction(arg1);
        }
        ajax_obj.open('GET', url, true);
        ajax_obj.send(null);
    } catch (open_e) {
        dummy = alert("Cannot open "+url+"\nexception="+open_e);
    }
}

function SchAjaxCall(url, nameOfUpdateFunction)
{
    initAjaxObject();
    if (ajax_obj.readyState != 4 && ajax_obj.readyState != 0) {
        return;
    }
    try {
        ajax_obj.onreadystatechange = function() {
            if (ajax_obj.readyState == 4)
                if (ajax_obj.status == 200)
                    nameOfUpdateFunction();
        }
        ajax_obj.open('GET', url, true);
        ajax_obj.send(null);
    } catch (open_e) {
        dummy = alert("Cannot open "+url+"\nexception="+open_e);
    }
}

function UpdatePriceAndTotal()
{
    var artnr = document.licenceForm.kurv_vnr.value;
    var i=document.licenceForm.pricegroup.selectedIndex;
    var pricegroup = document.licenceForm.pricegroup.options[i].value;
    var quantity = document.licenceForm.kurv_antal.value;
    SchAjaxCall(schillingbase+"/servlet/oase.art.getAjaxVal?artnr="+artnr+"&pricegroup="+pricegroup+"&quantity="+quantity, updatePage);
}

function getElementsByClassName(elementTagType, className) {
  var children = document.body.getElementsByTagName(elementTagType);
  var re = new RegExp('\\b' + className + '\\b');
  var element, elements = [];
  var i = 0;
  while ((element = children[i++])) {
    if ( element.className && re.test(element.className)) {
      elements.push(element);
    }
  }
  return elements;
}
function updatePage() {
    if (ajax_obj.readyState ==4) {
        if (ajax_obj.status == 200 || ajax_obj.status == 302) {
                var licPrice = document.getElementById("update-licence-price");
                var licTotal = document.getElementById("update-licence-total");
                var responseTexts = ajax_obj.responseText.split("|");
                if (licPrice && licPrice.innerHTML)
                    licPrice.innerHTML = responseTexts[0];
                if (licTotal && licTotal.innerHTML)
                    licTotal.innerHTML = responseTexts[1];
                var id = responseTexts[2];
                var tablecell = document.getElementById(id);
                var tds = getElementsByClassName('TD', 'selected-price');
                if (tds.length > 0) {
                    for (var i = 0; i < tds.length; i++) {
                        td = tds[i];
                        td.className='licence-price';
                    }
                }
                tablecell.className="licence-price selected-price";
        } else {
            alert('SchAjaxUpdateHTML() - Der var opstod problemer ved server kald - status='+ajax_obj.status);
        }
    }
}

function showBCOrderStat()
{
    changeProsaHref(showarticle+"?ident=OrderStats&wfw="+(new Date()).getTime());
}


function flipflopblock(nodehit, idshowornot)
{
    elemtoshowornot = document.getElementById(idshowornot);
    iconwhenhidden = document.getElementById(idshowornot+"_icoshow");
    iconwhenshown = document.getElementById(idshowornot+"_icohide");
    if (elemtoshowornot != null) {
        if (elemtoshowornot.style.display == "none") {
            elemtoshowornot.style.display = "block";
            if (iconwhenshown != null)
                iconwhenshown.style.display = "block";
            if (iconwhenhidden != null)
                iconwhenhidden.style.display = "none";
        } else {
            elemtoshowornot.style.display = "none";
            if (iconwhenshown != null)
                iconwhenshown.style.display = "none";
            if (iconwhenhidden != null)
                iconwhenhidden.style.display = "block";
        }
    }
}

function flipflopol(nodehit, targetId, mantxt)
{
    targetTD = document.getElementById(targetId);
    showButton = document.getElementById(targetId+'_show_keys');
    hideButton = document.getElementById(targetId+'_hide_keys');
    if (targetTD != null) {
        if (targetTD.innerHTML == "") {
            SchAjaxCallArg(schillingbase+"/servlet/oase.user.printUserMoodleKeys?moodlekey="+mantxt, updateLineMoodleKeys, targetId);
                showButton.style.display = "none";
                hideButton.style.display = "block";
        } else {
            if (targetTD.firstChild.style.display == "none") {
                targetTD.firstChild.style.display = "block";
		showButton.style.display = "none";
		hideButton.style.display = "block";
            } else {
                targetTD.firstChild.style.display = "none";
		showButton.style.display = "block";
		hideButton.style.display = "none";
            }
        }
    }
}
function updateLineMoodleKeys(targetIdName) {
    if (ajax_obj.status == 200 || ajax_obj.status == 302) {
        var targetTD = document.getElementById(targetIdName);
        if (targetTD)
            targetTD.innerHTML = ajax_obj.responseText
    } else {
        alert('SchAjaxUpdateHTML() - Der var opstod problemer ved server kald - status='+ajax_obj.status);
    }
}

function confirmAcceptConditions(checkbox) {
    if (checkbox.checked == true)
        return true;
    else {
        alert("Venligst l\u00e6s og godkend salgs- og leveringsbetingelserne!");
        return false;
    }
}

