// JavaScript Document
var browserName=navigator.appName;var browserVer=parseInt(navigator.appVersion);var version="";var msie4=(browserName=="Microsoft Internet Explorer"&&browserVer>=4);if((browserName=="Netscape"&&browserVer>=3)||msie4||browserName=="Konqueror"||browserName=="Opera"){version="n3";}else{version="n2";}
function blurLink(theObject){if(msie4){theObject.blur();}}
function decryptCharcode(n,start,end,offset){n=n+offset;if(offset>0&&n>end){n=start+(n-end-1);}else if(offset<0&&n<start){n=end-(start-n-1);}
return String.fromCharCode(n);}
function decryptString(enc,offset){var dec="";var len=enc.length;for(var i=0;i<len;i++){var n=enc.charCodeAt(i);if(n>=0x2B&&n<=0x3A){dec+=decryptCharcode(n,0x2B,0x3A,offset);}else if(n>=0x40&&n<=0x5A){dec+=decryptCharcode(n,0x40,0x5A,offset);}else if(n>=0x61&&n<=0x7A){dec+=decryptCharcode(n,0x61,0x7A,offset);}else{dec+=enc.charAt(i);}}
return dec;}
function linkTo_UnCryptMailto(s){location.href=decryptString(s,-1);}

function doubleCheck(id) {      
        var checkid= 'uid1001_' + id;
        var checkid2= 'uid1002_' + id;
        var checker1= 'tx_powermail_pi1[uid1002]['+id+']';       
        
        var checked = document.getElementById(checkid).checked;        
	
	if(checked == true){
		document.getElementById(checkid2).checked = true;
	} else {
		document.getElementById(checkid2).checked = false;
	}
}
//Jquery
(function($) {
  $(document).ready(function(){
	LatestNewsSlider();
	ShowHeadersAndSliders();
  });
	
	function LatestNewsSlider() {
		$('#newsSliderContainer').cycle ({
		   fx:'custom', 
			speed:500, 
			pause:1,
			timeout: 5000,
			cssBefore: {  
				left: -750, 
				display: 'block',
				opacity: 1
			}, 
		 	animIn:  { 
				left: 0,
				opacity: 1
			}, 
			animOut: {  
				left: -750,
				opacity: 0
			},
			cssFirst: 
			{  
				left: 0, 
				display: 'block',
				opacity: 1
			}
		});
	}
	function ShowHeadersAndSliders() {
		$('#headerContentContainer').cycle({
			startingSlide:5,
    			timeout: 0,
    			speed:500
		});		
		$('#sloganContainer').cycle({
    		fx: 'custom',
			random: 1,
			cleartype:  1,
			startingSlide:5,
    		sync: 0,
			pause:  1,
			timeout: 5000,
			before: changeSlider,
    		cssBefore: {  
        		top:  0, 
        		left: -400, 
        		display: 'block'
			//opacity: 1
   		}, 
    		animIn:  { 
        		left: 0
			//opacity: 1
    		}, 
    		animOut: {  
		 	left: -400
		 	//opacity: 0
    		},
			cssFirst: 
			{  
        		display: 'block'
			//opacity: 1
    		}, 
    		delay: -1000
		});
	}
	function changeSlider (curr, next, opts, fwd) {
		//alert("current:"  + opts.currSlide + "\n nextslide:" +  opts.nextSlide); 
		//alert("current:"  + curr + "\n nextslide:" +  next); 
		if (!opts.addSlide) 
        	return; 
		$('#headerContentContainer').cycle(opts.nextSlide);
//		if(opts.nextSlide == 0)
//	  		{$('#headerContentContainer').cycle(0);}
//	  	else
//	  		{$('#headerContentContainer').cycle(opts.currSlide + 1);}
 	}

$(document).ready(function () {
	$('div.panel').jScrollPane();
	var $panels = $('.tx-kiwislider-pi1 .scrollContainer > div');
	var $container = $('.tx-kiwislider-pi1 .scrollContainer');
		
	// if false, we'll float all the panels left and fix the width 
	// of the container
	var horizontal = true;
		
	// float the panels left if we're going horizontal
	if (horizontal) {
			$panels.css({
		'float' : 'left',
		'position' : 'relative' // IE fix to ensure overflow is hidden
			});
		
		if($panels[0] != null)
		{
			// calculate a new width for the container (so it holds all panels)
			$container.css('width', $panels[0].offsetWidth * $panels.length);
		}
	}
		
	// collect the scroll object, at the same time apply the hidden overflow
	// to remove the default scrollbars that will appear
	var $scroll = $('.tx-kiwislider-pi1 .scroll').css('overflow', 'hidden');
		
	// apply our left + right buttons
	$scroll
			.before('<img class="scrollButtons left" src="typo3conf/ext/kiwi_slider/pi1/res/scroll_left.png">')
			.after('<img class="scrollButtons right" src="typo3conf/ext/kiwi_slider/pi1/res/scroll_right.png">');
		
	// handle nav selection
	function selectNav() {
			$(this)
		.parents('ul:first')
				.find('a')
			.removeClass('selected')
				.end()
		.end()
		.addClass('selected');
	}
		
	$('.tx-kiwislider-pi1 .navigation').find('a').click(selectNav);
		
	// go find the navigation link that has this target and select the nav
	function trigger(data) {
			var el = $('.tx-kiwislider-pi1 .navigation').find('a[href$="' + data.id + '"]').get(0);
			// alert (data.id);
			// alert (el);

			var $temp = $('.tx-kiwislider-pi1 .navigation').find('a[href$="' + data.id + '"]').html();
    			//alert($temp);
    			if ($temp.indexOf("Recensies") != -1){ $('#comment-form').attr("action", el) ;}
			selectNav.call(el);
	}
		
	if (window.location.hash) {
			trigger({ id : window.location.hash.substr(1) });
	} else {
			$('.tx-kiwislider-pi1 ul.navigation a:first').click();
	}
		
	// offset is used to move to *exactly* the right place, since I'm using
	// padding on my example, I need to subtract the amount of padding to
	// the offset.  Try removing this to get a good idea of the effect
	var offset = parseInt((horizontal ? 
			$container.css('paddingTop') : 
			$container.css('paddingLeft')) 
			|| 0) * -1;
		
		
	var scrollOptions = {
			target: $scroll, // the element that has the overflow
		
			// can be a selector which will be relative to the target
			items: $panels,
		
			navigation: '.navigation a',
		
			// selectors are NOT relative to document, i.e. make sure they're unique
			prev: 'img.left', 
			next: 'img.right',
		
			// allow the scroll effect to run both directions
			axis: 'xy',
		
			onAfter: trigger, // our final callback
		
			offset: offset,
		
			// duration of the sliding effect
			duration: 500,
		
			// easing - can be used with the easing plugin: 
			// http://gsgd.co.uk/sandbox/jquery/easing/
			easing: 'swing'
	};
		
	// apply serialScroll to the slider - we chose this plugin because it 
	// supports// the indexed next and previous scroll along with hooking 
	// in to our navigation.
	$('.tx-kiwislider-pi1').serialScroll(scrollOptions);
		
	// now apply localScroll to hook any other arbitrary links to trigger 
	// the effect
	$.localScroll(scrollOptions);
		
	// finally, if the URL has a hash, move the slider in to position, 
	// setting the duration to 1 because I don't want it to scroll in the
	// very first page load.  We don't always need this, but it ensures
	// the positioning is absolutely spot on when the pages loads.
	scrollOptions.duration = 1;
	$.localScroll.hash(scrollOptions);
});
	
})( jQuery );

function show(element){
   //element.className += "hover";
	   if (element.tagName != "LI"){return;}
		//alert(element.tagName);	   
		   var elementLeft = getElementPosition(element).left;
		   var ParentPos = getElementPosition(element.parentNode).left;
		   //var NewChildPos = elementLeft-ParentPos;
		   var NewChildPos = elementLeft;
		  // alert (NewChildPos);
		  //alert ("ParentPos: " + ParentPos + "\nelementLeft: " + elementLeft+ "\nNewChildPos: " + NewChildPos);
		   var childNodeUL;
		   // Find UL Child 
		   var children = element.childNodes;
				for (var i = 0; i < children.length; i++ )
				{
					if (children.item(i).tagName == "UL") {childNodeUL = children.item(i);}
				}
			//re-assign position!
			if(childNodeUL) {
			childNodeUL.style.left = NewChildPos + 'px';
			//alert(NewChildPos + 'px');
			//alert ("ParentPos: " + ParentPos + "\nelementLeft: " + elementLeft+ "\nNewChildPos: " + NewChildPos);
			//if outside de headerbox move box to left	
			//if ((NewChildPos+195) > 970 ){childNodeUL.style.left = NewChildPos-(195-element.offsetWidth)+ 'px';}
			if ((NewChildPos + 195) > (1000 + ParentPos)  ){childNodeUL.style.left = NewChildPos-(195 - element.offsetWidth)+ 'px';}
			}
}

function getElementPosition(elemID){
  var offsetTrail = elemID;
	var offsetLeft = 0;
	var offsetTop = 0;
	while (offsetTrail){
			offsetLeft += offsetTrail.offsetLeft;
			offsetTop += offsetTrail.offsetTop;
			offsetTrail = offsetTrail.offsetParent;
	}

	if (navigator.userAgent.indexOf('Mac') != -1 && typeof document.body.leftMargin != 'undefined'){
		offsetLeft += document.body.leftMargin;
		offsetTop += document.body.topMargin;
	}
   return {left:offsetLeft,top:offsetTop};
}



