﻿// JavaScript Document

// Funktion til at fikse links med parametere fra et ecom tekstfelt, og åbne linket i en ny side.
function ReplaceGoto(url){
	url=url.replace(/&;/gi,'&');
	window.open(url);
}

function ProductOverviewSwitchImage(obj)
{
	var img = new Image;
	var RefObj = obj.getElementsByTagName("img");
	var ImgPath = RefObj[0].src;
	var FilePath = ImgPath.slice(0,ImgPath.lastIndexOf("/")+1);
	var FileName = ImgPath.slice(ImgPath.lastIndexOf("/")+1,ImgPath.lastIndexOf("."));
	var FileExt = ImgPath.slice(ImgPath.lastIndexOf("."),ImgPath.length);
	if(ImgPath.indexOf("_over")>=0)
	{
		FileName = FileName.replace(/_over/gi, "");
		img.src = FilePath + FileName + FileExt;
		RefObj[0].src = img.src
	} else {
		img.src = FilePath + FileName + "_over" + FileExt;
		RefObj[0].src = img.src
	}
}


var AllowMove = false;
CheckIfMovesAllowed();
function CheckIfMovesAllowed()
{
	// PageID numre på produktvisningssiderne. Når der tilføjes et nyt sprog skal PageID'et på produktsiden tilføjes i linjen herunder.
	var arrAllowedPageIDs = new Array("ID=3&","ID=3330&","ID=5895&","ID=7988&","ID=8040&","ID=10101&","ID=12185&","ID=5895&","ID=16280&","-3.","-3330.","-5895.","-7988.","-8040.","-10101.","-12185.","-5895.","-16280.","-16279.","-21019.","-21113.","-21186.","-21322.","-21447.","-22427.","-22049.","-21937.","-22565.","ID=22524&","ID=22529&","ID=22531&","ID=22532&","ID=22533&","ID=22534&","ID=22535&","-22704.","ID=22704&","-22706.","ID=22706&","-22707.","ID=22707&","-22708.","ID=22708&","-22709.","ID=22709&","-22710.","ID=22710&","-22711.","ID=22711&","-22718.","ID=22718&");
	for (x=0;x<=arrAllowedPageIDs.length;x++)
	{
		if(location.href.indexOf(arrAllowedPageIDs[x])>=0)
		{
			AllowMove = true;
			break;
		}
	}
}


function MoveRightColumnBoxes()
{
	var Output = "";
	if(AllowMove)
	{
		var objArray = document.getElementById('RightColumn').getElementsByTagName('td');
		for(x=0;x<objArray.length;x++)
		{
			if(!(objArray[x].innerHTML=="&nbsp;"))
			{
				Output+="<div style=\"padding-top:10px; float:left;\">";
				Output+=objArray[x].innerHTML;
				Output+="</div>";
				Output+="<div style=\"clear: both;\"></div>";
				Output+="<!--IE 6 Fix --><!-- comment --><!-- comment --><!-- comment --><!-- comment --><!-- comment --><!-- comment --><!-- comment --><!-- comment --><!-- comment --><!-- comment --><!-- comment --><!-- comment -->";
			}
		document.getElementById('ProductRightColumnBoxesPlaceHolder').innerHTML=Output;
		}
		
	}
}


function MoveProdInfoBox()
{
	if(AllowMove)
	{
		document.getElementById('ProductInfoBoxPlaceHolder').innerHTML = document.getElementById('ProductInfoBox').innerHTML;
		//document.getElementById('ProductInfoBox').innerHTML = "";
	}
}


function MoveProjInfoBox()
{
	if(document.getElementById('ProjInfoBox'))
	{
		if(AllowMove)
		{
			if(document.getElementById('ProjInfoBox').innerHTML.length<=34) {document.getElementById('ProjRightColumnBox').style.display="none";}
			document.getElementById('ProjRightColumnBoxesPlaceHolder').innerHTML = document.getElementById('ProjInfoBox').innerHTML;
		}
	}
	else
	{
		if(AllowMove){
			document.getElementById('ProjRightColumnBox').style.display="none";
		}
	}
}


function MoveEcomMenu()
{
		document.getElementById('leftMenu').innerHTML = document.getElementById('EcomMenu').innerHTML;
		document.getElementById('EcomMenu').innerHTML = "";
}

function ProjectItem(url){
	if(url.indexOf("http://")>=0){
		url=url.slice(6,url.length);
	}
	window.open(url);
}