	function doClass(obj, wN){
		obj.className=obj.className.replace(/\d/, wN);
	}
	
	function doBgImg(obj, wN){
		obj.style.backgroundImage=obj.style.backgroundImage.replace(/\d+/, wN);
	}
	
 	function getOffsetTop(obj){
		var ot=obj.offsetTop;
		while((obj=obj.offsetParent)!=null)ot+=obj.offsetTop;
		return ot;
	}
	
 	function getOffsetLeft(obj){
		var ot=obj.offsetLeft;
		while((obj=obj.offsetParent)!=null)ot+=obj.offsetLeft;
		return ot;
	}
	
	function openWin(url, width, height, status, toolbar, menubar, location, resizeable, scrollbars){
		var iWinLeft, iWinTop;	
		if (width==null)    width=800;
		if (height==null)   height=600;
        iWinLeft=Math.ceil((window.screen.width-width)/2);
        iWinTop=Math.ceil((window.screen.height-height)/2);	
		window.open(url, 'Prods','height='+ height +',width='+ width +', top='+ iWinTop +', left='+ iWinLeft +',status='+ status +',toolbar='+ toolbar +',menubar='+ menubar +',location='+ location +',resizable='+ resizeable +',scrollbars='+scrollbars);
	}
	
	function openWinBlank(url, width, height, status, toolbar, menubar, location, resizeable, scrollbars){
		var iWinLeft, iWinTop;	
		if (width==null)    width=800;
		if (height==null)   height=600;
        iWinLeft=Math.ceil((window.screen.width-width)/2);
        iWinTop=Math.ceil((window.screen.height-height)/2);	
		window.open(url, '_blank','height='+ height +',width='+ width +', top='+ iWinTop +', left='+ iWinLeft +',status='+ status +',toolbar='+ toolbar +',menubar='+ menubar +',location='+ location +',resizable='+ resizeable +',scrollbars='+scrollbars);
	}

	function showAccept(OrdreID, tst){
		if(!tst)tst=1;
		openWin('/tms/modul/tilmelding/signup_show.asp?menu=0&ordreid='+OrdreID+'&tst='+ tst +'&ku=true', 800, 600, 'no', 'no', 'no', 'no', 'no', 'yes');
		event.cancelBubble=true;
	}	

	function showAcceptSearch(OrdreID, tst){
		if(!tst)tst=1;
		openWin('/tms/modul/statussearch/showaccept.asp?menu=0&ordreid='+OrdreID+'&formular=1&tst='+ tst +'&ku=true', 800, 600, 'no', 'no', 'no', 'no', 'no', 'yes');
		event.cancelBubble=true;
	}	

	function showThreadFlow(StatusID, tst){
		if(!tst)tst=1;
		openWin('/tms/modul/statussearch/threadflow.asp?menu=0&sid='+StatusID+'&formular=1&tst='+ tst +'&ku=true', 800, 600, 'no', 'no', 'no', 'no', 'no', 'yes');
		event.cancelBubble=true;
	}	

	function showFaktura(FakturaID, KundeID, tst){
		if(!tst)tst=1;
		openWin('/tms/modul/faktura/pdf_fakturashow.asp?Faktura='+FakturaID+'&tst='+ tst +'&KundeID=' + KundeID, 800, 600, 'no', 'no', 'no', 'no', 'no', 'yes');
		event.cancelBubble=true;
	}	

	function showLetter(LetterID, tst){
		if(!tst)tst=1;
		openWin('/tms/modul/letter/visbrev.asp?letter_id='+LetterID, 800, 600, 'no', 'no', 'no', 'no', 'no', 'yes');
		event.cancelBubble=true;
	}	

	function showArchiveImage(imgID){
		openWin('/tms/modul/journalisering/archive_image.asp?oid='+imgID, 800, 600, 'no', 'no', 'no', 'no', 'no', 'yes');
	}

	function showPaper( iOrdreID, bPrint, iFormular){

		// openWin('/tms/modul/tilmelding/signup_formular.asp?ordreID='iOrdreID&formular=1&nomenu=1
		openWin('/tms/modul/tilmelding/signup_formular.asp?menu=0&formular='+ iFormular +'&print='+ bPrint +'&ordreid='+iOrdreID, 800, 600, 'no', 'no', 'no', 'no', 'no', 'yes');
	}

	function showPaperLetter( iOrdreID, bPrint, iFormular){
		// openWin('/tms/modul/tilmelding/signup_formular.asp?ordreID='iOrdreID&formular=1&nomenu=1
		openWin('/tms/modul/tilmelding/signup_formular_Letter.asp?menu=0&formular='+ iFormular +'&print='+ bPrint +'&ordreid='+iOrdreID, 800, 600, 'no', 'no', 'no', 'no', 'no', 'yes');
	}

	function processthisstatus( oForm, iStatusID, iStampMark ){
		oForm.command.value = 'saProcess';
		oForm.saStatusID.value = iStatusID;
		oForm.saStampmark.value = iStampMark;
		oForm.submit();
	}

	//Sætter den default valgte på et SELECT element.
	function setSelectDefault(oSelect, sValue){
		for(var i=0;i<oSelect.length;i++){
			if(oSelect.item(i).value==sValue){
				oSelect.item(i).selected=true;
			}	
		}
	}
	
	function updateSum(n){
		if(document.signup.CcBasicAmount)document.signup.CcBasicAmount.value=n + ',00';
		var iStartAmount = 0;
		if(document.signup.CcStartAmount)iStartAmount=document.signup.CcStartAmount.value.replace(',','.');
		//alert( iStartAmount + ' ' + parseFloat(iStartAmount));
		var iExtraTank = 0;
		if(document.signup.CcMethod.value==1 | !document.signup.FirstPayment){
		    iExtraTank=parseFloat(n);
		}
		//if(document.signup.CcStartAmount && document.signup.CcStartAmount.value>0)iStartAmount=document.signup.CcStartAmount.value.replace(',','.');
		document.signup.CcWithdrawAmount.value=(parseFloat(iStartAmount)+iExtraTank).toString().replace('.', ',');
	}
	
	function ChangeTankMethod() {
        if(document.signup.CcMethod.value==1 & !!document.signup.FirstPayment){ //Manual tank på signup
            var oOption = document.createElement("OPTION");
            oOption.text="0";
            oOption.value="0";
            document.signup.CcAmount.add(oOption,1);
            updateSum(document.signup.CcAmount.value);
        }
        else{
            if(document.signup.CcAmount.item(1).value==0){
                document.signup.CcAmount.remove(1);
                if(document.signup.CcAmount.value==0){
                    document.signup.CcAmount.selectedIndex = 1;
                    updateSum(document.signup.CcAmount.item(1).value);
                }
                else{
                    updateSum(document.signup.CcAmount.value);
                }
            }
        }
    }
	
	function fillform() {
		document.signup.AdrA_Cprnr.value = '1111111118';
		document.signup.AdrA_Fornavn.value = 'Test';
		document.signup.AdrA_Efternavn.value = 'Testesen';
		document.signup.AdrA_Gadenavn.value = 'Test Allé';
		document.signup.AdrA_Husnr.value = '12';
		document.signup.AdrA_Postnr.value = '1200';
		document.signup.AdrA_Postby.value = 'København K';
		document.signup.AdrA_Email.value = 'mester@tester.com';		
	}

	function fillform_pay() {
		document.signup.fld_CcNumber.value = '4564891634864';
		document.signup.CcControlNumbers.value = '413';
		setSelectDefault(document.signup.CcMonth, '6');
		setSelectDefault(document.signup.CcYear, '2005');
	}
	
	/*	This function uses the style INPUT.READONLY in the stylesheets and formats readonlye input-fields with a 'gray' background
		Needs to be called in each 'document.body.onload' function-call (IN the called function!!!) on the following pages:
		- htmlpage2.htm
		- tms\test.asp
		- tms\modul\tilmelding\signup_cards.asp
		- class\website_backoffice_product.asp
		- javascript\signup_rule.js
		with this: init_fields();
	*/
	function init_fields() {
		var el, els, e, f = 0, form, forms = document.getElementsByTagName('form');
		while (form = forms.item(f++))
		{
			e = 0; els = form.getElementsByTagName('input');
			while (el = els.item(e++))
				if (el.readOnly)
					el.className = 'readonly';
		}
	}
