// JavaScript Document

$(function() { 
	setupRotator();
});

 function setupRotator()
 {
     if($('.textItem').length > 1)
     {
         $('.textItem:first').addClass('current').fadeIn(700);
         setInterval('textRotate()', 8000);
     }
 }
 function textRotate()
 {
	 var current = $('#news > .current');
	 if(current.next().length == 0)
	 {
		 current.removeClass('current').fadeOut(200);
		 $('.textItem:first').addClass('current').fadeIn(700);
	 }
	 else
	 {
		 current.removeClass('current').fadeOut(200);
		 current.next().addClass('current').fadeIn(700);
	 }
 }

function ChangeTabVergroting(element) {

	if ( element == 'VergrotingFoto' ) {
		
		document.getElementById('IdVergrotingFoto').className='VergrotingFotoActief';
		if (document.getElementById('IdVergrotingTekening')) {document.getElementById('IdVergrotingTekening').className='VergrotingTekening';}
		if (document.getElementById('IdVergrotingDownload')) {document.getElementById('IdVergrotingDownload').className='VergrotingDownload';}
		document.getElementById('vergrotingen').innerHTML=document.getElementById('imageHidden').innerHTML;
		
	}
	
	if ( element == 'VergrotingTekening' ) {
		
		document.getElementById('IdVergrotingTekening').className='VergrotingTekeningActief';
		if (document.getElementById('IdVergrotingFoto')) {document.getElementById('IdVergrotingFoto').className='VergrotingFoto';}
		if (document.getElementById('IdVergrotingDownload')) {document.getElementById('IdVergrotingDownload').className='VergrotingDownload';}
		document.getElementById('vergrotingen').innerHTML=document.getElementById('tekeningHidden').innerHTML;
		
	}
	
}

function saveStap1() {
	
	var field	=	new Array();
	
	field[0]	=	"voornaam";
	field[1]	=	"achternaam";
	field[2]	=	"email";
	field[3]	=	"telnr";
	field[4]	=	"straatnaam";
	field[5]	=	"huisnr";
	field[6]	=	"postcode";
	field[7]	=	"plaats";
	
	var fout = "";
	
	for(var i = 0; i < field.length; i++) {
		
		if(document.getElementById(field[i]).value == '') {
			fout = 1;
			document.getElementById(field[i]).className = 'bestellenError';	
		} else {
			document.getElementById(field[i]).className = 'bestellen';	
		}
	}
	
	if(fout) {
		$(function() {	
			$("#stap1Fouten").dialog({
				modal: true,
				buttons: {
					'Ok': function() {
						$(this).dialog('close');
					}
				}
			});

		});	
	} else {
		document.formStap1.submit();	
	}
		
}

function hideVergelijkLayer(id) {
	document.getElementById('product_'+id).checked = '';
	postForm();
}

function validateContact() {	

	var fout 	= 	0;
	var array	=	new Array();
	
	array[0]	=	"voornaam";
	array[1]	=	"achternaam";
	array[2]	=	"straat";
	array[3]	=	"postcode";
	array[4]	=	"woonplaats";
	array[5]	=	"email";
	
	for(var i = 0; i < array.length; i++) {
	
		if(document.getElementById(array[i]).value == '') {
			fout = 1;
			document.getElementById(array[i]).className = 'bestellenError';	
		} else {
			document.getElementById(array[i]).className = 'bestellen';	
		}
	}
	
	if(fout) {
		$(function() {	
			$("#contactFout").dialog({
				modal: true,
				buttons: {
					'Ok': function() {
						$(this).dialog('close');
					}
				}
			});

		});	
	} else {
		document.contactForm.submit();	
	}
}

function validateJubileum() {	

	var fout 	= 	0;
	var array	=	new Array();
	
	array[0]	=	"naam";
	array[1]	=	"adres";
	array[2]	=	"bedrijf";
	
	for(var i = 0; i < array.length; i++) {
	
		if(document.getElementById(array[i]).value == '') {
			fout = 1;
			document.getElementById(array[i]).className = 'bestellenError';	
		} else {
			document.getElementById(array[i]).className = 'bestellen';	
		}
	}
	
	if(document.getElementById('naam').value == 'Directie/Hoofd inkoop' || document.getElementById('naam').value == ''){
		fout = 1;
		document.getElementById('naam').className = 'bestellenError';	
	} else {
		document.getElementById('naam').className = 'bestellen';	
	}
	
	if(fout) {
		$(function() {	
			$("#contactFout").dialog({
				modal: true,
				buttons: {
					'Ok': function() {
						$(this).dialog('close');
					}
				}
			});

		});	
	} else {
		document.frmJubileum.submit();	
	}
}
