/*
	Lightbox JS: Fullsize Image Overlays 
	by Lokesh Dhakar - http://www.huddletogether.com

	For more information on this script, visit:
	http://huddletogether.com/projects/lightbox/

	Licensed under the Creative Commons Attribution 2.5 License - http://creativecommons.org/licenses/by/2.5/
	(basically, do anything you want, just leave my name and link)
*/

document.write("<script src=\"/casa/vipp/md5.js\"></script>");

var loadingImage = 'loading.gif';		
var closeButton = 'close.gif'; 

var iterationNo = 0;
var paths = []; 
var tags_paths = ["kampagne.gif", "tilbud.gif", "spar20p.gif", "spar25p.gif", "spar40p.gif", "spar50p.gif", "kommersnart.gif", "demo.gif", "saetpris.gif", "introtilbud.gif", "udgaar.gif", "limitedstock.gif", "solgt.gif", "restordre.gif", "returvare.gif"]; 
var tags_pos = [1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2]; 

function getPageScroll(){

	var yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
	}

	arrayPageScroll = new Array('',yScroll) 
	return arrayPageScroll;
}

function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}


	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

function pause(numberMillis) {
	var now = new Date();
	var exitTime = now.getTime() + numberMillis;
	while (true) {
		now = new Date();
		if (now.getTime() > exitTime)
			return;
	}
}

function showLightbox(ev, objLink)
{
	var objLightbox = document.getElementById('lightbox');
	var objImage = document.getElementById('lightboxImage');

	if (objLightbox.style.display == "block")
		return false;

	var arrayPageSize = getPageSize();
	var arrayPageScroll = getPageScroll();

	if (!ev)
		ev = window.event;

	var evClientX = ev.clientX;
	var evClientY = ev.clientY;
        var evImageHeight;
        
         
//        if (ev.currentTarget)
//        	evImageHeight = ev.currentTarget.getAttribute('mheight');
//        else if (ev.srcElement)
//        	evImageHeight = ev.srcElement.parentNode.getAttribute('mheight');
//        else
//        	evImageHeight = 0;

	imgPreload = new Image();

	imgPreload.onload = function()
	{
		objImage.src = objLink;

		// center lightbox and make sure that the top and left values are not negative
		// and the image placed outside the viewport
		var lightboxTop = arrayPageScroll[1] + evClientY + 10;
		var lightboxLeft = evClientX + 15;

//		if (evImageHeight == 0)
//		{
//			evImageHeight = this.height;
//
//			alert(this.height);
//		}

	        if (evClientY + 10 + 360 > document.body.clientHeight &&
	            document.body.clientHeight / 2 < evClientY)
	        {
	        	lightboxTop = arrayPageScroll[1] + evClientY - 20 - imgPreload.height;
	        }
		
		objLightbox.style.top = (lightboxTop < 0) ? "0px" : lightboxTop + "px";
		objLightbox.style.left = (lightboxLeft < 0) ? "0px" : lightboxLeft + "px";


		// A small pause between the image loading and displaying is required with IE,
		// this prevents the previous image displaying for a short burst causing flicker.
		if (navigator.appVersion.indexOf("MSIE")!=-1){
			pause(0);
		} 

		// Hide select boxes as they will 'peek' through the image in IE
		selects = document.getElementsByTagName("select");

        	for (i = 0; i != selects.length; i++) {
                	selects[i].style.visibility = "hidden";
        	}
	
		objLightbox.style.display = 'block';

		// After image is loaded, update the overlay height as the new image might have
		// increased the overall page height.
		arrayPageSize = getPageSize();
		//objOverlay.style.height = (arrayPageSize[1] + 'px');

		return false;
	}

 	objImage.setAttribute('class','mouseoverImage');
	imgPreload.src = objLink;
}


function hideLightbox()  
{
	objLightbox = document.getElementById('lightbox');

	if (objLightbox)
	{
		objLightbox.style.display = 'none';

		selects = document.getElementsByTagName("select");
	
		for (i = 0; i != selects.length; i++) {
			selects[i].style.visibility = "visible";
		}
	}
}


function checkOrphanLightbox(e) 
{
	if (!document.elementFromPoint)
		return false;
	
	if (!e) var e = window.event;

	var obj = document.elementFromPoint(e.clientX, e.clientY);

	if (obj)
	{
		if (obj.id != "thImage")
			hideLightbox();
	}
}


function initLightbox()
{
	
	if (!document.getElementsByTagName){ return; }

	var objBody = document.getElementsByTagName("body").item(0);
	
	var arrayPageSize = getPageSize();
	var arrayPageScroll = getPageScroll();

	// create lightbox div, same note about styles as above
	var objLightbox = document.createElement("div");
	objLightbox.setAttribute('id','lightbox');
	objLightbox.style.display = 'none';
	objLightbox.style.position = 'absolute';
	objLightbox.style.zIndex = '100';
      
	objBody.insertBefore(objLightbox, objBody.firstChild);
	
	// create image
	var objImage = document.createElement("img");
	objImage.setAttribute('id','lightboxImage');
      
	objImage.style.border = 'solid 1px #000000';
  
	objLightbox.appendChild(objImage);
      
	document.onmousemove = checkOrphanLightbox;
}


function addLoadEvent(func)
{	
	var oldonload = window.onload;

	if (typeof window.onload != 'function'){
    	window.onload = func;
	} else {
		window.onload = function(){
		oldonload();
		func();
		}
	}
}

function handle_load_error(objImage)
{
	objImage.removeNode(true);
}

function chkImgOnLoad(obj)
{
	if (obj.src.indexOf('more.gif') != -1 || obj.src.indexOf('zoom.gif') != -1)
		return; 

	obj.src = '/casa/vipp/more.gif';
}   

function chkImgOnError(obj)
{
	obj.src = '/casa/vipp/zoom.gif';
}  

function findPos(obj) 
{
	var curleft = curtop = 0;

	if (obj.offsetParent) 
	{
		curleft = obj.offsetLeft;
		curtop = obj.offsetTop;

		while (obj = obj.offsetParent) 
		{
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		}
	}

	return [curleft,curtop];
}


function processAllTags()
{
	for (var i = 0; i < paths.length; i = i + 2)
	{
		processProductTags1(paths[i], paths[i + 1]);
      //alert("processing tag" + paths[i + 1]);
	}
}



function processProductTags1(hex_path, strPath)  
{
	var tagImg = new Image();

   // See if tags.jpg exist - signifying that some tag is in use 

	tagImg.onload = function()
	{
 
      //alert("tags.gif found for: " + strPath + ">  detecting which tag to show");
      // tags exist -- look through the possible tags and show the ones found

      for (var i = 0; i < tags_paths.length; i++)
      {
         processProductTags2(hex_path, tags_paths[i], strPath);
      }

	};

	tagImg.border = 0;
	tagImg.id = hex_path;
 
   //alert("looking for tags.gif" + strPath + ">"); 
	tagImg.src = "http://www.bolig-shoppen.dk/casa/get-thumbnail.php?path=" + strPath + "&pic=tags.gif"; 
   //tagImg.src = "http://www.casanovafurniture.dk/casa/vipp/nyhed.gif";
}

 
function processProductTags2(hex_path, filename, strPath)
{
	var tagImg = new Image();

   // Check which tag to show, by checking for existance of various files

	tagImg.onload = function()
	{
      //alert("showing tag for product: " + strPath);
		show_tag(hex_path, filename, strPath);
	}; 
 
	tagImg.border = 0;
	tagImg.id = hex_path; 
  
	//tagImg.src = "http://www.bolig-shoppen.dk/casa/get-thumbnail.php?path=" + strPath + "&pic=" + filename;
   tagImg.src = "http://www.casanovafurniture.dk/casa/vipp/nyhed.gif";
}
 

function show_tag(hex_path, filename, strPath)
{
	var tagImg = new Image();

   // Check if a certain tag semaphore file exist

	tagImg.onload = function()
	{
      var dv = document.getElementById(this.id + "-div");

      if (dv)
      {
         var elTD;   
 
         if (window.navigator.appVersion.indexOf("IE") != -1)
            elTD = dv.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.childNodes.item(0);
         else
            elTD = dv.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.childNodes.item(1);

         elTD.insertBefore(document.createElement("br"), elTD.childNodes.item(0));
         elTD.insertBefore(this, elTD.childNodes.item(0));
      }
	};

	tagImg.border = 0;
	tagImg.id = hex_path;
 
	//tagImg.src = "http://www.casanovafurniture.dk/casa/vipp/tags/" + filename;
   tagImg.src = "http://www.casanovafurniture.dk/casa/vipp/nyhed.gif";
}



function processProductTags(hex_path, strPath)
{
/*
	// price-top tag //

	var tagImg = new Image();

	tagImg.onload = function()
	{
		var dv = document.getElementById(this.id + "-div");

		if (dv)
		{
			var elTD;

			if (window.navigator.appVersion.indexOf("IE") != -1)
				elTD = dv.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.childNodes.item(3).childNodes.item(0).childNodes.item(0).childNodes.item(0).childNodes.item(0);
			else			
				elTD = dv.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.childNodes.item(7).childNodes.item(1).childNodes.item(1).childNodes.item(0).childNodes.item(1);

			elTD.insertBefore(document.createElement("br"), elTD.childNodes.item(0));
			elTD.insertBefore(this, elTD.childNodes.item(0));
		}
	};

	tagImg.border = 0;
	tagImg.id = hex_path;

	tagImg.src = "http://www.bolig-shoppen.dk/casa/get-thumbnail.php?path=" + strPath + "&pic=price-top.jpg";

	// main-bottom-center tag //

	var tagImg2 = new Image();

	tagImg2.onload = function()
	{
		var dv = document.getElementById(this.id + "-div");

		if (dv)
		{
			var elTD = dv.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode;
			var elDiv = document.createElement("div");
			var aPos = findPos(elTD);

                        if (aPos[0] != 0 && aPos[1] != 0)
                        {
				elDiv.style.top = aPos[1] + 150 - this.height;
                                elDiv.style.left = aPos[0];
                                elDiv.style.width = elTD.clientWidth;
                                elDiv.style.height = this.clientHeight;
                                elDiv.style.display = "block";
                                elDiv.style.position = "absolute";
                                elDiv.align = "center";

                                elDiv.appendChild(this);

                                elTD.appendChild(elDiv);
                        }
		}
	};


	tagImg2.border = 0;
	tagImg2.id = hex_path;

	tagImg2.src = "http://www.bolig-shoppen.dk/casa/get-thumbnail.php?path=" + strPath + "&pic=main-bottom-center.jpg";

	// main-bottom-left tag //

	var tagImg3 = new Image();

	tagImg3.onload = function()
	{
		var dv = document.getElementById(this.id + "-div");

		if (dv)
		{
			var elTD = dv.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode;
			var elDiv = document.createElement("div");
			var aPos = findPos(elTD);

                        if (aPos[0] != 0 && aPos[1] != 0)
                        {
				elDiv.style.top = aPos[1] + 150 - this.height;
                                elDiv.style.left = aPos[0];
                                elDiv.style.width = this.clientWidth;
                                elDiv.style.height = this.clientHeight;
                                elDiv.style.display = "block";
                                elDiv.style.position = "absolute";

                                elDiv.appendChild(this);

                                elTD.appendChild(elDiv);
                        }
		}
	};


	tagImg3.border = 0;
	tagImg3.id = hex_path;
	      
	tagImg3.src = "http://www.bolig-shoppen.dk/casa/get-thumbnail.php?path=" + strPath + "&pic=main-bottom-left.jpg";

	// main-bottom-right tag //

	var tagImg4 = new Image();

	tagImg4.onload = function()
	{      
		var dv = document.getElementById(this.id + "-div");

		if (dv)
		{
			var elTD = dv.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode;
			var elDiv = document.createElement("div");
			var aPos = findPos(elTD);

                        if (aPos[0] != 0 && aPos[1] != 0)
                        {
				elDiv.style.top = aPos[1] + 150 - this.height;
                                elDiv.style.left = aPos[0];
                                elDiv.style.width = elTD.clientWidth;
                                elDiv.style.height = this.clientHeight;
                                elDiv.style.display = "block";
                                elDiv.style.position = "absolute";
                                elDiv.align = "right";

                                elDiv.appendChild(this);
                                elTD.appendChild(elDiv);

//				elDiv.style.top = aPos[1];
//                              elDiv.style.left = aPos[0];
//                                elDiv.style.width = "100%";
//                                elDiv.style.height = "100%";
//                                elDiv.style.height = elTD.clientHeight;
//                                elDiv.style.zIndex = "50";
//                                elDiv.style.display = "block";
//                                elDiv.style.position = "absolute";
//                                elDiv.align = "right";
//
//                                elTD.appendChild(elDiv);
//                                
//                                var elTable = document.createElement("table");
//                                var elTBody = document.createElement("tbody");
//                                var elTR = document.createElement("tr");
//                                var elNewTD = document.createElement("td");
//
//                                elNewTD.height = "100%";
//                                elNewTD.style.verticalAlign = "bottom";
//                                elNewTD.appendChild(this);
//
//                                elTR.height = "100%";
//
//                                elTable.height = "100%";
//
//                                elTR.appendChild(elNewTD);
//                                elTBody.appendChild(elTR);
//                                elTable.appendChild(elTBody);
//
//                                elDiv.appendChild(elTable);
//
                        }
		}
	};


	tagImg4.border = 0;
	tagImg4.id = hex_path;

	tagImg4.src = "http://www.bolig-shoppen.dk/casa/get-thumbnail.php?path=" + strPath + "&pic=main-bottom-right.jpg";

	// nyhed tag //

	var tagImg5 = new Image();

	tagImg5.onload = function()
	{
		var dv = document.getElementById(this.id + "-div");

		if (dv)
		{
			var elTD;

			if (window.navigator.appVersion.indexOf("IE") != -1)
				elTD = dv.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.childNodes.item(3).childNodes.item(0).childNodes.item(0).childNodes.item(0).childNodes.item(0);
			else			
				elTD = dv.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.childNodes.item(7).childNodes.item(1).childNodes.item(1).childNodes.item(0).childNodes.item(1);

//			alert("<" + elTD.tagName + ">" + elTD.innerHTML + "</" + elTD.tagName + ">");

			var elDiv = document.createElement("div");
			var aPos = findPos(elTD);

                        if (aPos[0] != 0 && aPos[1] != 0)
                        {
				elDiv.style.top = aPos[1] - 4;
                                elDiv.style.left = aPos[0] + 3;
                                elDiv.style.width = elTD.clientWidth;
                                elDiv.style.height = elTD.clientHeight;
                                elDiv.style.zIndex = "100";
                                elDiv.style.display = "block";
                                elDiv.style.position = "absolute";

                                elDiv.appendChild(this);
                                elTD.appendChild(elDiv);

                                if (window.navigator.appVersion.indexOf("IE") != -1)
                                	this.style.filter = "alpha(opacity=75)";
                                else
                                	this.style.MozOpacity = "0.75";
                        }

		}
	};


	tagImg5.border = 0;
	tagImg5.id = hex_path;

	tagImg5.src = "http://www.bolig-shoppen.dk/casa/get-thumbnail.php?path=" + strPath + "&pic=nyhed.gif";

*/

	// nyhed2 tag //

	var tagImg6 = new Image();
 
	tagImg6.onload = function()
	{
		var dv = document.getElementById(this.id + "-div");

		if (dv) 
		{
			var elTD; 

			if (window.navigator.appVersion.indexOf("IE") != -1)
				elTD = dv.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.childNodes.item(0);
			else
            elTD = dv.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.childNodes.item(1);

//			alert("<" + elTD.tagName + ">" + elTD.innerHTML + "</" + elTD.tagName + ">"); 

         elTD.insertBefore(document.createElement("br"), elTD.childNodes.item(0));
			elTD.insertBefore(this, elTD.childNodes.item(0));

//
//			var elDiv = document.createElement("div");
//			var aPos = findPos(elTD);
//
//         if (aPos[0] != 0 && aPos[1] != 0)
//         {
//				elDiv.style.top = aPos[1] - 1;
//                                elDiv.style.left = aPos[0];
//                                elDiv.style.width = elTD.clientWidth;
//                                elDiv.style.height = this.clientHeight;
//                                elDiv.style.zIndex = "100";
//                                elDiv.style.display = "block";
//                                elDiv.style.position = "relative";
//                                elDiv.align = "right";
//
//                                elTD.appendChild(elDiv);
//                                elDiv.appendChild(this);
//
//                                if (window.navigator.appVersion.indexOf("IE") != -1)
//                                	this.style.filter = "alpha(opacity=75)";
//                                else
//                                	this.style.MozOpacity = "0.75";
//         }

		}
	};


	tagImg6.border = 0;
	tagImg6.id = hex_path;

	tagImg6.src = "http://www.bolig-shoppen.dk/casa/get-thumbnail.php?path=" + strPath + "&pic=nyhed2.gif";

/*
	// after-title tag //

	var tagImg7 = new Image();

	tagImg7.onload = function()
	{
		var dv = document.getElementById(this.id + "-div");

		if (dv)
		{
			var elTD = dv.parentNode.parentNode.childNodes.item(5).childNodes.item(0);

			this.style.verticalAlign = "middle";
                        elTD.insertBefore(this, elTD.childNodes.item(1));
                                
		}
	};


	tagImg7.border = 0;
	tagImg7.id = hex_path;
	      
	tagImg7.src = "http://www.bolig-shoppen.dk/casa/get-thumbnail.php?path=" + strPath + "&pic=after-title.jpg";
*/ 
}

function th(strPath, inspUrl, strAltPath)
{
	var szNumber;
	var strFinalPath;

	if (strPath == "")
		strFinalPath = strAltPath;
	else
		strFinalPath = strPath;

   if (strFinalPath == "")
   {
      //alert("path not found!");
      return false;
   }

	iterationNo++;

	document.write("<img src='/casa/1.jpg' width=1 height=12><br><div id=\"" + hex_md5(strFinalPath + iterationNo) + "-div\"></div>");

	var checkImg = new Image();

	checkImg.onload = function() 
	{ 
		var dv = document.getElementById(this.id + "-div");

		if (dv)
		{
			// remove the two <br> tags after our <div> - they enlarge the cell height
			//

         var anchorTD = dv.parentNode.parentNode;
         var elLastItem;

         for (var i = 0; i < 2; i++)
         {
            elLastItem = anchorTD.childNodes.item(anchorTD.childNodes.length - 1);

            if (elLastItem && elLastItem.tagName == "BR")
               anchorTD.removeChild(elLastItem);
         }

         // find out which pics are present and generate small squares
         //

			for (i = 0; i < 6; i++)
			{
				if (((this.width - 1) & (1 << i)) == (1 << i))
				{
					var elImg = new Image;
					var elAnchor = document.createElement("a");
					var pn = i + 1;
					var url = "http://www.bolig-shoppen.dk/casa/get-thumbnail.php?path=" + strFinalPath + "&pic=" + pn + ".jpg";

					elImg.border = 0;

					elAnchor.href = "javascript:poptastic(\"" + inspUrl + "\");";

					elImg.id = "thImage";
					elImg.src = "http://www.casanovafurniture.dk/casa/thumb-s.gif";


					elAnchor.id = url;
					elAnchor.onmouseover = function(event) { showLightbox(event, this.id); };
					elAnchor.onmouseout =  function() { hideLightbox(); };

					dv.appendChild(elAnchor);
					elAnchor.appendChild(elImg);
				}
			}

         var elTD;

         if (window.navigator.appVersion.indexOf("IE") != -1)
            elTD = dv.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.childNodes.item(0);
         else
            elTD = dv.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.parentNode.childNodes.item(1);

         var y_offset = 0, othertags = 0, percent_tag_shown = 0;

			for (i = 0; i < tags_paths.length; i++)
			{
				if (((this.height - 1) & (1 << i)) == (1 << i))
				{
               var bjImg = new Image;

               bjImg.id = "bjImage" + i;


					bjImg.src = "http://www.casanovafurniture.dk/casa/vipp/tags/" + tags_paths[i];

               /* position 1 */
					if (tags_pos[i]  == 1)
					{
                  elTD.insertBefore(document.createElement("br"), elTD.childNodes.item(0));
                  elTD.insertBefore(bjImg, elTD.childNodes.item(0));

                  //elDiv.insertBefore(bjImg);
                  if (window.navigator.appVersion.indexOf("IE") != -1)
                     bjImg.style.filter = "alpha(opacity=95)";
                  else
                     bjImg.style.MozOpacity = "0.95";

						othertags = othertags + 15;
					}
               else if (tags_pos[i] == 2)
               {
                  // Set up a DIV at beginning of product, just above product image
                  var elDiv = document.createElement("div");

                  elDiv.style.width = 0; 
                  elDiv.style.height = 0;
                  elDiv.style.zIndex = "100";
                  elDiv.style.display = "block";
                  elDiv.style.position = "relative";
                  elDiv.align = "left";

                  // position an image within that DIV
                  bjImg.style.position = 'absolute';

                  if (tags_paths[i] == 'spar20p.gif' || tags_paths[i] == 'spar25p.gif' || tags_paths[i] == 'spar40p.gif'|| tags_paths[i] == 'spar50p.gif')
						{
	                  bjImg.style.top = 15 + y_offset + othertags;
                     bjImg.style.left = 90;
							y_offset = (y_offset + 62);
                     percent_tag_shown = 1;
	                  //bjImg.style.top = 0 + othertags;
                     //bjImg.style.left = 0;
                  }
                  else if (tags_paths[i] == 'returvare.gif')
                  {
	                  bjImg.style.top = 0;
                     bjImg.style.left = 80;
						}
                  else if (tags_paths[i] == 'demo.gif')
                  {
	                  bjImg.style.top = 0;
                     bjImg.style.left = 120;
						}
                  else 
                  {
	                  bjImg.style.top = 15 + y_offset + othertags;
                     bjImg.style.left = 95;
		               y_offset = (y_offset + 50);
						} 

//                  bjImg.style.position = 'absolute';
//                  bjImg.style.top = 103 + othertags;
//                  y_offset = (y_offset + 47);
//                  bjImg.style.left = 450 - y_offset;

                  //Insert DIV into page
                  elTD.insertBefore(elDiv, elTD.childNodes.item(0));

                  // insert image into DIV, so it becomes absolute positioned in relation to the DIVs relative position 
                  elDiv.appendChild(bjImg);

                  //elDiv.insertBefore(bjImg);
                  if (tags_paths[i] == 'demo.gif')
                  {
                     if (window.navigator.appVersion.indexOf("IE") != -1)
                        bjImg.style.filter = "alpha(opacity=30)";
                     else
                        bjImg.style.MozOpacity = "0.30";
						}

               }

               bjImg.src = "http://www.casanovafurniture.dk/casa/vipp/tags/" + tags_paths[i];
            }
			}
		}
		else
		{
			//alert("div not found!");
			//return;
		}
	}

	checkImg.id = hex_md5(strFinalPath + iterationNo);
	checkImg.src = "http://www.bolig-shoppen.dk/casa/get-info.php?path=" + strFinalPath + "&dummy=" + iterationNo;

	//alert(checkImg.src);
	//return false;

/*
	szNumber = 6;
			
	var checkImg = new Image();

	checkImg.onload = function() 
	{ 
		var dv = document.getElementById(this.id + "-div");

		if (dv)
		{
			for (i = 1; i < szNumber + 1; i++)
			{
				var elImg = new Image;
				var elAnchor = document.createElement("a");
				var url = "http://www.bolig-shoppen.dk/casa/get-thumbnail.php?path=" + strFinalPath + "&pic=" + i + ".jpg";

				elImg.border = 0;

				elAnchor.href = "javascript:poptastic(\"" + inspUrl + "\");";

				elImg.id = "thImage";
				elImg.src = "http://www.casanovafurniture.dk/casa/thumb-s.gif";


				elAnchor.id = url;
				elAnchor.onmouseover = function(event) { showLightbox(event, this.id); };
				elAnchor.onmouseout = function() { hideLightbox(); };
				elAnchor.setAttribute('mheight', this.height);

				dv.appendChild(elAnchor);
				elAnchor.appendChild(elImg);
			}
		}
	}; 

	checkImg.onerror = function() { szNumber--; if (szNumber > 0) checkImg.src = "http://www.bolig-shoppen.dk/casa/get-thumbnail.php?path=" + strFinalPath + "&pic=" + szNumber + ".jpg"; };
	checkImg.id = hex_md5(strFinalPath + iterationNo);
	checkImg.src = "http://www.bolig-shoppen.dk/casa/get-thumbnail.php?path=" + strFinalPath + "&pic=" + szNumber + ".jpg";

 */

	paths = paths.concat([hex_md5(strFinalPath + iterationNo), strFinalPath]);
}




var newwindow;

function poptastic(url)
{
	newwindow = window.open(url,'name','height=768,width=1024,resizable=1');

	if (window.focus) 
		newwindow.focus();
}

function hideKob()
{
	addLoadEvent(doHideKob);
}

function doHideKob()
{

}

addLoadEvent(initLightbox);	// run initLightbox onLoad
//addLoadEvent(processAllTags);  
