

$(document).ready(function(){ 

	$("#featured").tabs({fx:{opacity: "toggle"}}).tabs("rotate", 5000, true);
	$("#featured").hover(
	function() {
	$("#featured").tabs("rotate",0,true);
	},
	function() {
	$("#featured").tabs("rotate",5000,true);
	}
	);
	
	$("#ShippingCountry").delegate('select[name="txtShippingCountry"]', 'change', function () {
		country = $('#ShippingCountrySelect').val(); 
		if ( country == 'BE') {
			alert("Leveringen in België dienen vooraf betaald te worden.\n Overigens zijn de energiekosten, transportverzekering en transportkosten ook voor België inclusief.");
		}
	});

	$('.cancelForm').live('click', function() {
		location.reload();
	});


	// BEGIN Offerte voor plaatsing
	
/*	$('#offerteplaatsing').click(function() {
		alert('Onze glaszetters kunnen voorlopig helaas geen werk aannemen. Het is daarom niet mogelijk een offerte aan te vragen voor plaatsing.');
	});
*/	$('#offerteplaatsing').click(function() {
		$.post('include/processPlaatsingOfferte.php', function(data){
			$('#container_plaatsingofferte_form').show('slow', function() {});
			$('#container_plaatsingofferte_form').html(data);
			$('.ft').append('<input style="float:right;" type="button" class="cancelForm" value="Cancel"/>');
			$('input[value="Cancel"]').attr('id','cancel');
		});
	});

	$.metadata.setType("attr", "validate");

	$("#PlaatsingForm").validate({
		  rules: {
			req_pc: {
				required: true,
				NLpostcode: true
		    },
		    req_tel: {
		    	required: true,
		    	phoneNL: true
		    }
		  }
	});
	
	$("#container_plaatsingofferte_form").delegate('select[name="req_opdrachttype"]', 'change', function () {
		$opdrachttype = $('#req_opdrachttype').val();
		switch ($opdrachttype) {
		case ('1'): // nieuw
			$('#glasschade').hide('slow', function() {});
			$('#glassoort').show('slow', function() {});
			$('#interieurGlassoort').hide('slow', function() {});
			break;
		case ('2'): // renovatie
			$('#glasschade').hide('slow', function() {});
			$('#glassoort').show('slow', function() {});
			$('#interieurGlassoort').hide('slow', function() {});
			break;
		case ('3'): // glasschade
			$('#glasschade').show('slow', function() {});
			$('#glassoort').show('slow', function() {});
			$('#interieurGlassoort').hide('slow', function() {});
			break;
		case ('4'): // interieur
			$('#glasschade').hide('slow', function() {});
			$('#glassoort').hide('slow', function() {});
			$('#interieurGlassoort').show('slow', function() {});
			$('#veiligheidsGlassoort').hide('slow', function() {});
			$('#enkelGlassoort').hide('slow', function() {});
			$('#dubbelGlassoort').hide('slow', function() {});
			$('#aantal').hide('slow', function() {});
			break;
		default:
		}
		if ($('#req_opdrachttype').val()=='3'){
			$('#glasschade').show('slow', function() {});
		} else if ($('#req_opdrachttype').val()=='4'){{
			$('#interieurGlassoort').show('slow', function() {});
			$('#glassoort').hide('slow', function() {});
			$('#glasschade').hide('slow', function() {});
		}} else {
			$('#glasschade').hide('slow', function() {});
			$('#glassoort').show('slow', function() {});
		}
	});
	
	$("#container_plaatsingofferte_form").delegate('select[name="req_verzekering"]', 'change', function () {
		$('#glassoort').show('slow', function() {});
	});

	$("#container_plaatsingofferte_form").delegate('select[name="req_glas"]', 'change', function () {
		if ($('#req_glas').val() == '1')	{
			$('#enkelGlassoort').show('slow', function() {});
			$('#dubbelGlassoort').hide('slow', function() {});
			$('#veiligheidsGlassoort').hide('slow', function() {});
		} else if ($('#req_glas').val() == '2')	{
			$('#enkelGlassoort').hide('slow', function() {});
			$('#dubbelGlassoort').show('slow', function() {});
			$('#veiligheidsGlassoort').hide('slow', function() {});
		} else if ($('#req_glas').val() == '3')	{
			$('#enkelGlassoort').hide('slow', function() {});
			$('#dubbelGlassoort').hide('slow', function() {});
			$('#veiligheidsGlassoort').show('slow', function() {});
		}
	});
	
	$("#container_plaatsingofferte_form").delegate('select[name="req_interieurglas"]', 'change', function () {
		$('#stuks').show('slow', function() {});
	});
	
	$("#container_plaatsingofferte_form").delegate('select[name="req_enkelglas"],[name="req_dubbelglas"],[name="req_veiligheidsglas"]', 'change', function () {
		$('#aantal').show('slow', function() {});
		$('#stuks').hide('slow', function() {});
	});
	
	$("#container_informatie_form").delegate('select[name="req_aantal"]', 'change', function () {
		if ($('#glasplaat1').length){
			return true;
		}
		var aantal;
		$('#glasplatenDiv').show('slow', function() {});
		aantal = $('#req_aantal').val();
		if (aantal == 0){
			aantal = $('#req_stuks').val();
		}
		for( i=1; i <= 10; i++){
			ruitdiv = '<div id="glasplaat' + i + '" class="glasplaatRegel">';
			ruitdiv += i + '  <input class="required digits glasplaat' + i + 'breedte" id="glasplaat' + i + 'breedte" name="glasplaat' + i + 'breedte" size="3" maxlength="4" type="text" value=""/>(mm)';
			ruitdiv += '<input class="required digits glasplaat' + i + 'hoogte" id="glasplaat' + i + 'hoogte" name="glasplaat' + i + 'hoogte" size="3" maxlength="4" type="text" value=""/>(mm)';
			ruitdiv += '<select id="glasplaat' + i + 'Floor" name="glasplaat' + i + 'Floor">';
			ruitdiv += '<option value="">- Maak keuze -</option>';
			ruitdiv += '<option value="0">Beg. grond</option>';
			ruitdiv += '<option value="1">1e</option>';
			ruitdiv += '<option value="2">2e</option>';
			ruitdiv += '<option value="3">3e</option>';
			ruitdiv += '<option value="4">4e</option>';
			ruitdiv += '<option value="5">hoger</option>';
			ruitdiv += '</select>';
			ruitdiv += '</div>';
			$('#glasplatenDiv').append(ruitdiv);
			if (i>aantal){
				$('#glasplaat' + i).hide();
				$('#glasplaat' + i + 'breedte').delay(1000).val('4999');
				$('#glasplaat' + i + 'hoogte').delay(1000).val('4999');
				$('#glasplaat' + i + 'Floor').delay(1000).val('0');
			} 
		}
		$('#memoDiv').delay(600).show('slow', function() {});
		$('#contactgegevens').delay(1200).show('slow', function() {});
		$('.submit').show('slow', function() {});
	}); 
	
	$("#container_plaatsingofferte_form").delegate('select[name="req_stuks"]', 'change', function () {
		if ($('#interierglas1').length){
			return true;
		}
		var aantal;
		$('#interierglasDiv').show('slow', function() {});
		aantal = $('#req_stuks').val();
		for( i=1; i <= 10; i++){
			ruitdiv = '<div id="interierglas' + i + '" class="interierglasRegel">';
			ruitdiv += i + '  <input class="required digits interierglas' + i + 'breedte" id="interierglas' + i + 'breedte" name="interierglas' + i + 'breedte" size="3" maxlength="4" type="text" value=""/>(mm)';
			ruitdiv += '<input class="required digits interierglas' + i + 'hoogte" id="interierglas' + i + 'hoogte" name="interierglas' + i + 'hoogte" size="3" maxlength="4" type="text" value=""/>(mm)';
			ruitdiv += '</div>';
			$('#interierglasDiv').append(ruitdiv);
			if (i>aantal){
				$('#interierglas' + i).hide();
				$('#interierglas' + i + 'breedte').delay(1000).val('4999');
				$('#interierglas' + i + 'hoogte').delay(1000).val('4999');
			} 
			$('#interierglas' + i + 'Floor').delay(1000).val('0');
		}
		$('#memoDiv').delay(600).show('slow', function() {});
		$('#contactgegevens').delay(1200).show('slow', function() {});
		$('#req_memo').css("rows","20");
		$('.submit').show('slow', function() {});
	}); 

	// EINDE offerte voor plaatsing
	//
	//
	//
	// BEGIN offerte voor levering

	$('#offertelevering').click(function() {
		$.post('include/processLeveringOfferte.php', function(data){
			$('#container_leveringofferte_form').show('slow', function() {});
			$('#container_leveringofferte_form').html(data);
			$('.ft').append('<input style="float:right;" type="button" class="cancelForm" value="Cancel"/>');
			$('input[value="Cancel"]').attr('id','cancel');
		});
	});
	
	$("#LeveringForm").validate({
		  rules: {
			req_pc: {
				required: true,
				NLpostcode: true
		    },
		    req_tel: {
		    	required: true,
		    	phoneNL: true
		    },
		    mailFile: {
		        accept: "jpg|jpeg|gif|bmp|docx?|txt|pdf|png"
		    }

		  }
	});
	
	$("#container_leveringofferte_form").delegate('select[name="req_opdrachttype"]', 'change', function () {
		$opdrachttype = $('#req_opdrachttype').val();
		switch ($opdrachttype) {
		case ('1'): // nieuw
			$('#glasschade').hide('slow', function() {});
			$('#glassoort').show('slow', function() {});
			$('#interieurGlassoort').hide('slow', function() {});
			break;
		case ('2'): // renovatie
			$('#glasschade').hide('slow', function() {});
			$('#glassoort').show('slow', function() {});
			$('#interieurGlassoort').hide('slow', function() {});
			break;
		case ('3'): // glasschade
			$('#glasschade').show('slow', function() {});
			$('#glassoort').show('slow', function() {});
			$('#interieurGlassoort').hide('slow', function() {});
			break;
		case ('4'): // interieur
			$('#glasschade').hide('slow', function() {});
			$('#glassoort').hide('slow', function() {});
			$('#interieurGlassoort').show('slow', function() {});
			$('#veiligheidsGlassoort').hide('slow', function() {});
			$('#enkelGlassoort').hide('slow', function() {});
			$('#dubbelGlassoort').hide('slow', function() {});
			$('#aantal').hide('slow', function() {});
			break;
		default:
			
		}
		
		if ($('#req_opdrachttype').val()=='3'){
			$('#glasschade').show('slow', function() {});
		} else if ($('#req_opdrachttype').val()=='4'){{
			$('#interieurGlassoort').show('slow', function() {});
			$('#glassoort').hide('slow', function() {});
			$('#glasschade').hide('slow', function() {});
		}} else {
			$('#glasschade').hide('slow', function() {});
			$('#glassoort').show('slow', function() {});
		}
	});
	
	$("#container_leveringofferte_form").delegate('select[name="req_verzekering"]', 'change', function () {
		$('#glassoort').show('slow', function() {});
	});

	$("#container_leveringofferte_form").delegate('select[name="req_glas"]', 'change', function () {
		if ($('#req_glas').val() == '1')	{
			$('#enkelGlassoort').show('slow', function() {});
			$('#dubbelGlassoort').hide('slow', function() {});
			$('#veiligheidsGlassoort').hide('slow', function() {});
		} else if ($('#req_glas').val() == '2')	{
			$('#enkelGlassoort').hide('slow', function() {});
			$('#dubbelGlassoort').show('slow', function() {});
			$('#veiligheidsGlassoort').hide('slow', function() {});
		} else if ($('#req_glas').val() == '3')	{
			$('#enkelGlassoort').hide('slow', function() {});
			$('#dubbelGlassoort').hide('slow', function() {});
			$('#veiligheidsGlassoort').show('slow', function() {});
		}
	});
	
	$("#container_leveringofferte_form").delegate('select[name="req_interieurglas"]', 'change', function () {
		$('#stuks').show('slow', function() {});
	});
	
	$("#container_leveringofferte_form").delegate('select[name="req_enkelglas"],[name="req_dubbelglas"],[name="req_veiligheidsglas"]', 'change', function () {
		$('#aantal').show('slow', function() {});
		$('#stuks').hide('slow', function() {});
	});
	
	$("#container_leveringofferte_form").delegate('select[name="req_aantal"]', 'change', function () {
		if ($('#glasplaat1').length){
			return true;
		}
		var aantal;
		$('#glasplatenDiv').show('slow', function() {});
		aantal = $('#req_aantal').val();
		if (aantal == 0){
			aantal = $('#req_stuks').val();
		}
		for( i=1; i <= 10; i++){
			ruitdiv = '<div id="glasplaat' + i + '" class="glasplaatRegel">';
			ruitdiv += i + '  <input class="required digits glasplaat' + i + 'breedte" id="glasplaat' + i + 'breedte" name="glasplaat' + i + 'breedte" size="3" maxlength="4" type="text" value=""/>(mm)';
			ruitdiv += '<input class="required digits glasplaat' + i + 'hoogte" id="glasplaat' + i + 'hoogte" name="glasplaat' + i + 'hoogte" size="3" maxlength="4" type="text" value=""/>(mm)';
			ruitdiv += '<select id="glasplaat' + i + 'Floor" name="glasplaat' + i + 'Floor">';
			ruitdiv += '<option value="">- Maak keuze -</option>';
			ruitdiv += '<option value="0">Beg. grond</option>';
			ruitdiv += '<option value="1">1e</option>';
			ruitdiv += '<option value="2">2e</option>';
			ruitdiv += '<option value="3">3e</option>';
			ruitdiv += '<option value="4">4e</option>';
			ruitdiv += '<option value="5">hoger</option>';
			ruitdiv += '</select>';
			ruitdiv += '</div>';
			$('#glasplatenDiv').append(ruitdiv);
			if (i>aantal){
				$('#glasplaat' + i).hide();
				$('#glasplaat' + i + 'breedte').delay(1000).val('4999');
				$('#glasplaat' + i + 'hoogte').delay(1000).val('4999');
				$('#glasplaat' + i + 'Floor').delay(1000).val('0');
			} 
		}
		$('#memoDiv').delay(600).show('slow', function() {});
		$('#contactgegevens').delay(1200).show('slow', function() {});
		$('.submit').show('slow', function() {});
	}); 
	
	$("#container_leveringofferte_form").delegate('select[name="req_stuks"]', 'change', function () {
		if ($('#interierglas1').length){
			return true;
		}
		var aantal;
		$('#interierglasDiv').show('slow', function() {});
		aantal = $('#req_stuks').val();
		for( i=1; i <= 10; i++){
			ruitdiv = '<div id="interierglas' + i + '" class="interierglasRegel">';
			ruitdiv += i + '  <input class="required digits interierglas' + i + 'breedte" id="interierglas' + i + 'breedte" name="interierglas' + i + 'breedte" size="3" maxlength="4" type="text" value=""/>(mm)';
			ruitdiv += '<input class="required digits interierglas' + i + 'hoogte" id="interierglas' + i + 'hoogte" name="interierglas' + i + 'hoogte" size="3" maxlength="4" type="text" value=""/>(mm)';
			ruitdiv += '</div>';
			$('#interierglasDiv').append(ruitdiv);
			if (i>aantal){
				$('#interierglas' + i).hide();
				$('#interierglas' + i + 'breedte').delay(1000).val('4999');
				$('#interierglas' + i + 'hoogte').delay(1000).val('4999');
			} 
			$('#interierglas' + i + 'Floor').delay(1000).val('0');
		}
		$('#memoDiv').delay(600).show('slow', function() {});
		$('#contactgegevens').delay(1200).show('slow', function() {});
		$('#req_memo').css("rows","20");
		$('.submit').show('slow', function() {});
	}); 
	
	
	// EINDE offerte voor levering	
}); 



