function externalLinks() {
	if (!document.getElementsByTagName) {
		return;
	}
	var anchors = document.getElementsByTagName("a");
	for (var i=0; i<anchors.length; i++) {
		var anchor = anchors[i];
		if (anchor.getAttribute("href")){
			if(anchor.getAttribute("rel") == "external" || anchor.getAttribute("rel") == "external nofollow" || anchor.getAttribute("rel") == "nofollow external"){
				anchor.target = "_blank";
            }
		}
    }
}
window.onload = externalLinks;

/* Home rechts */
var rotate=1;
function showLatest(){
	$("#latest").show();
}

function hideLatest(){
	$("#latest").hide();
}
function switchimg(t,auto){
	if(t == parseInt(t)){
		var id = ((t-1)+2);
	}else{
		var id = $(t).attr('id').replace(/tmb/,'');
	}
	var img = $("#rimgul li");
	
	$('#title').html($("#tmb"+id).attr('title'));

	for(var i=1; i<=img.length; i++){
		if(i == id){
			$("#rimg"+id).addClass('active');
			$("#tmb"+id).addClass('active');
			$("#rimg"+id).removeClass('disabled');
			$("#tmb"+id).removeClass('disabled');
		}else{
			$("#rimg"+i).removeClass('active');
			$("#tmb"+i).removeClass('active');
			$("#rimg"+i).addClass('disabled');
			$("#tmb"+i).addClass('disabled');
		}
	}
	
	if(auto == 1){
		if(rotate <= img.length){
			rotate++;	
		}else{
			rotate=1;
		}
	}else{
		clearInterval(rotater);
	}
}
var rotater = setInterval("switchimg(rotate,1);",8000);
/* Home rechts */





/* HEADER MODULE */
var counter = 1;
function getImg(limit){
	var id = counter;
    var img = new Image();
	if((id-1) >= 0){
	    $('#img'+(id-1)).fadeOut(1500);
	}else if(!$('#img'+limit).attr('class').match(/loading/gi)){
	    $('#img'+limit).fadeOut(1500);
	}
	
	if($('#img'+id).attr('class').match(/loading/gi)){
		$(img).load(function() {
			$(this).css('display', 'none');
			$('#img'+id).removeClass('loading').append(this);
			$(this).fadeIn(1500);
		}).attr('src', '/uploaded/headers/'+$('#img'+id).attr('title'));
		$('#img'+id).removeAttr('title');
	}else{
		$('#img'+id).fadeIn(1500);
	}
	var wait = $('#img'+id).attr('class').replace(/loading /,'');
	if(counter >= limit){
		counter = 0;
	}else{
		counter = counter + 1;
	}
	setTimeout('getImg('+limit+');',wait);
}
/* HEADER MODULE */


/* FAQ Module */
function openclosefaq(t){
	if($(t).next().attr('class').match('faq_opened')){
		$(".faq_item").removeClass("faq_opened");
		$(".faq_item").addClass("faq_closed");
		$(t).next().removeClass("faq_opened");
		$(t).next().addClass("faq_closed");
	}else{
		$(".faq_item").removeClass("faq_opened");
		$(".faq_item").addClass("faq_closed");
		$(t).next().addClass("faq_opened");
		$(t).next().removeClass("faq_closed");
	}
}
/* FAQ Module */

/* Fotoalbum */
function loadimages(loadimg){
	if(loadimg < toload.length){
		$(toload).eq(loadimg).find('a').html('<img src="/uploaded/album/'+$(toload).eq(loadimg).attr('title')+'" height="52" />');
		$(toload).eq(loadimg).removeClass('loadimg');
		$(toload).eq(loadimg).removeAttr('title');
		if(!$(toload).eq(loadimg).attr('class').match(/active/)){
			$(toload).eq(loadimg).fadeTo("slow", 0.23);
			$(toload).eq(loadimg).find('img').mouseout(function(){
				$($(toload).eq(loadimg)).fadeTo("slow", 0.23);
			}).mouseover(function(){
				$($(toload).eq(loadimg)).fadeTo("slow", 0.9);
			});
		}

		
		loadimages(((loadimg-1)+2));
	}
}


if($('#imgcon').html() != null){
	var curmarg = $('#imgcon').css('marginLeft').replace(/px/,'');
}
$("#scrollleft").click(function(){
	var maxmag = parseInt(($('#imgcon').css('width').replace(/px/,'')-442));
	curmarg = (curmarg-83);
	c = curmarg * -1;
	if(c<=maxmag){
		$('#imgcon').css('marginLeft',curmarg+'px');
	}
});
$("#scrollright").click(function(){
	curmarg = ((curmarg-1)+84);
	if(curmarg<=359){
		$('#imgcon').css('marginLeft',curmarg+'px');
	}
});
/* Fotoalbum */


/* Bestellen */
function showprijs(t,id){
	var ophang = 0;
	if($('#ophangsysteem').attr('checked') == true){
		ophang=5;
	}

	$.ajax({
		url: "/includes/jquery_incl/fetchprijs.php",
		data: ({id : id, ophang:ophang}),
		success: function(html){
			if(html != "0,00"){
				$('#shprijs').html(html);					
			}
		}
	});
}

function checkorderform(){
	var check=new Array("naam","adres","zip","city","email");
	var error='';
	
	for(var i=0; i<check.length; i++){
		if($('#'+check[i]).val() == ''){
			$('#'+check[i]).parent().css('backgroundImage','url("/images/input_false.jpg")');
			$('#'+check[i]).css('color','#FFFFFF');
			$('#'+check[i]).css('backgroundColor','#990000');
			error='1';
		}else{
			$('#'+check[i]).removeAttr('style');
			$('#'+check[i]).parent().removeAttr('style');
		}
	}

	if($('#zip').val() == '' && $('#city').val() == '') {
		$('#zip').parent().css('backgroundImage','url("/images/zipcity_false.jpg")');
	}else if($('#zip').val() == '' && $('#city').val() != ''){
		$('#zip').parent().css('backgroundImage','url("/images/zip_false.jpg")');
	}else if($('#zip').val() != '' && $('#city').val() == ''){
		$('#zip').parent().css('backgroundImage','url("/images/city_false.jpg")');
	}

	if(error != ''){
		alert("Vul a.u.b. alle velden met een * in.");
		return false;
	}
}
/* Bestellen */
