var strContent;
var blnClose;
var wat;
var strStatus = 'onbekend';
var intPrevMode = -1;
var strAgent = 'IE';

var woei;
var intOpen; //beetje crappy. er zijn andere methoden, maar even snel en dirty. nb, http://blog.reindel.com/src/einstein.html
var numTimeout;
var arrLinksOrg = new Array();

var arrLinks;
var objHelpDiv;
var objHelpText;

function d(strTitle, strGenre, strMedia, strStock, strNjaa, intStatus, strArtikelNR, strEdition, thumbFolder) {
  switch(intStatus) {
    case -1:			
		  strStatus = 'Op = Op';
			break;
		case 0:
		  strStatus = 'Pre-release';
			break;
		case 1:
		  strStatus = 'Bestelbaar';
			break;
		case 2:
		  strStatus = 'Mogelijk langere levertijd';
			break;
		case 3:
		  strStatus = 'Vervallen';
			break;
		case 4:
		  strStatus = 'Uitgesteld';
			break;
		case 10:
		  strStatus = '<font color=red><b>VERVALLEN</b></font>';
	}
	
	strEdition = (strEdition == '')?'-':strEdition;

    blnClose = false;
    strContent = '<table width="100%"  border="0" cellspacing="0" cellpadding="0">';

    if (thumbFolder == 'cd') {
        strContent += '<tr><td class="imgFloatNA"><div class="CDimgFloat" style="background-image: url(Images/cdproductsthumbs/' + strNjaa + '.jpg);background-repeat: no-repeat;"></div></td><td>';
    } else {
        strContent += '<tr><td class="imgFloatNA"><div class="imgFloat" style="background-image: url(Images/ProductThumbs/' + strNjaa + '.jpg);background-repeat: no-repeat;"></div></td><td>';
    }
	strContent += '<table width="100%"  border="0" cellspacing="0" cellpadding="0">';
	strContent += '<tr><td width="80"><b>Titel:</b></td><td>' + strTitle + '</td></tr>';
	strContent += '<tr><td><b>ArtikelNR:</b></td><td>' + strArtikelNR + '</td></tr>';
	strContent += '<tr><td><b>Editie:</b></td><td>' + strEdition + '</td></tr>';
	strContent += '<tr><td><b>Genre:</b></td><td>' + strGenre + '</td></tr>';
	strContent += '<tr><td><b>Media:</b></td><td>' + strMedia + '</td></tr>';
	strContent += '<tr><td><b>Voorraad:</b></td><td>' + strStock + '</td></tr>';
	strContent += '<tr><td><b>Status:</b></td><td>' + strStatus + '</td></tr>';
	strContent += '</table></td></tr>';
	strContent += '</table>';
  return overlib(strContent);
}

function c(het) {
	wat = het;
  blnClose = true;
	setTimeout('doCloseFinal()', 1);
}

function doCloseFinal(wat) {
  if (blnClose == true) {
    return nd(wat);
  }
}

function i(wat) {
  var strOpen = 'popup.aspx?articleID=' + wat;
  objWindow = window.open(strOpen,'bla','resizable=no,scrollbars=yes,status=yes,resizable=yes,width=500,height=500');
  objWindow.focus();
	return void(0);
}

function doDisable(wat) {
  var objDisable = document.getElementById(wat);
	objDisable.enabled = false;
  objDisable.style.color = '#888888';
}

function doFullDisable() {
  var arrButtons = new Array();
	arrButtons = document.getElementsByTagName('input');
	for (i=0; i<arrButtons.length; i++) {
	  if ((arrButtons[i].type.toLowerCase() == 'submit') || (arrButtons[i].type.toLowerCase() == 'button')){
	    arrButtons[i].enabled = false;
		  arrButtons[i].style.color = '#888888';
	  }
	}
}

function op(inID, strSecCode, intModus) {
	
	var strOpen = 'popupimage.aspx?productcode=' + inID + '&SecCode=' + strSecCode + '&type=' + intModus;
	var intWidth = 390;
	var intHeight = 590;
	
	if (intPrevMode == -1) {
	  intPrevMode = intModus;
	} else {
	  if (intPrevMode !== intModus) {
		  try {
			  objOpen.close();
			} catch(er) {
			}
		}
	}
	
	intPrevMode = intModus;
	
	if (intModus == 1) {
	  intWidth = 700;
		intHeight = 505;
 	}
	
	var strArguments = 'status=yes,scrollbars=yes,resizable=yes,width=' + intWidth + ',height=' + intHeight;
  objOpen = window.open(strOpen,'njaa',strArguments);
	objOpen.focus();
}

if (navigator.userAgent.toLowerCase().indexOf('msie') == -1) {
  strAgent = 'MOZ';
}

function getField(fldName, strType) {
  var arrCheck = new Array;
  var blnFound = false;
  arrObjects = document.getElementsByTagName(strType.toUpperCase());

  for (x=0; x<arrObjects.length; x++) {
    if (arrObjects[x].id.split("_")[arrObjects[x].id.split("_").length - 1] == fldName) {
      blnFound = true;
      break;
    }
  }
	
  return arrObjects[x];
}

function handleGridUp(e) {
	if (!e) var e = window.event
	if (e.keyCode) code = e.keyCode;
	else if (e.which) code = e.which;
	
	if (code==13) {
	  getField('btnLogin','input').focus();
	}
}


function killHelp() {
	var re = /\<\!--\#start--\>[\s\S]*?\<!--\#end--\>/i;
	document.body.innerHTML = document.body.innerHTML.replace(re, "");
}

function checkOpen() {
	if (woei == null) {
		document.body.innerHTML += ' \
		<!--#start--> \
		<div id="popLayer1" onclick="killHelp();">&nbsp;</div> \
		<div id="popLayer2"> \
			<iframe frameborder="none" id="framePopup" src="' + arrLinksOrg[intOpen] + '"></iframe> \
		</div> \
		<!--#end-->'
		;
	}
}

function shopHelpDiv() {
  document.getElementById('helptext').style.display = 'inline'; 
	objHelpDiv.style.backgroundImage = 'url(images/help_show.gif)';
}

function hideHelpDiv() {
  document.getElementById('helptext').style.display = 'none';  
	objHelpDiv.style.backgroundImage = 'url(images/help.gif)';
}
	
function Page_Load() {
  arrLinks = document.getElementsByTagName('A');
  objHelpDiv = document.getElementById('help');
  objHelpText = document.getElementById('helptext');
	
	if (objHelpDiv && objHelpDiv !== null) {
  	objHelpDiv.onclick = function() {
      objHelpDiv.style.backgroundImage = 'url(images/help_hint.gif)';
			clearTimeout(numTimeout);
    	shopHelpDiv();
		}
		
		objHelpDiv.onmouseover = function() {
			if (objHelpDiv.style.backgroundImage != 'url(images/help_hint.gif)') {
   			if (objHelpDiv.style.backgroundImage != 'url(images/help_show.gif)') { 
          objHelpDiv.style.backgroundImage = 'url(images/help_hint.gif)';
				}
			}
			clearTimeout(numTimeout);
 			numTimeout = setTimeout(shopHelpDiv, 1000);
		}

    objHelpDiv.onmouseout = function() {
			clearTimeout(numTimeout);
			numTimeout = setTimeout(hideHelpDiv, 500);
		}
	}
	
	if (objHelpText && objHelpText !== null) {
    objHelpText.onmouseover = function() {
			clearTimeout(numTimeout);
 			numTimeout = setTimeout(shopHelpDiv, 1000);
		}
    objHelpText.onmouseout = function() {
			clearTimeout(numTimeout);
			numTimeout = setTimeout(hideHelpDiv, 500);
		}
	}
	
	
	var objLink;
	
	for (x=0; x<arrLinks.length; x++) {
		objLink = arrLinks[x];
		arrLinksOrg[x] = objLink.href;
		if (objLink.href.indexOf('help.aspx') !== -1) {
			objLink.href='javascript:intOpen=' + x + ';woei=window.open(\'' + objLink.href + '\',\'njaa\',\'width=450,height=500\');setTimeout(\'checkOpen()\',1);void(null);';
		}
	}
}


if(document.getElementById && document.createTextNode){
	window.onload=function() { Page_Load(); }
}
