/*
Purpose:	Replace invalid charcters in input fields
Created:	Viscom      2004-09-23
Comment:	Viscom	(Added / to the regEx for allowing to send relative path in request)
*/
function ReplaceInvalidChars(strText) {
	if (strText != '') {
		var re = new RegExp("[^a-zA-Z0-9-æøåäöÆØÅÄÖ\s#_\.,@\!\x26\(\)=\?\*:;\+\/]|\|", "g");
		return strText.replace(re, '');
	}
}

/*
Purpose:	Redirect to page based on combobox value
Created:	Viscom      2004-09-02
*/
function GotoCboURL(objCBO) {
	var objVal = ReplaceInvalidChars(objCBO.value);
	if (objVal != '') {
		if (objVal.indexOf("://") > 0) {
			location = objVal;
		}
		else {
			location = "<%= GetCommonName() & GetAppPath() %>" + objVal;
		}
	}
}
 
/*
Purpose:	Redirect to page
Created:	Viscom      2004-09-02
*/
function GotoURL(strPath){
	document.location.href = "<%= GetCommonName() & GetAppPath() %>" + ReplaceInvalidChars(strPath);
}

/*
Purpose:	Read faq-ID and
			call procedure to activate faq
Created:	Viscom      2004-09-02
Changed:	Viscom		2004-09-20	Use post value insted of get
*/
function DisplayFaq(strDefaultSelected){
	var strFaqItem
	
	strFaqItem = document.RedirForm.hdnPostValue.value
	
	if ((strFaqItem != null) || (strFaqItem != '')) {
		ActivateFaq(strFaqItem);
	} else {
		if ((strDefaultSelected != null) || (strDefaultSelected != '')) {
			ActivateFaq(strDefaultSelected);
		}
	}
}

/*
Purpose:	Display FAQ item and mark link
Created:	Viscom      2004-09-02
*/
function ActivateFaq(strFaqName){
	
	
	document.getElementById(strFaqName).style.display = 'inline';
	
	if (strFaqName != 'HowToGet2') {
		var tekst = document.getElementById("lnk" + strFaqName).innerHTML;
		document.getElementById("span" + strFaqName).innerHTML = tekst;
		document.getElementById("span" + strFaqName).style.fontWeight = 'bold';
	}
}

/*
Purpose:	Read faq-ID and
			call procedure to activate faq
Created:	DS      2005-02-04
*/
function DisplayFaq2(strDefaultSelected){
	var strFaqItem
	
	strFaqItem = document.RedirForm.hdnPostValue.value

	if ((strFaqItem != null) || (strFaqItem != '')) {
		ActivateFaq2(strFaqItem);
	} else {
		if ((strDefaultSelected != null) || (strDefaultSelected != '')) {
			ActivateFaq2(strDefaultSelected);
		}
	}
}

/*
Purpose:	Display faq item
Created:	DS      2005-02-02
*/
function ActivateFaq2(strName){
	document.getElementById(strName).style.display = 'inline';
}

/*
Purpose:	Read image-ID and
			call procedure to activate image
Created:	DS      2005-02-02
*/
function DisplayImage(strDefaultSelected){
	var strItem
	
	strItem = document.RedirForm.hdnPostValue2.value

	if ((strItem != null) || (strItem != '')){
		ActivateImage(strItem);
	} else {
		if ((strDefaultSelected != null) || (strDefaultSelected != '')) {
			ActivateImage(strDefaultSelected);
		}
	}
}

/*
Purpose:	Display image item
Created:	DS      2005-02-02
*/
function ActivateImage(strName){
	document.getElementById(strName).style.display = 'inline';
}

/*
Purpose:	Read faq-ID and
			call procedure to activate faq
Created:	Viscom      2004-09-02
Changed:	Viscom		2004-09-20	Use post value insted of get
*/
function DisplayRelevant(strDefaultSelected){
	var strFaqItem
	
	strFaqItem = document.RedirForm.hdnPostValue.value

	if (strFaqItem != ''){
		ActivateRelevant(strFaqItem);
	}
	else{
		ActivateRelevant(strDefaultSelected);
	}
}

/*
Purpose:	Display FAQ item, hide FAQ links and
			select FAQ item in combobox
Created:	Viscom      2004-09-02
*/
function ActivateRelevant(strFaqName){
	if (strFaqName != ''){
		document.getElementById(strFaqName).style.display = 'inline';
		document.getElementById("divLinks").style.display = 'none';
		for (i=0; i < document.getElementById("cboRelevant").length; i++){
			var astrCbo = document.getElementById("cboRelevant").options[i].value.split("=");
			if (astrCbo.length > 1){
				if (astrCbo[1] == strFaqName){
					document.getElementById("cboRelevant").selectedIndex = i
				}
			}
		}
	}
}

/*
Purpose:	Generate combobox for business area and
			output to screen
Created:	Viscom      2004-09-02
*/
function InsertPartnerCbo(){
	var strPartner = "\<img src='Images/Headers/min_konto_links.gif'\>" +
						"\<br\>\<img src='Images/dotClear.gif' height='4' width='1'\>\<br\>" +
						"\<select name='cboPartner' onchange='GotoCboURL(this);'\>" +
						"\<option value='' selected\>Dine muligheder med dit AcceptCard...\</option\>" +
						"\<option value='PagesBusiness/Balance.aspx'\>Løbende salg\</option\>" +
						"\<option value='PagesBusiness/Credit.aspx'\>Kreditoprettelser\</option\>" +
						"\<option value='PagesBusiness/PersonalInfo.aspx'\>Stamdata\</option\>" +
						"\<option value='PagesBusiness/Merchandice.aspx'\>Bestil materiale\</option\>" +
						"\<option value='PagesBusiness/Phone.aspx'\>Telefonautorisation\</option\>" +
						"\<option value='PagesBusiness/PartnerNews.aspx'\>Nyheder for partnere\</option\>" +
						"\<option value='PagesBusiness/FaqClone.aspx'\>Spørgsmål & svar\</option\>" +
						"\</select\>"

	document.write(strPartner);
}

/*
Purpose:	Generate combobox for my account area and
			output to screen
Created:	Viscom      2004-09-02
*/
function InsertCustomerCbo(){
	var strCustomer =	
						"\<table cellpadding='0' cellspacing='0' border='0'\>" +
						"\<tr\>" +
						"\<td\>\<img src='Images/Headers/min_konto_links.gif'\>\</td\>" +
						"\</tr\>" +
						"\<tr\>" +
						"\<td height='4'\><img src='Images/dotClear.gif' height='4' width='1'\>\</td\>" +
						"\</tr\>" +
						"\<tr\>" +
						"\<td\>" +
						"\<select name='cboPartner' onchange='GotoCboURL(this);'\>" +
						"\<option value='' selected\>Dine muligheder...\</option\>" +
						"\<option value='PagesPrivate/Balance.aspx'\>Saldooplysninger\</option\>" +
						"\<option value='PagesPrivate/LatestNews.aspx'\>Seneste nyheder\</option\>" +
						"\<option value='PagesPrivate/Assurance.aspx'\>Alt om AcceptForsikring\</option\>" +
						"\<option value='PagesPrivate/Price.aspx'\>Alt om PrisGaranti\</option\>" +
						"\<option value='PagesPrivate/Card.aspx'\>Alt om kortet\</option\>" +
						"\<option value='PagesPrivate/SignAssurance.aspx'\>Tegn en AcceptForsikring\</option\>" +
						"\<option value='PagesPrivate/ApplyCredit.aspx'\>Ansøg om kreditforhøjelse\</option\>" +
						"\<option value='PagesPrivate/ApplyFree.aspx'\>Ansøg om betalingsfri måned\</option\>" +
/* START_CR2349_20080728_S071808_4664963 Deleted 
						"\<option value='PagesPrivate/OrderCheck.aspx'\>Bestil check\</option\>" +
END_CR2349_20080728_S071808_4664963 Deleted */
						"\<option value='PagesPrivate/NewCode.aspx'\>Bestil ny pinkode\</option\>" +
						"\<option value='PagesPrivate/NewAcceptCard.aspx'\>Bestil nyt AcceptCard\</option\>" +
						"\<option value='PagesPrivate/Contact.aspx'\>Kontakt os\</option\>" +
						"\</select\>" +
						"\<td\>" +
						"\<tr\>" +
						"\</table\>"

	document.write(strCustomer);
}

/*
Purpose:	Decide which div-tags to display
Created:	Viscom      2004-09-02
*/
function CreateLayout(){
	if (GetFileName().toUpperCase() == 'FAQCLONE'){
		document.getElementById("divImageClone").style.display = 'inline';
	}
	else{
		document.getElementById("divFaq").style.display = 'inline';
		document.getElementById("divImage").style.display = 'inline';
	}
}

/*
Purpose:	Get name of file without extention
Created:	Viscom      2004-09-02
*/
function GetFileName(){
	var strLocation = window.location.href;
	var astrLocation = strLocation.split('/');
	var astrFileName = astrLocation[astrLocation.length-1].split(".")
	return astrFileName[0]
}
 
/*
Purpose:	Decide which action to use
			and submit using "SubmitRedirect"
Created:	Viscom      2004-09-02
Changed:	Viscom		2004-09-20	Use post value insted of get
*/
function ShowFaq(strFaqItem){

	var strFileName = GetFileName()

	if (strFileName.toUpperCase() == 'FAQCLONE'){
		var strLocation = 'PagesBusiness/'
	}
	else{
		var strLocation = 'Pages/About/'
	}
	var strPath = strLocation + strFileName + '.aspx'
	var strAction = "<%= GetCommonName() & GetAppPath() %>" + strPath;

	SubmitRedirect(strAction, strFaqItem)
}

/*
Purpose:	Submit form (custom action)
Created:	Viscom		2004-09-20
*/
function SubmitRedirect(strPostPage, strPostValue){
	document.forms[0].hdnPostValue.value = strPostValue;
	if (strPostPage != ''){
		document.forms[0].action = strPostPage;
	}
	document.forms[0].submit();
}

/*
Purpose:	Submit form (custom action)
Created:	DS		2005-02-04
*/
function SubmitRedirect2(strPostPage, strPostValue, strPostValue2){
	document.RedirForm.hdnPostValue2.value = strPostValue2;
	SubmitRedirect(strPostPage, strPostValue);
}

/*
Purpose:	Clear field value first time
			user access the field
Created:	Viscom      2004-09-20
*/
function ClearInitValue(objClear, objField){
	if (objClear.value == '0' || objClear.value == ''){
		objClear.value = '1';
		objField.value = '';
	}
}
