var browserV=navigator.appName;

//generate div with image for portofolio and cases
function productDetailsDiv(imageSrc, imageDescription, currentImage, imageCount, nextImageSrc)
{
	blockObj();
	var smallDiv = document.getElementById('smallDivId');
	
	smallDiv.innerHTML = '';		
	
	var oHiddenDiv = document.createElement('div');
	oHiddenDiv.style.paddingLeft = '110px';
	oHiddenDiv.style.display = 'none';
	oHiddenDiv.id = 'hiddenDivId';		
	
	var prevImage = document.createElement('img');
	prevImage.src = 'http://www.businesscommunication.nl/images/prev.jpg';
	
	var nextImage = document.createElement('img');
	nextImage.src = 'http://www.businesscommunication.nl/images/next.jpg';
	
	var closeImage = document.createElement('img');
	closeImage.src = 'http://www.businesscommunication.nl/images/close.jpg';
	
	var oDivLinks = document.createElement('div');
	
	var oPreviousLink = document.createElement('a');
	oPreviousLink.appendChild(prevImage);
	oPreviousLink.onmouseover = function()
								{
									oPreviousLink.title = 'Previous';
								}
	oPreviousLink.style.cursor = "pointer";
	oPreviousLink.style.marginLeft = "105px";
	oPreviousLink.style.marginTop = "10px";
	oPreviousLink.id = "prevLink";
	
	oPreviousLink.onclick = function()
						{
							oNextLink.style.display = 'inline';							
							oPreviousLink.style.disabled = '';
							oPreviousLink.style.cursor = "pointer";
									
							var bRet = false;
							
							for(var i = 0; i < projectAlbum.length; i++)
							{								
								var src = 'http://www.businesscommunication.nl/' + projectAlbum[i].src;
								
								if(src == document.getElementById('currentImageId').src)
								{									
									var pos = i;
									bRet = true;
								}
							}

							if(bRet == true)
							{
								var prevPos = pos - 1;

								if(prevPos >= 0)
								{
									document.getElementById('currentImageId').src = 'http://www.businesscommunication.nl/' + projectAlbum[prevPos].src;
									currentImage2 = prevPos + 1;
									oCount.innerHTML = 'Image ' + currentImage2 + ' of ' + imageCount;
								}

								if(prevPos == 0)
								{
									oPreviousLink.style.disabled = 'disabled';							
								}
							}							
						};
						
	var oImage = document.createElement('img');
	oImage.src = imageSrc;
	oImage.style.marginLeft = '150px';
	oImage.style.marginTop = '25px';
	oImage.id = 'currentImageId';
	
	var oNextLink = document.createElement('a');
	oNextLink.appendChild(nextImage);
	oNextLink.onmouseover = function()
							{
								oNextLink.title = 'Next';
							};
	oNextLink.style.cursor = "pointer";
	
	oNextLink.style.paddingLeft = (oImage.width / 2) - 50;
	oNextLink.style.paddingRight = "5px";
	oNextLink.id = "nextLink";
	oNextLink.onclick = function()
						{
							oPreviousLink.style.display = 'inline';
							oNextLink.style.disabled = '';
							oNextLink.style.cursor = "pointer";
							
							var bRet = false;
							
							for(var i = 0; i < projectAlbum.length; i++)
							{
								var j = i + 1;
								var src = 'http://www.businesscommunication.nl/' + projectAlbum[i].src;
							
								if(src == document.getElementById('currentImageId').src)	
								{
									var pos = i;
									bRet = true;
								}
							}						

							if(bRet == true)
							{
								var nextPos = pos + 1;

								if(nextPos < projectAlbum.length)
								{
									document.getElementById('currentImageId').src = 'http://www.businesscommunication.nl/' + projectAlbum[nextPos].src;
									currentImage1 = nextPos + 1;
									oCount.innerHTML = 'Image ' + currentImage1 + ' of ' + imageCount;
								}

								if(nextPos >= parseInt(projectAlbum.length - 1))
								{
									oNextLink.style.disabled = 'disabled';																	
								}
							}
						};

	var oDescription = document.createElement('p');
	oDescription.innerHTML = imageDescription;
	oDescription.style.marginLeft = '10px';
	oDescription.style.textAlign = 'justify';
	oDescription.style.fontSize = '8pt';
	oDescription.style.fontFamily = 'Arial';

	var oClose = document.createElement('<a>');
	oClose.appendChild(closeImage);
	oClose.onmouseover = function()
						{
							oClose.title = 'Close';
						}
	oClose.style.cursor = 'pointer';
	oClose.style.marginLeft = oImage.width / 2 + 150;
	oClose.onclick = function()
					{						
						document.getElementById('smallDivId').style.visibility = 'hidden';
						deblockObj();
					};

	var oHidden = document.createElement('input');
	oHidden.type = 'hidden';
	oHidden.value = imageSrc;
	oHidden.name = 'currentImageHidden';

	var oCount = document.createElement('font');
	oCount.innerHTML = 'Image ' + currentImage + ' of ' + imageCount;	
	oCount.style.marginLeft = parseInt((oImage.width / 2) - 10) + "px";	
	oCount.style.fontSize = '8pt';
	oCount.style.fontFamily = 'Arial';

	oDivLinks.appendChild(oImage);
	oDivLinks.appendChild(document.createElement('<br>'));
	oDivLinks.appendChild(document.createElement('<br>'));

	var oTableBig = document.createElement('table');
	oTableBig.style.align = "center";

	var oTable = document.createElement('tbody');
	var oTableTr = document.createElement('tr');
	
	//first td
	var oTableTd_prev = document.createElement('td');
	oTableTd_prev.appendChild(oPreviousLink);
	
	//seccond td
	var oTableTd_count = document.createElement('td');
	oTableTd_count.style.verticalAlign = 'middle';
	oTableTd_count.appendChild(oCount);
	
	//3-RD TD
	var oTableTd_next = document.createElement('td');
	oTableTd_next.style.paddingRight = "50px";
	oTableTd_next.appendChild(oNextLink);
	
	oTableTr.appendChild(oTableTd_prev);
	oTableTr.appendChild(oTableTd_count);
	oTableTr.appendChild(oTableTd_next);
	oTable.appendChild(oTableTr);
	oTableBig.appendChild(oTable);
	
	oDivLinks.appendChild(oTableBig);
	//oDivLinks.appendChild(oNextLink);
	oDivLinks.appendChild(oHiddenDiv);

	smallDiv.appendChild(oDivLinks);
	smallDiv.appendChild(document.createElement('<br>'));
	smallDiv.appendChild(oDescription);

	smallDiv.appendChild(oClose);
	smallDiv.appendChild(document.createElement('<br>'));
	smallDiv.appendChild(document.createElement('<br>'));
	
	smallDiv.appendChild(oHidden);				
		
	new Effect.BlindDown(document.getElementById('smallDivId'), {duration:1});		
	
	smallDiv.style.width = (document.getElementById('currentImageId').width + 300 );
	
	if (browserV.indexOf("Netscape") >= 0)
		smallDiv.style.height = parseInt(document.getElementById('currentImageId').height + 200) + "px";
		
	if (browserV.indexOf("Microsoft") >= 0)
		smallDiv.style.height = document.getElementById('currentImageId').height + "px";
	
	
	smallDiv.style.visibility = 'visible';		
	
	setSmallDivSize(smallDiv);
}

//generate div with image for pages
function pageDetailsDiv(imageSrc, imageDescription, currentImage, imageCount, nextImageSrc)
{
	blockObj();
	var smallDiv = document.getElementById('smallDivId');
	
	smallDiv.innerHTML = '';		
	
	var oHiddenDiv = document.createElement('div');
	oHiddenDiv.style.paddingLeft = '110px';
	oHiddenDiv.style.display = 'none';
	oHiddenDiv.id = 'hiddenDivId';
	
	var oCount = document.createElement('p');
	oCount.innerHTML = 'Image ' + currentImage + ' of ' + imageCount;
	oCount.style.marginLeft = '10px';
	oCount.style.textAlign = 'justify';
	oCount.style.fontSize = '8pt';
	oCount.style.fontFamily = 'Arial';
	
	var oDivLinks = document.createElement('div');
	
	var oPreviousLink = document.createElement('a');
	oPreviousLink.innerHTML = "[Prev]";
	oPreviousLink.style.cursor = 'pointer';
	oPreviousLink.style.marginLeft = "105px";
	oPreviousLink.style.marginTop = "10px";
	oPreviousLink.id = "prevLink";
	
	oPreviousLink.onclick = function()
						{
							oNextLink.style.display = 'inline';
							oHiddenDiv.innerHTML = '';
							oHiddenDiv.style.display = 'none';
							
							var bRet = false;
							
							for(var i = 0; i < pageAlbum.length; i++)
							{								
								var src = 'http://www.businesscommunication.nl/' + pageAlbum[i].src;
								
								if(src == document.getElementById('currentImageId').src)
								{									
									var pos = i;
									bRet = true;
								}
							}
						
						
							if(bRet == true)
							{
								var prevPos = pos - 1;

								if(prevPos >= 0)
								{
									document.getElementById('currentImageId').src = 'http://www.businesscommunication.nl/' + pageAlbum[prevPos].src;
									currentImage2 = prevPos + 1;
									oCount.innerHTML = 'Image ' + currentImage2 + ' of ' + imageCount;
								}

								if(prevPos == 0)
								{
									oPreviousLink.style.display = 'none';
									oNextLink.style.paddingLeft = oImage.width + 150;
								}
							}							
						};
						
	var oImage = document.createElement('img');
	oImage.src = imageSrc;
	oImage.style.marginLeft = '150px';
	oImage.style.marginTop = '25px';
	oImage.id = 'currentImageId';
	
	var oNextLink = document.createElement('a');
	oNextLink.innerHTML = "[Next]";
	oNextLink.style.cursor = 'pointer';
	oNextLink.style.paddingLeft = oImage.width + 20;
	oNextLink.style.paddingRight = "5px";
	oNextLink.id = "nextLink";
	oNextLink.onclick = function()
						{
							oPreviousLink.style.display = 'inline';

							var bRet = false;							
							
							for(var i = 0; i < pageAlbum.length; i++)
							{
								var j = i + 1;
								var src = 'http://www.businesscommunication.nl/' + pageAlbum[i].src;								
							
								if(src == document.getElementById('currentImageId').src)	
								{
									var pos = i;
									bRet = true;
								}
							}
						
							
							if(bRet == true)
							{
								var nextPos = pos + 1;

								if(nextPos < pageAlbum.length)
								{
									document.getElementById('currentImageId').src = 'http://www.businesscommunication.nl/' + pageAlbum[nextPos].src;
									currentImage1 = nextPos + 1;
									oCount.innerHTML = 'Image ' + currentImage1 + ' of ' + imageCount;
								}
									
								if(nextPos >= parseInt(pageAlbum.length - 1))
								{									
									oNextLink.style.display = 'none';
									oHiddenDiv.style.display = 'inline';
								}
							}							
						};						
							
	var oDescription = document.createElement('p');
	oDescription.innerHTML = imageDescription;
	oDescription.style.marginLeft = '10px';
	oDescription.style.textAlign = 'justify';
	oDescription.style.fontSize = '8pt';
	oDescription.style.fontFamily = 'Arial';		
	
	var oClose = document.createElement('<a>');
	oClose.innerHTML = '[close] x';
	oClose.style.cursor = 'pointer';
	oClose.style.marginLeft = oImage.width + 150;
	oClose.onclick = function()
					{						
						document.getElementById('smallDivId').style.visibility = 'hidden';
						deblockObj();
					};
					
	var oHidden = document.createElement('input');
	oHidden.type = 'hidden';
	oHidden.value = imageSrc;
	oHidden.name = 'currentImageHidden';
			
	oDivLinks.appendChild(oImage);
	oDivLinks.appendChild(document.createElement('<br>'));
	oDivLinks.appendChild(document.createElement('<br>'));
	oDivLinks.appendChild(oPreviousLink);
	oDivLinks.appendChild(oNextLink);
	oDivLinks.appendChild(oHiddenDiv);
																												
	smallDiv.appendChild(oDivLinks);
	smallDiv.appendChild(document.createElement('<br>'));
	smallDiv.appendChild(oDescription);
	
	smallDiv.appendChild(document.createElement('<br>'));
	smallDiv.appendChild(oCount);
	smallDiv.appendChild(document.createElement('<br>'));
	
	smallDiv.appendChild(oClose);
	smallDiv.appendChild(document.createElement('<br>'));
	smallDiv.appendChild(document.createElement('<br>'));
	
	smallDiv.appendChild(oHidden);				
		
	new Effect.BlindDown(document.getElementById('smallDivId'), {duration:1});
	
	smallDiv.style.visibility = 'visible';
	
	smallDiv.style.width = (document.getElementById('currentImageId').width + 300 );
	if (browserV.indexOf("Netscape") >= 0)
		smallDiv.style.height = parseInt(document.getElementById('currentImageId').height + 200) + "px";
		
	if (browserV.indexOf("Microsoft") >= 0)
		smallDiv.style.height = document.getElementById('currentImageId').height + "px";
	
	setSmallDivSizePage(smallDiv);
}

//generate div with image for news
function newsDetailsDiv(imageSrc, imageDescription, currentImage, imageCount, nextImageSrc)
{
	blockObj();
	var smallDiv = document.getElementById('smallDivId');
	
	smallDiv.innerHTML = '';		
	
	var oHiddenDiv = document.createElement('div');
	oHiddenDiv.style.paddingLeft = '110px';
	oHiddenDiv.style.display = 'none';
	oHiddenDiv.id = 'hiddenDivId';
	
	var oCount = document.createElement('p');
	oCount.innerHTML = 'Image ' + currentImage + ' of ' + imageCount;
	oCount.style.marginLeft = '10px';
	oCount.style.textAlign = 'justify';
	oCount.style.fontSize = '8pt';
	oCount.style.fontFamily = 'Arial';
	
	var oDivLinks = document.createElement('div');
	
	var oPreviousLink = document.createElement('a');
	oPreviousLink.innerHTML = "[Prev]";
	oPreviousLink.style.cursor = 'pointer';
	oPreviousLink.style.marginLeft = "105px";
	oPreviousLink.style.marginTop = "10px";
	oPreviousLink.id = "prevLink";
	
	oPreviousLink.onclick = function()
						{
							oNextLink.style.display = 'inline';
							oHiddenDiv.innerHTML = '';
							oHiddenDiv.style.display = 'none';
							
							var bRet = false;
							
							if(newsAlbumJs.length > 0)
							{
								for(var i = 0; i < newsAlbumJs.length; i++)
								{								
									var src = 'http://www.businesscommunication.nl/' + newsAlbumJs[i].src;
									
									if(src == document.getElementById('currentImageId').src)
									{									
										var pos = i;
										bRet = true;
									}
								}
								
								if(bRet == true)
								{
									var prevPos = pos - 1;
	
									if(prevPos >= 0)
									{
										document.getElementById('currentImageId').src = 'http://www.businesscommunication.nl/' + newsAlbumJs[prevPos].src;
										currentImage2 = prevPos + 1;
										oCount.innerHTML = 'Image ' + currentImage2 + ' of ' + imageCount;
									}
	
									if(prevPos == 0)
									{
										oPreviousLink.style.display = 'none';
										oNextLink.style.paddingLeft = oImage.width + 150;
									}
								}
							}
						};
						
	var oImage = document.createElement('img');
	oImage.src = imageSrc;
	oImage.style.marginLeft = '150px';
	oImage.style.marginTop = '25px';
	oImage.id = 'currentImageId';
	
	var oNextLink = document.createElement('a');
	oNextLink.innerHTML = "[Next]";
	oNextLink.style.cursor = "pointer";
	oNextLink.style.paddingLeft = oImage.width + 20;
	oNextLink.style.paddingRight = "5px";
	oNextLink.id = "nextLink";
	oNextLink.onclick = function()
						{
							oPreviousLink.style.display = 'inline';
							
							var bRet = false;
							
							if(newsAlbumJs.length > 0)
							{
								for(var i = 0; i < newsAlbumJs.length; i++)
								{
									var j = i + 1;
									var src = 'http://www.businesscommunication.nl/' + newsAlbumJs[i].src;								
									
									if(src == document.getElementById('currentImageId').src)
									{
										var pos = i;
										bRet = true;
									}
								}
								
								if(bRet == true)
								{
									var nextPos = pos + 1;
	
									if(nextPos < newsAlbumJs.length)
									{
										document.getElementById('currentImageId').src = 'http://www.businesscommunication.nl/' + newsAlbumJs[nextPos].src;
										currentImage1 = nextPos + 1;
										oCount.innerHTML = 'Image ' + currentImage1 + ' of ' + imageCount;
									}
									
									if(nextPos >= parseInt(newsAlbumJs.length - 1))
									{									
										oNextLink.style.display = 'none';
										oHiddenDiv.style.display = 'inline';
									}
								}
							}
						};
							
	var oDescription = document.createElement('p');
	oDescription.innerHTML = imageDescription;
	oDescription.style.marginLeft = '10px';
	oDescription.style.textAlign = 'justify';
	oDescription.style.fontSize = '8pt';
	oDescription.style.fontFamily = 'Arial';
	
	var oClose = document.createElement('<a>');
	oClose.innerHTML = '[close] x';
	oClose.style.cursor = 'pointer';
	oClose.style.marginLeft = oImage.width + 160;
	oClose.onclick = function()
					{						
						document.getElementById('smallDivId').style.visibility = 'hidden';
						deblockObj();
					};
					
	var oHidden = document.createElement('input');
	oHidden.type = 'hidden';
	oHidden.value = imageSrc;
	oHidden.name = 'currentImageHidden';
			
	oDivLinks.appendChild(oImage);
	oDivLinks.appendChild(document.createElement('<br>'));
	oDivLinks.appendChild(document.createElement('<br>'));
	oDivLinks.appendChild(oPreviousLink);
	oDivLinks.appendChild(oNextLink);
	oDivLinks.appendChild(oHiddenDiv);

	smallDiv.appendChild(oDivLinks);
	smallDiv.appendChild(document.createElement('<br>'));
	smallDiv.appendChild(oDescription);
	
	smallDiv.appendChild(document.createElement('<br>'));
	smallDiv.appendChild(oCount);
	
	smallDiv.appendChild(oClose);
	smallDiv.appendChild(document.createElement('<br>'));
	smallDiv.appendChild(document.createElement('<br>'));
	
	smallDiv.appendChild(oHidden);
		
	new Effect.BlindDown(document.getElementById('smallDivId'), {duration:1});
	
	smallDiv.style.visibility = 'visible';
	
	smallDiv.style.width = (document.getElementById('currentImageId').width + 300 );
	if (browserV.indexOf("Netscape") >= 0)
		smallDiv.style.height = parseInt(document.getElementById('currentImageId').height + 200) + "px";
		
	if (browserV.indexOf("Microsoft") >= 0)
		smallDiv.style.height = document.getElementById('currentImageId').height + "px";
	
	setSmallDivSizeNews(smallDiv);
}

function setSmallDivSize(imageDivId)
{	
	var bigDivHeight = 0;
	var smallDivHeight = imageDivId.style.height ;
	var top = 0;
	
	smallDivHeight = smallDivHeight.substring(0, smallDivHeight.length - 2);
	
	if (browserV.indexOf("Microsoft") >= 0)
	{				
		bigDivHeight = document.getElementById('bigDiv').clientHeight;
		
		if(smallDivHeight < 100)
			top = (bigDivHeight - smallDivHeight) - 600;
		else
			top = ( (bigDivHeight - smallDivHeight) + 800) / 2;
	}
	
	if (browserV.indexOf("Netscape") >= 0)
	{
		bigDivHeight = document.getElementById('bigDiv').offsetHeight;

		if((document.getElementById('currentImageId').height) < 100)
			top = (bigDivHeight - smallDivHeight) + 500;
		else
			top = (bigDivHeight - smallDivHeight) + 990;
	}

	imageDivId.style.left = '250px';
	imageDivId.style.top = top + 'px';
	
	imageDivId.style.position = 'absolute';
}

function setSmallDivSizeNews(imageDivId)
{
	var bigDivHeight = 0;
	var smallDivHeight = imageDivId.style.height ;
	var top = 0;
	
	smallDivHeight = smallDivHeight.substring(0, smallDivHeight.length - 2);
	
	if (browserV.indexOf("Microsoft") >= 0)
	{				
		bigDivHeight = document.getElementById('bigDiv').clientHeight;
				
		top = (bigDivHeight - smallDivHeight) / 2;
	}
	
	if (browserV.indexOf("Netscape") >= 0)
	{
		bigDivHeight = document.getElementById('bigDiv').offsetHeight;

		top = (bigDivHeight - smallDivHeight) / 2;		
	}

	imageDivId.style.left = '250px';
	imageDivId.style.top = top + 'px';
	
	imageDivId.style.position = 'absolute';
}

function setSmallDivSizePage(imageDivId)
{
	var bigDivHeight = 0;
	var smallDivHeight = imageDivId.style.height ;
	var top = 0;
	
	smallDivHeight = smallDivHeight.substring(0, smallDivHeight.length - 2);
	
	if (browserV.indexOf("Microsoft") >= 0)
	{				
		bigDivHeight = document.getElementById('bigDiv').clientHeight;
				
		top = ((bigDivHeight - smallDivHeight) - 500 ) / 2;
	}
	
	if (browserV.indexOf("Netscape") >= 0)
	{
		bigDivHeight = document.getElementById('bigDiv').offsetHeight;

		top = ((bigDivHeight - smallDivHeight))/ 2;		
	}

	imageDivId.style.left = '250px';
	imageDivId.style.top = top + 'px';
	
	imageDivId.style.position = 'absolute';
}

function closeDiv(divId)
{	
	setBigDivOpacity(document.getElementById('bigDiv'), 0);
	document.getElementById(divId).style.visibility = 'hidden';	
}

function blockObj()
{	
	if(document.getElementById('_blocked_'))
		document.body.removeChild(document.getElementById('_blocked_'));
	
	if(!document.getElementById('_blocked_'))
	{
		var o = document.createElement("div");                        
		o.id = '_blocked_';
		
		if (browserV.indexOf("Microsoft") >= 0)
		{
			o.style.height = document.getElementById('bigDiv').clientHeight;
			o.style.width = document.getElementById('bigDiv').clientWidth;
		}
		
		if (browserV.indexOf("Netscape") >= 0)
		{
			o.style.height = "2471px";
			o.style.width = "1299px";
		}
        
		o.innerHTML = '';
        
		document.body.appendChild(o);                
    }
    
    if(document.getElementById('_blocked_'))
    {		
		if (browserV.indexOf("Microsoft") >= 0)
		{
			o.style.height = document.getElementById('bigDiv').clientHeight;
			o.style.width = document.getElementById('bigDiv').clientWidth;
		}
		
		if (browserV.indexOf("Netscape") >= 0)
		{
			o.style.height = "2471px";
			o.style.width = "1299px";
		}
		
		o.className = 'blockedDiv';
	}
}

function deblockObj()
{
    document.getElementById('_blocked_').style.display = 'none';
}