//<script>

// ***************************************************************
// Oprettet dato : ?
// Oprettet af   : ?
// Beskrivelse   :
// Brugt på sider med annoncer. Viser/skjuler thumbnails, åbner billed pop-up'er
// Overførsel til notesblok, sortering af annoncer, bredde af søgeresultat tabel
//
// Sidst ændret :
// 08 Sep 2003 - Jakt - Checker nu for select felter og flash filer ved minibanner. Nedsætter hyppigheden af at minibanneret bliver skjult ved thumbnail pop-up.
// ***************************************************************


//******************** vis thump ****************************

var thumpImg = new Image();
var thumpInt;
var minibannerArray	= new Array();

function checkImg(imgName) {
	if (thumpImg.readyState == "complete" || thumpImg.readyState == 4) { 
		document.all.thumpPic.innerHTML = "<img width=125 height=94 src='" + imgName + "'>";
		if (imgWidth) {
			objDivStyle.width		= (imgWidth + windowPadding);
			objDivStyle.height	= (imgHeight + windowPadding);
		}
		clearInterval(thumpInt);
	}
}

function showPop(imgName,hideSwitch) {
	thumpImg.src = imgName;
	imgWidth = 125;
	imgHeight = 94;
	thumpInt = window.setInterval("checkImg('" + imgName + "')",100);
	windowPadding = 24;
	
	if (mouseThumpX + imgWidth + 24 + 20 >= document.body.clientWidth) {	
		objDivStyle.left = mouseThumpX - (imgWidth + 24 + 30);
	}
	if ((mouseThumpY - document.body.scrollTop) + imgHeight + windowPadding > document.body.clientHeight) {
		objDivStyle.top = (mouseThumpY - (((mouseThumpY - document.body.scrollTop) + imgHeight + windowPadding + 10) - document.body.clientHeight));
	}
	if (document.all.minibannerTabel && hideSwitch) {
		minibannerArray	= new Array();
		if (document.all.minibannerTabel.innerHTML.indexOf(".swf") != -1) {
			minibannerArray[minibannerArray.length]	= document.all.minibannerTabel;
			document.all.minibannerTabel.style.visibility = "hidden"
		}
		else if (document.all.minibannerTabel.all.tags("SELECT") && document.all.minibannerTabel.all.tags("SELECT").length > 0) {
			for (i = 0; document.all.minibannerTabel.all.tags("SELECT")[i]; i++) {
				minibannerArray[minibannerArray.length]	= document.all.minibannerTabel.all.tags("SELECT")[i];
				document.all.minibannerTabel.all.tags("SELECT")[i].style.visibility = "hidden";
			}
		}
	}
	document.all.thumpLayer.style.visibility = "visible";
}

function hidePop() {
	if (document.all) {
		document.all.thumpLayer.style.visibility = "hidden";
		document.all.thumpLayer.style.backgroundColor = strPopBG;
		if (minibannerArray.length > 0)
			for (i = 0; minibannerArray[i]; i++) minibannerArray[i].style.visibility = "visible";
		document.all.thumpPic.innerHTML = "<img src='/images/misc/clock.gif'>";
		clearInterval(thumpInt);
	}
}

var strPopBG;

function positionPop(imgName,hideSwitch,specialPopBG) {
  if (document.all) {

		mouseThumpX = event.clientX - event.offsetX + document.body.scrollLeft + 20;
		mouseThumpY = event.clientY - event.offsetY + document.body.scrollTop;
		objDivStyle = document.all.thumpLayer.style;

		objDivStyle.left = mouseThumpX;
		objDivStyle.top = mouseThumpY;
		strPopBG = objDivStyle.backgroundColor;
		if (typeof specialPopBG == "string") objDivStyle.backgroundColor = specialPopBG;
		objDivStyle.visibility = "visible";
		
		if (typeof hideSwitch != "number") hideSwitch = 0;
		showPop(imgName,hideSwitch);
	}
}

function bigPicPop_tmp(bigImgName,picWidth,picHeight,picType,AnnonceId) {
	hidePop();
	picWidth = picWidth + 20;
	picHeight = picHeight + 50;
	winX = (screen.availWidth - picWidth)/2;
	winY = (screen.availHeight - picHeight)/2 - 12;
	picWind = window.open("/asp/soegning/picpop.asp?AnnonceId="+AnnonceId+"&picType="+picType+"&ImgName="+bigImgName, "blank_", "resizable=no,scrollbars=no,toolbar=no,location=no,directories=no,status=no,screenY=" + winY + ",top=" + winY + ",screenX=" + winX + ",left=" + winX + ",width= " + picWidth + ",height= " + picHeight + ""); 
	picWind.focus();
}

function bigPicPop(Url,picWidth,picHeight,AnnonceId) {
	hidePop();
	picWidth = picWidth + 20;
	picHeight = picHeight + 40;
	winX = (screen.availWidth - picWidth)/2;
	winY = (screen.availHeight - picHeight)/2 - 12;
	picWind = window.open(Url, "blank_", "resizable=no,scrollbars=no,toolbar=no,location=no,directories=no,status=no,screenY=" + winY + ",top=" + winY + ",screenX=" + winX + ",left=" + winX + ",width= " + picWidth + ",height= " + picHeight + ""); 
	picWind.focus();
}
  
//******************** overfoer til notesblok ****************************
var timeOut = false;
var imgName;
var Id;
var checkArray = new Array ();
var countNotes

for (i = 1; i <= 100; i++) {
		checkArray[i] = 0;		
	}

function countAnnoncer() {
	countNotes = 0;
	for (i = 1; i <= 100; i++) {
		countNotes = countNotes + checkArray[i];
	}
}

function checkNotesblok(special) {
	if (special) { 
		document.images[imgName].src = "/images/iconer/" + special + ".gif";
	}
	else {
		document.images[imgName].src = "/images/misc/blokCheck.gif";
	}	
}

function hideLayer() {
	document.all.flytDiv.style.visibility = "hidden";
}

function showLayer(special) {
	if (document.all && navigator.appVersion.indexOf("Mac") == -1) document.all.flytDiv.style.visibility = "visible";
	checkNotesblok(special);	
	if (document.all && navigator.appVersion.indexOf("Mac") == -1) timeOut = setTimeout("hideLayer()",2000);
}

function gemNotesb(e,theImg, special) {
	if (document.all && navigator.appVersion.indexOf("Mac") == -1) {
		if (timeOut) clearTimeout(timeOut);
		mouseX = event.clientX - event.offsetX + document.body.scrollLeft + 20;
		mouseY = event.clientY - event.offsetY + document.body.scrollTop;
		if (document.all && event.clientY + 100 >= document.body.clientHeight) {
		   if (event.clientY + 100 >= document.body.clientHeight) { 
		      mouseY = document.body.clientHeight - 105 + document.body.scrollTop;
		   }
		}
  
		objDivStyle = document.all.flytDiv.style;
		objDivStyle.left = mouseX;
		objDivStyle.top = mouseY;
		objDivStyle.visibility = "visible";
	
	}
	
	if ((document.all && navigator.appVersion.indexOf("Mac") == -1) || (typeof theWin != "object")) {
		imgName = theImg;
		Id = parseInt(imgName.substr(6));
		if (checkArray[Id] == 1) {
			if (timeOut) clearTimeout(timeOut);
			if (document.all) hideLayer();
			alert('Denne annonce er allerede gemt i Udvalgte annoncer')
		}
		else {
			checkArray[Id] = 1;
			showLayer(special);
		}
		countAnnoncer();
	}
}

//******************** Sortering af annoncer ****************************
function sortering(submitUrl) {
	if (document.all) {
		location.href = submitUrl ;
	}
}

//******************** tabelbredder i søgeresultat ****************************
var arrImgWidth = new Array();
var conTableWidth = 0;
var iePad = (document.getElementById && navigator.appVersion.indexOf("Mac") == -1) ? -6 : 2;

function innerTable() {
	if (!document.all && document.getElementById) {
		for (i = 1; document.getElementById("col" + (i + 1)); i++) {
			subst = (i == 2) ? 56 : 8;
			arrImgWidth[arrImgWidth.length] = document.getElementById("col" + i).parentNode.offsetWidth - subst;
		}
		arrImgWidth[arrImgWidth.length - 1] += 48;
		conTableWidth = document.getElementById("col").parentNode.parentNode.parentNode.offsetWidth;
	}
	else {
		docObj = (document.all) ? document.all : document;
		for (i = 1; docObj["col" + (i + 1)]; i++) {
			arrImgWidth[arrImgWidth.length] = (document.all) ?
				docObj["col" + i].parentElement.clientWidth + iePad :
				docObj["col" + (i + 1)].pageX - docObj["col" + i].pageX - 8;
			conTableWidth += (arrImgWidth[arrImgWidth.length -1] + 8);
		}
		conTableWidth += 26;
		if (document.all) {
			arrImgWidth[arrImgWidth.length - 1] -= 1;
			conTableWidth -= 1;
		}
	}
}

function innerTableReSize() {
	if (document.getElementById && navigator.appVersion.indexOf("Mac") == -1) {
		doInnerTableReSize();
	}
	else {
		setTimeout("doInnerTableReSize()",10);
	}
}

function doInnerTableReSize() {
	if (document.all) {
		conTableWidth = 0;
		for (j = 1; document.all["col"+j+"_1"]; j++) {
			for (i = 1; document.all["col"+j+"_"+i]; i++) {
				document.all["col"+j+"_"+i].style.pixelWidth = document.all["col" + i].parentElement.clientWidth + iePad;
				if (j == 1) conTableWidth += (document.all["col"+j+"_"+i].style.pixelWidth + 8);
			}
			document.all["col"+j+"_8"].style.pixelWidth -= 1;
			if (j == 1) {
				conTableWidth += 25;
			}
			document.all["conTable" + j].style.pixelWidth = conTableWidth;
		}
		document.all["conTable" + j].style.pixelWidth = conTableWidth;
	}
}