/******************************************************************/
PositionX = 10;
PositionY = 10;
defaultWidth = 600;
defaultHeight = 400;

var AutoClose = false;

function popImage(imageURL,imageTitle){

var imgWin = window.open('','_blank','scrollbars=no,resizable=1,width='+defaultWidth+',height='+defaultHeight+',left='+PositionX+',top='+PositionY);
if( !imgWin ) { return true; } //popup blockers should not cause errors
imgWin.document.write('<html><head><title>'+imageTitle+'<\/title><script type="text\/javascript">\n'+
'function resizeWinTo() {\n'+
'if( !document.images.length ) { document.images[0] = document.layers[0].images[0]; }'+
'var oH = document.images[0].height, oW = document.images[0].width;\n'+
'if( !oH || window.doneAlready ) { return; }\n'+ //in case images are disabled
'window.doneAlready = true;\n'+ //for Safari and Opera
'var x = window; x.resizeTo( oW + 200, oH + 200 );\n'+
'var myW = 0, myH = 0, d = x.document.documentElement, b = x.document.body;\n'+
'if( x.innerWidth ) { myW = x.innerWidth; myH = x.innerHeight; }\n'+
'else if( d && d.clientWidth ) { myW = d.clientWidth; myH = d.clientHeight; }\n'+
'else if( b && b.clientWidth ) { myW = b.clientWidth; myH = b.clientHeight; }\n'+
'if( window.opera && !document.childNodes ) { myW += 16; }\n'+
'x.resizeTo( oW = oW + ( ( oW + 200 ) - myW ), oH = oH + ( (oH + 200 ) - myH ) );\n'+
'var scW = screen.availWidth ? screen.availWidth : screen.width;\n'+
'var scH = screen.availHeight ? screen.availHeight : screen.height;\n'+
'if( !window.opera ) { x.moveTo(Math.round((scW-oW)/2),Math.round((scH-oH)/2)); }\n'+
'}\n'+
'<\/script>'+
'<\/head><body onload="resizeWinTo();"'+(AutoClose?' onblur="self.close();"':'')+'>'+
(document.layers?('<layer left="0" top="0">'):('<div style="position:absolute;left:0px;top:0px;display:table;">'))+
'<img src='+imageURL+' alt="Luk vindue ..." title="" onload="resizeWinTo();" onclick="self.close();" style="cursor:pointer;">'+
(document.layers?'<\/layer>':'<\/div>')+'<\/body><\/html>');
imgWin.document.close();
}


/******************************************************************/

function dn() {
return false;
}

/******************************************************************/

var numbah = 0;
function showPic (whichpic, direction, pics) {
if (document.getElementById) {
splitIMGs = pics.split("#");
totalIMGs = splitIMGs.length;
if(!(((direction == 1) && ( numbah >= (totalIMGs-1)))||((direction==-1) && (numbah <= 0)))) {numbah += direction;}
if (numbah == (totalIMGs-1)) {document.getElementById("next").style.visibility = "hidden";} else {document.getElementById("next").style.visibility = "visible";}
if (numbah == 0) {document.getElementById("prev").style.visibility = "hidden";} else {document.getElementById("prev").style.visibility = "visible";}
document.getElementById('status').childNodes[0].nodeValue = (numbah + 1) + "/" + (splitIMGs.length);
document.getElementById('placeholder').src = "shoppics/" + splitIMGs[numbah];
document.getElementById('biglink').href = "javascript:popImage('shoppics/lg" +  splitIMGs[numbah] + "','Dalbro Porcelænsbrænderi');";
return false;
} else {
return true;
}
}

/********************************************************************/

var CLASS_NAME = "expandable";
var DEFAULT_DISPLAY = "none";
var XMLNS = "http://www.w3.org/1999/xhtml";
var CLOSED_PREFIX = "Udvid: ";
var OPENED_PREFIX = "Formindsk: ";

/******************************************************************************/

String.prototype.trim = function() {
return this.replace(/^\s+/, "").replace(/\s+$/, "");
}
function getNodesByType(root, type, filter) {
var node = root;
var nodes = [];
var next;

while (node != null) {
if (node.hasChildNodes())
node = node.firstChild;
else if (node != root && null != (next = node.nextSibling))
node = next;
else {
next = null;
for ( ; node != root; node = node.parentNode) {
next = node.nextSibling;
if (next != null) break;
}
node = next;
}
if (node != null && node.nodeType == type && filter(node))
nodes.push(node);
}
return nodes;
}
function getInnerText(node) {
if (node == null || node.nodeType != 1)
return;
var text = "";
var textnodes = getNodesByType(node, 3, function() { return true; });
for (var i = 0; i < textnodes.length; i++)
text += textnodes[i].data;
return text;
}

function initExpandableLists() {
if (!document.getElementsByTagName) return;
switchNode = function(id) {
var node = document.getElementById(id);
if (node && /^switch /.test(node.className)) node.onclick();
}
actuate = function() {
var sublist = this.parentNode.getElementsByTagName("ul")[0] ||
this.parentNode.getElementsByTagName("ol")[0];
if (sublist.style.display == "block") {
sublist.style.display = "none";
this.firstChild.data = "+";
this.className = "switch off";
this.title = this.title.replace(OPENED_PREFIX, CLOSED_PREFIX);
} else {
sublist.style.display = "block";
this.firstChild.data = "-";
this.className = "switch on";
this.title = this.title.replace(CLOSED_PREFIX, OPENED_PREFIX);
}
return false;
}
if (typeof document.createElementNS == "function")
var template = document.createElementNS(XMLNS, "a");
else
var template = document.createElement("a");
template.appendChild(document.createTextNode(" "));

var list, i = 0, j = 0;
var pattern = new RegExp("(^| )" + CLASS_NAME + "( |$)");

while ((list = document.getElementsByTagName("ul")[i++]) ||
(list = document.getElementsByTagName("ol")[j++]))
{
if (pattern.test(list.className) == false) continue;

var item, k = 0;
while ((item = list.getElementsByTagName("li")[k++])) {
var sublist = item.getElementsByTagName("ul")[0] ||
item.getElementsByTagName("ol")[0];
if (sublist == null) continue;
var symbol;
switch (sublist.style.display) {
case "none" : symbol = "+"; break;
case "block": symbol = "-"; break;
default:
var display = DEFAULT_DISPLAY;
if (sublist.currentStyle) {
display = sublist.currentStyle.display;
} else if (document.defaultView &&
document.defaultView.getComputedStyle &&
document.defaultView.getComputedStyle(sublist, ""))
{
var view = document.defaultView;
var computed = view.getComputedStyle(sublist, "");
display = computed.getPropertyValue("display");
}
symbol = (display == "none") ? "+" : "-";
sublist.style.display = display || "block";
break;
}

var child = item.firstChild;
var text = "";
while (child) {
if (child.nodeType == 3 && "" != child.data.trim()) {
text = child.data;
break;
} else if (child.nodeType == 1 &&
!/^[ou]l$/i.test(child.tagName))
{
text = child.innerText || getInnerText(child);
break;
}
child = child.nextSibling;
}

var actuator = template.cloneNode(true);
var uid = "switch" + i + "-" + j + "-" + k;
actuator.id = uid;
actuator.href = "javascript:switchNode('" + uid + "')";
actuator.className = "switch " + ((symbol == "+") ? "off" : "on");
actuator.title = ((symbol == "+")
? CLOSED_PREFIX : OPENED_PREFIX) + text.trim();
actuator.firstChild.data = symbol;
actuator.onclick = actuate;
item.insertBefore(actuator, item.firstChild);
}
}
}

var oldhandler = window.onload;
window.onload = (typeof oldhandler == "function")
? function() { oldhandler(); initExpandableLists(); } : initExpandableLists;

