/*
  get cookie
*/
function getCookie(sName){
	var aCookie = document.cookie.split("; ");
	
	for (var i=0; i < aCookie.length; i++){
		var aCrumb = aCookie[i].split("=");
		if (sName == aCrumb[0]){
			return unescape(aCrumb[1]);
		}
	}
	
	return null;
} /*
  getElementsByClassName
*/
document.getElementsByClassName = function (needle){
    var s = [document.documentElement || document.body], i = 0, r = [], l = 0, e;
    var re = new RegExp('(^|\\s)' + needle + '(\\s|$)');

    do{
        e = s[i];

        while (e){
            if (e.nodeType == 1){
                if (e.className && re.test(e.className)) r[l++] = e;

                s[i++] = e.firstChild;
            }

            e = e.nextSibling;
        }
    }
	
    while (i--);

    return r;
}
 /*

handleBodyLoad();

*/

function handleBodyLoad() {

    document.body.className += ' jsOn';
    setNavHeight();
    initSignavureCarousel();
    flashHeader();
    initMultiTab();
    markLinks();
//    initInputFocusByTitle();


    initInputFocus('text-299', 'Naam');
    initInputFocus('text-300', 'E-mailadres');
    initInputFocus('textarea-301', 'Uw vraag of bericht');
    initInputFocus('text-310', 'Telefoon');
    initGallery2009();

    if (typeof activatePagePeel == 'function') {
       activatePagePeel();
   }

} /*
  initFader
*/
  
function initFader(){

	// hide for old browsers
	if(!document.getElementById || !document.createElement || !document.getElementById('albumFader')) return;

	//var li = document.getElementById('listContainer').getElementsByTagName('a');

	window.fadeTime = 3200;

	window.anchors = new Array();
	window.current = 0;
	window.pause = false;
	window.loaded = -1;
	window.loading = true;

	// set opacity to 0 for all images, except the first image 
	anchors = document.getElementById('albumFader').getElementsByTagName('img');

	// get the rest of the images that are loaded in the listBanners pagelet
	//window.alternateImgs = document.getElementById('listContainer').getElementsByTagName('a');
	window.alternateImgs = faderImgList;
	window.totalImages = window.alternateImgs.length + anchors.length;

	anchors[0].style.display = 'block';
	anchors[0].xOpacity = .99;
	anchors[0].onload = function(){

		window.loaded = 0;
		 // if there are more images availbale fade them in
		if(window.alternateImgs.length) addImage(window.alternateImgs[0]);

		setTimeout(fadeBanners, fadeTime);
	}
}

function fadeBanners(){

	if(window.loading){
		setTimeout(fadeBanners, fadeTime);
		return;
	}

	cOpacity = anchors[current].xOpacity;
	nIndex = anchors[current+1]?current+1:0;
	nOpacity = anchors[nIndex].xOpacity;
	cOpacity -= .05;
	nOpacity += .05;

	anchors[nIndex].style.display = 'block';
	anchors[current].xOpacity = cOpacity;
	anchors[nIndex].xOpacity = nOpacity;

	setOpacity(anchors[current]); 
	setOpacity(anchors[nIndex]);

	if(cOpacity<=0){
		anchors[current].style.display = 'none';
		current = nIndex;

		if(window.alternateImgs.length > window.loaded){
			window.loading=true;
			addImage(window.alternateImgs[window.loaded]);
		}

		setTimeout(fadeBanners,fadeTime);
	}else{
		setTimeout(fadeBanners,50);
	}

	function setOpacity(obj){
		if(obj.xOpacity>.99){
			obj.xOpacity = .99;
			return;
		}

		obj.style.opacity = obj.xOpacity;
		obj.style.MozOpacity = obj.xOpacity;
		obj.style.filter = 'alpha(opacity=' + (obj.xOpacity*100) + ')';
	}
}

function addImage(imgSrc){

	var newImage = document.createElement('img');
	newImage.src = imgSrc;
	newImage.xOpacity = 0;

	document.getElementById('albumFader').appendChild(newImage);
	newImage.style.display = 'none';

	newImage.onload = function(){
		window.loading = false;
		window.anchors = document.getElementById('albumFader').getElementsByTagName('img');
	}

	window.loaded++;
}

 /*
  initGallery2009	
*/
function initGallery2009(){
	
	window.TnCollection = new Array();
	
	if(document.getElementsByClassName('newsImages').length){
		var newsImages = document.getElementsByClassName('newsImages')[0];
		var linksA = newsImages.getElementsByTagName('a');
		
		for(var i = 0; i < linksA.length; i++){
			window.TnCollection.push(linksA[i]);
		}
	}

	if(document.getElementsByClassName('album').length){
		var album = document.getElementsByClassName('album')[0];
		var linksB = album.getElementsByTagName('a');
		
		for(var i = 0; i < linksB.length; i++){
			window.TnCollection.push(linksB[i]);
		}
	}

	var initPaging = false;
	if(window.TnCollection.length > 1)initPaging = true;

	for(var i = 0; i < window.TnCollection.length; i++){
		window.TnCollection[i].onclick = function(){
			createPopup2009(this, initPaging);
			return false;
		}
	}
}


function createPopup2009(thisElement, initPaging){
	var picture = thisElement.href;
	var titleText = '';
	//var imageInstance = new Image();
	//imageInstance.src = unescape(picture);
	//var imageWidth = imageInstance.width;
	var borderColor = '#fff';

	var buttonNext = '/img/siteTemplate/popup-volgende.png';
	var buttonPrev = '/img/siteTemplate/popup-vorige.png';
	var buttonClose = '/img/siteTemplate/popup-sluiten.png';
	var loaderImg = '/img/siteTemplate/loader.gif';

	var nextTitle = 'Volgende afbeelding';
	var prevTitle = 'Vorige afbeelding';
	var closeTitle = 'Sluiten';

	// remove old wrapper
	closePopup2009();
	
	// position y of wrapper
	var Geometry = {};
	if(window.innerWidth) { //All but IE
		Geometry.getVerticalScroll = function() { return window.pageYOffset; };
	} else if (document.documentElement && document.documentElement.clientWidth) { //IE6 with doctype
		Geometry.getVerticalScroll = function() { return document.documentElement.scrollTop; };
	} else if (document.body.clientWidth){
		Geometry.getVerticalScroll = function() { return document.body.scrollTop; };
	}
	var yPos = Geometry.getVerticalScroll();
			
	// popupLoader
	popupLoader = document.createElement('div');
	popupLoader.id = 'popupLoader';
	popupLoader.style.border = '2px '+borderColor+' solid';
	popupLoader.style.display = 'block';
	popupLoader.style.position = 'absolute';
	popupLoader.style.left = '50%';
	popupLoader.style.marginLeft = '-21px';
	popupLoader.style.top = yPos+250+'px';
	popupLoader.style.zIndex = '99';
	popupLoader.style.width = '42px';
	popupLoader.style.height = '42px';
	popupLoader.style.backgroundImage = 'url('+loaderImg+')';
	popupLoader.style.backgroundPosition = 'top left';
	document.body.appendChild(popupLoader);
	
	// popup div
	popup = document.createElement('div');
	popup.id = 'popupWrapper';
	popup.style.backgroundColor = borderColor;
	popup.style.border = '10px '+borderColor+' solid'; 
	//popup.style.borderTop = '30px '+borderColor+' solid';
 	popup.style.position = 'absolute';
	popup.style.left = '100px';
	popup.style.top = '50px';
	popup.style.zIndex = '101';
	popup.style.display = 'block';
	popup.style.visibility = 'hidden';

	// header div
	var popupHeader = document.createElement('div');
	popupHeader.id = 'popupHeader';
	popupHeader.style.position = 'relative';
	popupHeader.style.zIndex = '3';
	//popupHeader.style.height = '30px';
	
	popup.appendChild(popupHeader);
	
		var headerTitle = document.createElement('h3');
		headerTitle.appendChild(document.createTextNode(titleText));
		headerTitle.id = 'headerTitle';
		headerTitle.style.visibility = 'hidden';
		popupHeader.appendChild(headerTitle);
		
		// close link
		var popupCloseLink = document.createElement('a');
		popupCloseLink.href = '#';
		popupCloseLink.id = 'popupCloseLink';
		popupCloseLink.title = closeTitle;
		popupCloseLink.onclick = function(){
			closePopup2009();
			return false; 
		}
		popupCloseLink.style.display = 'block';
		popupCloseLink.style.width = '10px';
		popupCloseLink.style.height = '10px';
		popupCloseLink.style.position = 'absolute';
		popupCloseLink.style.top = '0px';
		popupCloseLink.style.right = '0px';
		popupCloseLink.style.backgroundImage = 'url('+buttonClose+')';
		popupCloseLink.style.backgroundPosition = 'top left';
		popupCloseLink.style.backgroundRepeat = 'no-repeat';
		popupHeader.appendChild(popupCloseLink);
	
	// img container
	var imgContainer = document.createElement('div');
	imgContainer.id = 'imgContainer';
	imgContainer.style.position = 'relative';
	imgContainer.style.zIndex = '2';
	imgContainer.style.overflow = 'hidden';
	
	popup.appendChild(imgContainer);

		if(initPaging == true){
			var overPrev = document.createElement('div');
			overPrev.id = 'overPrev';
			overPrev.title = prevTitle;
			overPrev.style.position = 'absolute';
			overPrev.style.top = '100px';
			overPrev.style.left = '0';
	
			overPrev.style.width = '80px';
			overPrev.style.height = '30px';
			overPrev.style.backgroundImage = 'url('+buttonPrev+')';
			overPrev.style.backgroundPosition = 'top left';
			overPrev.style.backgroundRepeat = 'no-repeat';
			overPrev.style.display = 'none';
			
			imgContainer.appendChild(overPrev);
			
			var overNext = document.createElement('div');
			overNext.id = 'overNext';
			overNext.title = nextTitle;
			overNext.style.position = 'absolute';
			overNext.style.top = '100px';
			overNext.style.right = '0';
			overNext.style.width = '80px';
			overNext.style.height = '30px';
			overNext.style.backgroundImage = 'url('+buttonNext+')';
			overNext.style.backgroundPosition = 'top right';
			overNext.style.backgroundRepeat = 'no-repeat';
			overNext.style.display = 'none';
			
			imgContainer.appendChild(overNext);

			// prev link
			var prevImg = document.createElement('a');
			prevImg.href = '#';
			prevImg.id = 'prevImg';
			prevImg.onclick = function(){
				this.blur();
				initPaging2009('prev');
				return false; 
			}
			prevImg.onmouseover = function(){
				document.getElementById('overPrev').style.display = 'block';
			}
			prevImg.onmouseout = function(){
				document.getElementById('overPrev').style.display = 'none';
			}
			prevImg.style.display = 'block';
			prevImg.style.width = '150px';
			prevImg.style.height = '1000px';
			prevImg.style.position = 'absolute';
			prevImg.style.top = '0';
			prevImg.style.left = '0';
			prevImg.style.backgroundColor = '#fff';
			prevImg.style.filter = 'alpha(opacity=0)';
			prevImg.style.mozOpacity = '0.0';
			prevImg.style.opacity = '0.0';
			
			imgContainer.appendChild(prevImg);
	
			// next link
			var nextImg = document.createElement('a');
			nextImg.href = '#';
			nextImg.id = 'nextImg';
			nextImg.onclick = function(){
				this.blur();
				initPaging2009('next');
				return false; 
			}
			nextImg.onmouseover = function(){
				document.getElementById('overNext').style.display = 'block';
			}
			nextImg.onmouseout = function(){
				document.getElementById('overNext').style.display = 'none';
			}
	
			nextImg.style.display = 'block';
			nextImg.style.width = '150px';
			nextImg.style.height = '1000px';
			nextImg.style.position = 'absolute';
			nextImg.style.top = '0';
			nextImg.style.right = '0';
			nextImg.style.backgroundColor = '#fff';
			nextImg.style.filter = 'alpha(opacity=0)';
			nextImg.style.mozOpacity = '0.0';
			nextImg.style.opacity = '0.0';
			
			imgContainer.appendChild(nextImg);
		}

	/* popup append */
	document.body.appendChild(popup);
	
	// popup image big
	var popupImage = document.createElement('img'); 
	popupImage.id = 'popupImageBig';
	
	popupImage.onload = function(){
		var imgW = this.width;
		var imgH = this.height;

		var yPos = Geometry.getVerticalScroll();	

document.getElementById('popupHeader').getElementsByTagName('h3')[0].innerHTML = '<span>' + thisElement.getElementsByTagName('img')[0].getAttribute('alt') + '</span>';


		document.getElementById('popupHeader').style.width = imgW +'px';
			
		document.getElementById('popupWrapper').style.top = yPos+100+'px';
		document.getElementById('popupWrapper').style.left = '50%';
		document.getElementById('popupWrapper').style.marginLeft = this.width/-2+'px';

		document.getElementById('popupWrapper').style.visibility = 'visible';
	//	document.getElementById('popupCloseLink').style.left =  this.width - 25 + 'px';
	}
	popupImage.src = unescape(picture);
	
	imgContainer.appendChild(popupImage);

}

function closePopup2009(){
	if(document.getElementById('popupLoader')){
		document.getElementById('popupLoader').parentNode.removeChild(document.getElementById('popupLoader'));
	}
	if(document.getElementById('popupWrapper')){
		document.getElementById('popupWrapper').parentNode.removeChild(document.getElementById('popupWrapper'));
	}
}

function initPaging2009(prevnext){
	var currentImg = unescape(document.getElementById('popupImageBig').src);
	var currentImgNr = 0;
	var initPaging = false;
	if(window.TnCollection.length > 1)initPaging = true;

	for(var i = 0; i < window.TnCollection.length; i++){
		if(unescape(window.TnCollection[i].href) == currentImg){
			currentImgNr = i;

		}
	}
	
	if(prevnext == 'next'){
		if(currentImgNr + 1 > window.TnCollection.length-1){
			closePopup2009();
			createPopup2009(window.TnCollection[0], initPaging);
		} else {
			closePopup2009();
			createPopup2009(window.TnCollection[currentImgNr+1], initPaging);
		}
	} else if (prevnext == 'prev'){
		if(currentImgNr - 1 < 0){
			closePopup2009();
			createPopup2009(window.TnCollection[window.TnCollection.length-1], initPaging);
		} else {
			closePopup2009();
			createPopup2009(window.TnCollection[currentImgNr-1], initPaging);
		}
	}
}

 /*
initInputFocus
*/
function initInputFocus(elemId, elemValue){
	if(!document.getElementById(elemId)) return false;
	var elem = document.getElementById(elemId);
	
	elem.value = elemValue;

	elem.onfocus = function(){
		if(this.value == elemValue){
			this.value = '';
		}
		this.select();
	}
	
	elem.onblur = function(){
		if(this.value == ''){
			this.value = elemValue;
		}
	}

	//hide label
	if(elem.parentNode.getElementsByTagName('span')){
		elem.parentNode.getElementsByTagName('span')[0].style.display = 'none';
	}
	
} /*
	initInputFocus by title
*/
function initInputFocusByTitle(){
	var inputs = document.getElementById('site').getElementsByTagName('input');
	var areas = document.getElementById('site').getElementsByTagName('textarea');
	
	var alLinputs = new Array();
	for(var i = 0; i < inputs.length; i++){
		if(inputs[i].getAttribute('type').toLowerCase() == 'text') alLinputs.push(inputs[i]);
	}
	for(var i = 0; i < areas.length; i++){
		alLinputs.push(areas[i]);
	}
	
	if(alLinputs.length == 0) return false;
	
	for(var i = 0; i < alLinputs.length; i++){
		
		if(alLinputs[i].parentNode.nodeName.toLowerCase() != 'label') continue;
		
		alLinputs[i].parentNode.getElementsByTagName('span')[0].style.display = 'none';
		alLinputs[i].value = alLinputs[i].parentNode.getAttribute('title');
		alLinputs[i].onfocus = function(){
			if(this.value == this.parentNode.getAttribute('title')){
				this.value = '';
			}
			this.select();
		}
		alLinputs[i].onblur = function(){
			if(this.value == ''){
				this.value = this.parentNode.getAttribute('title');
			}
		}
	}
}


 /*
  main-nav for IE6
*/
function initMainNav() {
	if (document.all && document.getElementById) {
		var nodes = document.getElementById('main-nav').getElementsByTagName('li');
		for (i = 0; i < nodes.length; i++) {
			if (nodes[i].nodeName.toUpperCase() == 'LI') {
				
				nodes[i].onmouseover = function(){
					this.className += ' hover';
				//	if(document.getElementById('breadcrumbs')) document.getElementById('breadcrumbs').style.visibility = 'hidden';
				}
				
				nodes[i].onmouseout = function() {
					this.className = this.className.replace(' hover', '');
					this.className = this.className.replace('hover', '');
				//	if(document.getElementById('breadcrumbs')) document.getElementById('breadcrumbs').style.visibility = 'visible';
				}
			}
		}
	}
} /*
	tab navigatie
*/

function initMultiTab(){ 
	var isTabs = document.getElementsByClassName('isTab');
	var hash = window.location.hash;
	var tabNavigations = document.getElementsByClassName('tabnavigation');
	
	// geen hash
	var newHash = '';
	if(hash.indexOf('#tab') == -1){
		
		var startTabs = document.getElementsByClassName('startTab');
		for(var i = 0; i < startTabs.length; i++){
			
			var startId = startTabs[i].id;
			var navId = '';
			for(var ii = 0; ii < tabNavigations.length; ii++){
				var links = tabNavigations[ii].getElementsByTagName('a');
				for(var iii = 0; iii < links.length; iii++){
					if(links[iii].href.indexOf(startId) != -1){
						navId = links[iii].parentNode.parentNode.parentNode.id;
					}
				}
			}

			if(i == 0){
				newHash = newHash+'#tab-'+navId+'-'+startId;
			} else {
				newHash = newHash+'&tab-'+navId+'-'+startId;
			}
		}
		
		if(newHash.length > 0){
			window.location.hash = newHash;
		}
		doTabsFromHash();
	}
	
	// wel hash
	else if(hash.indexOf('#tab-') != -1){
		doTabsFromHash();
	}
	
	// init onclicks
	for(var i = 0; i < tabNavigations.length; i++){
		var tablinks = tabNavigations[i].getElementsByTagName('a');
		for(var ii = 0; ii < tablinks.length; ii++){
			tablinks[ii].onclick = function(){
				var newOpen = this.href.split('#')[1];

				var thisnavId = '';
				var tabNavigations = document.getElementsByClassName('tabnavigation');
				for(var iii = 0; iii < tabNavigations.length; iii++){
					var navLinks = tabNavigations[iii].getElementsByTagName('a');
					for(var iiii = 0; iiii < navLinks.length; iiii++){
						if(navLinks[iiii].href.indexOf(newOpen) != -1){
							thisnavId = navLinks[iiii].parentNode.parentNode.parentNode.id;
						}
					}
				}

				var oldTabId = '';
				thisHash = window.location.hash.split('&');
				for(var iii = 0; iii < thisHash.length; iii++){
					var thish = thisHash[iii].split('-');
					if(thish[1] == thisnavId){
						oldTabId = thish[2];
					}
				}
				window.location.hash = window.location.hash.replace(oldTabId, newOpen);
				doTabsFromHash();
				this.blur();
				return false;
				
			}
		}
	}
}


function doTabsFromHash(){
	var isTabs = document.getElementsByClassName('isTab');
	
	for(var i = 0; i < isTabs.length; i++){
		isTabs[i].style.display = 'none';
	}

	var hash = window.location.hash;
	hash = hash.split('&');	
	for(var i = 0; i < hash.length; i++){
		var h = hash[i].split('-');
		var navId = h[1];
		var tabToOpen = h[2];
		
		if(document.getElementById(tabToOpen))document.getElementById(tabToOpen).style.display = 'block';
		
		// set startlink to active
		if(document.getElementById(navId)){
		var navLinks = document.getElementById(navId).getElementsByTagName('a');
			for(var ii = 0; ii < navLinks.length; ii++){
				navLinks[ii].parentNode.className = navLinks[ii].parentNode.className.replace(' active', '');
				navLinks[ii].parentNode.className = navLinks[ii].parentNode.className.replace('active', '');
				
				if(navLinks[ii].href.indexOf(tabToOpen) != -1){
					navLinks[ii].parentNode.className = navLinks[ii].parentNode.className + ' active';
				}
			}	
		}
	}

	hash = null;
	tabNavigations = null;
	startTabs = null;
	newHash = null;
	mediaObjects = null;
	mediaEmbeds = null;
}

function initStartCountry(){
	bodyClass = document.getElementsByTagName('body')[0].className;
	if(bodyClass.indexOf('country-') != -1){
		var index = bodyClass.indexOf('country-');
		countryCode = bodyClass.substring(index + 8,index + 10);
		
		var startId = '';
		var countryLi = document.getElementsByClassName(countryCode);
		if(!countryLi.length == 0){
			startId = countryLi[0].getElementsByTagName('a')[0].href.split('#')[1];
		}
		if(document.getElementById(startId))document.getElementById(startId).className = document.getElementById(startId).className + ' startTab';
	}
}


 /*
  initSignavureCarousel
*/

function initSignavureCarousel(){
	if(!document.getElementsByClassName('carousel').length) return false;
	
	var referencePage = 'd1169';

	// default: tWidth = 1000
	var cPadding = 0;
	var buttonWidth = 333;
	var cViewWidth = 333;
	var cHeight = 200;
	var tWidth = cPadding+buttonWidth+cViewWidth+buttonWidth+cPadding;
	var white = '/img/siteTemplate/carousel/white.png';
	var buttonPrevActive = '/img/siteTemplate/carousel/white-active.png';
	var buttonNext = '/img/siteTemplate/carousel/white.png';
	var buttonNextActive = '/img/siteTemplate/carousel/white-active.png';

	//get elements
	var carousel = document.getElementsByClassName('carousel')[0];
	var carouselList = carousel.getElementsByTagName('ul')[0];
	var carouselItems = carousel.getElementsByTagName('li');
	
	//minimun of 2 items
	//if(carouselItems.length <= 1) return false;
	if(carouselItems.length <= 0) return false;

	carousel.className += ' carouselOn';
	carousel.style.position = 'relative';
	carousel.style.width = buttonWidth+cViewWidth+buttonWidth+'px';
	carousel.style.height = cHeight+'px';
	carousel.style.overflow = 'hidden';
	carousel.style.borderLeft = cPadding+'px white solid';
	carousel.style.borderRight = cPadding+'px white solid';


	carouselList.style.display = 'block';
	carouselList.style.listStyleType = 'none';
	carouselList.style.position = 'absolute';
	carouselList.style.margin = '0';
	carouselList.style.padding = '0';
	carouselList.style.left = '0px';
	carouselList.style.width = (cViewWidth*carouselItems.length)+100+'px';
	
	//clone first to last
	carouselList.appendChild(carouselItems[0].cloneNode(true));
	
	//clone last to first
	carouselList.insertBefore(carouselItems[carouselItems.length-2].cloneNode(true),carouselItems[0]);
	
	
	for(i = 0; i < carouselItems.length; i++){
		carouselItems[i].style.position = 'absolute';
		carouselItems[i].style.left = (cViewWidth)*i+'px';
		carouselItems[i].style.width = cViewWidth+'px';
		carouselItems[i].style.height = (cHeight)+'px';
		carouselItems[i].style.cursor = 'pointer';
		
		var span = carouselItems[i].getElementsByTagName('span')[0];
		span.style.display = 'none';
		span.style.position = 'absolute';
		span.style.cursor = 'pointer';
		
		//if(!document.body.className.match(referencePage)){
		if(_reference_showPopUp){
			carouselItems[i].getElementsByTagName('a')[0].onclick = function(){
				var spn = this.getElementsByTagName('span')[0];
				if(spn.style.display == 'block'){
					spn.style.display = 'none';
				} else {
					spn.style.display = 'block';
				}
				return false;
			}
		}
	}
	
	var totalPages = carouselItems.length-3;
	var currentPage = 0;
	var speed = 0.8;
	var pageSize = cViewWidth;
	
	//prevButtonWrapper
	var prevWrapper = document.createElement('div');
	prevWrapper.id = 'prevButtonWrapper';
	prevWrapper.style.display= 'block';
	prevWrapper.style.width = buttonWidth+'px';
	prevWrapper.style.height = cHeight+'px';
	prevWrapper.style.position = 'absolute';
	prevWrapper.style.top = '0px';
	prevWrapper.style.left = '0px';
	prevWrapper.style.backgroundImage = 'url("'+white+'")';
	prevWrapper.style.opacity = 0.8;
	prevWrapper.style.MozOpacity = 0.8;
	prevWrapper.style.filter = 'alpha(opacity=80)';
	
	
	//prevButton
	var prevButton = document.createElement('a');
	prevButton.id = 'prevButton';
	prevButton.style.href= '#';
	prevButton.style.display= 'block';
	prevButton.style.width = buttonWidth+'px';
	prevButton.style.height = cHeight+'px';
	prevButton.style.cursor = 'pointer';
	prevButton.style.backgroundImage = 'url("'+buttonPrevActive+'")';
	prevButton.onclick = handlePrev;
	
	//nextButtonWrapper
	var nextWrapper = document.createElement('div');
	nextWrapper.id = 'nextButtonWrapper';
	nextWrapper.style.display= 'block';
	nextWrapper.style.width = buttonWidth+'px';
	nextWrapper.style.height = cHeight+'px';
	nextWrapper.style.position = 'absolute';
	nextWrapper.style.top = '0px';
	nextWrapper.style.left = cViewWidth + cViewWidth +'px';
	nextWrapper.style.backgroundImage = 'url("'+white+'")';
	nextWrapper.style.opacity = 0.8;
	nextWrapper.style.MozOpacity = 0.8;
	nextWrapper.style.filter = 'alpha(opacity=80)';

	//nextButton
	var nextButton = document.createElement('a');
	nextButton.id = 'nextButton';
	nextButton.style.href= '#';
	nextButton.style.display= 'block';
	nextButton.style.width = buttonWidth+'px';
	nextButton.style.height = cHeight+'px';
	nextButton.style.cursor = 'pointer';
	nextButton.style.backgroundImage = 'url("'+buttonNextActive+'")';
	nextButton.onclick = handleNext;

	prevWrapper.appendChild(prevButton);
	nextWrapper.appendChild(nextButton);

	carousel.appendChild(prevWrapper);
	carousel.appendChild(nextWrapper);
	
	function handlePrev() {
		if (currentPage == 0) {
			currentPage = totalPages;
		} else {
			currentPage--;
		}
		
		var spans = carousel.getElementsByTagName('span');
		for(i = 0; i < spans.length; i++){
			spans[i].style.display = 'none';
		}

		new Effect.Morph(carouselList , {style: 'left:-'+ (currentPage * (pageSize))+'px', duration: speed});
		return false;
	}
	
	function handleNext() {
		if ((currentPage+1) > totalPages) {
			currentPage = 0;
		} else {
			currentPage++;
		}
		
		var spans = carousel.getElementsByTagName('span');
		for(i = 0; i < spans.length; i++){
			spans[i].style.display = 'none';
		}
		
		new Effect.Morph(carouselList , {style: 'left:-'+ (currentPage * (pageSize))+'px', duration: speed});
		return false;
	}	
}



 /*
  marklinks
*/
function markLinks(){

        var links = document.getElementsByTagName('a');
        var link, href, mark;
        
        for(var i = 0; i < links.length; i++){

               link = links[i];

               switch(link.getAttribute('rel')){

                       case 'ext': case 'external':
                               link.className += ' external';
                               link.target = '_blank';
                               
                               
                               if(link.getElementsByTagName('img').length == 0){
                                      href = link.getAttribute('href').toLowerCase();
                                      href = href.substring((href.length - 4), (href.length));

                                      switch(href){

                                              case '.pdf':
                                                     link.className += ' pdf';
                                                     mark = document.createElement('img');
                                                     mark.src = '/data/link-icons/pdf.png';
                                                     link.insertBefore(mark , (link.firstChild));
                                                     link.onclick = handleDownloadClick;
                                                     break;

                                              case '.xls':

                                                     link.className += ' pdf';
                                                     mark = document.createElement('img');
                                                     mark.src = '/data/link-icons/xls.png';
                                                     link.insertBefore(mark , (link.firstChild));
                                                     link.onclick = handleDownloadClick;
                                                     break;

                                              case '.doc':

                                                     link.className += ' pdf';
                                                     mark = document.createElement('img');
                                                     mark.src = '/data/link-icons/doc.png';
                                                     link.insertBefore(mark , (link.firstChild));
                                                     link.onclick = handleDownloadClick;
                                                     break;


                                              case '.ppt':
                                                     link.className += ' pdf';
                                                     mark = document.createElement('img');
                                                     mark.src = '/data/link-icons/ppt.png';
                                                     link.insertBefore(mark , (link.firstChild));
                                                     link.onclick = handleDownloadClick;
                                                     break;
                                                     
                                              default:
                                                     mark = document.createElement('img');
                                                     mark.src = '/data/link-icons/external.png';
                                                     link.appendChild(mark);
                                                     link.onclick = handleExternalSiteClick;
                                                     break;

                               }
                       }
               }
        }
      

        links = document.getElementById('content').getElementsByTagName('a');
  
        for(var i = 0; i < links.length; i++){
               if(links[i].getAttribute('href')){
                       href = document.createElement('span');
                               href.className = 'print';
                               href.appendChild((document.createTextNode(' [' + links[i].href + ']')));
                      

                       links[i].appendChild(href);
               }
        }

        mark = null;
        href = null;
        link = null;
        links = null;

}

function handleDownloadClick(){
	pageTracker._trackPageview(this.href);
}

function handleExternalSiteClick(){
	pageTracker._trackPageview('/externalSites/' + this.href);
} function peelRelocate(targetLocation) {
	window.open(targetLocation, '_blank');
}
 /*
  popups
*/
var aPopups = new Array();
var aModalPopups = new Array();

window.onfocus = function()
{
	if(aModalPopups.length != 0)
	{
		aModalPopups[0].focus();
	}
}


var sDefaultFeatures = 'channelmode=0, fullscreen=0, location=0, menubar=0, resizable=0, scrollbars=0, status=0, titlebar=0, toolbar=0';

// create popup
function createPopup(sURL, sName, sFeatures, iWidth, iHeight)
{
	var iLeft	= (screen.availWidth - iWidth) / 2;
	var iTop	= (screen.availHeight - iHeight) / 2;
	
	return window.open(sURL, sName, sFeatures + ', width=' + iWidth + ', height=' + iHeight + ', left=' + iLeft + ', top=' + iTop);
} /*
  set mainnav height
*/

function setNavHeight(){
	var activeUl = true;
	var navLi = document.getElementById('main-nav').childNodes;
	
	for(var i = 0; i < navLi.length; i++){
		// check active LI for child UL
		if(navLi[i].nodeName.toUpperCase() == 'LI' && navLi[i].className.match('active')){
			if(!navLi[i].getElementsByTagName('ul').length) activeUl = false;
		}
		// manualy disable submenus
		if(navLi[i].nodeName.toUpperCase() == 'LI' && navLi[i].className.match('active') && navLi[i].className.match('d430')){
			activeUl = false;
		}
		if(navLi[i].nodeName.toUpperCase() == 'LI' && navLi[i].className.match('active') && navLi[i].className.match('d1169')){
			activeUl = false;
		}
		if(navLi[i].nodeName.toUpperCase() == 'LI' && navLi[i].className.match('active') && navLi[i].className.match('d1217')){
			activeUl = false;
		}
	}
	
	if(activeUl == false) document.getElementById('main-nav').className += 'noSubnav';
}

 /*
  site flash header
*/

function flashHeader(){

	if(!document.getElementById('flashHeader')) return false;

	var so = new SWFObject('/img/siteTemplate/Signavure-logo.swf', "flashHeaderObj", "155", "70", "7");
	so.addParam("wmode", "transparent");
	so.write("flashHeader");

	if(document.getElementById("flashHeaderObj")){
		document.getElementById("headerLink").style.display = 'none';
	}


} /**
 * SWFObject v1.5: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
 *
 * SWFObject is (c) 2007 Geoff Stearns and is released under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 *
 */
if(typeof deconcept=="undefined"){var deconcept=new Object();}if(typeof deconcept.util=="undefined"){deconcept.util=new Object();}if(typeof deconcept.SWFObjectUtil=="undefined"){deconcept.SWFObjectUtil=new Object();}deconcept.SWFObject=function(_1,id,w,h,_5,c,_7,_8,_9,_a){if(!document.getElementById){return;}this.DETECT_KEY=_a?_a:"detectflash";this.skipDetect=deconcept.util.getRequestParameter(this.DETECT_KEY);this.params=new Object();this.variables=new Object();this.attributes=new Array();if(_1){this.setAttribute("swf",_1);}if(id){this.setAttribute("id",id);}if(w){this.setAttribute("width",w);}if(h){this.setAttribute("height",h);}if(_5){this.setAttribute("version",new deconcept.PlayerVersion(_5.toString().split(".")));}this.installedVer=deconcept.SWFObjectUtil.getPlayerVersion();if(!window.opera&&document.all&&this.installedVer.major>7){deconcept.SWFObject.doPrepUnload=true;}if(c){this.addParam("bgcolor",c);}var q=_7?_7:"high";this.addParam("quality",q);this.setAttribute("useExpressInstall",false);this.setAttribute("doExpressInstall",false);var _c=(_8)?_8:window.location;this.setAttribute("xiRedirectUrl",_c);this.setAttribute("redirectUrl","");if(_9){this.setAttribute("redirectUrl",_9);}};deconcept.SWFObject.prototype={useExpressInstall:function(_d){this.xiSWFPath=!_d?"expressinstall.swf":_d;this.setAttribute("useExpressInstall",true);},setAttribute:function(_e,_f){this.attributes[_e]=_f;},getAttribute:function(_10){return this.attributes[_10];},addParam:function(_11,_12){this.params[_11]=_12;},getParams:function(){return this.params;},addVariable:function(_13,_14){this.variables[_13]=_14;},getVariable:function(_15){return this.variables[_15];},getVariables:function(){return this.variables;},getVariablePairs:function(){var _16=new Array();var key;var _18=this.getVariables();for(key in _18){_16[_16.length]=key+"="+_18[key];}return _16;},getSWFHTML:function(){var _19="";if(navigator.plugins&&navigator.mimeTypes&&navigator.mimeTypes.length){if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","PlugIn");this.setAttribute("swf",this.xiSWFPath);}_19="<embed type=\"application/x-shockwave-flash\" src=\""+this.getAttribute("swf")+"\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\"";_19+=" id=\""+this.getAttribute("id")+"\" name=\""+this.getAttribute("id")+"\" ";var _1a=this.getParams();for(var key in _1a){_19+=[key]+"=\""+_1a[key]+"\" ";}var _1c=this.getVariablePairs().join("&");if(_1c.length>0){_19+="flashvars=\""+_1c+"\"";}_19+="/>";}else{if(this.getAttribute("doExpressInstall")){this.addVariable("MMplayerType","ActiveX");this.setAttribute("swf",this.xiSWFPath);}_19="<object id=\""+this.getAttribute("id")+"\" classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" width=\""+this.getAttribute("width")+"\" height=\""+this.getAttribute("height")+"\" style=\""+this.getAttribute("style")+"\">";_19+="<param name=\"movie\" value=\""+this.getAttribute("swf")+"\" />";var _1d=this.getParams();for(var key in _1d){_19+="<param name=\""+key+"\" value=\""+_1d[key]+"\" />";}var _1f=this.getVariablePairs().join("&");if(_1f.length>0){_19+="<param name=\"flashvars\" value=\""+_1f+"\" />";}_19+="</object>";}return _19;},write:function(_20){if(this.getAttribute("useExpressInstall")){var _21=new deconcept.PlayerVersion([6,0,65]);if(this.installedVer.versionIsValid(_21)&&!this.installedVer.versionIsValid(this.getAttribute("version"))){this.setAttribute("doExpressInstall",true);this.addVariable("MMredirectURL",escape(this.getAttribute("xiRedirectUrl")));document.title=document.title.slice(0,47)+" - Flash Player Installation";this.addVariable("MMdoctitle",document.title);}}if(this.skipDetect||this.getAttribute("doExpressInstall")||this.installedVer.versionIsValid(this.getAttribute("version"))){var n=(typeof _20=="string")?document.getElementById(_20):_20;n.innerHTML=this.getSWFHTML();return true;}else{if(this.getAttribute("redirectUrl")!=""){document.location.replace(this.getAttribute("redirectUrl"));}}return false;}};deconcept.SWFObjectUtil.getPlayerVersion=function(){var _23=new deconcept.PlayerVersion([0,0,0]);if(navigator.plugins&&navigator.mimeTypes.length){var x=navigator.plugins["Shockwave Flash"];if(x&&x.description){_23=new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/,"").replace(/(\s+r|\s+b[0-9]+)/,".").split("."));}}else{if(navigator.userAgent&&navigator.userAgent.indexOf("Windows CE")>=0){var axo=1;var _26=3;while(axo){try{_26++;axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+_26);_23=new deconcept.PlayerVersion([_26,0,0]);}catch(e){axo=null;}}}else{try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");}catch(e){try{var axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");_23=new deconcept.PlayerVersion([6,0,21]);axo.AllowScriptAccess="always";}catch(e){if(_23.major==6){return _23;}}try{axo=new ActiveXObject("ShockwaveFlash.ShockwaveFlash");}catch(e){}}if(axo!=null){_23=new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));}}}return _23;};deconcept.PlayerVersion=function(_29){this.major=_29[0]!=null?parseInt(_29[0]):0;this.minor=_29[1]!=null?parseInt(_29[1]):0;this.rev=_29[2]!=null?parseInt(_29[2]):0;};deconcept.PlayerVersion.prototype.versionIsValid=function(fv){if(this.major<fv.major){return false;}if(this.major>fv.major){return true;}if(this.minor<fv.minor){return false;}if(this.minor>fv.minor){return true;}if(this.rev<fv.rev){return false;}return true;};deconcept.util={getRequestParameter:function(_2b){var q=document.location.search||document.location.hash;if(_2b==null){return q;}if(q){var _2d=q.substring(1).split("&");for(var i=0;i<_2d.length;i++){if(_2d[i].substring(0,_2d[i].indexOf("="))==_2b){return _2d[i].substring((_2d[i].indexOf("=")+1));}}}return "";}};deconcept.SWFObjectUtil.cleanupSWFs=function(){var _2f=document.getElementsByTagName("OBJECT");for(var i=_2f.length-1;i>=0;i--){_2f[i].style.display="none";for(var x in _2f[i]){if(typeof _2f[i][x]=="function"){_2f[i][x]=function(){};}}}};if(deconcept.SWFObject.doPrepUnload){if(!deconcept.unloadSet){deconcept.SWFObjectUtil.prepUnload=function(){__flash_unloadHandler=function(){};__flash_savedUnloadHandler=function(){};window.attachEvent("onunload",deconcept.SWFObjectUtil.cleanupSWFs);};window.attachEvent("onbeforeunload",deconcept.SWFObjectUtil.prepUnload);deconcept.unloadSet=true;}}if(!document.getElementById&&document.all){document.getElementById=function(id){return document.all[id];};}var getQueryParamValue=deconcept.util.getRequestParameter;var FlashObject=deconcept.SWFObject;var SWFObject=deconcept.SWFObject;

 /*
  thumbnails
*/
function initThumbnails(){
	var aThumbnails = document.getElementsByTagName('img');
	var oThumbnail;
	
	for(var i = 0; i < aThumbnails.length; i++)	{
		oThumbnail = aThumbnails[i];
		
		if(oThumbnail.className.toLowerCase() == 'thumbnail'){
			
			oThumbnail.parentNode.setAttribute('naturalWidth', oThumbnail.width);
			oThumbnail.parentNode.setAttribute('naturalHeight', oThumbnail.height);
			
			// resize image
			if(oThumbnail.width > oThumbnail.height){
				oThumbnail.style.width = '90px';
			}else{
				oThumbnail.style.height = '60px';
			}
			
			// create popup
			oThumbnail.parentNode.onclick = function(){
				var iWidth = this.getAttribute('naturalWidth');
				var iHeight = this.getAttribute('naturalHeight');
				
				createPopup(this.getAttribute('href'), 'thumbnail', sDefaultFeatures, iWidth, iHeight);
				
				return false;
			}
		}
	}
}

