	function initCartBackground(){
		setTimeout("resizeCartBackground();",250);
		setTimeout("resizeCartBackground();",2500);
		setTimeout("resizeCartBackground();",7500);
		setTimeout("resizeCartBackground();",15000);
		  }

	function resizeCartBackground(){
		//
		//if (document.getElementById("cart-block-contents-ajax").className == 'ajax-cart-processed'){
		  document.getElementById('winkelwagen-blok-achter').style.height = (document.getElementById('winkelwagen-blok').clientHeight - 102 + document.getElementById('winkelwagen-blok').clientHeight * 0.15) + 'px';
		//}
		  }

function setMainImgOnLoad(mainImgInputURL){
    setMainImg(mainImgInputURL);
}

function setMainImg(mainImgInputURL){
	if (document.getElementById('hoofdafbeelding')){
		document.getElementById('hoofdafbeelding').style.background = 'url(\''+getMainImgURL(mainImgInputURL)+'\') no-repeat center';
	}
}

function choose_gallery (){
	window.open('/snippets/vrijontwerp_image_browser/-select_image_gallery.php','wijzig_kopafbeelding','width=718,toolbar=0,resizable=0,scrollbars=no,height=620');
	}

function getFullSizeDimensions() {

	if (window.innerHeight != null) { // webkit; opera; gecko;
		var fullSizeHeight = window.innerHeight;
		var fullSizeWidth = window.innerWidth;
	}
	else if (document.documentElement.clientWidth != null && document.documentElement.clientWidth != 0) { // msie 5 + 6; gecko
		var fullSizeHeight = document.documentElement.clientHeight;
		var fullSizeWidth = document.documentElement.clientWidth;
	}

	else if (document.getElementById('pseudo-body') != null){ // msie 7
		var fullSizeHeight = Math.round(document.getElementById('pseudo-body').clientHeight);
		var fullSizeWidth = Math.round(document.getElementById('pseudo-body').clientWidth);
	}
	else { // alles is hopeloos (MSIE 5.0)
		var fullSizeWidth = 1024-30;
		var fullSizeHeight = 768-120;
	}

	return [fullSizeWidth,fullSizeHeight];
}


function getMainImgURL(mainImgInputURL){
    var windowHeight = getFullSizeDimensions()[1];


    var mainImgHeight = Math.round((windowHeight - 144 + 50)/100)*100;
    var mainImgWidth = 210;
    var mainImgURL = mainImgInputURL.replace('-x.','-cutout-'+mainImgWidth+'x'+mainImgHeight+'.');
    return mainImgURL;
}

function correctPosition(oElement,oPos,oWhich) {
	while( oElement.offsetParent ) {
		oPos -= oElement['offset'+oWhich];
		oElement = oElement.offsetParent;
	}
	oPos += document.documentElement['scroll'+oWhich] ? document.documentElement['scroll'+oWhich] : document.body['scroll'+oWhich];
	return oPos;
}

function enableMenu(menuName){

if (menuName == 'block-menu-primary-links'){
	var menuButton = document.getElementById(menuName).getElementsByTagName('h2')[0];
	var menuButtonText = menuButton.innerHTML;
	var newLink = document.createElement('a');
	newLink.href = "/catalog";
	newLink.innerHTML = menuButton.innerHTML;
	menuButton.innerHTML = "";
	document.getElementById(menuName).getElementsByTagName('h2')[0].appendChild(newLink);
}


document.getElementById(menuName).onmouseover = new Function('toonMenu(\''+menuName+'\');');
document.getElementById(menuName).onmouseout = new Function('verbergMenu(\''+menuName+'\');');


//document.getElementById(menuName).setAttribute('onmouseover','toonMenu(\''+menuName+'\');');
//document.getElementById(menuName).setAttribute('onmouseout','verbergMenu(\''+menuName+'\');');

document.getElementById(menuName).getElementsByTagName('ul')[0].style.display = "none";
}

function toonMenu(menuName) {
	document.getElementById(menuName).getElementsByTagName('h2')[0].className += " active";
	document.getElementById(menuName).getElementsByTagName('ul')[0].style.display = "block";

}

function verbergMenu(menuName) {
	document.getElementById(menuName).getElementsByTagName('h2')[0].className = document.getElementById(menuName).getElementsByTagName('h2')[0].className.replace(' active','');
	document.getElementById(menuName).getElementsByTagName('ul')[0].style.display = "none";
}


function activeer(object)	{
	object.className = "active";
}
function deactiveer(object)	{
	object.style.opacity = "0.72";
	object.style.background = "transparent";
	object.className = "";
}




/*****************************************************************************/
/* galerie_scriptlib.js							     */
/*****************************************************************************/



function reloadPage(){
	window.location.reload();
}



	var nMaxVars = 0;
	var sVarLine = "";
	var sName = new Array();
	var sValue = new Array();

	function getMaxVars() { return nMaxVars; }
	function getVarString() { return sVarLine; }
	function getNameArray() { return sName; }
	function getValueArray() { return sValue; }

	function parseCallingURL(sCallingURL) {
		//Get the calling URL and parse out variables
		sCallingURL = String(sCallingURL);

		if (sCallingURL.length == 0)
			return;

		// Check if there are any variables
		if (sCallingURL.indexOf('?') != -1) {
			sVarLine = String(sCallingURL.substring(sCallingURL.indexOf('?') + 1, sCallingURL.length));
		} else {
			// No variables
			return;
		}

		var nPos = 0;
		var sChar = "";
		var sWord = "";
		nMaxVars = 0;

		// Parse
		while (nPos < sVarLine.length) {
			sChar = sVarLine.substring(nPos, nPos + 1);

			if (sChar == "=") {
				sName[nMaxVars] = sWord;
				sWord = "";

			} else if (sChar == "&") {
				sValue[nMaxVars] = sWord;
				sWord = "";
				nMaxVars++;

			} else if (nPos == sVarLine.length - 1) {
				sWord += sVarLine.substring(nPos, nPos + 1);
				sValue[nMaxVars] = sWord;
				sWord = "";
				nMaxVars++;

			} else {
				sWord += sChar;
			}
			nPos++;
		}
	}



var qsParm = new Array();

function qs() {
    var query = window.location.search.substring(1);
    var parms = query.split('&');
    for (var i=0; i<parms.length; i++) {
	var pos = parms[i].indexOf('=');
	if (pos > 0) {
	    var key = parms[i].substring(0,pos);
	    var val = parms[i].substring(pos+1);
	    qsParm[key] = val;
	}
    }
}

qsParm['code'] = null;
qsParm['desc'] = null;
qs();



function getFullSizeDimensions() {

            if (window.innerHeight != null) { // webkit; opera; gecko;
                var fullSizeHeight = window.innerHeight;
                var fullSizeWidth = window.innerWidth;
	    }
	    else if (document.documentElement.clientWidth != null && document.documentElement.clientWidth != 0) { // msie 5 + 6; gecko
                var fullSizeHeight = document.documentElement.clientHeight;
                var fullSizeWidth = document.documentElement.clientWidth;
            }
            else if (document.getElementById('fullscreenPage') != null){ // msie 7
		var fullSizeHeight = Math.round(getHeight('fullscreenPage'));
		var fullSizeWidth = Math.round(getWidth('fullscreenPage'));
            }
	    else { // alles is hopeloos (MSIE 5.0)
                var fullSizeWidth = 1024-30;
		var fullSizeHeight = 768-120;
	    }

            return [fullSizeWidth,fullSizeHeight];
}



function getFullSizeImgURL(imgURLwithoutExtension,imgExtension) {

	    var fullSizeImageMaxWidth = getFullSizeDimensions[0];
	    var fullSizeImageMaxHeight = getFullSizeDimensions[1];

            fullSizeImageMaxHeight = (Math.round((fullSizeImageMaxHeight-50)/100)*100)-150;
            fullSizeImageMaxWidth = (Math.round((fullSizeImageMaxWidth-50)/100)*100)-50;

            if (fullSizeImageMaxHeight < 250) fullSizeImageMaxHeight = 250;
            if (fullSizeImageMaxWidth < 250) fullSizeImageMaxWidth = 250;

            if (fullSizeImageMaxHeight > 1050) fullSizeImageMaxHeight = 1050;
            if (fullSizeImageMaxWidth > 1050) fullSizeImageMaxWidth = 1050;

            var fullSizeImgURL = imgURLwithoutExtension+'!'+fullSizeImageMaxWidth+'x'+fullSizeImageMaxHeight+imgExtension;
            return fullSizeImgURL;

}

//thanks to http://www.quirksmode.org/js/findpos.html

function findPosition(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) { // not a syntax error!
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return [curleft,curtop];
}

function findPos(element) {
	obj = document.getElementById(element);
	findPosition(element);
}

function getHeight(element){
    return document.getElementById(element).clientHeight;
}

function getWidth(element){
    return elementWidth = document.getElementById(element).clientWidth;
}

function getOffsetLeft(element){
        return document.getElementById(element).offsetLeft;
}
function getOffsetTop(element){
        return document.getElementById(element).offsetTop;
}



function mOverAct(imgID){

     var navi = navigator.appVersion;
     var oldMSIE = false;

    if(navi.indexOf("MSIE")>-1){
	var navAr = navi.split(";");
	if(parseFloat(navAr[1].split(" ")[2])< 6) oldMSIE = true;
    }

    if (!oldMSIE) document.getElementById('thumb'+imgID).style.cursor='pointer';
        document.getElementById('thumb'+imgID).style.border='1px inset #cababb';
}


function mOutAct(imgID){
    document.getElementById('thumb'+imgID).style.border='1px #cabcbc outset';
}

function parentHideFullscreenURL(imgURL){

    var parentURL = parent.location.href;
    parentURL = parentURL.replace('flush','')
    parseCallingURL(parentURL);
    parentVarString = getVarString();

    // override zonder split-pages
    parentVarString = '';

    if (parent.document.getElementById('fullscreenContainer') == null) return './';
    else {
       if (parentVarString == 'page=1' || parentVarString == ''){
	      //parentVarString = 'page=1';
	      return parentURL.replace('?'+parentVarString,'')
       }
       else return parentURL.replace(parentVarString,'page='+parent.pWithImg[imgURL]);
    }
}

function parentHideFullscreenImage(imgURL){

    if (parent.location.href != parentHideFullscreenURL(imgURL)){
	top.location.href = parentHideFullscreenURL(imgURL);
    }
    else {
	parentHideFullscreenContainer();
	parent.document.getElementById('fullscreenContainer').src='';
    }
}

function hideFullscreenImage(){
    document.getElementById('fullscreenContainer').style.display='none';
    document.getElementById('fullscreenBG').style.display='none';
    document.getElementById('fullscreenContainer').src='';
    document.body.style.overflow = 'auto';
}

function parentHideFullscreenContainer(){
    parent.document.getElementById('fullscreenContainer').style.display='none';
    parent.document.getElementById('fullscreenBG').style.display='none';
    //parent.document.getElementById('fullscreenContainer').src='';
    parent.document.body.style.overflow = 'auto';
}

function arrayMax(array){
  var narray = [];
  for ( var i = 0; i < array.length; i++ )
    if ( array[i] != null )
      narray.push( array[i] );
  return Math.max.apply( Math, narray );
};

function oldBrowser(){
    var navi = navigator.appVersion;
    if(navi.indexOf("Macintosh")>-1){
	return navigator.appVersion;
    }
    else if(navi.indexOf("MSIE")>-1){
	var navAr = navi.split(";");
	if(parseFloat(navAr[1].split(" ")[2])< 5.0) {
        return parseFloat(navAr[1].split(" ")[2]);
        }
    else return false;
    }
else return false;
}

function oldMSIE(){
    var navi = navigator.appVersion;
    if(navi.indexOf("MSIE")>-1){
	var navAr = navi.split(";");
	if(parseFloat(navAr[1].split(" ")[2])< 7.0) {
        return true;
        }
    else return false;
    }
else return false;
}

function shwDirTh(imgID,thumbWidth,dirTitle,dirURL,imgThumbURL,itemCount,dirThumbTxtStart,dirThumbTxtEnd){
    var imgURLprefix = document.getElementById('imgURLprefix').value;
    var linkURLprefix = document.getElementById('linkURLprefix').value;
	if (thumbWidth == ''){ var leftOffset = 150; }
    thumbOutput = thumbOutput+('<a href="'+linkURLprefix+dirURL+'/" class="dirThumb" onmouseover="mOverAct('+imgID+');" onmouseout="mOutAct('+imgID+');"><img id="thumb'+imgID+'" style="width:'+thumbWidth+'px; margin-left:'+(150-leftOffset)+'px;" title="'+dirTitle+'" alt="'+dirTitle+'" src=\"'+imgURLprefix+imgThumbURL+'" /><span class="dirTxt"><h3>'+dirTitle+'</h3>'+dirThumbTxtStart+' '+itemCount+' '+dirThumbTxtEnd+'.</span></a>');
}

function showFullscreenImage (){
    document.getElementById('fullscreenBG').style.background='black url(\'/css/loading.gif\') no-repeat center';
      document.body.style.overflow = 'hidden';
	  document.getElementById('fullscreenBG').style.display = 'block';
      document.getElementById('fullscreenContainer').style.display = 'block';
}


function shwImgTh(imgID,thumbWidth,imgName,imgThumbURL,path){
    var imgURLprefix = document.getElementById('imgURLprefix').value;
    var linkURLprefix = document.getElementById('linkURLprefix').value;
    var imgURL = imgThumbURL.replace('-x90','');
    var imgURL = imgURL.replace('.jpg','.html');
    var imgURL = imgURL.replace('.JPG','.HTML');
    var pageLink = linkURLprefix+imgURL;
    thumbOutput = thumbOutput+('<a target="fullscreenContainer" href="'+pageLink+'\" onclick="showFullscreenImage();document.getElementById(\'fullscreenContainer\').src=\''+pageLink+'\';return false;" class="imgThumb">');
    thumbOutput = thumbOutput+('<img id="thumb'+imgID+'" style="width:'+thumbWidth+'px;" title="'+imgName+'" alt="'+imgName+'" src=\"'+imgURLprefix+imgThumbURL+'" />');
    thumbOutput = thumbOutput+('<br/>'+imgName);
    thumbOutput = thumbOutput+('</a>');
}

	function putDimensionsInFilename(filename,fileNameExtension,width,height) {

		//var filename = remove_dimensions_from_filename($fn);
		//fileNameExtension = '.jpg';
		var imgDimensions = "!"+width+"x"+height;
		return filename.replace(fileNameExtension,imgDimensions+fileNameExtension);
		}

function getResizedDimensions(fileWidth,fileHeight,maxWidth,maxHeight,outputType){

	if(maxHeight < fileHeight) var ratioVert = maxHeight / fileHeight;
	else var ratioVert = 1;

	if(maxWidth < fileWidth) var ratioHoriz = maxWidth / fileWidth;
	else var ratioHoriz = 1;

        var ratio = Math.min(ratioVert,ratioHoriz);

        var outputWidth = Math.round(fileWidth * ratio);
        var outputHeight = Math.round(fileHeight * ratio);

        if (ratio == ratioHoriz) var outputURLWidth = '';
        else var outputURLWidth = outputWidth;

	var outputURLHeight = outputHeight;

	if (outputType == 'width') return outputWidth;
	if (outputType == 'height') return outputHeight;
	//if (outputType == 'urlWidth') return outputURLWidth;
	//if (outputType == 'urlHeight') return outputURLHeight;
	else return null;
}


timerLeft="";
timerRight="";

function scrollDivLeft(div){
  clearTimeout(timerRight)
  document.getElementById(div).scrollLeft+=1
  timerRight=setTimeout("scrollDivLeft('"+div+"')",10)
}

function scrollDivRight(div){
  clearTimeout(timerRight)
  document.getElementById(div).scrollLeft-=1
  timerRight=setTimeout("scrollDivRight('"+div+"')",10)
}

function stopMe(){

  clearTimeout(timerRight);
  clearTimeout(timerLeft);
}

