﻿/* -- Strikonline, indsat af ts-pkr -- */

function MemberLogin()
{
var CurrentPage = document.location.href;
Tangora.Cookies.SetCookie('Dest', CurrentPage);
if (location.href.indexOf('/admin')==-1)
{
document.location.replace('/page3228.aspx?validating=1&orgpageid=3415')
}
}

/* ---------- BFB Tangora - strikonline navigation ---------- */

/* --- makes an array of first level items --- */
function getMenuArray(){
  // use handy tangora classname array to get an array of nav points  
  var firstNavItemArray = Tangora.DOM.GetCollectionByClassName('mergefield_navigation_level1', 'li', 'navigationlistitem');   
  var firstNavItemArray2 = new Array();
  // go through all the nav li's, and add them that have a greatgrandparent level 1 to an alternative array 
  for (var i=0; i<firstNavItemArray.length; i++) {
    if (firstNavItemArray[i].parentNode.parentNode.parentNode.id.indexOf('mergefield_navigation_level1')>-1) {
	   firstNavItemArray2.push(firstNavItemArray[i]);     
    }   
   
  }
  return firstNavItemArray2;
}

/* --- adds mouseover for each first level item --- */
function setMenuOverEffects (){
  var firstNavItemArray = getMenuArray();  
  for (var i=0; i<firstNavItemArray.length; i++) {
     firstNavItemArray[i].onmouseover=mainMenuOver;
     firstNavItemArray[i].onmouseout=mainMenuOut;
  }  
}

/* --- mouseover: make all points normal, and make the hover point active --- */
function mainMenuOver(){
  var firstNavItemArray = getMenuArray();
  //make all items use normal state graphic
  for (var i=0; i<firstNavItemArray.length; i++) {
    firstNavItemArray[i].firstChild.style.background = 'url(/media/navNormalRepeat.gif) repeat-x left top';  //anchor in li
    firstNavItemArray[i].firstChild.firstChild.style.background = 'url(/media/navNormalRight.gif) no-repeat right top'; //span in anchor in li
    firstNavItemArray[i].firstChild.firstChild.style.color = '#fff'; //span in anchor in li
  }
  //and for the hovered anchor, choose its parent li, and use the hover graphic
  this.firstChild.style.background = 'url(/media/navActiveLeft.gif) no-repeat left top';  //anchor in li
  this.firstChild.firstChild.style.background = 'url(/media/navActiveRight.gif) no-repeat right top'; //span in anchor in li
  this.firstChild.firstChild.style.color = '#000'; //span in anchor in li
}

/* --- mouseout: make all points normal, and make the active point active --- */
function mainMenuOut(paramThis){
  //make an array to get the li item with class = activeitem, so we can restore the active graphic state
  var activeItem =  Tangora.DOM.GetCollectionByClassName('mergefield_navigation_level1', 'li', 'activeitem');   
  var firstNavItemArray = getMenuArray();
  for (var i=0; i<firstNavItemArray.length; i++) {
    firstNavItemArray[i].firstChild.style.background = 'url(/media/navNormalRepeat.gif) repeat-x left top';  //anchor in li
    firstNavItemArray[i].firstChild.firstChild.style.background = 'url(/media/navNormalRight.gif) no-repeat right top'; //span in anchor in li
    firstNavItemArray[i].firstChild.firstChild.style.color = '#fff'; //span in anchor in li
  }
  //restore active graphic state
  if (activeItem.length != 0){
    activeItem[0].firstChild.style.background = 'url(/media/navActiveLeft.gif) no-repeat left top';  //anchor in li
    activeItem[0].firstChild.firstChild.style.background = 'url(/media/navActiveRight.gif) no-repeat right top'; //span in anchor in li
    activeItem[0].firstChild.firstChild.style.color = '#000'; //span in anchor in li
  }
}

/* ---------- END BFB Tangora - strikonline navigation ---------- */



Tangora.Events.AddHandler(window, "onload", HookUpEmail);

var TheFlag=0;

function HookUpEmail()
{
	var email = document.getElementById("idemail");
	if (email)
	{
		if (email.value=="")
		{
			var cookie = Tangora.Cookies.GetCookieValue("tangora_email","emailaddress");
			if (cookie) email.value = cookie;
		}
	}
}

function GenerateOptions(username, tilmeldtPBS, tilmeldtPBSCookie, udmeldt, pauseret, pauseretCookie, sprog)
{			
	if (tilmeldtPBSCookie=="1") tilmeldtPBS = "1";
	if (pauseretCookie=="1") pauseret = "1";
	else if (pauseretCookie=="0") pauseret = "0";
	document.write("<ul class=\"sectionlist\">");
	if (sprog=="da" || sprog=="")
	{
		document.write("<li class=\"section\"><a class=\"inlinelink\" href=\"/Adresseændring.67.aspx\">Adresseændring</a></li>");			
		if (udmeldt=="0" || username=="")
		{
			if (pauseret=="0" || username=="") document.write("<li class=\"section\"><a class=\"inlinelink\" href=\"/Skift+abonnement.68.aspx\">Skift abonnement</a></li>");
			if (pauseret=="0" || username=="") document.write("<li class='section'><a class='inlinelink' href='/Sæt+dit+abonnement+på+pause.72.aspx'>Sæt dit abonnement på pause</a></li>");
			if (pauseret=="1" || username=="") document.write("<li class='section'><a class='inlinelink' href='/Genoptag+abonnement.245.aspx'>Dit abonnement er på pause. Genoptag abonnement.</a></li>");
			if (tilmeldtPBS=="0" || username=="") document.write("<li class=\"section\"><a class='inlinelink' href='/Tilmeld+PBS.70.aspx'>Tilmeld PBS</a></li>");
			if(pauseret=="0" || username=="") document.write("<li class=\"section\"><a class=\"inlinelink\" href=\"/page73.aspx\">Andre ændringer</a></li>");
		}
	}
	else if (sprog == "se")
	{
		document.write("<li class=\"section\"><a class=\"inlinelink\" href=\"/Adressändring.110.aspx\">Adressändring</a></li>");			
		if (udmeldt=="0" || username=="")
		{
			if (pauseret=="0" || username=="") document.write("<li class=\"section\"><a class=\"inlinelink\" href=\"/Ändra+prenumeration.117.aspx\">Ändra prenumeration</a></li>");
			if (pauseret=="0" || username=="") document.write("<li class='section'><a class='inlinelink' href='/Pausa+din+prenumeration.241.aspx'>Pausa din prenumeration</a></li>");
			if (pauseret=="1" || username=="") document.write("<li class='section'><a class='inlinelink' href='/Fortsätt+prenumerationen.249.aspx'>Din prenumeration är pausad. Uppstarte prenumerationen igen.</a></li>");					
			if(pauseret=="0" || username=="") document.write("<li class=\"section\"><a class=\"inlinelink\" href=\"/vriga+ndringar.112.aspx\">Övrige ändringar...</a></li>");
		}
	}
	else if (sprog == "no")
	{			
		document.write("<li class=\"section\"><a class=\"inlinelink\" href=\"/Adresseændring.170.aspx\">Adresseendring</a></li>");		
		if (udmeldt=="0" || username=="")
		{
			if (pauseret=="0" || username=="") document.write("<li class=\"section\"><a class=\"inlinelink\" href=\"/Skift+abonnement.177.aspx\">Skift abonnement</a></li>");
			if (pauseret=="0" || username=="") document.write("<li class='section'><a class='inlinelink' href='/Sæt+dit+abonnement+på+pause.234.aspx'>Sett ditt abonnement på pause</a></li>");
			if (pauseret=="1" || username=="") document.write("<li class='section'><a class='inlinelink' href='/Gjennoppta+abonnement.247.aspx'>Ditt abonnement er på pause. Gjennoppta abonnement</a></li>");					
			if(pauseret=="0" || username=="") document.write("<li class=\"section\"><a class=\"inlinelink\" href=\"/Andre+endringer.174.aspx\">Andre endringer</a></li>");
		}
	}
	document.write("</ul>");	
}

function GetRndKey()
{
	 return Math.random()*10000;
}

function AjaxLoadPage (url, contentfield, callback)
{
	url += "&rndkey="+GetRndKey();
	tsAjax.innerHTML(url, 'tsAjax', null, contentfield, null);
}

function getBaseURL()
{
	 return location.protocol + "//" + location.host;
}

function ClearInputFields(containerID)
{
	if(getParam("action",document.location.href)!="post")
	{
		var elms = document.getElementById(containerID).getElementsByTagName("input");

		for(var i = 0; i < elms.length; i++)
		{
			if(elms[i].type == "text")
			{
				elms[i].value = "";
			}
		}
	}
}

var PauseString = function(up)
{
	this.Get = function()
	{
		var cp = Tangora.Cookies.GetCookieValue("tangora_pause","pausestr");
		var elm = document.getElementById("pausestr");

		if(elm)
		{
			elm.innerHTML = (cp != null) ? cp : up;
		}
	}
	
	this.Nuke = function()
	{
		Tangora.Cookies.SetCookieValue("tangora_pause","pausestr",null);
		Tangora.Cookies.SetCookieValue("tangora_pause","pause","0");
	}
}

function RemoveDeliveryCharge(charge)
{
	var row = document.getElementById("delivery_charge");

	if(charge == 0 && row)
	{	
		row.style.display = "none";
	}
}

function CompareValues(val1,val2)
{
	if(val1 != val2)
	{
		return false;
	}

	return true;
}

function ToggleNewsletterLayers(layerID, hideLayerID)
{
	ShowLayer(layerID);
	HideLayer(hideLayerID);	
}

function ShowDeliveryAddressLayer()
{
	SetInputItemsState("delivery_address","disabled",false);
	ShowLayer("delivery_address");
}

function HideDeliveryAddressLayer()
{
	HideLayer("delivery_address");
	SetInputItemsState("delivery_address","disabled",true);
}

function ShowPaymentInfoLayer()
{
	SetInputItemsState("payment_info","disabled",true);
	ShowLayer("payment_info");
}

function HidePaymentInfoLayer()
{
	HideLayer("payment_info");
	SetInputItemsState("payment_info","disabled",false);
}

function SetInputItemsState(containerID, state, val)
{
	var elms = Tangora.DOM.GetCollection(containerID,"input")

	for(var i = 0; i < elms.length; i++)
	{
		if(elms[i].id != "")
		{
			SetInputItemState(elms[i].id, state, val);
		}
	}
}

function SetInputItemState(elmid,state,val)
{
	var elm = document.getElementById(elmid);

	if(elm)
	{
		switch(state)
		{
			case "disabled":
				elm.disabled = val;
				break;
			case "readonly":
				elm.readOnly = val;
				break;
		}
	}
}

function ShowLayer(layerID)
{
	var elm = document.getElementById(layerID);
	
	if(elm)
	{
		elm.style.display = 'block';
	}
	if(Tangora.Layout.Resize) {
		Tangora.Layout.Resize();
		Tangora.Layout.Resize();
	}
}

function HideLayer(layerID)
{
	var elm = document.getElementById(layerID);
	
	if(elm)
	{
		elm.style.display = 'none';
	}
	if(Tangora.Layout.Resize) {
		Tangora.Layout.Resize();
		Tangora.Layout.Resize();
	}
}
function ValidatePaymentInfoForm(elmID1, elmID2, elmID3, elmID4, f, lang, blnVal)
{
	var errMsg = "";
	
	if(!blnVal)
	{
		var val1 = document.getElementById(elmID1).value;
		var val2 = document.getElementById(elmID2).value;
		var val3 = document.getElementById(elmID3).value;
		var val4 = document.getElementById(elmID4).value;

		if(val1 == "")
		{
			switch(lang)
			{
				case "se":
					break;
				default:
					errMsg = "Indtast registreringsnummer.";
			}
		}
		else if(val2 == "")
		{
			switch(lang)
			{
				case "se":
					break;
				default:
					errMsg = "Indtast kontonummer.";
			}
		}
		else if((val3 == "") || (val4 == ""))
		{
			switch(lang)
			{
				case "se":
					break;
				default:
					errMsg = "Indtast personnummer.";
			}
		}
	}

	if(errMsg != "")
	{
		alert(errMsg);
	}
	else
	{
		f.submit();
	}
}
function ValidateNewsletterForm(elmID1,elmID2,f,lang)
{
	var val1 = document.getElementById(elmID1).value;
	var val2 = document.getElementById(elmID2).value;
	var errMsg = "";

	if(!CompareValues(val1,val2))
	{
		switch(lang)
		{
			case "se":
				errMsg = "Kontrollera att dina e-mailadresser stämmer överens";
				break;
			default:
				errMsg = "Kontroller at dine e-mailadresser stemmer overens";
				break;
		}

		alert(errMsg);
	}
	else
	{
		f.submit();
	}
}

function PlaceInputHelpText(elmID,text)
{
	var elm = document.getElementById(elmID);

	SetHelpText(elm,text);
	Tangora.Events.AddHandler(elm,"onfocus",function() {RemoveHelpText(elm,text);});
	Tangora.Events.AddHandler(elm,"onblur",function() {SetHelpText(elm,text);});
}

function SetHelpText(elm,text)
{
	if(elm && elm.value == '')
	{
		elm.value = text;
	}
}

function RemoveHelpText(elm,text)
{
	if(elm.value == text)
	{
		elm.value = '';
	}
}

function Count(n,elmid)
{
	var elm = document.getElementById(elmid);

	if(elm)
	{
		elm.innerHTML = n;
	}
}

function IsNumeric(sText)
{
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;

 
   for (i = 0; i < sText.length && IsNumber == true; i++) 
	{ 
	Char = sText.charAt(i); 
	if (ValidChars.indexOf(Char) == -1) 
	   {
	   IsNumber = false;
	   }
	}
   return IsNumber;
   
   }

function GoToFirstLevelPage(s,pageid)
{
	if((s != "") && (s != "(vælg)"))
	{
				if (IsNumeric (s)) {
				  document.location="/page"+pageid+".aspx?doshow"+pageid+"1=1&filtercontrol"+pageid+"1="+s;
				}
				else {
		s = s.replace("&","");
		document.location = "/" + s;
	}
			    }
}

function GoToSecondLevelPage(filterID, rootID, pageID)
{
  var ThePageId=33;
  if (pageID && pageID==88) {
    ThePageId=88;
  }
	if(filterID > 0 && rootID > 0)
	{
		document.location = "/page"+ThePageId+".aspx?doshow"+ThePageId+"=1&filtercontrol"+ThePageId+"1=" + filterID + "&rootid=" + rootID;
	}
}

function GoToProductDetailsPage(productID, parentID, pageID, frompageid, huskededu)
{
  if (huskededu) {
  }
  else {
    huskededu="0";
  }
	if(productID > 0)
	{
		document.location = "/page"+pageID+".aspx?recordid"+pageID+"=" + productID + "&parent=" + parentID + "&frompageid=" + frompageid+"&huskededu="+huskededu;
	}
}

function GoToProductCategory(categoryID, pageID)
{
	if((categoryID > 0) && (pageID))
	{
		document.location = "/page" + pageID + ".aspx?doshow" + pageID + "=1&filtercontrol" + pageID + "1=" + categoryID;
	}
}

function GenerateFormAction(frm, arrID, searchFieldID)
{
	var arrID = arrID.split(",");
	var target = null;
	//var action = "/page" + searchFieldID + ".aspx?action=search";
	var action = frm.action;
	var searchWord = encodeURIComponent(document.getElementById("id" + searchFieldID + "search").value);

	for(var i = 0; i < arrID.length; i++)
	{
		action += "&doshow" + arrID[i] + "=1&searchword" + arrID[i] + "=" + searchWord;
	}

	frm.action = action;
}

function RemoveCurrencyFromMiniBasketSum()
{
	var td = document.getElementById("minibasket_sum");

	if(td)
	{
		td.innerHTML = td.innerHTML.substring(3,td.innerHTML.length);
	}
}

Tangora.Events.AddHandler(window,"onload",RemoveCurrencyFromMiniBasketSum);

var SubscriptionName = function(num, lang)
{
	this.Get = function()
	{
		var sub = "";

		switch(num)
		{
			case "1":
				if(lang == "se")
				{
					sub = "Løbende abonnement";
				}
				else
				{
					sub = "Løbende abonnement";
				}
				break;
			case "3":
				if(lang == "se")
				{
					sub = "3 måneders prenumeration";
				}
				else
				{
					sub = "3 måneders abonnement";
				}
				break;
			case "6":
				if(lang == "se")
				{
					sub = "6 måneders prenumeration";
				}
				else
				{
					sub = "6 måneders abonnement";
				}
				break;
			case "12":
				if(lang == "se")
				{
					sub = "12 måneders prenumeration";
				}
				else
				{
					sub = "12 måneders abonnement";
				}
				break;
		}

		return sub;
	}
}

function SelectToCheck(selectId)
{
	if(selectId.indexOf("id") == -1) selectId = "id" + selectId;
	this.Select = document.getElementById(selectId);
	this.CheckBoxArea = null;
	this.Debug = false;

	this.BuildCheckBoxes = function()
	{
		var area = document.createElement('div');
		this.Select.parentNode.insertBefore(area, this.Select);
		this.Select.style.display = 'none';
		this.CheckBoxArea = area;
		for (var i=0; i<this.Select.options.length; i++)
		{
			var opt = this.Select.options[i];
			area.insertBefore(this.BuildCheckBox(i, opt.innerHTML, opt.checked), null);
		}
		
	}
	
	this.BuildCheckBox = function(i, text, checked)
	{
		var div = document.createElement('div');
		div.style.cssText = 'clear:both';
		div.className = 'input_exception';
		var chk = document.createElement('input');
		chk.type = 'checkbox';
		chk.checked = checked;
		chk.style.cssText = 'float:left; margin-right:5px;';
		chk.id = 'auto_chk' + i;
		div.insertBefore(chk, null);
		div.innerHTML += '<label class="section" style="clear:right" for="' + chk.id + '">' + text + '</label>';
		return div;
	}
	
	this.GetValues = function()
	{
		var coll = this.CheckBoxArea.getElementsByTagName('input');
		for (var i=0; i<coll.length; i++)
		{
			this.Select.options[i].selected = coll[i].checked;
		}
		if (this.Debug) this.Select.style.display = '';
	}
}

var DateOptions = function(lang, sd)
{
    this.NextDate = null;
    var targetElm = null;
    
    this.FormatDate = function(date)
    {
	 date = new Date(date);
	 var day = date.getDate();
	 var month = date.getMonth()+1;

	 if(day < 10) {day = "0" + day;}
	 if(month < 10) {month = "0" + month;}

	 var dt = day + "-" + month + "-" + date.getFullYear();
	 return dt;
    }

    this.AddOption = function(val,txt,select)
    {
	  var opt = document.createElement("option");
	  opt.value = val;
	  opt.text = txt;	
	  opt.selected = select;	    
	  targetElm.options.add(opt);
    }

    this.GenerateOptions = function(date)
    {
	  var months = null;
	  switch(lang)
	  {
		case "se":
		    break;
		case "no":
		    months = "Jan,Feb,Mar,Apr,Mai,Juni,Juli,Aug,Sep,Okt,Nov,Dec".split(",");
		    break;
		default:
		    months = "Jan,Feb,Mar,Apr,Maj,Jun,Jul,Aug,Sep,Okt,Nov,Dec".split(",");
	  }
	  var ds = date.split("-")[1]+"-"+date.split("-")[0]+"-"+date.split("-")[2];
	  
	  var d = new Date(ds);
	  var val = d.getMonth();

	  this.NextDate = new Date(d);
	  this.NextDate.setDate(4);

	  if(d.getDate() > 3)
//if(d.getMonth() > (sd-1))	  
{
		val++;
		if(val == 12)
		{
		    this.NextDate.setMonth(0);
		    val = 0;
		    d.setMonth(0);
		    d.setYear(d.getFullYear()+1);		    
		}
		else
		{
		    this.NextDate.setMonth(val);
		}
	  }

	  this.NextDate = this.FormatDate(this.NextDate);

	  var pause = getParam('pause');
	  var pauseI = 0;
	  if (typeof(pause)=="string") pauseI = parseInt(pause);

	  var j = 0;
	  var disp = 0;
	  for(var i = 0; i<3; i++)
	  {		
		if (j+val==12) 
		{   
		    val = 0;	  
		    d.setMonth(0);
		    d.setYear(d.getFullYear()+1);		    
		    j = 0;   
	  	  disp = 12;
		}		
		d.setMonth(val+j);
		j++;
		this.AddOption(d.getMonth()+disp,months[d.getMonth()]+" "+d.getFullYear().toString().substring(2,4), (pause-1)==i);
	  }
    }

    this.Render = function(valElmID,targetElmID)
    {
	  var valElm = document.getElementById(valElmID);  
	  targetElm = document.getElementById(targetElmID);	
	  while(targetElm.options.length>0) targetElm.options[0] = null;
	  this.GenerateOptions(valElm.value);
    }

}
var DetailImageGallery = function(thumbContainer, imgContainer, thumbWidth, thumbHeight, imgWidth, imgHeight)
{
	var imgArray = new Array();

	this.AddImage = function(strPath)
	{
		if(strPath != "")
		{
			imgArray.push(strPath);
		}
	}

	this.Render = function()
	{
		var container = document.getElementById(thumbContainer);

		if(container)
		{
			var thumb = null;

			for(var i = 0; i < imgArray.length; i++)
			{
				thumb = document.createElement("img");
				thumb.src = "/img.aspx?path=/media/" + imgArray[i] + "&action=6&6param1=" + thumbWidth + "&6param2=" + thumbHeight;
				thumb.alt = imgArray[i];
				thumb.className = "hideImage0";
				thumb.index = i;
				thumb.onclick = this.ClickHandler;
				thumb.onload = this.LoadHandler;
				container.appendChild(thumb);
			}

			this.ShowImage(0);
		}
	}

	this.ShowImage = function(index)
	{
		var img = document.getElementById(imgContainer);

		if(img)
		{
			img.src = "/img.aspx?path=/media/" + imgArray[index] + "&action=6&6param1=" + imgWidth + "&6param2=" + imgHeight;
			var grabber = document.getElementById("model_img_text");

			if(grabber)
			{
				grabber.onclick = function() {var w = window.open("/page50.aspx?source=" + imgArray[index],"image","width=50,height=50,toolbars=no")};
			}
		}
	}

	this.ClickHandler = function()
	{
		dig.ShowImage(this.index);
	}

	this.LoadHandler= function()
	{
		this.className = "gallery_thumb";
	}
}

var ImageHoverText = function (imgContainerID)
{
	var textArr = new Array();
	var wrapper = document.createElement("div");
	wrapper.id = "img_txt_wrapper";
	var grabber = document.createElement("div");
	grabber.id = "img_txt_grabber";
	grabber.innerHTML = ' ';
	//grabber.onmouseover = function() {wrapper.className = 'visible'};
	//grabber.onmouseout = function() {wrapper.className = ''};

	this.AddText = function(strTxt)
	{
		if(strTxt != "")
		{
			textArr.push(strTxt);
		}
	}

	this.Render = function()
	{
		var elm = document.getElementById(imgContainerID);
		var img = Tangora.DOM.GetFirstCollectionMember(elm,"img");

		if(img && img.className != "hideImage0")
		{
			if((elm) && (textArr.length > 0))
			{
				var div = null;

				for(var i = 0; i < textArr.length; i++)
				{
					div = document.createElement("div");
					div.id = "img_txt_" + i;
					div.className = "img_txt_container";
					div.innerHTML = textArr[i];
					wrapper.appendChild(div);
				}

				elm.appendChild(wrapper);
						 elm.insertBefore(grabber,elm.childNodes[0]);
			}
		}
	}
}

var BreadCrumbs = function(containerID, wrapperID, activeIndex)
{
	var wrapper = document.createElement("div");
	wrapper.id = (typeof(wrapperID) == "string") ? wrapperID : "breadcrumbs";
	var seperator = ">";
	var txtArray = new Array();
	var linkArray = new Array();

	var container = document.getElementById(containerID);
	var orgCrumb = Tangora.DOM.GetFirstCollectionMemberByClassName(container,"span","HereAreYou");

	if(orgCrumb)
	{
		orgCrumb.style.display = "none";
	}

	this.AddCrumb = function(strTxt, strLink)
	{
		if(typeof(strTxt) == "string")
		{
			txtArray.push(strTxt);
		}

		if(typeof(strLink) == "string")
		{
			linkArray.push(strLink);
		}
	}

	this.Render = function()
	{
		var crumb = null;

		for(var i = 0; i < txtArray.length; i++)
		{
			if(i > 0)
			{
				crumb = document.createElement("span");
				crumb.className = "breadcrumb_seperator";
				crumb.innerHTML = " " + seperator + " ";
				wrapper.appendChild(crumb);
			}

			if(linkArray.length > i)
			{
				crumb = document.createElement("a");
				crumb.className = "breadcrumb_link";
				crumb.href = linkArray[i];
			}
			else
			{
				crumb = document.createElement("span");
				crumb.className = "breadcrumb_txt";
			}

			crumb.innerHTML = txtArray[i];
			wrapper.appendChild(crumb);
		}

		if(typeof(activeIndex) != "undefined")
		{
			wrapper.childNodes[activeIndex].className += " active";
		}

		if(container)
		{
			container.appendChild(wrapper);
		}
	}
}

// Models

function GoToModelDetails(p,pageid)
{
  if (pageid==44) {
    pageid=33;
  }
  if (pageid==130 || pageid==132) {
    pageid=88;
  }
  if (pageid==190 || pageid==192) {
    pageid=148;
  }
	if(p > 0)
	{
		document.location = "/page"+pageid+".aspx?recordid"+pageid+"=" + p;
	}
}

function HoverBox(elmId)
{
	var elm = document.getElementById("model_" + elmId);
	var className = "";

	if(elm)
	{
		className = (elm.className == "hover_box") ? "hover_box hovered" : "hover_box";
		elm.className = className;
	}
}

// Fix by NIS
function getParam(paramName, valueStr) {

	 // get value of paramName, pass url as valueStr 

	 if (typeof(valueStr=='undefined')){
		  valueStr = window.location.search;
	 }
	 var expr = eval("/[\\?|\\&]" + paramName + "=(.*?)\\&/");
	 regex = new RegExp(expr);
	 regex.global=true;
	 regex.ignoreCase=true;

	 // fix by NIS start
	 var match = regex.exec(valueStr+'&'); 
	 if (match != null) return RegExp.$1;
	 return "";
	 // fix by NIS end
}

// Shop

function INLI_GetGlobalVar(varname) {
  return eval("typeof("+varname+")!='undefined'?"+varname+":null");
}

function SizeChange(Language) {
  var i,j,coll,obj,RecId,Count,Price,NormalPrice;
  if (document.forbrugform) {
  i=document.forbrugform.size.options.selectedIndex+1;
  coll=document.getElementsByTagName ("INPUT");
  for (j=0;j<coll.length;j++) {
    obj=coll.item(j);
    if (obj.name.indexOf ('buycheck')==0) {
	RecId=obj.value;
			   var vis=INLI_GetGlobalVar ('Vis'+i+'_'+RecId);
		  var tbl=obj.parentNode.parentNode.parentNode.parentNode;
		  if (vis=='Ja') {
		    tbl.style.display='inline-block';
		    if (tbl.previousSibling) {
			tbl.previousSibling.style.display='inline-block';
		    }
		 }
		 else {
		    tbl.style.display='none';
		    if (tbl.previousSibling) {
			tbl.previousSibling.style.display='none';
		    }
		 }
	value=INLI_GetGlobalVar ('Antal'+i+'_'+RecId);
	 if (value=='' || value=='0' || value=='0.00') {
	  value=INLI_GetGlobalVar ('Antal1_'+RecId);
	 }
			    if (document.getElementById ('count'+RecId).value!=value) {
  	   document.getElementById ('count'+RecId).value=value;
				CountChange (RecId,Language);
			    }
			    else {
				document.getElementById ('count'+RecId).value=value;
			    }
     }
  }

    Price=0;
    NormalPrice=0;
    for (j=0;j<coll.length;j++) {
	obj=coll.item(j);
	if (obj.name.indexOf ('buycheck')==0) {
	RecId=obj.value;
			  var vis=INLI_GetGlobalVar ('Vis'+i+'_'+RecId);
				if (!obj.disabled && obj.checked && vis=='Ja') {
	   Price=Price+Number (document.getElementById ('price'+RecId).innerHTML.replace('.','').replace (',','.'));  
	   NormalPrice=NormalPrice+Number (eval ('document.forbrugform.count'+RecId).value)*eval ('VarePris_'+RecId); 
			     }
			     if (INLI_GetGlobalVar ('VareBeholdning_'+RecId)=='0' || INLI_GetGlobalVar ('VareBeholdning_'+RecId)=='') {
	  obj.parentNode.parentNode.className+=' soldout';
	}
	}
    }
   document.getElementById ('totalprice').innerHTML=FormatPrice (String (Price).replace ('.',','));
   NormalPrice=NormalPrice-Price;
  if (NormalPrice>1) {
     document.getElementById ('spanRabat').innerHTML=document.getElementById ('spanRabat').innerHTML.split (' ') [0]+' '+FormatPrice (String (NormalPrice).replace ('.',','));
    document.getElementById ('rowRabat').style.display='';
   }
   else {
     document.getElementById ('rowRabat').style.display='none';
   }
  }
}

function CountChange(RecId,Language) {
  if (TheFlag==1) {
    return 0;
  }
  var VareId,Antal,NewPrice,TotalPrice,NormalPrice,s;
  VareId=INLI_GetGlobalVar ('VareId_'+RecId);
  Antal=document.getElementById ('count'+RecId).value;
  Antal=Antal.replace (',','.');
  var ajaxpageid=34;
  if (Language && Language==2) {
    ajaxpageid=87;
  }
  else if (Language && Language==3) {
    ajaxpageid=147;
  }
  if (Antal!='' && Antal.substring (Antal.length-1,Antal.length)!='.' && VareId!='0') {
    var s=tsAjax.innerHTML ('/page'+ajaxpageid+'.aspx?vareid='+VareId+'&antal='+Antal+'&vareid2=0&vareid3=0&vareid4=0&vareid5=0&vareid6=0&vareid7=0&vareid8=0&rnd='+RandomName(4));
    s=s.split ('STARTHERE'+VareId+'_')[1].split('ENDHERE'+VareId)[0];
//    if (document.getElementById ('price'+RecId).innerHTML!='') {
//	OldPrice=Number (document.getElementById ('price'+RecId).innerHTML.replace (',','.'));
//    }
//    else {
//	OldPrice=0;
//    }
    NewPrice=Number (s.replace (',','.'));
    document.getElementById ('price'+RecId).innerHTML=FormatPrice (s);
    UpdatePrices();
  }
}

function UpdatePrices() {
    var coll,RecId,TotalPrice,NormalPrice,s,i;
    coll=document.getElementsByTagName ("INPUT");
    Price=0;
    NormalPrice=0;
    i=document.forbrugform.size.options.selectedIndex+1;
    for (j=0;j<coll.length;j++) {
	obj=coll.item(j);
	if (obj.name.indexOf ('buycheck')==0) {
	RecId=obj.value;
			  var vis=INLI_GetGlobalVar ('Vis'+i+'_'+RecId);
			   if (!obj.disabled && obj.checked && vis=='Ja') {
	   Price=Price+Number (document.getElementById ('price'+RecId).innerHTML.replace('.','').replace (',','.'));  
				NormalPrice=NormalPrice+Number (eval ('document.forbrugform.count'+RecId).value.replace (',','.'))*eval ('VarePris_'+RecId); 
			     }
	}
    }
    s=String (Price).replace ('.',',');
    s=FormatPrice (s);
	  document.getElementById ('totalprice').innerHTML=s;
    NormalPrice=NormalPrice-Price;
   if (NormalPrice>1) {
     document.getElementById ('spanRabat').innerHTML=document.getElementById ('spanRabat').innerHTML.split (' ') [0]+' '+FormatPrice (String (NormalPrice).replace ('.',','));
    document.getElementById ('rowRabat').style.display='';
   }
   else {
     document.getElementById ('rowRabat').style.display='none';
   }
}

function BuyClick (RecId) {
  UpdatePrices();
}

function AddProductsToBasket(Language) {
  
  var coll,i,obj,Count,VareId,s;
  coll=document.getElementsByTagName ("INPUT");
  s='';
  for (i=0;i<coll.length;i++) {
    obj=coll.item(i);
    if (obj.name.indexOf ('buycheck')==0 && obj.checked) {
	RecId=obj.value;
	var vis=INLI_GetGlobalVar ('Vis'+(document.forbrugform.size.options.selectedIndex+1)+'_'+RecId);
    }
    if (obj.name.indexOf ('buycheck')==0 && obj.checked && vis=='Ja') {
	VareId=INLI_GetGlobalVar ('VareId_'+RecId);
	Count=document.getElementById ('count'+RecId).value;
	if (s!='') {
	  s=s+'<,[].>';
	}
	s=s+VareId+'%C2%A4'+Count;
    }
  }
  if (s!='') {
    CheckForSoldOutProducts(Language);
    INLI_AddToBasket (s,'',Language);
  }
}

function INLI_AddToBasket(productid,count) {
 var pageid=35;
 var basketid=-300003;
  if (Language && Language==2) {
    pageid=124;
   basketid=-300014;
  }
  if (Language && Language==3) {
    pageid=184;
   basketid=-300013;
  }
//Midlertidig løsning til kreativstrik.dk
  if (Language && Language==60) {
    pageid=695;
   basketid=-300031;
  }
  URL='/page'+pageid+'.aspx?isbasket=1&pageid='+pageid+'&listid='+basketid+'&action=add&productid='+productid+'&count='+count;
  location.href=URL;
}

function AddProductToBasket (productid) {
  INLI_AddToBasket (productid,document.getElementById('antal').value);
}

function AddProductToBasket_Discount (productid) {
  INLI_AddToBasket (productid,document.getElementById('antal_rabat').value);
}

function Navigate_PrevProduct (pageid,parent,frompageid,huskededu) {
  var obj,recid;
  if (frompageid==46 || frompageid==133 || frompageid==193) {
    obj=document.getElementById ('top10varer');
  }
  else if (huskededu=='1') {
    obj=document.getElementById ('huskededuvarer');
  }
  else {
    obj=document.getElementById ('relateredevarer');
  }
  if (obj.selectedIndex>0) {
    recid=obj.options [obj.selectedIndex-1].value;
  }
  else {
    recid=obj.options [obj.length-1].value;
  }
  location.href='page'+pageid+'.aspx?recordid'+pageid+'='+recid+'&parent='+parent+'&frompageid='+frompageid+'&huskededu='+huskededu;
}

function Navigate_NextProduct (pageid,parent,frompageid,huskededu) {
  var obj,recid;
  if (frompageid==46 || frompageid==133 || frompageid==193) {
    obj=document.getElementById ('top10varer');
  }
  else if (huskededu=='1') {
    obj=document.getElementById ('huskededuvarer');
  }
  else {
    obj=document.getElementById ('relateredevarer');
  }
  if (obj.selectedIndex<obj.length-1) {
    recid=obj.options [obj.selectedIndex+1].value;
  }
  else {
    recid=obj.options [0].value;
  }
  location.href='page'+pageid+'.aspx?recordid'+pageid+'='+recid+'&parent='+parent+'&frompageid='+frompageid+'&huskededu='+huskededu;
}

function Navigate_PrevModel (PageId,ModelNo,RecId) {
  var s,t;
  s=OtherClothes.split (ModelNo+'=') [0];
  if (s!='') {
    t=s.split (';') [s.split (';').length-2];
  }
  else {
    t=OtherClothes.split (';') [OtherClothes.split (';').length-2];
  }
  t=t.split ('=') [1];
  location.href='/page'+PageId+'.aspx?recordid'+PageId+'='+t;
}

function Navigate_NextModel (PageId,ModelNo,RecId) {
  var s,t;
  s=OtherClothes.split (ModelNo+'='+RecId+';') [1];
  if (s!='') {
    t=s.split (';') [0];
  }
  else {
    t=OtherClothes.split (';') [0];
  }
  t=t.split ('=') [1];
  location.href='/page'+PageId+'.aspx?recordid'+PageId+'='+t;
}

var Changing=false;
var CountFlag=0;

function VareNrChange (e, i) {
  if (!e && window.event) e = window.event;
  var kc = e.keyCode;
  if (kc && (kc == 13 || (kc >= 37 && kc <= 40))) 
 {
  return false;
  }
  else {
     Changing=true;
    CountFlag=CountFlag+1;
    window.setTimeout ('UpdateCouponData('+i+','+CountFlag+')',500);
  }
}


function UpdateCouponData (i,j) {
  var s,t,obj,j,name;
  if (j==CountFlag) {
  obj=document.getElementById ('divvarenr'+i);
  obj.innerHTML='';
  obj.style.display='none';
  document.getElementById ('unit'+i).innerHTML='';
  selectedCouponMenuItem = null;
  eval ('document.bestillingskupon.vareid'+i).value='';
  eval ('document.bestillingskupon.varenavn'+i).value='';
  s=eval ('document.bestillingskupon.varenr'+i).value;
  if (s!='') {
    if (AjaxPageID) {
    }
    else {
     AjaxPageID=49;
    }
    t=tsAjax.innerHTML('/page'+AjaxPageID+'.aspx?varenr='+s+'&len='+s.length+'&rnd='+RandomName(4));
    if (t.indexOf ('[VARE]')!=-1) {
				  	for (j=1;j<t.split ('[VARE]').length;j++) {
	name=t.split ('[VARE]') [j].split ('[SEP]') [0];
	name=name.split (' -- ') [0]+' - '+name.split (' -- ') [1]+'<span style="display:none"> -- '+name.split (' -- ') [2]+'</span>';
	  obj.innerHTML+='<a id="ref'+i+'_'+j+'" href="#" onclick="AddToCoupon('+i+','+j+','+t.split ('[VARE]') [j].split ('[SEP]') [1].split ('[/VARE]') [0]+'); return false">'+name+'</a>';
	}
 if (t.split ('[VARE]').length==2) {
			     AddToCoupon (i,1,t.split ('[VARE]') [1].split ('[SEP]') [1].split ('[/VARE]') [0]);
			   }
			    else {
	obj.style.display='inline';
	    }
    }
  }
  }
}

function AddToCoupon (i,j,productid) {
  var s,t,obj;
  obj=document.getElementById ('divvarenr'+i);
  obj.style.display='none';
  eval ('document.bestillingskupon.vareid'+i).value=productid;
  s=document.getElementById ('ref'+i+'_'+j).innerHTML;
  eval ('document.bestillingskupon.varenr'+i).value=s.split (' - ') [0];
  t=s.substring (s.indexOf (' - ')+3,s.length);
  //if (s.indexOf ('<SPAN ')!=-1) {
    //eval ('document.bestillingskupon.varenavn'+i).value=s.split (' -- ') [1].split ('<SPAN')[0];
  //}
  //else {
   // eval ('document.bestillingskupon.varenavn'+i).value=s.split (' -- ') [1].split ('<span')[0];
  //}
  if (t.indexOf ('<SPAN ')!=-1) {
    eval ('document.bestillingskupon.varenavn'+i).value=t.split ('<SPAN')[0];
  }
  else {
    eval ('document.bestillingskupon.varenavn'+i).value=t.split ('<span')[0];
  }
  //document.getElementById ('unit'+i).innerHTML=s.split (' -- ') [2].split ('</span') [0];
  document.getElementById ('unit'+i).innerHTML=t.split (' -- ') [1].split ('</span') [0];
  eval ('document.bestillingskupon.vareid'+i).value=productid;
}

function AddCouponToBasket () {
  var i,productid,count,s;
  s='';
  for (i=1;i<=11;i++) {
    productid=eval ('document.bestillingskupon.vareid'+i).value;
    count=eval ('document.bestillingskupon.count'+i).value;
    if (productid!='' && count!='' && count!='0') {
	if (s!='') {
	  s=s+'<,[].>';
	}
	s=s+productid+'%C2%A4'+count;
    }
  }
  if (s!='') {
    INLI_AddToBasket (s,'');
  }
}

var selectedCouponMenuItem = null;

function keyNavigate(e, i)
{
	if (!e && window.event) e = window.event;
	var kc = e.keyCode;
	var menu = document.getElementById('divvarenr' + i);
	if (!menu || menu.style.display == 'none') return false;
	var coll = menu.getElementsByTagName('a');
	if (!coll || coll.length == 0) return false;
	if (kc == 40) // arrow down
	{
		if (!selectedCouponMenuItem)
		{
			selectedCouponMenuItem = coll[0];
			coll[0].style.background = '#ffb';
		}
		else
		{
			var ns = selectedCouponMenuItem.nextSibling;
			if (ns && ns.parentNode == selectedCouponMenuItem.parentNode)
			{
				selectedCouponMenuItem.style.background = '';
				selectedCouponMenuItem = ns;
				ns.style.background = '#ffb';
			}
		}
	}
	else if (kc == 38) // arrow up
	{
		if (!selectedCouponMenuItem)
		{
			selectedCouponMenuItem = coll[coll.length -1];
			coll[coll.length -1].style.background = '#ffb';
		}
		else
		{
			var ns = selectedCouponMenuItem.previousSibling;
			if (ns && ns.parentNode == selectedCouponMenuItem.parentNode)
			{
				selectedCouponMenuItem.style.background = '';
				selectedCouponMenuItem = ns;
				ns.style.background = '#ffb';
			}
		}
	}
	else if (kc == 13) // enter
	{
		if (selectedCouponMenuItem)
		{
			selectedCouponMenuItem.onclick();
		}
	}
}

function CustomerLogin() {
  var Name,Password;
  Name=document.rediger.txtUsername.value;
  Password=document.rediger.txtPassword.value;
  document.rediger51.username.value=Name;
  document.rediger51.password.value=Password;
  document.rediger51.submit();
}

function Logon_Failed(Language) {
  if (Language==1) {
    alert ('De indtastede login-oplysninger er ikke korrekte. Kontakt evt. vores kundeservice.');
  }
  else if (Language==2) {
    alert ('Dina login-uppgifter är felaktiga. Vänligen kontakta kundtjänst.');
  }
  else if (Language==3) {
    alert ('De indtastede login-oplysninger er ikke korrekte. Kontakt evt. vores kundeservice.');
  }
  //var s,Name,Password;
  //Name=document.rediger.txtUsername.value;
  //Password=document.rediger.txtPassword.value;
  //s=tsAjax.innerHTML ('/page54.aspx?email='+Name+'&zipcode='+Password);
  //if (s && s.indexOf ('[USER]')!=-1) {
    //s=s.split ('[USER]') [1];
    //document.rediger.field28.value=s.split ('[]') [0];
    //document.rediger.field32.value=s.split ('[]') [1];
    //document.rediger.field35.value=s.split ('[]') [2];
    //document.rediger.field36.value=s.split ('[]') [3];
    //document.rediger.field38.value=s.split ('[]') [4];
    //document.rediger.field42.value=s.split ('[]') [5].split ('>') [1].split ('<') [0];
  //}
}

function FormatPrice (p) {
  var i;
  i=p.indexOf(',');
  if (i==-1) {
if (location.href.indexOf('debug')!=-1) {
  alert (p);
}
	p=p+',00';
    }
    else if (i==p.length-2) {
	p=p+'0';
    }
    else if (i<p.length-3) {
	//alert (p.substring (i+3,i+4));
			   var num=Number (p.substring (i+3,i+4));
			   if (num>=5) {
			     var num2=Number (p.substring (i+2,i+3));
											   if (num2==9) {
	var num3=Number (p.substring (i+1,i+2));
			    p=p.substring (0,i+1)+(num3+1)+'0';
//	 alert (p+' * '+num+' * '+num2);
											   }
											  else {
			     p=p.substring (0,i+2)+(num2+1);
			   }
											  }
			   else {
   	  p=p.substring (0,i+3);
			   }
    }
    return (p);
}

function CustomerInfo_SendClick() {
  if (document.rediger.cbNewsletter.checked && document.rediger.field28.value!='' && document.rediger.field42.value!='') {
    document.formNewsletter.name.value=document.rediger.field28.value;
    document.formNewsletter.email.value=document.rediger.field42.value;
    PostFormUsingHTTPReq (getHTTPObject(),'/page23.aspx?action=write','formNewsletter');
  }
  document.rediger.submit();
}

function ImageError(img)
{
  img.onerror = null;
  img.src = img.src.replace('_1','');
}

function IL_KeyUp (Id) {
  var obj=document.getElementById (Id);
  if (event.keyCode==13) {
    obj.click();
  }
}
var TipObject = new Object();
function OpenTipWindow(safeUrl, title, paramOpenFromSite)
{
	if(!paramOpenFromSite)
	{
		if(location.href.indexOf("alltomhandarbete.se")>-1) paramOpenFromSite = "alltomhandarbete.se";
		if(location.href.indexOf("altomhaandarbeide.no")>-1) paramOpenFromSite = "altomhaandarbeide.no";
	}

	if (paramOpenFromSite == 'burda'){
		   var url = "/burdatipformular?safeurl=" + encodeURIComponent(safeUrl) + "&title=" + encodeURIComponent(title);
	} else if(paramOpenFromSite == 'burdase'){
 		   var url = "/burdasetipformular?safeurl=" + encodeURIComponent(safeUrl) + "&title=" + encodeURIComponent(title);
 	}
	
	else if(paramOpenFromSite == 'alltomhandarbete.se')
	{var url = "/tipformular_se?safeurl=" + encodeURIComponent(safeUrl) + "&title=" + encodeURIComponent(title);}

	else if(paramOpenFromSite == 'altomhaandarbeide.no')
	{var url = "/tipformular_no?safeurl=" + encodeURIComponent(safeUrl) + "&title=" + encodeURIComponent(title);}

	else{
	var url = "/tipformular?safeurl=" + encodeURIComponent(safeUrl) + "&title=" + encodeURIComponent(title);
	}

	
	var w = window.open(url,"Tip_en_veninde","width=477,height=490,toolbars=no,resizeable=no");	 

}

//used in Burda layout, detail page for smugkig as an alternative to 3rd level navigaiton
function makeSmugkigUnderlined(){

//if (getParam('test')==1){}

var anchorArray=document.getElementsByTagName("a");
for (var i=0;i<anchorArray.length;i++) { 
//alert (anchorArray[i].href);
	if (anchorArray[i].href.match('Smugkig')){	 // == 'http://ingelise.dk/Smugkig+i+n%c3%a6ste+nr.492.aspx'){
							 //alert (anchorArray[i]);
		anchorArray[i].className = "navigationactiv";
	}
}
}

function FixRestrictedLinks(userID)
{
	this.Init = function()
	{
		if(userID != "" && userID != "{user.id}") return;

		var wraps = Tangora.DOM.GetCollectionByClassName("spotswrapper","div","clubingelise_spot");

		for(var i = 0; i < wraps.length; i++)
		{
			var a = wraps[i].getElementsByTagName("a")[0];
			if(a)
			{
				var href = a.href;
				var pageId = fl.GetPageIdFromUrl(href);
				a.href = "/page" + fl.GetLoginPageId() + ".aspx?validating=1&orgpageid=" + pageId;
			}
		}
	}

	this.GetLoginPageId= function()
	{
		var pageId = "537";

		switch(location.host)
		{
			case "www.alltomhandarbete.se":
				pageId = "548";
				break;
			case "www.altomhaandarbeide.no":
				pageId = "557";
				break;
		}

		return pageId;
	}

	this.GetPageIdFromUrl = function(url)
	{
		var pageId = "";

		if(url.indexOf("/page")==-1)
		{
			var re = new RegExp(/\.(\d+?)\./gi);
			var ma = re.exec(url);
			pageId = ma[1];
		}
		else
		{
			var re = new RegExp(/page(\d+)\./gi);
			var ma = re.exec(url);
			pageId = ma[1];
		}

		return pageId;
	}
}

function SetBodyBackground(pId)
{
  if(pId=="442")
  {
    var medie = xtender.GetMedie(document.location.pathname);
    if(medie == null) return;
    medie = medie.toLowerCase();
    var bg = "/media/forlagsservice/falcon_bg" + medie + ".gif";
if(document.location.href.indexOf("debug") > -1) alert(bg);
    document.getElementsByTagName("body")[0].style.background = "#f2f2f2 url("+ bg +")";
  }
}

function SetPageTitle()
{
  var opt = document.getElementById("nav_list");
  if(!opt) return;

  var pt = document.getElementById("page-title");
  if(!pt) return;

   if(opt.selectedIndex > 0) pt.innerHTML = opt.options[opt.selectedIndex].innerHTML;
}

function UrlParser(id)
{
    this.Id = id;
    
    this.Parameters = [];
    this.IndexedParameters = [];
    
    this.Parse = function (url)
    {		
	  var fractions = url.split('?');	  
	  var qs = fractions.length>1 ? fractions[1] : "";	  
	  var params = qs.split('&');	  
	  var pset = [];
	  for(var i = 0; i<params.length;i++)
	  {
		var parts = params[i].split('=');
		var name = parts[0];		
		var value = parts[1];		
		pset[name] = value;
		pset.length++;		
	  }	  
	  return pset;
    }
	     
    this.Parameters = this.Parse(location.href);    
    for (var i in this.Parameters) {
	  var a = {q: i, v: this.Parameters[i]};
	  this.IndexedParameters.push(a);	
    }
}
Tangora.URLParser = new UrlParser("urlparser");

function EncodeClickHandler(e)
{
  var href = this.href;

  if(typeof(href)== 'undefined') return;

  var params = Tangora.URLParser.Parse(href);
  var encodedURL = href.substring(0,href.indexOf("?")) + "?";

  for(var name in params)
  {
    encodedURL += name + "=" + encodeURIComponent(decodeURIComponent(params[name])) + "&";
  }

  CancelBubble(e);
  document.location = encodedURL;
  return false;
}

function AttachEncodeClickHandlers(scope)
{
  var scope = document.getElementById(scope);
  var links = scope.getElementsByTagName("a");

  for(var idx in links)
  {
    var link = links[idx];

    if(typeof(link.href)!='undefined' && (link.href.indexOf("?") > -1) && !(link.onclick)) link.onclick = EncodeClickHandler;
  } 
}
function CancelBubble(e) {
	if (!e) { e=window.event; }
	if (e) {
		if (e.stopPropagation) {
			e.stopPropagation();
		}
		e.cancelBubble=true;
	}
}
function CheckForSoldOutProducts(lang)
{
  var frm = document.getElementById("forbrugform");
  var soldOutRows = Tangora.DOM.GetCollectionByClassName(frm,"tr","soldout");
  if(soldOutRows.length > 0)
  {
    var txt = "";

    switch(lang)
    {
	case "2": //SE
	  txt = "OBS! Var uppmärksam på att några av de varor som hör till denna modell är utsålda och därför inte kommer att läggas till i din inköpskorg.";
	  break;
	case "3": //NO
	  txt = "OBS! Vær opmærksom på at nogle af varerne til denne model er udsolgte og ikke vil blive lagt i din indkøbskurv.";
	  break;
	default: //DK
	  txt = "OBS! Vær opmærksom på at nogle af varerne til denne model er udsolgte og ikke vil blive lagt i din indkøbskurv.";
	  break;
    }
    
    window.alert(txt);
  }
}

/* --- indsat af ts-pkr - benyttes til manipulering af breadcrumb på strikonline.dk --- */
function ReplaceSeparator()
{
$(".breadcrumb_separator").html(" > ");
$("A.breadcrumb:first").hide();
$("SPAN.breadcrumb_separator:first").hide();
$("A.breadcrumb").attr('href', '#');
}
 
 
 
