function isIE6(){
	var ie55 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 5.5") != -1);
	var ie6 = (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion) == 4 && navigator.appVersion.indexOf("MSIE 6.0") != -1);
	return $.browser.msie && (ie55 || ie6);
}
browser = {
	msie:	 /msie/i.test(navigator.userAgent),
	ie6:	/msie (5|6)/i.test(navigator.userAgent),
	opera:	 /opera/i.test(navigator.userAgent),
	safari:  /webkit/i.test(navigator.userAgent),
	mozilla: /mozilla/i.test(navigator.userAgent)
};
function initHome(){
	loadStylePatch();
	$(document).pngFix(); 
	initSlider();
	fixHacks();
	scrollTop(true);
	initTopNav();
	initBtn();
	initTabForm();
	initProject();
	initPageSize();
	//initFeeder();
	initSiteMap();
	
	$('#wie .bek, #wie .less').hover(function(){
		$('.arrow', this).addClass('arrow-hover');
	}, function(){
		$('.arrow', this).removeClass('arrow-hover');
	});
	$("#wat ul li").mouseout(function(){
		$(this).removeClass('hover');
		if(isIE6()){
			IEfilter($(this).find(".arrow"), "icon_arrow.png");
		}
    });
	$("#wat ul li").mouseover(function(){
		$(this).addClass('hover');
		if(isIE6()){
			IEfilter($(this).find(".arrow"), "icon_bright_arrow.png");
		}
	});
	initMenuItems();
	//initSIRconfig();
}
function initSubPage(){
	loadStylePatch();
	$(document).pngFix(); 
	fixHacks();
	initbreadcrumb(0.44);
	scrollTop(false);
	initTopNav();
	initBtn();
	initPageSize();
	initMenuItems();
	initSiteMap();
	//initSIRconfig();
}
function NewsItem(title, url, date, img, summary)
{
	this.title = title;
	this.url = url;
	this.date = date;
	this.img = img;
	this.summary = summary;
	this.tohtml = function ToHtml(){
		var ret = "<img class=\"avatar\" alt=\"\" title=\"\" src=\"images/news/" + this.img+ "\"  height=\"53\" width=\"53\" />";
		ret += "<h2><span class=\"title\">"+ this.title +"</span></h2>";
		ret += "<p class=\"date\">"+ this.date +"</p>";
		ret += "<p>"+this.summary+"</p>";
		ret += "<p align=\"center\"><a href=\""+this.url+"\"><img alt=\"\" title=\"\" class=\"btn-click\" src=\"images/blank.gif\"/></a></p>";
		return ret;
	}
}
function NewsRotator(selector, settings){
	settings = $.extend({
		fade: 750,
		timeout: 9000,
		minHeight:170
	}, settings);
	
	this.opts = settings;
	this.dom = $(selector);
	var divs = $('div', selector);
	this.frontNewsFrame = divs[1];
	this.backNewsFrame = divs[0];

	this.newsList = [];	// array of news items
	this.curNews = 0;

	this.links = [];		// news Nav

	this.fadeNewsSpeed = null;		// fade settings
	this.timeout = null; 		// js timeout function

	this.init();
}
NewsRotator.prototype = {
	init: function(){
		this.dom.css({'min-height': this.opts.minHeight + 'px'});
		if(isIE6()){
			this.dom.css({'height': this.opts.minHeight + 'px'});
		}
		$(this.frontNewsFrame).hide();
		var self = this;
		$.get(this.opts.url, function(xml){
			var i = 0;
			$(xml).find('item').each(function() {
				var item = $(this);
				self.newsList[i] = new NewsItem(
					item.find('title').text(),
					item.find('url').text(),
					item.find("date").text(),
					item.find('img').text(),
					item.find('summary').text()
				);
				i++;
			});
			self.toggleNews();
		});
	}
	,toggleNews: function(){
		if (++this.curNews >= this.newsList.length) this.curNews = 0;

		// swap frames
		var temp = this.frontNewsFrame;
		this.frontNewsFrame = this.backNewsFrame;
		this.backNewsFrame = temp;

		// set current image to hide next
		//$(this.frontNewsFrame).show();

		// prepare to swap image
		//$(this.backNewsFrame).hide();
		$(this.backNewsFrame).html(this.newsList[this.curNews].tohtml());

		$('.btn-click').hover(function(){
			$(this).addClass('btn-click-hover');
		}, function(){
			$(this).removeClass('btn-click-hover');
		});
		// fade in next image and repeat
		var self = this;
		this.timeout = setTimeout(function() { self.fadeNews(); }, this.opts.timeout);	
	}
	,fadeNews: function(){
		var self = this;
		$(this.frontNewsFrame).slideUp(this.opts.fade,function(){
			$(self.backNewsFrame).slideDown(self.opts.fade, function(){
				self.toggleNews();
			});
		});
	}
};
function Tabmenu(tabContainer, menuPanel){
	this.tabResetTimer = {};
	this.panelCloseTimer = null;
	this.menuPanelOpen = false;
	this.mouseOverPanel = false;
	this.activeTab = null;
	this.options = {
		slideDuration    : 800, // duration of slide effect
		slideInTimeout   : 500, // time until panel closes on mouseout
		activeTabClass: 'hover',
		tabContentPrefix: 'sub_menu',
		tabMenuPrefix: 'menu-item',
		tabframe: 'tabbed-menu-slider-frame',
		tabBg: 'tabbed-menu-slider-bg',
		bgOpacity: 0.9
	};
	this.init(tabContainer, menuPanel);

}
Tabmenu.prototype = {
	init: function(tabContainer, menuPanel){
		this.tabCollection = $("#"+ tabContainer +" ul li");
		this.menuPanel = $("#" + menuPanel);
		this.tabFrame = $("#" + this.options.tabframe);
		this.tabBg = $("#" + this.options.tabBg);

		this.initMargins(tabContainer, menuPanel);

		/*
		this.tabBg.css({
			"opacity": this.options.bgOpacity,
			"-moz-opacity": this.options.bgOpacity,
			"filter": "alpha(opacity="+(this.options.bgOpacity*100)+")"
		});
		*/
		$('ul li', this.tabFrame).hover(function(){
			$(this).addClass('hover');
			$(this).prev('li').addClass('hover-prev');
		}, function(){
			$(this).removeClass('hover');
			$(this).prev('li').removeClass('hover-prev');
		});
		var self = this;
		//this.tabFrame.slideUp(this.options.slideDuration);
		this.tabCollection.each(function(tab) {
			
			$(this).hover(function(){
				self.checkTimers(this);
				self.resetOtherTabs(this);
				self.activateTab(this);

				var panelId = self.getPanelId(this);
				if(($(panelId).length > 0) && (!self.menuPanelOpen)) self.openMenuPanel();
			}, function(){
				var tab = this;
				var t = setTimeout(function(){
					if( self.activeTab != tab ){
						self.deactivateTab(tab);
					}
					else{
						if(! self.mouseOverPanel ){
							self.closeMenuPanel(tab);
						}
					}
				}, 80);
			});
			/*
			$(this).bind('mouseenter', function(){
				self.checkTimers(this);
				self.resetOtherTabs(this);
				self.activateTab(this);

				if(! self.menuPanelOpen ) self.openMenuPanel();
			});

			$(this).bind('mouseleave', function(e){
				var tab = this;
				var t = setTimeout(function(){
					if( self.activeTab != tab ){
						self.deactivateTab(tab);
					}
					else{
						if(! self.mouseOverPanel ){
							self.closeMenuPanel(tab);
						}
					}
				}, 20);
			});
			*/
		});
		
		$(this.menuPanel).bind('mouseover', function(){
			if( self.menuPanelOpen ){
				self.checkTimers();
				self.mouseOverPanel = true;
			}
		});
		
		$(this.menuPanel).bind('mouseout', function(){
			if( self.menuPanelOpen ){
				self.mouseOverPanel = false;
				self.panelCloseTimer = setTimeout(function(){self.closeMenuPanel(self.activeTab)}, self.options.slideInTimeout);
			}
		});

	},
  initMargins: function(tabContainer, menuPanel){
     var self = this;
     var cotainerLeft = $('#'+tabContainer).offset().left;
	 var containerWidth = $('#'+tabContainer).width();
	 this.tabCollection.each(function(){
		var left = $(this).offset().left;
		left = left - cotainerLeft;
		var panelId = self.getPanelId(this);
		if($(panelId).length > 0){
			$(panelId+' > div > ul > li > a').each(function(){
				$(this).parent().css({'paddingLeft': left + 'px'});
				var subMenuItems = $('ul', $(this).parent());
				if(subMenuItems.length > 0){
					$(this).append('<div class="arrow"></div>');
					var subLeft = left + parseInt($(this).css('width').replace('px', '')) + 20;
					subMenuItems.css({'left': subLeft  + 'px'});
					$('li a', subMenuItems).each(function(){
						var ssubLeft = subLeft + parseInt($(this).css('width').replace('px', ''));
						var a = containerWidth;
						if(!subMenuItems.hasClass('long-menu')){
							$(this).css({'paddingRight': containerWidth - ssubLeft + 'px'});
						}
					});
					
				}
			});
		}
	 });
  },
  getPanelId: function(tab){
		var panelId = $(tab).attr('id').replace(this.options.tabMenuPrefix, '');
		panelId = '#' + this.options.tabContentPrefix + panelId;
		return panelId;
  },
  activateTab: function(tab){
    this.activeTab = tab;
	$('a', tab).addClass(this.options.activeTabClass);
	var panelId = this.getPanelId(tab);
	if($(panelId).length<=0){
		this.tabFrame.slideUp();
		this.menuPanelOpen = false;
		return false;
	}
    $(panelId).show();

  },
  
  deactivateTab: function(tab){
    if( this.activeTab == tab ){
      this.activeTab = null; // only reset if theres no new active tab
    }
	$('a', tab).removeClass(this.options.activeTabClass);

	var panelId = this.getPanelId(tab);
    $(panelId).hide();
  },
  
  /**
   * If the mouse went from panel to a non-active tab, the previous active
   * tab should be deactivated.
   * @param {Object} newTab The tab that triggers the mouseover
   */
  resetOtherTabs: function(newTab){
    if( this.activeTab && this.activeTab != newTab ){
      this.deactivateTab(this.activeTab);
    }
  },
  
  openMenuPanel: function(){
	  var self = this;
	  this.menuPanelOpen = true;
	  this.tabFrame.slideDown(this.options.slideDuration, function(){
		  //this.dequeue();
	  });
  },
  
  closeMenuPanel: function(resetTab){
    if( this.mouseOverPanel ) this.mouseOverPanel = false;
    
    this.menuPanelOpen = false;

    
	var self = this;
    self.tabResetTimer = {
      tab  : resetTab,
      timer: setTimeout(function(){self.deactivateTab(resetTab);}, 800)
    };
	var self = this;
	this.tabFrame.slideUp(this.options.slideDuration);
  },
  
  checkTimers: function(tab){
    if( this.panelCloseTimer  ){ // if slider is is set to close
      clearTimeout(this.panelCloseTimer);
    }
    
    if( this.tabResetTimer.timer && tab ){ // if slider is still closing
      if( this.tabResetTimer.tab == tab ){
        this.clearTabResetTimer(false);
      }
      else {
        this.clearTabResetTimer(true);
      }
    }
  },
  
  clearTabResetTimer: function(resetTab){
    if( resetTab ){
      this.deactivateTab(this.tabResetTimer.tab);
    }
	clearTimeout(this.tabResetTimer.timer);
    this.tabResetTimer = {};
  }
}
function initMenuItems(){
	var tabmenu = new Tabmenu("menu", "tabbed-menu-slider");			
}
function initPageSize(){
	var size = 500;
	if($("#doc-content .doc-content-bd").height()< size){
		if(isIE6()){
			$("#doc-content .doc-content-bd").css({"height": size+"px"});
		}
		else{
			$("#doc-content .doc-content-bd").css({"min-height": size+"px"});
		}
	}
	initPageWidth();
	var diffH = $(window).height() - $('body').height();
	if(diffH > 0){
		$('body').addClass('h-screen');
		$('body>div:first-child').wrap('<div id="page-wrap"></div>');
		$('body').append('<div id="footer-space"></div>');
		$('#footer-space').height(diffH);
	}
}
function initPageWidth(){
		$('body').css({'overflow-x': 'hidden'});
		var pW = $(window).width();
		if(pW<=1060){
			$('#scroll-top').hide();
			//$('#page').css({'width': '1100px'});
		}
		else{
			$('#scroll-top').show();
			//$('#page').css({'width': '100%'});
		}
		if(pW<=1008){
			$('#container .shadow-left, #container .shadow-right').hide();
			$('#container, #top').css({'padding-left':'0px', 'padding-right':'0px'});
		}
}
function initTagCloud(tags){
	var so = new SWFObject("flash/tagcloud.swf", "tagcloudflash", "233", "177", "9");
	so.addParam("allowScriptAccess", "always");
	so.addVariable("tcolor", "0x3b78d3");
	so.addVariable("tcolor2", "0x333333");
	so.addVariable("hicolor", "0x5391d0");
	so.addVariable("tspeed", "100");
	so.addVariable("distr", "true");
	so.addVariable("mode", "tags");	
	so.addVariable("tagcloud", tags);	
	so.addParam("transparent", true);	
	so.addParam("menu", false);	
	so.write("tagcloud");
}
function initbreadcrumb(rate){
	$("#theme .breadcrumb-shadow").css({
			"opacity": rate,
			"-moz-opacity": rate,
			"filter": "alpha(opacity="+(rate*100)+")"
	});
}
function initFeeder(){
	$('#feeder').innerfade({
		animationtype: 'fade',
		speed: 2000,
		timeout: 4500,
		containerheight: '120px',
		containerwidth: '202px'
	});
}
function initBtn(){
	$('span.btn').mouseout(function(){
		$(this).removeClass('btn-active');							   
	});
	$('span.btn').mouseover(function(){
		$(this).addClass('btn-active');	
	});		
	$("span.btn a").focus(function(){this.blur();});
}
function initProject(){
	$('#home .leftcx #project .detail .pic').mouseout(function(){
		$(this).removeClass('pic-hover');							   
	});
	$('#home .leftcx #project .detail .pic').mouseover(function(){
		$(this).addClass('pic-hover');	
	});			
	$('body').append('<div id="prjhover"></div>');
 	$('#project-infos .detail .pic a img').hover(function(e){
  		$('#prjhover').css({left:e.pageX+15,top:e.pageY}).show();
 		},function(e){
  			$('#prjhover').css({left:e.pageX+15,top:e.pageY}).hide();
 		}).mousemove(function(e){
  		$('#prjhover').stop().css('opacity',1).css({left:e.pageX+15,top:e.pageY});});	
}
function initContactform(){
	$('#contactform').validate({
		rules: {
			bedrijfsnaam: {
				required: true
			}
			,email:{
				required: true,
				email: true
			}
			,vraag:{
				required: true
			}
			,tel:{
				number: true,
				maxlength: 10
			}
			,securitycode:{
				required: true,
				remote: "check_verifycode.php"
			}
		},
		messages: {
			bedrijfsnaam: {
				required: ''
			}
			,email:{
				required: '',
				email: ''
			}
			,vraag:{
				required: ''
			}
			,tel:{
				number: '',
				maxlength: ''
			}			
			,securitycode:{
				required: '',
				remote: ''
			}
		},
		errorPlacement: function(error, element){
			$(element).addClass('error');
		}
	});
	$('#btn-verzenden').click(function(){
		$('#contactform').submit();
		return false;
	});	
}

function initOfferteForm(){
	$('#contactform').validate({
		rules: {
			uwnaam: {
				required: true
			}
			,bedrijfsnaam:{
				required: true
			}
			,adress:{
				required: true
			}
			,postcode:{
				required: true,
				postcode: true
			}
			,vestigingsplaats:{
				required: true
			}
			,email:{
				required: true,
				email: true
			}
			,tel:{
				number: true,
				maxlength: 10
			},			
			website: {
				url: true
			}
			,projectinfo:{
				required: true
			}
			,attachmentfile:{
				accept: 'doc|docx|jpg|jpeg|gif|pdf|txt|xls|xlsx|zip|rar'
			}
			,securitycode:{
				required: true,
				remote: "check_verifycode.php"
			}
		},
		messages: {
			uwnaam: {
				required: ''
			}
			,bedrijfsnaam:{
				required: ''
			}
			,adress:{
				required: ''
			}
			,postcode:{
				required: '',
				postcode: ''
			}
			,vestigingsplaats:{
				required: ''
			}
			,email:{
				required: '',
				email: ''
			}
			,tel:{
				number: '',
				maxlength: ''
			}
			,website: {
				url: ''
			}
			,projectinfo:{
				required: ''
			}
			,attachmentfile:{
				accept: ''
			}			
			,securitycode:{
				required: '',
				remote: ''
			}
		},
		errorPlacement: function(error, element){
			$(element).addClass('error');
		}
	});
	$('#btn-verzenden').click(function(){
		$('#contactform').submit();
		return false;
	});	
	
	$('#contactform #f11').change(function(){
		$('#contactform #f12').empty();
		val = $(this).val();
		$.ajax({
			   url: 'getComponents.php',
			   type: 'post',
			   dataType: 'html',
			   data: 'comp='+val,
			   success: function(html){
				   $('#contactform #f12').html(html);
			   }
		});
	});
}
function initTabForm(){
	$("#tab-form .hd ul li a").focus(function(){this.blur();});
	$('#tab-form .hd ul li').each(function(index){
		$(this).click(function(){
			$(this).parents("ul").find('li').removeClass('active');
			$(this).addClass('active');	
			var tbody = $(this).parents('.hd').siblings('.bd').find('.form-panel');
			tbody.hide();
			$(tbody[index]).show();
			return false;
		});								   
	});
	
	$('#tab-form #contactform1').validate({
		rules: {
			name: {
				required: true
			},
			bed: {
				required: true
			}
			,email:{
				required: true,
				email: true
			}
			,vraag:{
				required: true
			}
			,securitycode:{
				required: true,
				remote: "check_verifycode.php"
			}
		},
		messages: {
			name: {
				required: ''
			},
			bed: {
				required: ''
			}
			,email:{
				required: '',
				email: ''
			}
			,vraag:{
				required: ''
			}
			,securitycode:{
				required: '',
				remote: ''
			}			
		},
		errorPlacement: function(error, element){
			$(element).addClass('error');
		},
		submitHandler: function() {
			$('#tab-form #contactform1 .form-ct').hide();
			$('#tab-form #contactform1 .result-info .result-text').fadeOut('fast');										  
			$('#tab-form #contactform1 .result-info').append('<div class="mail-processing"></div>');				
			$('#tab-form #contactform1').ajaxSubmit({
				type: 'post',
				dataType: 'json',
				success: function(result){
					$('#tab-form #contactform1 .result-info .mail-processing').fadeOut('fast', function(){
						$('#tab-form #contactform1 .result-info .result-text').fadeIn('fast');
						$(this).remove();
					});
				}
			});
		}
	});
	$('#tab-form #contactform2').validate({
		rules: {
			name: {
				required: true
			},
			bed: {
				required: true
			}
			,securitycode:{
				required: true,
				remote: "check_verifycode.php"
			}
		},
		messages: {
			name: {
				required: ''
			},
			bed: {
				required: ''
			}
			,securitycode:{
				required: '',
				remote: ''
			}			
		},
		errorPlacement: function(error, element){
			$(element).addClass('error');
		},
		submitHandler: function() {
			$('#tab-form #contactform2 .form-ct').hide();
			$('#tab-form #contactform2 .result-info .result-text').fadeOut('fast');										  
			$('#tab-form #contactform2 .result-info').append('<div class="mail-processing"></div>');				
			$('#tab-form #contactform2').ajaxSubmit({
				type: 'post',
				dataType: 'json',
				success: function(result){
					$('#tab-form #contactform2 .result-info .mail-processing').fadeOut('fast', function(){
						$('#tab-form #contactform2 .result-info .result-text').fadeIn('fast');
						$(this).remove();
					});
				}
			});
		}
	});	
	$('#tab-form #contactform3').validate({
		rules: {
			name: {
				required: true
			},
			bed: {
				required: true
			}
			,email:{
				required: true,
				email: true
			}
		},
		messages: {
			name: {
				required: ''
			},
			bed: {
				required: ''
			}
			,email:{
				required: '',
				email: ''
			}		
		},
		errorPlacement: function(error, element){
			$(element).addClass('error');
		},
		submitHandler: function() {
		$('#tab-form #contactform3 .form-ct').hide();
		$('#tab-form #contactform3 .result-info .result-text').fadeOut('fast');										  
		$('#tab-form #contactform3 .result-info').append('<div class="mail-processing"></div>');			
			$('#tab-form #contactform3').ajaxSubmit({
				type: 'post',
				dataType: 'json',
				success: function(result){
					$('#tab-form #contactform3 .result-info .mail-processing').fadeOut('fast', function(){
						$('#tab-form #contactform3 .result-info .result-text').fadeIn('fast');	
						$(this).remove();
					});
				}
			});
		}
	});	
	$('#tab-form #contactform1 input, #tab-form #contactform1 textarea').focus(function(){
		$('#tab-form #contactform1 .result-info .result-text').slideUp('fast');											  
	});	
	$('#tab-form #contactform2 input').focus(function(){
		$('#tab-form #contactform2 .result-info .result-text').slideUp('fast');											  
	});	
	$('#tab-form #contactform3 input').focus(function(){
		$('#tab-form #contactform3 .result-info .result-text').slideUp('fast');											  
	});
	$('#contact-btn1').click(function(){								  
		$('#contactform1').submit();
		return false;
	});
	$('#contact-btn2').click(function(){								  
		$('#contactform2').submit();
		return false;
	});	
	$('#contact-btn3').click(function(){
		$('#contactform3').submit();
		return false;
	});
	$('#home .rightcx #tab-form .back-btn .btn a').click(function(){
		var formpanel = $(this).parents('.form-panel');
		$('.result-text', formpanel).hide();
		$('.form-ct', formpanel).show();
		return false;
	});
}
function initTopNav(){
	$.sifr({ path: 'flash/' , font: 'agendaboldcondensed', save: true });
	$("#btn-sitemap").click(function(){
		$('#sitemap-wrap').slideToggle(400);
		return false;
	});
	$("#btn-minilogin").click(function(){
		$("#miniloginForm").toggle();
		return false;
	});
	$('#top .top-nav #miniloginForm .btn-close').click(function(){
		$("#miniloginForm").hide();
	});
	$('.login-panel .btn-login').hover(function(){
		$(this).addClass('btn-login-hover');
		if(isIE6()){
			IEfilter($(this), "btn_login_active.png");
		}		
	}, function(){
		$(this).removeClass('btn-login-hover');
		if(isIE6()){
			IEfilter($(this), "btn_login.png");
		}			
	});
 	$('#top .search-form .txt').focus(function(){
		$(this).addClass('txt-active');
		if(this.value == 'Zoeken') this.value = '';
	});
	$('#top .search-form .txt').blur(function(){
		$(this).removeClass('txt-active');
		if(this.value == '') this.value = 'Zoeken';
	});	

 	$('input.txt, textarea.txt').focus(function(){
		$(this).addClass('txt-active');
	});
	$('input.txt, textarea.txt').blur(function(){
		$(this).removeClass('txt-active');
	});	
	
 	$('select').focus(function(){
		$(this).addClass('active');
	});
	$('select').blur(function(){
		$(this).removeClass('active');
	});		
	
	var p = '#home .leftcx #wie p ,#home .leftcx #project .detail p, .subpage .colpadding p, #concepten .sub-content p';
	$('#text-size1').click(function(){
		$(this).parent().find('a').removeClass('active');
		$(this).addClass('active');
		$(p).removeClass('text-middle');							
		$(p).removeClass('text-large');
		$(p).addClass('text-small');
		return false;
	});
	$('#text-size2').click(function(){
		$(this).parent().find('a').removeClass('active');
		$(this).addClass('active');
		$(p).removeClass('text-small');							
		$(p).removeClass('text-large');									
		$(p).addClass('text-middle');
		return false;
	});
	$('#text-size3').click(function(){
		$(this).parent().find('a').removeClass('active');
		$(this).addClass('active');
		$(p).removeClass('text-small');							
		$(p).removeClass('text-middle');									
		$(p).addClass('text-large');
		return false;
	});	
}
function scrollTop(ishome){
	$("#scroll-top a").focus(function(){this.blur();});
	var offset = ishome ? -49: 20;
 	if($(window).scrollTop()!=0){
  		$('#scroll-top').stop().animate({top:$(window).scrollTop() + offset},750,'swing');
	}
 	$(window).scroll(function(){
  	$('#scroll-top').stop().animate({top:$(window).scrollTop() + offset},750,'swing');});	
}
function scroll(obj,offset){
 if(location.pathname.replace(/^\//,'')==obj.pathname.replace(/^\//,'') && location.hostname==obj.hostname){
  var $target=$(obj.hash);
  $target=$target.length&&$target||$('[name='+obj.hash.slice(1)+']');
  if($target.length){
   var targetOffset=$target.offset().top+offset;
   $('html,body').stop().animate({scrollTop:targetOffset},500,'swing');
   return false;
  }
 }
}
function initSlider(){
	if(isIE6()){
		$('body').addClass('ie6');
	}
	var promo = new Promo({id: 'slider'});
	initHover("#slider .tab-body #tab-panel1 .items li");
	initHover("#slider .tab-body #tab-panel3 .items li");
	
	$("#slider .tab-body #tab-panel4 .items .item").mouseout(function(){
		$(this).removeClass('hover');
		if(isIE6()){
			IEfilter($(this).find(".check"), "icon_check4.png");
		}
    });
	$("#slider .tab-body #tab-panel4 .items .item").mouseover(function(){
		$(this).addClass('hover');
		if(isIE6()){
			IEfilter($(this).find(".check"), "icon_check4_hover.png");
		}
	});		
}
function loadStylePatch(){
	if(isIE6()){
		var style = document.createElement('link');
			style.setAttribute('rel','stylesheet');
			style.setAttribute('type','text/css');
			style.setAttribute('href','css/style.patch.css');
			document.getElementsByTagName('head')[0].appendChild(style)	;		
	}	
}
function fixHacks(){
	if(isIE6()){
		$("#doc-content .shadow-right").css("right", "-1px");
		$("#doc-content #scroll-top").css("right", "-41px");
		//if($("#page").width()<1100) $("#page").css({"width": "1100px"});
	};
	
}
function initHover(selector){
	$(selector).mouseout(function(){
		$(this).removeClass('hover');
	});
	$(selector).mouseover(function(){
		$(this).addClass('hover');
	});		
}
function IEfilter(obj, image){
		$(obj).get(0).runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='images/"+image+"',sizingMethod='image')";		
}
function Promo(config){
	  config = config||{};
	  if(!config.id) return false;
	  this.selector = '#' + config.id;
	  this.menuwrap = config.menuwrap || '.tab-menu';
	  this.bodywrap = config.bodywrap || '.tab-body-wrap';
	  this.menuprefix = config.menuprefix || 'tab-item';
	  this.bodyprefix = config.menuprefix || 'tab-panel';
	  this.itemclass = "panel";
	  this.target = config.target || '.tab-body-wrap';
	  this.speed = config.speed || 1200;
	  this.easing = config.easing|| 'swing';
	  
	  this.itemWidth = 975;
  	  this.iCurItem = 0;
  	  this.iLastItem = 0;
  	  this.iInterval = config.iInterval || 10;
	  this.auto = true;
	  
	  this.iArray = new Array();
	  
	  this.initPromo();
	  this.cycleItems();
}
Promo.prototype = {
	initPromo: function(){
		$(this.selector).find(this.menuwrap + " li").mouseout(function(){
			$(this).removeClass('hover');		
			$(this).prev('li').removeClass('hover-prev');	
			$(this).next('li').removeClass('hover-next');				
		});
		$(this.selector).find(this.menuwrap + " li").mouseover(function(){
			$(this).addClass('hover');	
			$(this).prev('li').addClass('hover-prev');	
			$(this).next('li').addClass('hover-next');	
		});			
		$(this.selector).find(this.menuwrap + " li a").focus(function(){this.blur();});
		var p = this;
		$(this.selector).find(this.menuwrap + " li a").each(function(index){
			$(this).click(function(e){
				if(p.auto){				   
					var leftstr = '-' + (p.itemWidth * (p.iCurItem -1)) + 'px';
					var itemWrapper = $(p.selector).find('.tab-body');		
					itemWrapper.css({left: leftstr});
					p.auto = false;
				}
				p.stopCycle(false);
				p.changeItem(index+1);
				return false;
			});
		});
		
		this.iTotItems = $(this.selector).find(this.menuwrap + " li").length + 1;
		
		var elems = $(this.selector +" " + this.bodywrap +" ." + this.itemclass);
		var lastItem = document.createElement('div');
		lastItem.className = elems[0].className;
		//$(lastItem).addClass(this.itemclass);
		$(lastItem).html($(elems[0]).html());
		$(this.selector).find('.tab-body').append(lastItem);

		$(this.selector).find('.tab-body').width(this.itemWidth * (this.iTotItems));
		
		this.iArray[0] = new Array(7, 6, 5, 4, 3, 2, 1);
		this.iArray[1] = new Array(1, 7, 6, 5, 4, 3, 2);
		this.iArray[2] = new Array(2, 1, 7, 6, 5, 4, 3);
		this.iArray[3] = new Array(3, 2, 1, 7, 6, 5, 4);
		this.iArray[4] = new Array(4, 3, 2, 1, 7, 6, 5);
		this.iArray[5] = new Array(5, 4, 3, 2, 1, 7, 6);
		this.iArray[6] = new Array(4, 3, 2, 1, 7, 6, 5);
		
	}
	,changeItem: function(index){
		this.iCurItem  = index;
		$(this.selector).find(this.menuwrap + " ul li").removeClass('active');
		$(this.selector).find(this.menuwrap + " ul li").removeClass('active-prev');
		$(this.selector).find(this.menuwrap + " ul li").removeClass('active-next');
		var currentItem = $($(this.selector).find(this.menuwrap + " ul li")[index-1]);
		currentItem.addClass('active');	
		currentItem.prev('li').addClass('active-prev');
		currentItem.next('li').addClass('active-next');
		
		var itemWrapper = $(this.selector).find('.tab-body');
		itemWrapper.stop();
			var leftstr = '-' + (this.itemWidth * (index -1)) + 'px';
			itemWrapper.animate({
					'left':leftstr
					},
					this.speed,
					this.easing,
					function(){
						return false;
					}
			);		

		/*
		var elem = $(this.selector +" " + this.bodywrap +" ." + this.itemclass)[index-1];
		if (elem){
			var target = $( this.target || $.scrollTo.window());
			target.scrollTo( elem, {
							 axis:'x',
							 duration:1000
							 }).trigger('notify.serialScroll',[elem]);
			target.queue(function(){
				$(this).dequeue();
			});
		}		
		*/
	}
	,fadeItem: function(index){
		this.iCurItem = index;
		$(this.selector).find(this.menuwrap + " ul li").removeClass('active');
		$(this.selector).find(this.menuwrap + " ul li").removeClass('active-prev');
		$(this.selector).find(this.menuwrap + " ul li").removeClass('active-next');
		var menuIndex = index;
		if(index >= this.iTotItems){
			menuIndex = 1;
		}
		var currentItem = $($(this.selector).find(this.menuwrap + " ul li")[menuIndex - 1]);
		currentItem.addClass('active');	
		currentItem.prev('li').addClass('active-prev');
		currentItem.next('li').addClass('active-next');
		
		var elems = $(this.selector +" " + this.bodywrap +" ." + this.itemclass);
		var itemWrapper = $(this.selector).find('.tab-body');
		var leftstr = '-' + (this.itemWidth * (index -1)) + 'px';
		
		var p = this;
		index = index -1;		
		var fArray = this.iArray[index];
		
		index = index -1;
		if(index <0) index = this.iTotItems-1;
		if(index > (this.iTotItems-1)) index = 0;
		
		var preIndex = index;
		index = index +1;
		if(index <0) index = this.iTotItems-1;
		if(index > (this.iTotItems-1)) index = 0;
		$(elems[index]).show();
		$(elems[preIndex]).fadeOut(this.speed, function(){
			//$(this).parent().css({left: leftstr});														
			$(p.selector +" " + p.bodywrap +" ." + p.itemclass).each(function(i){				
				$(this).css({
		  			'zIndex': fArray[i]				
				});					
			});
			
		});
		/*
		itemWrapper.fadeOut(this.speed, function(){
			$(itemWrapper).css('left', leftstr).fadeIn(this.speed);
		});
		*/
		/*
		itemWrapper.stop();
			var leftstr = '-' + (this.itemWidth * (index -1)) + 'px';
			itemWrapper.animate({
					'left':leftstr
					},
					this.speed,
					this.easing,
					function(){
						return false;
					}
			);
		*/
	}
	,cycleItems: function(){
		this.stopCycle(true);
		 if(++this.iCurItem>this.iTotItems){
    		this.iCurItem = 1;
  		}
  		this.fadeItem(this.iCurItem,false);
		if(this.iCurItem>=this.iTotItems){
			this.iCurItem = 1;
		}
		this.startCycle();		
	},
	stopCycle: function(auto){
		if(!auto){
			$(this.selector +" " + this.bodywrap +" ." + this.itemclass).css({
		  		'position': 'relative',
				'display': 'block'
			});			
			clearTimeout(this.tCycle);
		}
	},
	initItems: function(){
		var p = this;
		$(this.selector +" " + this.bodywrap +" ." + this.itemclass).each(function(index){
			$(this).css({
		  		'position': 'absolute',
		  		'zIndex': (p.iTotItems - index)					
			});																	   
		});
	}
	,startCycle: function(auto){
		this.initItems();
		var f=function(self){
				return function(){
  					self.cycleItems();
				};
			};
		this.tCycle = setTimeout(f(this),this.iInterval*1000);
	}	
};
function initList(list){
	$(list).mouseover(function(){
			if($(this).hasClass('first')) return;
			$(this).addClass('hover');
			if($(this).hasClass('active-prev')) $(this).removeClass('active-prev');
			$(this).prev('li').addClass('hover-prev');
	});
	$(list).mouseout(function(){
			$(this).removeClass('hover');
			$(this).prev('li').removeClass('hover-prev');	
			initActiveClass(list);
	});		
	initActiveClass(list);
}
function initActiveClass(list){
	var lists = $(list);
	for(var i=0; i<lists.length; i++){
		var li = $(lists[i]);
		li.removeClass('active-prev');
		if(li.hasClass('active')){
			li.prev('li').addClass('active-prev');
		}
	}	
}
function initHoverClass(list){
	$(list).mouseover(function(){
			if($(this).hasClass('first')) return;
			$(this).addClass('hover');
	});
	$(list).mouseout(function(){
			$(this).removeClass('hover');
	});		
}
function initTabPanel(tab){
	$(tab).find(".tab-header a").focus(function(){this.blur();});
	$(tab).find(".tab-header li").each(function(index){
		$(this).click(function(){
			$(this).parents("ul").find('li').removeClass('active');
			$(this).addClass('active');	
			var tbody = $(this).parents('.tab-header').siblings('.tab-body').find('.panel');
			tbody.hide();
			$(tbody[index]).show();
			initPageSize();
			return false;
		});								   
	});
}
function initFAQItems(){
	$("#faq .rightcx .panel .item").mouseout(function(){
		if($(this).hasClass('active')) return;
		$(this).removeClass('hover');
    });
	$("#faq .rightcx .panel .item").mouseover(function(){
		if($(this).hasClass('active')) return;
		$(this).addClass('hover');
	});		
}
function initPortFolioItems(){
	initHoverItems('#portfolio .leftcx .panel ul li', 'li');
	if(isIE6()){
		$("#portfolio .leftcx .panel .fd").css({"margin-left": "2px"});
	}
	//$('#portfolio .leftcx .panel ul li a').focus($(this).blur());
}
function initConceptenItems(){
	initHoverItems('#concepten .leftcx .gray-box .bd ul li', 'li');
}
function initHoverItems(selector, itemSelector){
	$(selector).mouseover(function(){
			$(this).addClass('hover');
			if($(this).prev(itemSelector).hasClass('active')) return;
			$(this).prev(itemSelector).addClass('hover-prev');			
	});
	$(selector).mouseout(function(){
			$(this).removeClass('hover');
			$(this).prev(itemSelector).removeClass('hover-prev');
	});	
	initActivePrevClass(selector, itemSelector);	
}
function initActivePrevClass(selector, itemClass){
	var trs = $(selector);
	for(var i=0; i<trs.length; i++){
		var tr = $(trs[i]);
		tr.removeClass('active-prev');
		if(tr.hasClass('active')){
			tr.prev(itemClass).addClass('active-prev');
		}
	}	
}
function loadContent(url, panel){
	$(panel).addClass('ajax-loadding');
	$.ajax({
	  url: url,
	  dataType: 'html',
	  success: function(html){
		$(panel).removeClass('ajax-loadding');
	  	$(panel).html(html);
	  }
	});
}
function initProductItems(){
	$('#producten .rightcx .gray-box .bd ul li').hover(function(){
		if($(this).hasClass('active')) return false;
		$(this).addClass('hover');
		//if($(this).hasClass('active-prev')) $(this).removeClass('active-prev');
		$(this).prev('li').addClass('hover-prev');
	}, function(){
		if($(this).hasClass('active')) return false;
		$(this).removeClass('hover');
		$(this).prev('li').removeClass('hover-prev');
	});
	initActivePrevClass('#producten .rightcx .gray-box .bd ul li', 'active');
	initProductTips();
	
}
function initProductTips(){
	var xOffset = 8;
	var yOffset = 15;
	
	$('.gray-box ul li').not('.active').find('a').each(function(index){
		$(this).hover(function(e){
			$("body").append("<div id='tooltip'></div>");
			var tipInfo = $(this).parents('.gray-box').find('.bd .tip-infos .tip-container')[index];
			$("#tooltip").html($(tipInfo).parent().html());	
			$("#tooltip")
			.css("top",(e.pageY + xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.fadeIn("fast");
			initProductTipsReady();
		}, function(){
			$("#tooltip").remove();
		});																
	});
	
	$('.gray-box ul li').not('.active').find('a').mousemove(function(e){
		$("#tooltip")
			.css("top",(e.pageY + xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});		
}
function initProductTipsReady(){
 	$("#tooltip").pngFix();
 	var rate = 0.9;
 	$("#tooltip .tip-container").css({
			"opacity": rate,
			"-moz-opacity": rate,
			"filter": "alpha(opacity="+(rate*100)+")"
	});	
}
function LinkTooltip(selector, url){	
    var xOffset = 8;
	var yOffset = 15;
	
	$(selector).hover(function(e){
		$("body").append("<div id='tooltip'></div>");	
		$.ajax({
			url: url,
			type: 'post',
			dataType: 'html',
			success: function(response){	 
				$("#tooltip").html(response);
				$("#tooltip")
				.css("top",(e.pageY + xOffset) + "px")
				.css("left",(e.pageX + yOffset) + "px")
				.fadeIn("fast");			
			}
		});							
    },
    
	function(){
		//this.title = this.t;	
		$("#tooltip").remove();
    });	
	$(selector).mousemove(function(e){
		$("#tooltip")
			.css("top",(e.pageY + xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});			
};

(function($) {
jQuery.fn.wayPanel = function(settings) {
	settings = jQuery.extend({
		tabmenu: '.hd .tab-menu',
		tabmenuHoverClass: 'hover',
		tabmenuActiveClass: 'active',
		tabbody: '.bd',
		tabpanelClass: '.way-Tpanel',
		tabpanelActiveClass: 'active',
		isHover: true
	}, settings);
	var opts = settings;
	var self = this;
	return this.each(function() {
		self.tabmenus = $(opts.tabmenu + ' ul li', self);
		$('a', self.tabmenus).focus(function(){
			$(this).blur();
		});
		self.tabpanels = $(opts.tabbody + ' ' + opts.tabpanelClass, self);
		if(opts.isHover){
			self.tabmenus.hover(function(){
				$(this).addClass(opts.tabmenuHoverClass);
			}, function(){
				$(this).removeClass(opts.tabmenuHoverClass);
			});
		}
		self.tabmenus.each(function(index){
			$(this).click(function(){
				self.tabpanels.hide();
				$(self.tabpanels[index]).show();
				self.tabmenus.removeClass(opts.tabmenuActiveClass);
				$(self.tabmenus[index]).addClass(opts.tabmenuActiveClass);
				$('h2', self.tabpanels[index]).sifr({color: '#fff', size: 17});
				$('.result h3 ', self.tabpanels[index]).sifr({color: '#000', size: 17});
			});
		});
	});
};
})(jQuery);
(function($) {
jQuery.fn.slideGallery = function(settings){
	settings = jQuery.extend({
		itemActiveClass: 'active',
		itemHoverClass: 'hover',
		itemWidth:118,
		maxItem: 5,
		activeIndex: 0
	}, settings);
	var opts = settings;	
	var self = this;

	var initPortfolioTitle = function(){
							$('#portfolio #our-projects #project-infos #project-view h2, #portfolio #our-projects #project-infos #about-us h2').sifr({color: '#2B589C', size: 17});
							$('#portfolio #what-we-do .side-list h2').sifr({color: '#2B589C', size: 17,height: 30});
							$('#portfolio #what-we-do .side-list h3').sifr({color: '#2B589C', size: 17,height: 30,width:300});	
	}
	return this.each(function(){
		$("img.reflect", this).reflect();					  
		self.ul = $('ul', this);
		self.len = $('ul li', this).length;
		for(var i = 0; i < self.len; i++){
			if($($('ul li .item', this)[i]).hasClass(opts.itemActiveClass)){
				opts.activeIndex = i;
			}
		}

		var totalWidth = self.len * opts.itemWidth - 12;
		self.ul.width(totalWidth);
		var itemsWidth = self.ul.innerWidth() - $(this).outerWidth();							  
		$('ul li .item', self).hover(function(){
	  		$(this).addClass(opts.itemHoverClass);
		}, function(){
	  		$(this).removeClass(opts.itemHoverClass);
		});	
		$('ul li .item a').focus(function(){$(this).blur();});
		$('ul li .item a', this).click(function(e){
			$(this).parents('ul').find('.item').removeClass(opts.itemActiveClass);
			$(this).parent().addClass(opts.itemActiveClass);
			var url = $(this).attr('href');
			var sTop = $(window).scrollTop();
			var pHeight = $('#our-projects').height();
			$('#our-projects').height(pHeight);
			$('#our-projects .portfolio-item').fadeOut('slow', function(){
				$('#our-projects').html("<div class=\"portfolio-loading\" style=\"height:"+pHeight+"px;\"></div>");
				$.ajax({
				  /* url: 'portfolio/' + url,*/
				  url: url,
				   dataType : 'html',
				   success: function(response){
					   var portfolioItem = document.createElement('div');
					   $(portfolioItem).html(response).hide();
					   $('#our-projects .portfolio-loading').fadeOut('slow', function(){
							$('#our-projects').append(portfolioItem);	
							$(portfolioItem).addClass('portfolio-item');
					   		$("div.slideview").slideView({
								itemWidth:513,
								largeView: true
							});	
							$('#our-projects .portfolio-item').fadeIn('slow', function(){
							$('#our-projects .portfolio-loading').remove();
							if(browser.msie){
							setTimeout(function(){
									initPortfolioTitle();		
							}, 200);
							}
							else{
								initPortfolioTitle();
							}
							//$('#our-projects').removeAttr('style');
   							//$('html,body').stop().animate({scrollTop:sTop},500,'swing');							
						});							
					   });
				   }
				});				
			});
			return false;
		});		
		if(self.len <= opts.maxItem){
			$('.slider-wrap', self).hide();
			return false;
		}
		var defaultValue = 0;
		if(opts.activeIndex >= opts.maxItem){
			defaultValue = opts.activeIndex * (opts.itemWidth - 2);
		}
		$('.slider-wrap', self).slider({
    		min: 0,
        	max: itemsWidth,
        	handle: '.slider',
			startValue: defaultValue,
        	stop: function (event, ui) {
            	self.ul.animate({'left' : ui.value * -1}, 500);
        	},
        	slide: function (event, ui) {
            	self.ul.css('left', ui.value * -1);
        	}
    	});	
	});
};
})(jQuery);
function initDien(){
	$("#doen .doc-content-bd .rightcx .panel ul li").hover(function(){
		$(this).addClass('hover');
		if(isIE6()){
			IEfilter($(this).find(".icon"), "icon_doen.png");
		}
    }, function(){
		$(this).removeClass('hover');
		if(isIE6()){
			IEfilter($(this).find(".icon"), "icon_doen_hover.png");
		}	
	});
	$("#doen .doc-content-bd .rightcx .panel .bd > ul > li > a").click(function(e){
		if (e.target == this && $(this).parent().find('ul').length > 0) {
			if($(this).attr('href') == '#'){
				$(this).parent().toggleClass('active');
				$(this).parent().find('ul').slideToggle('slow');
				return false;
			}
		}
	}).focus(function(){this.blur();});
	
	
		$("#doen .doc-content-bd .rightcx .panel .bd > ul > li > span").click(function(e){
		if (e.target == this && $(this).parent().find('ul').length > 0) {
			if($("#doen .doc-content-bd .rightcx .panel .bd > ul > li > a").attr('href') == '#'){
				$(this).parent().toggleClass('active');
				$(this).parent().find('ul').slideToggle('slow');
				return false;
			}
			
		}
		else {
			location.href = $(this).next("a").attr('href');
		}
	}).focus(function(){this.blur();});
	
	
	$("h1").sifr({size:19, width:500});
	$('#doen .doc-content-bd .leftcx h2').not('.title').sifr({color: '#2B589C', linkColor: '#2B589C',  size: 15});
	$('#doen .doc-content-bd .leftcx h1').not('.title').sifr({color: '#2B589C', linkColor: '#2B589C',  size: 15, height: 20, width:90});
	$('#doen .doc-content-bd .leftcx h2.title, #doen .doc-content-bd .rightcx .panel h2').sifr({color: '#2B589C', size: 19});
	$('#doen-contact .dc-bd #mw-panel h2').sifr({color: '#1e4f9b', size:13});
	initDienContact();
	$('#doen .doc-content-bd .rightcx .panel .menu-title .icon-plus').click(function(){
		$("#doen .doc-content-bd .rightcx .panel .bd > ul > li > ul").slideDown('slow');
		return false;
	});
	$('#doen .doc-content-bd .rightcx .panel .menu-title .icon-min').click(function(){
		$("#doen .doc-content-bd .rightcx .panel .bd > ul > li > ul").slideUp('slow');
		return false;
	});
}
function initDienContact(){
		$('#contactform1').validate({
		rules: {
			name: {
				required: true
			},
			bed: {
				required: true
			}
			,email:{
				required: true,
				email: true
			}
			,vraag:{
				required: true
			}
			,securitycode:{
				required: true,
				remote: "check_verifycode.php"
			}
		},
		messages: {
			name: {
				required: ''
			},
			bed: {
				required: ''
			}
			,email:{
				required: '',
				email: ''
			}
			,vraag:{
				required: ''
			}
			,securitycode:{
				required: '',
				remote: ''
			}			
		},
		errorPlacement: function(error, element){
			$(element).addClass('error');
		},
		submitHandler: function() {
			$('#contactform1 .form-ct').hide();
			$('#contactform1 .result-info .result-text').fadeOut('fast');										  
			$('#contactform1 .result-info').append('<div class="mail-processing"></div>');				
			$('#contactform1').ajaxSubmit({
				type: 'post',
				dataType: 'json',
				success: function(result){
					$('#contactform1 .result-info .mail-processing').fadeOut('fast', function(){
						$('#contactform1 .result-info .result-text').fadeIn('fast');
						$(this).remove();
					});
				}
			});
		}
	});

	$('#contactform1 input,#contactform1 textarea').focus(function(){
		$('#contactform1 .result-info .result-text').slideUp('fast');											  
	});	
	$('#contact-btn1').click(function(){								  
		$('#contactform1').submit();
		return false;
	});
	$('#contactform1 .back-btn .btn a').click(function(){
		var formpanel = $(this).parents('.form-panel');
		$('.result-text', formpanel).hide();
		$('.form-ct', formpanel).show();
		return false;
	});

	$('#doen-contact .dc-hd ul li a').each(function(index){
		$(this).focus(function(){this.blur();});
		$(this).click(function(){
			$('#doen-contact .dc-hd ul li').removeClass('active');
			$(this).parent().parent().addClass('active');
			var panels = $('#doen-contact .dc-bd .dc-panel');
			panels.removeClass('dc-active-panel');
			$(panels[index]).addClass('dc-active-panel');
			return false;
		});
	});
}
function initSiteMap(){
	$.ajax({
		url: 'inc/sitemap.html',
		dataType: 'html',
		success: function(response){
			$('#sitemap').html(response);
		}
	});
}
