function changeBackground(bg_lay,bg_img,bg_max){
	if (bg_img < bg_max){
		bg_img++;
	} else {
		bg_img = 0;
	}
	var bgimage = q_background[bg_img];
	if (bg_lay == 1){
		$("#main_flash_2").fadeIn(1000,function(){
			$("#main_flash_1 img").attr({ src: bgimage });
			setTimeout('changeBackground(2,'+bg_img+','+bg_max+')',4000);
		});
	} else if (bg_lay == 2){
		$("#main_flash_2").fadeOut(1000,function(){
			$("#main_flash_2").hide();
			$("#main_flash_2 img").attr({ src: bgimage });
			setTimeout('changeBackground(1,'+bg_img+','+bg_max+')',4000);
		});
	}
}

function changePics(){
	var randval = Math.floor(Math.random()*9);
	$.post("db/db_frontpic.php?q="+randval+"", function(picdata){
	if(picdata.length > 0) {
		var imagepic = picdata.split(";");
		$("#frontpic_"+randval).fadeOut(500,function(){
			$("#frontpic_"+randval+" img").attr({src: imagepic[0]})
			$("#frontpic_"+randval).css("cursor","pointer");
			$("#frontpic_"+randval).unbind('click').click(function() {
				location.href=imagepic[1];
			});
			$("#frontpic_"+randval).fadeIn(500,function(){
				setTimeout('changePics()', 2000);
			});
		});
	}
	});
}

function closeNews(){
	$("#close_news").fadeOut(150);
	var randval = Math.floor(Math.random()*254);
	$.ajax({ type: "GET", url: "db/db_newsitem.php?latest=true&q="+randval+"", data: "", dataType: "xml", success: function(xml){
	$("#main_header").animate({ "height": "1px" }, "slow", function() {
		var jData = $( xml );
		var jSections = jData.children();
		$("newsitem", jSections).each(function(){
			var news_id = $(this).find('news_id').text();
			var news_caption = $(this).find('news_caption').text();
			var news_text = $(this).find('news_small').text();
			var news_image = $(this).find('news_image').text();
			var news_image_w = $(this).find('news_image_w').text();
			var news_image_h = $(this).find('news_image_h').text();
			
			$("#nws_title").html(news_caption);
			var newsitemtxt = news_text.replace(/\n/g, "<br />");
			$("#nws_text").html(newsitemtxt);
			if (news_image == ""){
				$("#header_img_left img").attr({ src: 'images/logo_button.gif' });
			} else {
				$("#header_img_left img").attr({ src: news_image, width: news_image_w, height: news_image_h });
			}

			$("#main_header").animate({ 'height': '200' }, "slow", function(){
				$("#nws_readmore").show();
			});
		});
	});
	},error: function(XMLHttpRequest, textStatus, errorThrown) {   
		//error
	}
	});
}

function utf8_decode (str_data) {
		var tmp_arr = [],
        i = 0,
        ac = 0,
        c1 = 0,
        c2 = 0,        
		c3 = 0;
 
    str_data += '';
 
    while (i < str_data.length) {        
		c1 = str_data.charCodeAt(i);
        if (c1 < 128) {
            tmp_arr[ac++] = String.fromCharCode(c1);
            i++;
        } else if (c1 > 191 && c1 < 224) {            
			c2 = str_data.charCodeAt(i + 1);
            tmp_arr[ac++] = String.fromCharCode(((c1 & 31) << 6) | (c2 & 63));
            i += 2;
        } else {
            c2 = str_data.charCodeAt(i + 1);            c3 = str_data.charCodeAt(i + 2);
            tmp_arr[ac++] = String.fromCharCode(((c1 & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
            i += 3;
        }
    } 
    return tmp_arr.join('');
} 
function drawNews(news_id){
	$("#close_news").fadeOut(150);
	$.ajax({ type: "GET", url: "db/db_newsitem.php?news_id="+news_id+"", data: "", dataType: "xml", success: function(xml){
	$("#main_header").animate({ "height": "1px" }, "slow", function() {
		var jData = $( xml );
		var jSections = jData.children();
		$("newsitem", jSections).each(function(){
			var news_id = $(this).find('news_id').text();
			var news_caption = $(this).find('news_caption').text();
			var news_text = decodeURIComponent(escape($(this).find('news_small').text()));
			//var news_text = utf8_decode($(this).find('news_small').text());
			var news_image = $(this).find('news_image').text();
			var news_image_w = $(this).find('news_image_w').text();
			var news_image_h = $(this).find('news_image_h').text();
			
			$("#nws_title").html(news_caption);
			var newsitemtxt = news_text.replace(/\n/g, "<br/>");
			$("#nws_text").html(newsitemtxt);
			if (news_image == ""){
				$("#header_img_left img").attr({ src: 'images/logo_button.gif', width: '140', height: '140' });
			} else {
				$("#header_img_left img").attr({ src: news_image, width: news_image_w, height: news_image_h });
			}
			$("#nws_readmore").unbind('click').click(function() {
				location.href="nieuws/"+news_id;
			});
			$("#main_header").animate({ 'height': '200' }, "slow", function(){
				$("#nws_readmore").show();
				$("#close_news").fadeIn(150);
			});
		});
	});
	},error: function(XMLHttpRequest, textStatus, errorThrown) {   
		//error
	}
	});
}
function drawNewslist(listName1,listName2,listName3){
	$.ajax({ type: "GET", url: "db/db_newslist.php", data: "", dataType: "html", success: function(response){
		$("#sub_content_2").css({ 'height': '258px' });
		$("#sub_search").hide();
		$("#sub_content_2").html(response);
		$("#subcontent_menu_1 a").html("<b>"+listName1+"</b>");
		$("#subcontent_menu_2 a").html(""+listName2+"");
		$("#subcontent_menu_3 a").html(""+listName3+"");
	},error: function(XMLHttpRequest, textStatus, errorThrown) {   
		//error
	}
	});
}
function drawArchive(listName1,listName2,listName3){
	$.ajax({ type: "GET", url: "db/db_newsarchive.php", data: "", dataType: "html", success: function(response){
		$("#sub_content_2").css({ 'height': '225px' });
		$("#sub_search").show();
		$("#archive_search").val('');
		$("#sub_content_2").html(response);
		$("#subcontent_menu_1 a").html(""+listName1+"");
		$("#subcontent_menu_2 a").html("<b>"+listName2+"</b>");
		$("#subcontent_menu_3 a").html(""+listName3+"");
	},error: function(XMLHttpRequest, textStatus, errorThrown) {   
		//error
	}
	});
}
function drawNieuwsbrief(listName1,listName2,listName3){
	$.ajax({ type: "GET", url: "db/db_newsletter.php", data: "", dataType: "html", success: function(response){
		$("#sub_content_2").css({ 'height': '258px' });
		$("#sub_search").hide();
		$("#sub_content_2").html(response);
		$("#subcontent_menu_1 a").html(""+listName1+"");
		$("#subcontent_menu_2 a").html(""+listName2+"");
		$("#subcontent_menu_3 a").html("<b>"+listName3+"</b>");
	},error: function(XMLHttpRequest, textStatus, errorThrown) {   
		//error
	}
	});
}
function searchArchive(){
	var search_cont = $("#archive_search").val();
	$.ajax({ type: "GET", url: "db/db_newsarchive.php?search_content="+search_cont, data: "", dataType: "html", success: function(response){
		$("#sub_content_2").html(response);
	},error: function(XMLHttpRequest, textStatus, errorThrown) {   
		//error
	}
	});
}
function drawNewsbrief(lngCap,lngTxt,lngEmail){
	$("#close_news").fadeOut(150);
	$("#main_header").animate({ "height": "1px" }, "slow", function() {
		$("#nws_title").html(lngCap);

		var nbhtml = "<form method=post action=\"index.php\">";
		nbhtml = nbhtml + lngTxt;
		nbhtml = nbhtml + "<br/><br/>"+lngEmail+": <input type=\"text\" id=\"cust_email\" name=\"cust_email\" size=\"30\">&nbsp;<input type=\"submit\" name=\"submit\" value=\"versturen\" onclick=\"return checkMail();\">";
		nbhtml = nbhtml + "</form>";
		
		$("#nws_text").html(nbhtml);
		$("#header_img_left img").attr({ src: 'images/logo_button.gif', width: '140', height: '140' });
		$("#nws_readmore").hide();
		$("#main_header").animate({ 'height': '200' }, "slow", function(){
			$("#close_news").fadeIn(150);
		});
	});
}
function checkMail(){
	var str = $("#cust_email").val();
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	if (str == ""){ 
		alert("U heeft geen emailadres opgegeven"); 
		return false;
	} else if (!filter.test(str)) {
		alert("U dient een geldig emailadres in te voeren!");
		return false;
	} else {
		$.post("db/db_mailing.php", { addr: str },function(maildata){
		if(maildata.length > 0) {
			alert(maildata);
			$("#cust_email").val('');
			closeNews();
		} else {
			alert("Er is een fout opgetreden, probeert u het nog eens.");
		}
		});
		return false;
	}
}
function changeOffer(offerid,randid){
	var offerid = parseInt(offerid);
	var randid = parseInt(randid);
	$.ajax({ type: "GET", url: "db/db_offer.php?q="+randid+"", data: "", dataType: "xml", success: function(xml){
	$("#offer_wrapper_"+offerid).animate({ "width": "3px" }, 1000, "linear", function() {
		var jData = $( xml );
		var jSections = jData.children();
		$("offer", jSections).each(function(){
			var prod_name = $(this).find('prod_name').text();
			var offer_name = $(this).find('offer_name').text();
			var prod_image = $(this).find('prod_image').text();
			var img_height = $(this).find('img_height').text();
			var img_width = $(this).find('img_width').text();
			var offer_text = $(this).find('offer_text').text();
			var offer_valid = $(this).find('offer_valid').text();
			var offer_price = $(this).find('offer_price').text();
			var topmargin = 80 - img_height;
			$("#offer_image_"+offerid+" img").attr({ 'src': prod_image }, function () {
				var cssObj = { 'width' : img_width,'height' : img_height,'margin-top' : topmargin }
				$("#offer_image_"+offerid+" img").css(cssObj);
			});
			$("#offer_image_"+offerid+" img").width( Math.floor(img_width) );
			$("#offer_image_"+offerid+" img").height( Math.floor(img_height) );
			$("#offer_image_"+offerid+" img").css( "margin-top", topmargin );
			$("#offer_name_"+offerid).html(offer_name);
			$("#offer_text_"+offerid).html(offer_text);
			$("#offer_price_"+offerid).html(offer_price);
			$("#offer_valid_"+offerid).html(offer_valid);
			if (!isNaN(offer_price)){
				if (offer_price != 0){
					$("#offer_divprice_"+offerid).show();
					if (offer_price.indexOf(".") != -1){
						offer_price = offer_price.replace(".",",");
					} else {
						offer_price = offer_price + ",-";
					}
					$("#offer_price_"+offerid).html('€ '+offer_price);
				} else {
					$("#offer_divprice_"+offerid).hide();
				}
			} else {
				$("#offer_divprice_"+offerid).show();
				$("#offer_price_"+offerid).html(offer_price);
			}
		});	
		$("#offer_wrapper_"+offerid).animate({ 'width': '285' }, 1000, 'linear', function(){
			var offernext = randid + 1;
			//if (offerid == 0){
				setTimeout('changeOffer(1,'+offernext+')', 5000);
			//} else {
			//	setTimeout('changeOffer(0,'+offernext+')', 5000);
			//}
		});
	});

	},error: function(XMLHttpRequest, textStatus, errorThrown) {   
		clearTimeout('changeOffer(0,'+randid+')');
		clearTimeout('changeOffer(1,'+randid+')');
	}
	});
}
function drawPicture(pic_picture,full_picture,pic_width,pic_height,pic_tag){
	if (pic_height > 320){ pic_width = parseInt(pic_width*320/pic_height); pic_height = 320; }
	if (pic_width > 450){ pic_height = parseInt(pic_height*450/pic_width); pic_width = 450; }
	if (pic_tag == ""){
		$("#picture_tag").hide();
	}
	$("#picture_photo img").fadeOut(250,function(){
		$("#picture_photo img").attr({ src: '../'+pic_picture, width: pic_width, height: pic_height });
		$("#picture_photo").unbind('click').click(function(){
			drawBigpicture(full_picture,pic_width,pic_height);
		});
		$("#picture_photo img").delay(150).fadeIn(250,function(){
			if (pic_tag != ""){
				$("#picture_tag").html(pic_tag);
				$("#picture_tag").show();
			}		
		});
	});
}
function drawBigpicture(full_picture,pic_width,pic_height){
	pic_ref_h = 600;
	pic_ref_w = pic_width * pic_ref_h / pic_height;	
	
	$("#main_mask").show();
	$("#main_full_pic").attr({ src: '../'+full_picture, width: pic_ref_w, height: pic_ref_h });
	$("#main_mask_pic").delay(150).show();
}
function closeBigpicture(){
	$("#main_full_pic").attr({ src: '' });
	$("#main_mask_pic").hide();
	$("#main_mask").hide();
}
function paintRow(row_id,direction){
	if (direction == 'in'){
		$("#price_row_"+row_id).css({ 'backgroundColor': '#0043ca','color': '#fff' });
	} else if (direction == 'out'){
		$("#price_row_"+row_id).css({ 'backgroundColor': '#fff','color': '#0043ca' });
	}
}
function drawPrice(subid,subname,lngVersion,lngClose){
	$("#loader").fadeIn(100);
	var html_piece = "<p style=\"font-size:12pt;font-weight:bold;width:936px;text-align:center;margin:5px;\">Prijslijsten van "+subname+"</p>";
	html_piece = html_piece + "<table cellspacing=\"0\" style=\"width:450px; margin: 0px 0px 0px 235px; text-align:left;border:1px solid #0043ca;\">";
	$.ajax({ type: "GET", url: "db/db_pricelist.php?item="+subid+"", data: "", dataType: "xml", success: function(xml){
	$("#price_extra").show().animate({ 'height': '230' }, 'fast', 'linear', function(){
		$("#close_price").fadeIn(250);
		var jData = $( xml );
		var jSections = jData.children();
		$("pricelist", jSections).each(function(){
			var pid = $(this).find('price_id').text();
			var price_brand = $(this).find('price_brand').text();
			var price_versie = $(this).find('price_versie').text();
			var price_url = $(this).find('price_url').text();
			html_piece = html_piece + "<tr id=\"price_row_"+pid+"\"><td class=\"price_row\">";
			html_piece = html_piece + "<a href=\"javascript:void(0);\" onclick=\"nieuwWindow('prijslijst/"+pid+"','Prijslijst');\" onmouseover=\"paintRow("+pid+",'in');\" onmouseout=\"paintRow("+pid+",'out');\">";
			html_piece = html_piece + "<img src=\"images/pdf.gif\" alt=\"\" style=\"width:18px;height:16px;margin:0px 5px 0px 5px;border:0px;\"/>";
			html_piece = html_piece + ""+price_brand+"</a>";
			html_piece = html_piece + "</td><td style=\"width:125px;\">"+lngVersion+": "+price_versie+"</td></tr>";
		});
		html_piece = html_piece + "</table>";
		html_piece = html_piece + "<p id=\"close_price\"><a href=\"javascript:void(0);\" onclick=\"closePrice()\"><font style=\"color: #f00;\">X</font> "+lngClose+"</a></p>";
		$("#price_extra").html(html_piece);
		$("#loader").fadeOut(100);
	});

	},error: function(XMLHttpRequest, textStatus, errorThrown) {   
		//error
	}
	});
}
function closePrice() {
	$("#price_extra").animate({ 'height': '0' }, 'fast', 'linear', function(){
		$("#price_extra").html('');
		$("#price_extra").hide();
	});
}
function supportRow(row_id,direction){
	if (direction == 'in'){
		$("#suprow_"+row_id+" td a").css({ 'color': '#fff' });
		$("#suprow_"+row_id+" td").css({ 'backgroundColor': '#0043ca' });
	} else if (direction == 'out'){
		$("#suprow_"+row_id+" td a").css({ 'color': '#0043ca' });
		$("#suprow_"+row_id+" td").css({ 'backgroundColor': '#fff' });
	}
}

function nieuwWindow(href,title) {
	var w = 980;
	var h = screen.availHeight - 50;
	var winl = ((screen.availWidth - w) / 2) - 20;
	var wint = (screen.availHeight - h) / 2;
	window.open(href, title, "width="+w+",height="+h+",top="+wint+",left="+winl+",scrollbars=yes,status=no,toolbar=no,location=no,resizable=no");
}
function CheckSearch() { 
    if (document.all || document.getElementById){  
		if (document.getElementById("zoekform").src_product.value.length < 3){
			alert ("Zoekopdracht moet groter zijn dan twee tekens");
			return false;
		} else {
			return true;
		}
	} else { 
		if (document.layers["zoekform"].src_product.value.length < 3){
			alert ("Zoekopdracht moet groter zijn dan twee tekens");
			return false;
		} else {
			return true;
		}
	} 
}
function LoadImage(URL,PicWidth,PicHeight) {
	if (!document.images)
	return
		document.images.prodimage.src = URL;
		document.images.prodimage.width = PicWidth;
		document.images.prodimage.height = PicHeight;
}
function encode_utf8( s ){  
	return unescape( encodeURIComponent( s ) );
}
function decode_utf8( s ){  
	return decodeURIComponent( escape( s ) );
}
function checkForm(){
 	var error_array = new Array();
	if ($("input[name=user_firstname]").val() == ""){ error_array.push('* U heeft geen voornaam of voorletters opgegeven'); }
	paint('user_firstname');
	if ($("input[name=user_lastname]").val() == ""){ error_array.push('* U heeft geen achternaam opgegeven'); }
	paint('user_lastname');
	if ($("input[name=user_street]").val() == ""){ error_array.push('* U heeft geen straat opgegeven'); }
	paint('user_street');
	if ($("input[name=user_streetnr]").val() == ""){ error_array.push('* U heeft geen huisnummer opgegeven'); }
	paint('user_streetnr');
	if ($("input[name=user_zipcode]").val() == ""){ error_array.push('* U heeft geen postcode opgegeven'); }
	paint('user_zipcode');
	if ($("input[name=user_town]").val() == ""){ error_array.push('* U heeft geen woonplaats opgegeven'); }
	paint('user_town');
	if ($("input[name=user_country]").val() == ""){ error_array.push('* U heeft geen land opgegeven'); }
	paint('user_country');
	if ($("input[name=user_phone]").val() == ""){ error_array.push('* U heeft geen telefoon opgegeven'); }
	paint('user_phone'); 
	var str = $("input[name=user_email]").val();
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i

	if ($("input[name=user_email]").val() == ""){ 
		error_array.push('* U heeft geen emailadres opgegeven'); 
	} else if (!filter.test(str)) {
		error_array.push('* U dient een geldig emailadres in te voeren!');
	}
 	paint('user_email');

	if ($("input[name=req_brand]").val() == ""){ error_array.push('* U heeft geen merk opgegeven'); }
	paint('req_brand');
	if ($("input[name=req_type]").val() == ""){ error_array.push('* U heeft geen type opgegeven'); }
 	paint('req_type');

	if(error_array.length){
		var alleerrors = 'Er zijn fout(en) opgetreden tijdens het controleren van het formulier.\r\nU kunt het formulier niet verzenden voordat het formulier compleet is ingevuld.\r\n\r\nFoutmeldingen:\r\n\r\n';
		for(var i=0; i <= (error_array.length-1); i++){
			alleerrors = alleerrors + error_array[i] + '\r\n';
		}
 		alert(alleerrors);
 		return false;
	} else {
		return true;
	}
}
function checkB2BForm(){
 	var error_array = new Array();
	if ($("input[name=user_company]").val() == ""){ error_array.push('* U heeft geen bedrijfsnaam opgegeven'); }
	paint('user_company');
	if ($("input[name=user_kvk]").val() == ""){ error_array.push('* U heeft geen KvK-nummer opgegeven'); }
	paint('user_kvk');
	if ($("input[name=user_btw]").val() == ""){ error_array.push('* U heeft geen BTW-nummer opgegeven'); }
	paint('user_btw');
	if ($("input[name=user_firstname]").val() == ""){ error_array.push('* U heeft geen voornaam of voorletters opgegeven'); }
	paint('user_firstname');
	if ($("input[name=user_lastname]").val() == ""){ error_array.push('* U heeft geen achternaam opgegeven'); }
	paint('user_lastname');
	if ($("input[name=user_street]").val() == ""){ error_array.push('* U heeft geen straat opgegeven'); }
	paint('user_street');
	if ($("input[name=user_streetnr]").val() == ""){ error_array.push('* U heeft geen huisnummer opgegeven'); }
	paint('user_streetnr');
	if ($("input[name=user_zipcode]").val() == ""){ error_array.push('* U heeft geen postcode opgegeven'); }
	paint('user_zipcode');
	if ($("input[name=user_town]").val() == ""){ error_array.push('* U heeft geen woonplaats opgegeven'); }
	paint('user_town');
	if ($("input[name=user_country]").val() == ""){ error_array.push('* U heeft geen land opgegeven'); }
	paint('user_country');
	if ($("input[name=user_phone]").val() == ""){ error_array.push('* U heeft geen telefoon opgegeven'); }
	paint('user_phone'); 
	var str = $("input[name=user_email]").val();
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i

	if ($("input[name=user_email]").val() == ""){ 
		error_array.push('* U heeft geen emailadres opgegeven'); 
	} else if (!filter.test(str)) {
		error_array.push('* U dient een geldig emailadres in te voeren!');
	}
 	paint('user_email');
	if(error_array.length){
		var alleerrors = 'Er zijn fout(en) opgetreden tijdens het controleren van het formulier.\r\nU kunt het formulier niet verzenden voordat het formulier compleet is ingevuld.\r\n\r\nFoutmeldingen:\r\n\r\n';
		for(var i=0; i <= (error_array.length-1); i++){
			alleerrors = alleerrors + error_array[i] + '\r\n';
		}
 		alert(alleerrors);
 		return false;
	} else {
		return true;
	}
}
function checkroadForm(){
 	var error_array = new Array();
	if ($("input[name=road_name]").val() == ""){ error_array.push('* U heeft geen naam opgegeven'); }
	paint('road_name');
	if ($("input[name=road_company]").val() == ""){ error_array.push('* U heeft geen bedrijfsnaam opgegeven'); }
	paint('road_company');
	if ($("input[name=road_phone]").val() == ""){ error_array.push('* U heeft geen telefoonnummer opgegeven'); }
	paint('road_phone'); 
	var str = $("input[name=road_email]").val();
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	if ($("input[name=road_email]").val() == ""){ 
		error_array.push('* U heeft geen emailadres opgegeven'); 
	} else if (!filter.test(str)) {
		error_array.push('* U dient een geldig emailadres in te voeren!');
	}
 	paint('road_email');
	if (document.getElementById('road_date').selectedIndex == 0){ error_array.push('* U heeft geen datum opgegeven'); }
	if (document.getElementById('road_personen').selectedIndex == 0){ error_array.push('* U heeft geen aantal personen opgegeven'); }

	if(error_array.length){
		var alleerrors = 'Er zijn fout(en) opgetreden tijdens het controleren van het formulier.\r\nU kunt het formulier niet verzenden voordat het formulier compleet is ingevuld.\r\n\r\nFoutmeldingen:\r\n\r\n';
		for(var i=0; i <= (error_array.length-1); i++){
			alleerrors = alleerrors + error_array[i] + '\r\n';
		}
 		alert(alleerrors);
 		return false;
	} else {
		return true;
	}
}
function paint_chkrow(thisrow,bgcolor,color){
	$("#"+thisrow).css({ 'backgroundColor': bgcolor });
	$("#"+thisrow+" td a").css({ 'color': color });
}
function paint(textbox){
	if ($("#"+textbox).val() == ""){
		$("#"+textbox).css({ 'backgroundColor':'#ffd2d2' })
	} else {
		$("#"+textbox).css({ 'backgroundColor':'#fff' })
	}
}
function clearRmaForm(){
	if (confirm("Weet je zeker dat je alle gegevens wilt verwijderen?")){
		document.getElementById('user_init').selectedIndex = 0;
		$("input[name=user_debnr]").val('');
		$("input[name=user_company]").val('');
		$("input[name=user_firstname]").val('');
		$("input[name=user_midname]").val('');
		$("input[name=user_lastname]").val('');
		$("input[name=user_street]").val('');
		$("input[name=user_streetnr]").val('');
		$("input[name=user_poststreetnr]").val('');
		$("input[name=user_zipcode]").val('');
		$("input[name=user_town]").val('');
		$("input[name=user_country]").val('');
		$("input[name=user_phone]").val('');
		$("input[name=user_fax]").val('');
		$("input[name=user_email]").val('');
	}
}
function show_rma(rmaid){
	$("#row_"+rmaid).show();
}
function hide_rma(rmaid){
	$("#row_"+rmaid).hide();
}
function showFlash(){
	var containerHeight = $(document).height();
	$('#flash_mask').height(containerHeight).show();
	var flashobj = '<p style="text-align:right;width:700px;padding:0px 10px;"><a href="javascript:void(0);" onclick="hideFlash();">Close</a></p>';
	flashobj = flashobj + '<object id="presentation" width="720" height="576" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" align="middle">\n';
	flashobj = flashobj + '<param name="allowScriptAccess" value="sameDomain" />\n';
	flashobj = flashobj + '<param name="movie" value="downloads/RobePlasma.swf" />\n';
	flashobj = flashobj + '<param name="quality" value="high" />\n';
	flashobj = flashobj + '<param name="bgcolor" value="#ffffff" />\n';
	flashobj = flashobj + '<param name="allowFullScreen" value="true" />\n';
	flashobj = flashobj + '<embed src="downloads/RobePlasma.swf" quality="high" bgcolor="#ffffff" width="720" height="576" name="presentation" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.adobe.com/go/getflashplayer" allowFullScreen="true" /></object>\n';
	$('#flash_obj').html(flashobj);
	$('#flash_obj').show();
}
function hideFlash(){
	$('#flash_obj').html('');
	$('#flash_mask').hide();
	$('#flash_obj').hide();
}
function searchDebtor(){
	var debtor_id = $("input[name=user_debnr]").val();
	$('#find_debtor').attr('disabled', true);
	$.ajax({ type: "POST", url: "db/db_search_debtor.php", data: "debtor_id="+debtor_id, dataType: "xml", success: function(xml){
		var jData = $( xml );
		var jSections = jData.children();
		$("debtor", jSections).each(function(){
			var deb_name = $(this).find('deb_name').text();
			var deb_contact = $(this).find('deb_contact').text();
			var deb_adres = $(this).find('deb_adres').text();
			var deb_zipcode = $(this).find('deb_zipcode').text();
			var deb_place = $(this).find('deb_place').text();
			var deb_country = $(this).find('deb_country').text();
			var deb_phone = $(this).find('deb_phone').text();
			var deb_fax = $(this).find('deb_fax').text();
			var deb_email = $(this).find('deb_email').text();

			$("input[name=user_company]").val(deb_name);
			$("input[name=user_firstname]").val('');
			$("input[name=user_midname]").val('');
			$("input[name=user_lastname]").val(deb_contact);
			$("input[name=user_street]").val(deb_adres);
			$("input[name=user_streetnr]").val('');
			$("input[name=user_poststreetnr]").val('');
			$("input[name=user_zipcode]").val(deb_zipcode);
			$("input[name=user_town]").val(deb_place);
			$("input[name=user_country]").val(deb_country);
			$("input[name=user_phone]").val(deb_phone);
			$("input[name=user_fax]").val(deb_fax);
			$("input[name=user_email]").val(deb_email);

			$('#find_debtor').attr('disabled', false);
		});
	},error: function(XMLHttpRequest, textStatus, errorThrown) {   
		alert("Fout bij het vinden van de debiteur");
		$('#find_debtor').attr('disabled', false);
	}
	});
}
function changeLanguage(lang,redirect){
	$.ajax({ type: "POST", url: "db/db_language.php", data: "langugage="+lang, dataType: "html", success: function(html){
		location.href = redirect;
	},error: function(XMLHttpRequest, textStatus, errorThrown) {   
		//error
	}
	});
}
