function prepareContent()
{
	/* Load Menu's */
	cmDraw ('cat_menu', categoryMenu, 'hbr', cmThemeMiniBlack);
	cmDraw ('page_menu', pageMenu, 'vbl', cmThemePageMenu);
	
	/* Get All Article Images */
	
	arrDivs = document.getElementsByTagName('div');
	for(var i = 0; i < arrDivs.length; i++)
	{
		if (arrDivs[i].className=='article_icon')
		{
			objImg = document.createElement('img');
			objImg.onclick=showArticlePopup
			objImg.onmouseover=fadeIn;
			objImg.onmouseout=fadeOut;
			objImg.onmouseout();
			objImg.className = arrDivs[i].className;
			objImg.setAttribute('a_id', arrDivs[i].getAttribute('a_id')); 
			objImg.setAttribute('a_title', arrDivs[i].getAttribute('a_title')); 
			objImg.setAttribute('a_img_1', arrDivs[i].getAttribute('a_img_1')); 
			objImg.setAttribute('a_img_2', arrDivs[i].getAttribute('a_img_2')); 
			objImg.setAttribute('a_img_3', arrDivs[i].getAttribute('a_img_3')); 
			objImg.setAttribute('a_img_4', arrDivs[i].getAttribute('a_img_4')); 
			objImg.setAttribute('a_is_active', arrDivs[i].getAttribute('a_is_active')); 
			objImg.setAttribute('a_description', arrDivs[i].innerHTML); 
	
			objImg.src = src="images/articles/"+objImg.getAttribute('a_img_1'); 
//			objImg.src = src="images/articles/200/"+objImg.getAttribute('a_img_1'); 

			objImg.style.width="200px";
			objImg.style.height="200px";
			
			arrDivs[i].parentNode.appendChild(objImg);
			//align="200px" width="200px"	
		
//			arrDivs[i].onmouseout();
		}
	}
	
//	showArticlePopup();
	
}

function smallImg_onclick()
{
	objBigImg.src = this.src;
	
}

function showPdfPopup(pdf_file)
{
	if (typeof pdf_file == 'undefined' || pdf_file.replace(/ /g, '')=='' || pdf_file.match('.pdf')!='.pdf')
	{
		return false;
	}
	
	objDiv = document.createElement('object');
	objDiv.data='images/cats/'+pdf_file;
	objDiv.type='application/pdf';
	objDiv.style.width='100%';
	objDiv.style.height='100%';
	objDiv.style.borderBottom='1px solid black';
	
	//<object data="index.php?view=fwd_pdfWbInvoice&iid=3&pdf=1&module_id=20&pid=20&module_item=20" type="application/pdf" style="width: 98%; height: 500px;z-index: 1">
	createPopupDiv('80%', '95%', 'Pdf Popup', 'big_pdf_popup', objDiv)
}

function showArticlePopup(ev)
{
	if (typeof ev == 'undefined') { ev = event }

/*
	this.getAttribute('a_id'); 
	this.getAttribute('a_title'); 
	this.getAttribute('a_img_1'); 
	this.getAttribute('a_img_2'); 
	this.getAttribute('a_img_3'); 
	this.getAttribute('a_img_4'); 
	this.getAttribute('a_is_active'); 
	this.getAttribute('a_description');
*/
	
	objBigImg = document.createElement('img');
	objBigImg.style.borderRight="1px dashed #C0C0C0";
	objBigImg.style.position = 'absolute';
	objBigImg.style.width="250px";
	objBigImg.style.height="250px";
	objBigImg.style.top="30px";
	objBigImg.style.left="10px";
	objBigImg.src = 'images/articles/'+this.getAttribute('a_img_1');

	objImgA = document.createElement('img');
	objImgA.style.position = 'absolute';
	objImgA.style.width="110px";
	objImgA.style.height="110px";
	objImgA.style.cursor = 'pointer';
	objImgB = objImgA.cloneNode(false);
	objImgC = objImgA.cloneNode(false);
	objImgD = objImgA.cloneNode(false);
	
	objImgA.style.top="30px";
	objImgA.style.left="270px";
	objImgA.src = 'images/articles/'+this.getAttribute('a_img_1');
	objImgA.onclick = smallImg_onclick;

	objImgB.style.top="30px";
	objImgB.style.left="380px";
	objImgB.src = 'images/articles/'+this.getAttribute('a_img_2');
	objImgB.onclick = smallImg_onclick;

	objImgC.style.top="150px";
	objImgC.style.left="270px";
	objImgC.src = 'images/articles/'+this.getAttribute('a_img_3');
	objImgC.onclick = smallImg_onclick;

	objImgD.style.top="150px";
	objImgD.style.left="380px";
	objImgD.src = 'images/articles/'+this.getAttribute('a_img_4');
	objImgD.onclick = smallImg_onclick;
	
	objCommentDiv = document.createElement('div');
	objCommentDiv.style.borderTop="1px dashed #C0C0C0";
	objCommentDiv.style.position = 'absolute';
	objCommentDiv.style.width="480px";
	objCommentDiv.style.height="200px";
	objCommentDiv.style.top="290px";
	objCommentDiv.style.left="10px";
	objCommentDiv.style.overflow="auto";
	objCommentDiv.innerHTML = this.getAttribute('a_description');

	objCommentDivShd = objCommentDiv.cloneNode(true);
	objCommentDivShd.style.color="#C0C0C0";
	objCommentDivShd.style.top="291px";
	objCommentDivShd.style.left="11px";
	objCommentDivShd.style.border="none";


	
	createPopupDiv(500, 500, this.getAttribute('a_title'), 'big_article_popup', new Array(objBigImg, objImgA, objImgB, objImgC, objImgD, objCommentDiv))
}

function fadeIn()
{
	this.setAttribute('opacity', 100);
	this.style.opacity = 1;
	this.style.MozOpacity = 1;
	this.style.KhtmlOpacity = 1;
	this.style.filter = "alpha(opacity=" + 100 + ")";
}
function fadeOut()
{
	this.setAttribute('opacity', 75);
	this.style.opacity = 0.75;
	this.style.MozOpacity = 0.75;
	this.style.KhtmlOpacity = 0.75;
	this.style.filter = "alpha(opacity=" + 75 + ")";
}


function createBlackoutLayer(strId)
{
	
	if( typeof( window.innerWidth ) == 'number' ) 
	{
		window_width = window.innerWidth;
		window_height = window.innerHeight;
	} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) 
	{
		window_width = document.documentElement.clientWidth;
		window_height = document.documentElement.clientHeight;
	} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) 
	{
		window_width = document.body.clientWidth;
		window_height = document.body.clientHeight;
	}
	
	var intHeight = 0;
	var intWidth = 0;
	var intTop = 0;
	var intLeft = 0;
	try	{ intHeight = Math.max(document.body.scrollHeight, document.documentElement.scrollHeight); } catch(e) { intHeight = document.documentElement.scrollHeight; }
	try	{ intWidth = Math.max(document.body.scrollWidth, document.documentElement.scrollWidth);	} catch(e) { intWidth = document.documentElement.scrollWidth; }

	try	{ intTop = Math.max(document.body.scrollTop, document.documentElement.scrollTop); } catch(e) { intHeight = document.documentElement.scrollTop; }
	try	{ intLeft = Math.max(document.body.scrollLeft, document.documentElement.scrollLeft);	} catch(e) { intWidth = document.documentElement.scrollLeft; }

	blackout = document.createElement('div');
	blackout.style.height=intHeight+'px';
	blackout.style.width=intWidth+'px';
	blackout.style.top='0px';
	blackout.style.left='0px';
	blackout.style.position='absolute';
	blackout.style.backgroundColor="black";
	blackout.style.zIndex=11;
	blackout.id = strId+'_blackout';
	var intOpacity = 50
	blackout.style.opacity = (intOpacity / 100);
	blackout.style.MozOpacity = (intOpacity / 100);
	blackout.style.KhtmlOpacity = (intOpacity / 100);
	blackout.style.filter = "alpha(opacity=" + intOpacity + ")";

	document.body.appendChild(blackout);
	doc = {height:intHeight, width:intWidth, top:intTop, left:intLeft};
	win = {height:window_height,width:window_width};
	return {d:doc, w:win};

}
function destroyBlackoutLayer(strId)
{
	document.body.removeChild(document.getElementById(strId+'_blackout'));
}

function is_array(mixVar)
{
	return mixVar instanceof Array
}

function substr_count(strHaystack, strNeedle, intOffset, intLength)
{
	var intHaystackLength = 0;
	try
	{
		if(!(typeof strHaystack == 'string' && strHaystack.length >= 0))
		{
			throw "ERROR_HAYSTACK_NO_STRING";
		} else
		{
			intHaystackLength = strHaystack.length;
		}

		if(!(typeof strNeedle == 'string' && strNeedle.length >= 0))
		{
			throw "ERROR_NEEDLE_NO_STRING";
		}
		if(!(intOffset instanceof Number))
		{
			intOffset = 0
		} else
		{
			if (intOffset > intHaystackLength)
			{
				throw "ERROR_OFFSET_OUT_OF_BOUNDS";
			}
		}

		if(!(intLength instanceof Number))
		{
			intLength = intHaystackLength - intOffset;
		} else
		{
			if (intLength + intOffset > intHaystackLength)
			{
				throw "ERROR_OUT_OF_BOUNDS";
			}
		}

		
	} catch(err)
	{
		switch(err)
		{
			case "ERROR_HAYSTACK_NO_STRING":
				alert('Error in substr_count :: First parameter needs to be a string');
				break;
			case "ERROR_NEEDLE_NO_STRING":
				alert('Error in substr_count :: Second parameter needs to be a string');
				break;
			case "ERROR_OFFSET_OUT_OF_BOUNDS":
				alert('Error in substr_count :: Third parameter is out of bounds');
				break;
			case "ERROR_OUT_OF_BOUNDS":
				alert('Error in substr_count :: Fourth parameter is out of bounds');
				break;
		}
	}
	return (strHaystack.substr(intOffset, intLength).split(strNeedle).length-1);
}

function createPopupDiv(intWidth, intHeight, strTitle, strId, mixContent)
{

try
	{
		x = document.getElementById(strId);
		if (x)
		{
			destroyBlackoutLayer(x.id);
			document.body.removeChild(document.getElementById(x.id+'_shadow'));
			document.body.removeChild(x);
		}
	} catch(e)
	{
		//alert(e.message);
	}

	cDrawArea = createBlackoutLayer(strId);

	try{
		if (intWidth.match('%'))
		{
			intWidth = (cDrawArea.w.width / 100) * parseInt(intWidth);	
		}
	} catch(e)
	{
		// Dont Care
	}
	try{
		if (intHeight.match('%'))
		{
			intHeight = (cDrawArea.w.height / 100) * parseInt(intHeight);
			if(!is_array(mixContent) && mixContent.style.height=='100%')
			{
				mixContent.style.height = intHeight-85 + 'px';
				//mixContent.style.position = 'absolute';
				mixContent.style.marginTop	= '30px';
				
			}	
		}
	} catch(e)
	{
		// Dont Care
	}

	divform_shadow = document.createElement('div');
	divform_shadow.id = strId+'_shadow'
	divform_shadow.style.position='absolute';
	divform_shadow.style.backgroundColor='#000000';
	divform_shadow.style.height=intHeight+'px';
	divform_shadow.style.width=intWidth+'px';
	divform_shadow.style.top=(cDrawArea.d.top + ((cDrawArea.w.height-intHeight)/2) + 10 )+'px';
	divform_shadow.style.left=(cDrawArea.d.left + ((cDrawArea.w.width-intWidth)/2) + 10 )+'px';
	divform_shadow.style.opacity = 0.5;
	divform_shadow.style.MozOpacity = 0.5;
	divform_shadow.style.KhtmlOpacity = 0.5;
	divform_shadow.style.filter = "alpha(opacity=50)";
	divform_shadow.style.zIndex=11;


	divform = document.createElement('div');
	divform.id = strId;
	divform.style.position='absolute';
	divform.style.border='1px solid black';
	divform.style.backgroundColor='white';
	divform.style.height=intHeight+'px';
	divform.style.width=intWidth+'px';
	divform.style.overflow='hidden';
//	divform.style.backgroundColor='bl'
	divform.style.top=cDrawArea.d.top + ((cDrawArea.w.height-intHeight)/2)+'px';
	divform.style.left=cDrawArea.d.left + ((cDrawArea.w.width-intWidth)/2)+'px';
	divform.style.zIndex=11;
	divform.destroy = function()
	{
		destroyBlackoutLayer(this.id);
		document.body.removeChild(document.getElementById(this.id+'_shadow'));
		document.body.removeChild(this);
	}

	titleDiv = document.createElement('div');
	titleDiv.innerHTML = strTitle;
	titleDiv.style.fontFamily='impact';
	titleDiv.style.position='absolute';
	titleDiv.style.fontSize='20px';
	titleDiv.style.left="20px";
	titleDiv.style.top="0px";
	titleDiv.style.letterSpacing="5px"
	titleDiv.style.borderBottom='1px solid #D0D0D0';


	titleDivShdw = titleDiv.cloneNode(true);
	titleDivShdw.style.left = parseInt(titleDivShdw.style.left) + 3 + 'px';
	titleDivShdw.style.top = parseInt(titleDivShdw.style.top) + 3 + 'px';
	titleDivShdw.style.color='#D0D0D0';
	titleDivShdw.style.borderBottom='1px solid #D0D0D0';
	titleDivShdw.style.borderBottom='none';



	closeImg = document.createElement('img');
	closeImg.src="images/sluiten.gif";
	closeImg.id='close_'+strId;
	closeImg.style.width="75px"
	closeImg.style.height="50px"
	closeImg.style.position='absolute';
	closeImg.style.cursor='pointer';
	closeImg.style.left=(intWidth-75) + 'px';
	closeImg.style.top=(intHeight-50) + 'px';
	closeImg.onclick=function()
	{
			destroyBlackoutLayer(strId);
			x = document.getElementById(this.parentNode.id+'_shadow');
			document.body.removeChild(this.parentNode);
			if (x)
			{
				document.body.removeChild(x);
			}
	}
	divform.appendChild(titleDivShdw);
	divform.appendChild(titleDiv);
	if (is_array(mixContent))
	{
		for(key in mixContent)
		{
			try
			{
				divform.appendChild(mixContent[key]);
			} catch(err)
			{
				// Blaat
			}
		}
	} else
	{
			try
			{
				divform.appendChild(mixContent);
			} catch(err)
			{
				// Blaat
			}
	}
	divform.appendChild(closeImg);

	document.body.appendChild(divform_shadow);
	document.body.appendChild(divform);
	
//	document.body.appendChild(divform);

}


function showExternal(link, showInIframe)
{
	if (showInIframe>=1)
	{
		div_iframe = document.getElementById('_iframe');
		div_cat = document.getElementById('_category');
		div_cat.style.display="none";
		//alert(div_iframe.childNodes[0].src);
		div_iframe.childNodes[0].src = link;
		div_iframe.childNodes[0].href = link;
		div_iframe.style.display='';
	}
	
	
}