﻿var domein		= 'mobielbouw';
var extentie	= 'nl';
function mail_link(ontvanger) {
	var adres = ontvanger + '@' + domein + '.' + extentie;
	document.write('<a href="mailto:' + adres + '">' + adres + '</a>');
}

$(document).ready(function() {
	$(document).pngFix();
	
	//	dropdown menu
	$('#menu li.lvl1').mouseover(function() { 
		$('ul', this).show();
		$('span', this).addClass('menu_lvl1_hover');
	});
	$('#menu li.lvl1').mouseout(function() { 
		$('ul', this).hide();
		$('span', this).removeClass('menu_lvl1_hover');				
	});
	
	//	diashow headers
	$('#diashow').cycle();
	
	//	branchebuttons op home
	$('#branchebuttons div').each(function(i) {
		$(this).css('cursor', 'pointer');
		$(this).click(function() {
			window.location = $(this).find("a").attr("href");
			return false;
		});
		$(this).mouseover(function() {
			$(this).addClass('hover');
		});
		$(this).mouseout(function() {
			$(this).removeClass('hover');
		});
	});
	
	//	Projecten
	$('#project_opsom div').each(function(i) {
		$(this).css('cursor', 'pointer');
		$(this).click(function() {
			var x = $(this).find("a");
			var t = x.attr('title') || x.attr('name') || null;
			var a = x.attr('href') || x.attr('alt');
			var g = x.attr('rel') || false;
	
			tb_show(t,a,g);
			return false;
		});
		$(this).mouseover(function() {
			$(this).addClass('hover');
		});
		$(this).mouseout(function() {
			$(this).removeClass('hover');
		});
	});
	
	//	Projecten
	$('#project_keuze select').change(function() {
		$('#project_opsom div').hide();
		var b = $('#branche').val();
		var p = $('#product').val();
		var v = 0;
		for (var n = 0; n < pro_arr.length; n++) {
			if (	(b == "" || pro_arr[n].indexOf('||'+b+'||') != -1) &&
					(p == "" || pro_arr[n].indexOf('||'+p+'||') != -1) ) {
				$('#p_'+n).show();
				v++;	
			}
		}
		if (v == 0) $('#geen_resultaten').show();
		else		$('#geen_resultaten').hide();
	});
	$('#geen_resultaten a').click(function() {
		$('#branche').val("");
		$('#product').val("").change();
		return false;
	});
	
	//	carousel voorvertoning referenties
	$('div.thumbs').jCarouselLite({
		btnNext: "#thumb_next",
		btnPrev: "#thumb_prev",
		visible: 6,
		scroll: 1,
		start: 0,
		circular: true,
		speed: 200
	});
	
	//	zoekfunctie
	$('#header form').submit(function() {
		if ($('#header form input').val() == '') {
			alert('Vul een zoekterm in.');
			return false;		
		}
	});
	
	//	hoogte project-scherm
	var WH = $(window).height();	// window.innerHeight;
	if (WH < 600) {
		$('a.thickbox').each(function() {
			var href = $(this).attr('href');
				href = href.split('&height=600&width=825').join('&height='+WH+'&width=825');
				href = href.split('&amp;height=600&amp;width=825').join('&amp;height='+WH+'&amp;width=825');
			$(this).attr('href', href);
		});
	}
	
	
//	Contact
	if ($('#kolom_route').position()) {
		$('#route_detail').css({
			top: 	$('#kolom_route').position().top + 170,
			left: 	$('#kolom_route').position().left - 190
		});
	}
	$('#kolom_route').hover(
		function() { $('#route_detail').show(); },
		function() { $('#route_detail').hide(); }
	);	
	$('#route_detail').hover(
		function() { $(this).addClass('route_hover'); },
		function() { $(this).removeClass('route_hover'); }
	);
	
	
	//	scrollmagie
	var nav = $('#kolom div');
	var	all = $('#kolom div');
	
	if (nav.length > 0) {	
		
		all.css('position', 'absolute');
		
		var topmost_point 	= nav.offset().top;
		var PADDING_TOP 	= 0;
	    var REAL_TOP 		= topmost_point;
		var the_window 		= $(window);
		var NAV_IS_FIXED 	= (nav.css('position') == 'fixed');
		
		the_window.scroll(function () {
	        if (the_window.scrollTop() > REAL_TOP) {
	            if ($.browser.msie && $.browser.version == "6.0") {
	                all.css('top', the_window.scrollTop());
	            } else if (!NAV_IS_FIXED) {
	        	    all.css({
	        	        top: PADDING_TOP,
	        	        position: 'fixed'
	        	    });
	        	    NAV_IS_FIXED = true;
	        	}
	        } else {
	            if (NAV_IS_FIXED) {
	                all.css({
	                    position: 'absolute',
	                    top: topmost_point
	                });
	                NAV_IS_FIXED = false;
	            }
	        }
		});
		the_window.scroll();
	}
});
