<!--
var portfolioMenuClickSet = false;
var portfolioImageClickSet = false;
var portfolioTextClickSet = false;
var normalTextClickSet = false;
var arrowAlwaysVisible;
var portfolioMenuUpState = 0;
var portfolioMenuDownState = 0;
var portfolioImageUpState = 0;
var portfolioImageDownState = 0;
var portfolioTextUpState = 0;
var portfolioTextDownState = 0;
var normalTextUpState = 0;
var normalTextDownState = 0;
var isTablet = false;
var imagePositions = '';

function startPage(arrowState) {
	var bName = Browser.Platform.name.toLowerCase();
	if (bName == 'android' || bName == 'ios' || bName == 'webos' || bName == 'blackberry') isTablet = true;
	arrowAlwaysVisible = arrowState;
	var winLoc = String(window.location);
	if (winLoc.indexOf('#') > 0) {
		var protocol = String(window.location.protocol) + '//';
		var host = String(window.location.hostname);
		var url = winLoc.split('#');
		var newUrl = protocol + host + url[1];
		document.location.href = newUrl;
		return;
	}
	
	initCurriculum();
	initFTP();
	changeSize();
	window.addEvent('resize', function() { 
		changeSize();
	});
}

function initImageScroller() {
	imagePositions = '';
	var imageList = $$('#portfolioImageContentScroller img');
	var plusY = $('portfolioImageContentScroller').getPosition('#wrapper').y;
	imageList.each(function(pImage, i) {
		var position = pImage.getPosition('#portfolioImageContentScroller');
		if (i > 0) imagePositions += ',';
		imagePositions += 0 - (position.y - plusY);
	});
}

function changeSize() {
	var size = window.getSize();
	var winHeight = size.y.toInt();
	var divHeight, containerHeight, minY, currentY, position;
	
	if ($('portfolioTextContent')) {
		containerHeight = winHeight - 553;
		$('portfolioTextContent').setStyle('height', containerHeight);
		divHeight = $('portfolioTextContentScroller').getStyle('height').toInt();
		minY = containerHeight - divHeight
		position = $('portfolioTextContentScroller').getPosition($('portfolioTextContent'));
		currentY = position.y.toInt();
		if (currentY < minY) currentY = minY;
		if (currentY > 0) currentY = 0;
		portfolioTextUpState = (currentY == 0) ? 0 : 1;
		portfolioTextDownState = (currentY <= minY) ? 0 : 1;
		if (($('portfolioText').getStyle('visibility') == 'visible') && (portfolioTextUpState == 1 || portfolioTextDownState == 1)) {
			$('portfolioTextUp').setStyle('visibility', 'visible');
			$('portfolioTextDown').setStyle('visibility', 'visible');
		} else {
			$('portfolioTextUp').setStyle('visibility', 'hidden');
			$('portfolioTextDown').setStyle('visibility', 'hidden');
		}
		if (divHeight > containerHeight) initPortfolioTextScroller();
	}

	if ($('portfolioMenuContent')) {
		containerHeight = winHeight - 322;
		$('portfolioMenuContent').setStyle('height', containerHeight);
		divHeight = $('portfolioMenuContentScroller').getStyle('height').toInt();
		minY = containerHeight - divHeight
		position = $('portfolioMenuContentScroller').getPosition($('portfolioMenuContent'));
		currentY = position.y.toInt();
		if (currentY < minY) currentY = minY;
		if (currentY > 0) currentY = 0;
		$('portfolioMenuUp').setStyle('visibility', (currentY == 0 && arrowAlwaysVisible == 0) ? 'hidden' : 'visible');
		$('portfolioMenuDown').setStyle('visibility', (currentY <= minY && arrowAlwaysVisible == 0) ? 'hidden' : 'visible');
		portfolioMenuUpState = (currentY == 0) ? 0 : 1;
		portfolioMenuDownState = (currentY <= minY) ? 0 : 1;
		if (divHeight > containerHeight) initPortfolioMenuScroller();
	}
	
	if ($('portfolioImageContent')) {
		containerHeight = winHeight - 261;
		$('portfolioImageContent').setStyle('height', containerHeight);
		divHeight = $('portfolioImageContentScroller').getStyle('height').toInt();
		minY = containerHeight - divHeight
		position = $('portfolioImageContentScroller').getPosition($('portfolioImageContent'));
		currentY = position.y.toInt();
		if (currentY < minY) currentY = minY;
		if (currentY > 0) currentY = 0;
		$('portfolioImageUp').setStyle('visibility', (currentY == 0 && arrowAlwaysVisible == 0) ? 'hidden' : 'visible');
		$('portfolioImageDown').setStyle('visibility', (currentY <= minY && arrowAlwaysVisible == 0) ? 'hidden' : 'visible');
		portfolioImageUpState = (currentY == 0) ? 0 : 1;
		portfolioImageDownState = (currentY <= minY) ? 0 : 1;
		if (divHeight > containerHeight) {
			initPortfolioImageScroller();
			initImageScroller();
		}
	}
	
	if ($('normalTextContent')) {
		if ($('userInfo')) {
			containerHeight = winHeight - 264;
		} else {
			containerHeight = winHeight - 238;
		}
		$('normalTextContent').setStyle('height', containerHeight);
		divHeight = $('normalTextContentScroller').getStyle('height').toInt();
		minY = containerHeight - divHeight
		position = $('normalTextContentScroller').getPosition($('normalTextContent'));
		currentY = position.y.toInt();
		if (currentY < minY) currentY = minY;
		if (currentY > 0) currentY = 0;
		normalTextUpState = (currentY == 0) ? 0 : 1;
		normalTextDownState = (currentY <= minY) ? 0 : 1;
		if (normalTextUpState == 1 || normalTextDownState == 1) {
			$('normalTextUp').setStyle('visibility', 'visible');
			$('normalTextDown').setStyle('visibility', 'visible');
		} else {
			$('normalTextUp').setStyle('visibility', 'hidden');
			$('normalTextDown').setStyle('visibility', 'hidden');
		}
		if (divHeight > containerHeight) initNormalTextScroller();
	}
	
}

function hoverScrollInfo(state) {
	if (state == 0) {
		$('infoLink').removeClass('active');	
	} else {
		$('infoLink').addClass('active');	
	}
}

function changeInfoText(lid) {
	var req = new Request({
		url: '/includes/ajax.asp?script=setPortfolioText',
		onSuccess: function(txt) {
			var result = txt.split('###|||###');
			var newState = result[0].toInt();
			var altText = trim(result[1]);
			linkButton = (newState == 0) ? 'Up' : 'Down';
			$('infoImage').src = 'images/btn' + linkButton + '.png';
			var Tween1 = new Fx.Tween($('portfolioText'), {
				duration: 250,
				property: 'opacity',
				onComplete: function() {
					if (newState == 1) changeSize();	
				}
			});
			Tween1.start(newState);
		}
	}).send();
	return false;
}

function initPortfolioMenuScroller() {
	if (portfolioMenuClickSet == true) return;
	portfolioMenuClickSet = true;
	var scrollStep, containerHeight, divHeight, currentY, direction, minY, position, newY, diffY, isBusy, newTween;
	$$('#menuProjecten .scroll').each(function(el) {
		
		el.addEvent('click', function(event) {
			if ((el.id.indexOf('Up') > 0 && portfolioMenuUpState == 1) || (el.id.indexOf('Down') > 0 && portfolioMenuDownState == 1)) {
				direction = (el.id.indexOf('Up') > 0) ? 1 : -1;
				containerHeight = $('portfolioMenuContent').getStyle('height').toInt();
				scrollStep = (containerHeight / 1.5).toInt();
				divHeight = $('portfolioMenuContentScroller').getStyle('height').toInt();
				minY = containerHeight - divHeight
				position = $('portfolioMenuContentScroller').getPosition($('portfolioMenuContent'));
				currentY = position.y.toInt();
				$('portfolioMenuContentScroller').setStyle('top', currentY);
				currentY += scrollStep * direction;
				if (currentY < minY) currentY = minY;
				if (currentY > 0) currentY = 0;
				newTween = new Fx.Tween($('portfolioMenuContentScroller'), {
					duration: 600,
					property: 'top',
					transition: Fx.Transitions.Quad.easeOut
				});
				newTween.start(currentY);
				$('portfolioMenuUp').setStyle('visibility', (currentY == 0 && arrowAlwaysVisible == 0) ? 'hidden' : 'visible');
				$('portfolioMenuDown').setStyle('visibility', (currentY <= minY && arrowAlwaysVisible == 0) ? 'hidden' : 'visible');
				portfolioMenuUpState = (currentY == 0) ? 0 : 1;
				portfolioMenuDownState = (currentY <= minY) ? 0 : 1;
			}
		})
		
		if (isTablet == false) {
		
			el.addEvent('mouseenter', function(event) {
				if ((el.id.indexOf('Up') > 0 && portfolioMenuUpState == 1) || (el.id.indexOf('Down') > 0 && portfolioMenuDownState == 1)) {
					containerHeight = $('portfolioMenuContent').getStyle('height').toInt();
					divHeight = $('portfolioMenuContentScroller').getStyle('height').toInt();
					minY = containerHeight - divHeight;
					position = $('portfolioMenuContentScroller').getPosition($('portfolioMenuContent'));
					currentY = position.y.toInt();
					$('portfolioMenuContentScroller').setStyle('top', currentY);
					newY = (el.id.indexOf('Up') > 0) ? 0 : minY;
					diffY = Math.abs(newY - currentY) * 5;
					if (diffY == 0) return;
					newTween = new Fx.Tween($('portfolioMenuContentScroller'), {
						duration: diffY,
						property: 'top',
						transition: Fx.Transitions.Quad.easeOut,
						onComplete: function() {
							isBusy = false;	
						}
					});
					isBusy = true;
					newTween.start(newY);
				}
			})
			
			el.addEvent('mouseleave', function(event) {
				if (isBusy == true) {
					newTween.stop();
					isBusy = false;
				}
				containerHeight = $('portfolioMenuContent').getStyle('height').toInt();
				divHeight = $('portfolioMenuContentScroller').getStyle('height').toInt();
				minY = containerHeight - divHeight;
				position = $('portfolioMenuContentScroller').getPosition($('portfolioMenuContent'));
				currentY = position.y.toInt();
				$('portfolioMenuUp').setStyle('visibility', (currentY == 0 && arrowAlwaysVisible == 0) ? 'hidden' : 'visible');
				$('portfolioMenuDown').setStyle('visibility', (currentY <= minY && arrowAlwaysVisible == 0) ? 'hidden' : 'visible');
				portfolioMenuUpState = (currentY == 0) ? 0 : 1;
				portfolioMenuDownState = (currentY <= minY) ? 0 : 1;
			})
			
		}
		
	});
}

function initPortfolioImageScroller() {
	if (portfolioImageClickSet == true) return;
	portfolioImageClickSet = true;
	var scrollStep, containerHeight, divHeight, currentY, direction, minY, position, newY, diffY, isBusy, newTween, arrPos, currentId;
	$$('#col3 .scroll').each(function(el) {
		
		el.addEvent('click', function(event) {
			if ((el.id.indexOf('Up') > 0 && portfolioImageUpState == 1) || (el.id.indexOf('Down') > 0 && portfolioImageDownState == 1)) {
				direction = (el.id.indexOf('Up') > 0) ? -1 : 1;
				containerHeight = $('portfolioImageContent').getStyle('height').toInt();
				divHeight = $('portfolioImageContentScroller').getStyle('height').toInt();
				minY = containerHeight - divHeight;
				position = $('portfolioImageContentScroller').getPosition($('portfolioImageContent'));
				currentY = position.y.toInt();
				$('portfolioImageContentScroller').setStyle('top', currentY);
				currentId = 0;
				arrPos = imagePositions.split(',');
				for (var i = 0; i < arrPos.length; i++) {
					if (currentY == arrPos[i].toInt()) {
						currentId = i;
						break;
					}	
				}
				currentId += direction;
				if (currentId < 0) currentId = 0;
				if (currentId > arrPos.length) currentId = arrPos[arrPos.length];
				currentY = arrPos[currentId];
				newTween = new Fx.Tween($('portfolioImageContentScroller'), {
					duration: 600,
					property: 'top',
					transition: Fx.Transitions.Quad.easeOut,
					link: 'cancel'
				});
				newTween.start(currentY);
				$('portfolioImageUp').setStyle('visibility', (currentY == 0 && arrowAlwaysVisible == 0) ? 'hidden' : 'visible');
				$('portfolioImageDown').setStyle('visibility', (currentY <= minY && arrowAlwaysVisible == 0) ? 'hidden' : 'visible');
				portfolioImageUpState = (currentY == 0) ? 0 : 1;
				portfolioImageDownState = (currentY <= minY) ? 0 : 1;
			}
		})
		
		if (isTablet == false) {
			
			el.addEvent('mouseenter', function(event) {
				if ((el.id.indexOf('Up') > 0 && portfolioImageUpState == 1) || (el.id.indexOf('Down') > 0 && portfolioImageDownState == 1)) {
					containerHeight = $('portfolioImageContent').getStyle('height').toInt();
					divHeight = $('portfolioImageContentScroller').getStyle('height').toInt();
					minY = containerHeight - divHeight
					position = $('portfolioImageContentScroller').getPosition($('portfolioImageContent'));
					currentY = position.y.toInt();
					$('portfolioImageContentScroller').setStyle('top', currentY);
					newY = (el.id.indexOf('Up') > 0) ? 0 : minY;
					diffY = Math.abs(newY - currentY) * 5;
					if (diffY == 0) return;
					newTween = new Fx.Tween($('portfolioImageContentScroller'), {
						duration: diffY,
						property: 'top',
						transition: Fx.Transitions.Quad.easeOut,
						onComplete: function() {
							isBusy = false;	
						}
					});
					isBusy = true;
					newTween.start(newY);
				}
			})
			
			el.addEvent('mouseleave', function(event) {
				if (isBusy == true) {
					newTween.stop();
					isBusy = false;
				}
				containerHeight = $('portfolioImageContent').getStyle('height').toInt();
				divHeight = $('portfolioImageContentScroller').getStyle('height').toInt();
				minY = containerHeight - divHeight
				position = $('portfolioImageContentScroller').getPosition($('portfolioImageContent'));
				currentY = position.y.toInt();
				$('portfolioImageUp').setStyle('visibility', (currentY == 0 && arrowAlwaysVisible == 0) ? 'hidden' : 'visible');
				$('portfolioImageDown').setStyle('visibility', (currentY <= minY && arrowAlwaysVisible == 0) ? 'hidden' : 'visible');
				portfolioImageUpState = (currentY == 0) ? 0 : 1;
				portfolioImageDownState = (currentY <= minY) ? 0 : 1;
			})
			
		}
		
	});
}

function initPortfolioTextScroller() {
	if (portfolioTextClickSet == true) return;
	portfolioTextClickSet = true;
	var scrollStep, containerHeight, divHeight, currentY, direction, minY, position, newY, diffY, isBusy, newTween;
	
	$$('#portfolioText .scroll').each(function(el) {
		
		el.addEvent('click', function(event) {
			if ((el.id.indexOf('Up') > 0 && portfolioTextUpState == 1) || (el.id.indexOf('Down') > 0 && portfolioTextDownState == 1)) {
				direction = (el.id.indexOf('Up') > 0) ? 1 : -1;
				containerHeight = $('portfolioTextContent').getSize().y;
				scrollStep = (containerHeight / 2).toInt();
				divHeight = $('portfolioTextContentScroller').getSize().y;
				minY = containerHeight - divHeight;
				currentY = $('portfolioTextContentScroller').getPosition($('portfolioTextContent')).y;
				$('portfolioTextContentScroller').setStyle('top', currentY);
				currentY += scrollStep * direction;
				if (currentY < minY) currentY = minY;
				if (currentY > 0) currentY = 0;
				newTween = new Fx.Tween($('portfolioTextContentScroller'), {
					duration: 600,
					property: 'top',
					transition: Fx.Transitions.Quad.easeOut
				});
				newTween.start(currentY);
				portfolioTextUpState = (currentY == 0) ? 0 : 1;
				portfolioTextDownState = (currentY <= minY) ? 0 : 1;
				if (($('portfolioText').getStyle('visibility') == 'visible') && (portfolioTextUpState == 1 || portfolioTextDownState == 1)) {
					$('portfolioTextUp').setStyle('visibility', 'visible');
					$('portfolioTextDown').setStyle('visibility', 'visible');
				} else {
					$('portfolioTextUp').setStyle('visibility', 'hidden');
					$('portfolioTextDown').setStyle('visibility', 'hidden');
				}
			}
		})
		
		if (isTablet == false) {
		
			el.addEvent('mouseenter', function(event) {
				if ((el.id.indexOf('Up') > 0 && portfolioTextUpState == 1) || (el.id.indexOf('Down') > 0 && portfolioTextDownState == 1)) {
					containerHeight = $('portfolioTextContent').getStyle('height').toInt();
					divHeight = $('portfolioTextContentScroller').getStyle('height').toInt();
					minY = containerHeight - divHeight
					position = $('portfolioTextContentScroller').getPosition($('portfolioTextContent'));
					currentY = position.y.toInt();
					$('portfolioTextContentScroller').setStyle('top', currentY);
					newY = (el.id.indexOf('Up') > 0) ? 0 : minY;
					diffY = Math.abs(newY - currentY) * 5;
					if (diffY == 0) return;
					newTween = new Fx.Tween($('portfolioTextContentScroller'), {
						duration: diffY,
						property: 'top',
						transition: Fx.Transitions.Quad.easeOut,
						onComplete: function() {
							isBusy = false;	
						}
					});
					isBusy = true;
					newTween.start(newY);
				}
			})
			
			el.addEvent('mouseleave', function(event) {
				if (isBusy == true) {
					newTween.stop();
					isBusy = false;
				}
				containerHeight = $('portfolioTextContent').getStyle('height').toInt();
				divHeight = $('portfolioTextContentScroller').getStyle('height').toInt();
				minY = containerHeight - divHeight
				position = $('portfolioTextContentScroller').getPosition($('portfolioTextContent'));
				currentY = position.y.toInt();
				portfolioTextUpState = (currentY == 0) ? 0 : 1;
				portfolioTextDownState = (currentY <= minY) ? 0 : 1;
				if (($('portfolioText').getStyle('visibility') == 'visible') && (portfolioTextUpState == 1 || portfolioTextDownState == 1)) {
					$('portfolioTextUp').setStyle('visibility', 'visible');
					$('portfolioTextDown').setStyle('visibility', 'visible');
				} else {
					$('portfolioTextUp').setStyle('visibility', 'hidden');
					$('portfolioTextDown').setStyle('visibility', 'hidden');
				}
		
			})
			
		}
		
	});
}

function initNormalTextScroller() {
	if (normalTextClickSet == true) return;
	normalTextClickSet = true;
	var scrollStep, containerHeight, divHeight, currentY, direction, minY, position, newY, diffY, isBusy, newTween;
	$$('#normalText .scroll').each(function(el) {
		
		el.addEvent('click', function(event) {
			if ((el.id.indexOf('Up') > 0 && normalTextUpState == 1) || (el.id.indexOf('Down') > 0 && normalTextDownState == 1)) {
				direction = (el.id.indexOf('Up') > 0) ? 1 : -1;
				containerHeight = $('normalTextContent').getStyle('height').toInt();
				scrollStep = (containerHeight / 1.5).toInt();
				divHeight = $('normalTextContentScroller').getStyle('height').toInt();
				minY = containerHeight - divHeight;
				position = $('normalTextContentScroller').getPosition($('normalTextContent'));
				currentY = position.y.toInt();
				$('normalTextContentScroller').setStyle('top', currentY);
				currentY += scrollStep * direction;
				if (currentY < minY) currentY = minY;
				if (currentY > 0) currentY = 0;
				newTween = new Fx.Tween($('normalTextContentScroller'), {
					duration: 600,
					property: 'top',
					transition: Fx.Transitions.Quad.easeOut
				});
				newTween.start(currentY);
				//$('normalTextUp').setStyle('visibility', (currentY == 0) ? 'hidden' : 'visible');
				//$('normalTextDown').setStyle('visibility', (currentY <= minY) ? 'hidden' : 'visible');	
				normalTextUpState = (currentY == 0) ? 0 : 1;
				normalTextDownState = (currentY <= minY) ? 0 : 1;
				if (normalTextUpState == 1 || normalTextDownState == 1) {
					$('normalTextUp').setStyle('visibility', 'visible');
					$('normalTextDown').setStyle('visibility', 'visible');
				} else {
					$('normalTextUp').setStyle('visibility', 'hidden');
					$('normalTextDown').setStyle('visibility', 'hidden');
				}
			}
		})
		
		if (isTablet == false) {
		
			el.addEvent('mouseenter', function(event) {
				if ((el.id.indexOf('Up') > 0 && normalTextUpState == 1) || (el.id.indexOf('Down') > 0 && normalTextDownState == 1)) {
					containerHeight = $('normalTextContent').getStyle('height').toInt();
					divHeight = $('normalTextContentScroller').getStyle('height').toInt();
					minY = containerHeight - divHeight
					position = $('normalTextContentScroller').getPosition($('normalTextContent'));
					currentY = position.y.toInt();
					$('normalTextContentScroller').setStyle('top', currentY);
					newY = (el.id.indexOf('Up') > 0) ? 0 : minY;
					diffY = Math.abs(newY - currentY) * 5;
					if (diffY == 0) return;
					newTween = new Fx.Tween($('normalTextContentScroller'), {
						duration: diffY,
						property: 'top',
						transition: Fx.Transitions.Quad.easeOut,
						onComplete: function() {
							isBusy = false;	
						}
					});
					isBusy = true;
					newTween.start(newY);
				}
			})
			
			el.addEvent('mouseleave', function(event) {
				if (isBusy == true) {
					newTween.stop();
					isBusy = false;
				}
				containerHeight = $('normalTextContent').getStyle('height').toInt();
				divHeight = $('normalTextContentScroller').getStyle('height').toInt();
				minY = containerHeight - divHeight
				position = $('normalTextContentScroller').getPosition($('normalTextContent'));
				currentY = position.y.toInt();
				//$('normalTextUp').setStyle('visibility', (currentY == 0) ? 'hidden' : 'visible');
				//$('normalTextDown').setStyle('visibility', (currentY <= minY) ? 'hidden' : 'visible');
				normalTextUpState = (currentY == 0) ? 0 : 1;
				normalTextDownState = (currentY <= minY) ? 0 : 1;
				if (normalTextUpState == 1 || normalTextDownState == 1) {
					$('normalTextUp').setStyle('visibility', 'visible');
					$('normalTextDown').setStyle('visibility', 'visible');
				} else {
					$('normalTextUp').setStyle('visibility', 'hidden');
					$('normalTextDown').setStyle('visibility', 'hidden');
				}
			})
		}
	});
}

function initCurriculum() {
	var list = $$('p.pCurriculum');
	var triggers = $$('div.linkCurriculum');
	var image = $$('img.imageCurriculum');
	var photos = $$('img.imgCurriculum');
	triggers.each(function(trigger, i) {
		var collapsible = new Fx.Slide(list[i], {
			duration: 500, 
			transition: Fx.Transitions.quadIn,
			onComplete: function() {
				changeSize();	
			}
		});
		trigger.onclick = function() {
			if (collapsible.open) {
				image[i].src = '/images/btnDown.png';
				trigger.removeClass('linkCurriculumActive');
			} else {
				image[i].src = '/images/btnUp.png';
				trigger.addClass('linkCurriculumActive');
			}
			collapsible.toggle();
		}
		photos[i].onclick = function() {
			if (collapsible.open) {
				image[i].src = '/images/btnDown.png';
				trigger.removeClass('linkCurriculumActive');
			} else {
				image[i].src = '/images/btnUp.png';
				trigger.addClass('linkCurriculumActive');
			}
			collapsible.toggle();
		}
		photos[i].onmouseover = function() {
			if (!collapsible.open) {
				trigger.addClass('linkCurriculumActive');
			}
		}
		photos[i].onmouseout = function() {
			if (!collapsible.open) {
				trigger.removeClass('linkCurriculumActive');
			}
		}
		collapsible.hide();
	});
}

function initFTP() {
	var ftpFolder = $$('div.ftpFolder');
	ftpFolder.each(function(folder, i) {
		var ftpFolderContent = folder.getElement('.ftpFolderContent');
		ftpFolderContent.setStyle('display', 'none');
		var ftpFolderClick = folder.getElement('.ftpFolderClick');
		var ftpPClick = folder.getElement('.ftpPClick');
		ftpFolderClick.onclick = function() {
			if (ftpFolderContent.getStyle('display') == 'block') {
				ftpFolderClick.src = '/images/folderClose.png';
				ftpFolderContent.setStyle('display', 'none');
			} else {
				ftpFolderClick.src = '/images/folderOpen.png';
				ftpFolderContent.setStyle('display', 'block');
			}
			changeSize();
		}
		ftpPClick.onclick = function() {
			if (ftpFolderContent.getStyle('display') == 'block') {
				ftpFolderClick.src = '/images/folderClose.png';
				ftpFolderContent.setStyle('display', 'none');
			} else {
				ftpFolderClick.src = '/images/folderOpen.png';
				ftpFolderContent.setStyle('display', 'block');
			}
			changeSize();
		}
	});	
}

function changePortfolio(obj, className) {
	$$('ul.portfolio' + className + ' li a').each(function(el) {
		if (el.rel == obj.rel) {
			var pageId = 0;
			$$('#portfolioMenuContentScroller a').each(function(elLink) {
				if (elLink.hasClass('active')) pageId = elLink.rel;
			});
			el.addClass('active');
			var req = new Request({
				url: '/includes/ajax.asp?script=setPortfolioMenu&className=' + className + '&strValue=' + obj.rel + '&pageId=' + pageId,
				onSuccess: function(txt) {
					var newTween = new Fx.Tween($('portfolioMenuContent'), {
						duration: 250,
						property: 'opacity',
						onComplete: function() {
							$('portfolioMenuContent').innerHTML = txt;
							$('portfolioMenuContentScroller').setStyle('top', 0);
							changeSize();
							var newTween = new Fx.Tween($('portfolioMenuContent'), {
								duration: 250,
								property: 'opacity'
							});
							newTween.start(1);
						}
					});
					newTween.start(0);
				}
			}).send();
		} else {
			el.removeClass('active');		
		}
	});
	return false;
}

function getURL(obj, pageId) {
	
	if ($('portfolioImageContent')) {
	
		var myURI = new URI(obj.href);
		var URL = myURI.toAbsolute().split('/');
		var newURL = '';
		for (var x = 0; x < URL.length; x++) {
			if (URL[x] != '') {
				if (newURL != '') newURL += '/';
				newURL += URL[x];
			}	
		}
		newURL = '#/' + newURL;
		document.location = newURL;
		
		$$('#portfolioMenuContentScroller ul li a').each(function(el) {
			if (obj.rel == el.rel) {
				el.addClass('active');	
			} else {
				el.removeClass('active');
			}
		});
		
		var photoHeight = $('portfolioImageContent').getStyle('height').toInt();
		var textHeight = $('portfolioTextContent').getStyle('height').toInt();
		var Tween1 = new Fx.Tween($('col2'), {
			duration: 250,
			property: 'opacity'
		});
		Tween1.start(0);
		var Tween2 = new Fx.Tween($('col3'), {
			duration: 250,
			property: 'opacity',
			onComplete: function() {
				var req = new Request({
					url: '/includes/ajax.asp?script=openPortfolio&pageId=' + pageId,
					onSuccess: function(txt) {
						var result = txt.split('###|||###');
						$('col2').innerHTML = result[0];
						$('portfolioTextContent').setStyle('height', textHeight);
						$('col3').innerHTML = result[1];
						$('portfolioImageContent').setStyle('height', photoHeight);
						var Tween1 = new Fx.Tween($('col2'), {
							duration: 250,
							property: 'opacity'
						});
						Tween1.start(1);
						var Tween2 = new Fx.Tween($('col3'), {
							duration: 250,
							property: 'opacity',
							onComplete: function() {
								portfolioImageClickSet = false;
								portfolioTextClickSet = false;
								changeSize();
							}
						});
						Tween2.start(1);
					}
				}).send();
			}
		});
		Tween2.start(0);
		return false;
	
	}
	
}

function changeLanguage(languageId, pageId) {
	var tmpPageId = 0;
	$$('#portfolioMenuContentScroller a').each(function(elLink) {
		if (elLink.hasClass('active')) tmpPageId = elLink.rel;
	});
	if (tmpPageId > 0) pageId = tmpPageId;
	
	var req = new Request({
		url: '/includes/ajax.asp?script=changeLanguage&languageId=' + languageId + '&pageId=' + pageId,
		onSuccess: function(txt) {
			document.location = trim(txt);
		}
	}).send();
	return false;
}

function keyStroke(e, validate) {
	var key = window.event ? e.keyCode : e.which;
	if (key == 8 || key == 0) return true;
	if (key == 124 ) return false;
	if (validate == 1 && key == 32) return false;
	if (validate == 3 || validate == 2) {
		if (key < 48 || key > 57) {
			if (key != 44 && key != 45) {
				return false;
			} else {
				if (validate == 2 && key == 44) {
					return false;
				}
			}
		}
	}
}

function checkForm(formIdentifier) {
	var formitem = document.getElementById('checkfields' + formIdentifier).value.split('#**#');
	for (var x = 0; x < formitem.length; x++) {
		var formproperties = formitem[x].split('#|#');
		var formfield = formproperties[0];
		var fieldname = formproperties[1];
		var validate = parseInt(formproperties[2]);
		var compulsary = parseInt(formproperties[3]);
		var unique = parseInt(formproperties[4]);
		if (validate != 2) {
			if ($(formfield)) {
				var a = trim($(formfield).value);
				$(formfield).value = a;
			}
		}
		if (compulsary == 1) {
			if ($(formfield).value == '') {
				if ($(formfield).getStyle('visibility') != 'hidden') {
					translate(3, '', ': ' + fieldname);
					$(formfield).focus();
					return false;
				}
			}
		}
		if (validate == 1) {
			if (emailCheck(formfield, compulsary) == false) {
				translate(4, '', '');
				$(formfield).focus();
				return false;
			}
		}
		if (unique == 1) {
			var result = $(formfield + '_unique').value.toInt();
			if (result == 0) {
				translate(5, '', ': ' + fieldname);
				$(formfield).focus();
				return false;
			}
		}
	}
	return;
}

function emailCheck(formfield, compulsary) {
	var emailStr = $(formfield).value
	if (compulsary == 0 && emailStr == '') return true;
	var checkTLD=1;
	var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;
	var emailPat=/^(.+)@(.+)$/;
	var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
	var validChars="\[^\\s" + specialChars + "\]";
	var quotedUser="(\"[^\"]*\")";
	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
	var atom=validChars + '+';
	var word="(" + atom + "|" + quotedUser + ")";
	var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
	var matchArray=emailStr.match(emailPat);
	if (matchArray==null) return false;
	var user=matchArray[1];
	var domain=matchArray[2];
	for (i = 0; i < user.length; i++) {
		if (user.charCodeAt(i) > 127) return false;
	}
	for (i=0; i<domain.length; i++) {
		if (domain.charCodeAt(i) > 127) return false;
	}
	if (user.match(userPat)==null) return false;
	var IPArray=domain.match(ipDomainPat);
	if (IPArray!=null) {
		for (var i = 1;i <= 4; i++) {
			if (IPArray[i] > 255) return false;
		}
		return true;
	}
	var atomPat=new RegExp("^" + atom + "$");
	var domArr=domain.split(".");
	var len=domArr.length;
	for (i = 0; i < len; i++) {
		if (domArr[i].search(atomPat) == -1) return false;
	}
	if (checkTLD && domArr[domArr.length-1].length!=2 && domArr[domArr.length-1].search(knownDomsPat)==-1) return false;
	if (len < 2) return false;
	return true;
}

function translate(id, before, after) {
	var req = new Request({
		url: '/includes/ajax.asp?script=translate&id=' + id,
		onSuccess: function(txt) {
			var response = before + txt + after;
			alert(response);
		}
	}).send();
}

function checkUnique(dbtable, dbfield, id, formfield) {
	var req = new Request({
		url: '/includes/ajax.asp?script=checkunique&dbtable=' + dbtable + '&dbfield=' + dbfield + '&dbvalue=' + escape(document.getElementById(formfield).value) + '&id=' + id,
		onSuccess: function(txt) {
			$(formfield + '_unique').value = txt;
		}
	}).send();
}

function doTrim(obj) {
	var a = trim(obj.value);
	obj.value = a;
	return a;
}

function trim(strValue) {
	if (strValue.length < 1) return '';
	strValue = rTrim(strValue);
	strValue = lTrim(strValue);
	return strValue;
}

function rTrim(strValue) {
	var w_space = String.fromCharCode(32);
	var v_length = strValue.length;
	var strTemp = '';
	if (v_length < 0) return '';
	var iTemp = v_length - 1;
	while(iTemp > -1) {
		if (strValue.charAt(iTemp) != w_space) {
			strTemp = strValue.substring(0, iTemp + 1);
			break;
		}
		iTemp = iTemp - 1;
	}
	return strTemp;
}

function lTrim(strValue) {
	var w_space = String.fromCharCode(32);
	if (v_length < 1) return '';
	var v_length = strValue.length;
	var strTemp = '';
	var iTemp = 0;
	while (iTemp < v_length) {
		if (strValue.charAt(iTemp) != w_space) {
			strTemp = strValue.substring(iTemp, v_length);
			break;
		}
		iTemp = iTemp + 1;
	}
	return strTemp;
}


//-->

