PageSourceSearch

https://ardholdings-sa.com/static/js/enquiries.js?v=18

js ardholdings-sa.com collected 2026-10-06 10:21:30 UTC 5,953 bytes, 158 lines download raw bytes

1
2function segment(material, name, products){ return { material:material, name:name, products:products } }
3
4// Define segments & translations
5var segments = [];
6
7// Metal
8segments.push(segment('Metal', 'Aerosols', ['All', 'Steel Aerosols', 'Aluminium Aerosols']));
9//segments.push(segment('Metal', 'Beverages', ['All', 'Aluminium Bottles', 'Kegs', 'Syrup Cans', 'Resealable Bottles']));
10segments.push(segment('Metal', 'Beverage Cans', ['All']));
11segments.push(segment('Metal', 'Aluminium Bottles', ['All']));
12segments.push(segment('Metal', 'Kegs', ['All']));
13segments.push(segment('Metal', 'Nutrition', ['All', 'Deep Drawn End', 'Infant Nutrition with Easy Peel']));
14segments.push(segment('Metal', 'Foods', ['All', 'Round Cans', 'Other Shapes', 'Bowls', 'Novelty Shapes', 'Microwaveable Trays']));
15segments.push(segment('Metal', 'Pet Food', ['All']));
16segments.push(segment('Metal', 'Seafood', ['All', 'Round', 'Other Shapes', 'Novelty Shapes']));
17segments.push(segment('Metal', 'Opening Solutions', ['All', 'Easy Peel Dry', 'Easy Peel Processed Food', 'OptiLift']));
18segments.push(segment('Metal', 'Custom', ['All', 'Custom Boxes', 'Custom Round Cans']));
19segments.push(segment('Metal', 'Paints and Coatings', ['All', 'Round', 'Pails and Drums', '3 finger shaped can']));
20
21// Glass
22segments.push(segment('Glass', 'Beer', false));
23segments.push(segment('Glass', 'Beverages', false));
24segments.push(segment('Glass', 'FABs', false));
25segments.push(segment('Glass', 'Cider', false));
26segments.push(segment('Glass', 'Food', false));
27segments.push(segment('Glass', 'Wines', false));
28segments.push(segment('Glass', 'NABs', false));
29segments.push(segment('Glass', 'Spirits', false));
30segments.push(segment('Glass', 'Pharmaceutical', false));
31
32
33$('select[name=material]').change(function() { set_segment(); });
34$('select[name=segment]').change(function() { set_product(); });
35
36
37// set the segment drop down
38function set_segment(active) {
39
40	//console.log(segments);
41	// Should we have an active segment
42	if(active != undefined) { selected = active; } else { selected = ''; }
43
44	// Remove all current children
45	$('select[name=segment]').children().remove();
46	var material = $('select[name=material]').val();
47
48	// Show / Hide the list of products
49	if(material == 'Metal') { $('.product_field').css('display', 'block'); }
50	else { $('.product_field').css('display', 'none'); }
51
52	$('select[name=segment]').append('<option value="">Choose</option>');
53
54	// Show the appropriate segment
55	for (i=0; i < segments.length; i++) {
56		if(segments[i].material == material) {
57			if(selected == segments[i].name) { show_selected = ' selected="selected"'; } else { show_selected = ''; }
58			$('select[name=segment]').append('<option value="'+segments[i].name+'"'+show_selected+'>'+segments[i].name+'</option>');
59		}
60	}
61
62	if(selected == '') { set_product(); }
63 	set_countries();
64}
65
66// Set the product drop down
67function set_product(active) {
68	// Should we have an active segment
69	if(active != undefined) { selected = active; } else { selected = ''; }
70
71	// Remove all current children
72	$('select[name=product]').children().remove();
73	$('select[name=product]').append('<option value="">Choose</option>');
74	var market_sector = $('select[name=segment]').val();
75
76	// Loop through the segments to check if the active segment has products
77	for (i=0; i < segments.length; i++) {
78		if(segments[i].name == market_sector && segments[i].products != false) {
79			for (j=0; j < segments[i].products.length; j++) {
80				if(selected == segments[i].products[j]) { show_selected = ' selected="selected"'; } else { show_selected = ''; }
81				$('select[name=product]').append('<option value="'+segments[i].products[j]+'"'+show_selected+'>'+segments[i].products[j]+'</option>');
82			}
83		}
84	}
85}
86
87// Set the countries based on the material
88function set_countries() {
89
90	//alert('set_countries');
91	$('#form_area select[name=country]').children().remove();
92	$('#form_area select[name=country]').append('<option value="">Choose</option>');
93	var material = $('select[name=material]').val();
94
95	if(material == 'Glass'){
96		var json_list = $('input[name=glass_countries]').val();
97	} else if(material == 'Metal'){
98		var json_list = $('input[name=metal_countries]').val();
99	} else {
100		var json_list = '[]';
101	}
102
103	json_list = JSON.parse(json_list);
104
105	for (var i = 0; i < json_list.length; i++){
106		$('select[name=country]').append('<option value="'+json_list[i].id+'">'+json_list[i].countryname+'</option>');
107	}
108}
109
110var getUrlParameter = function getUrlParameter(sParam) {
111    var sPageURL = decodeURIComponent(window.location.search.substring(1)),
112        sURLVariables = sPageURL.split('&'),
113        sParameterName,
114        i;
115
116    for (i = 0; i < sURLVariables.length; i++) {
117        sParameterName = sURLVariables[i].split('=');
118
119        if (sParameterName[0] === sParam) {
120            return sParameterName[1] === undefined ? true : sParameterName[1];
121        }
122    }
123};
124
125// Switch form on load
126var showForm = getUrlParameter('form');
127if (typeof showForm  !== "undefined"){
128	$('.enqform').hide();
129	$('#'+showForm).show();
130	preselectOptions(showForm)
131	$('#showForm option[value="'+showForm+'"]').attr("selected", "selected");
132}
133
134// Switch form based on selection
135$('#showForm').on('change', function(){
136	var form = $(this).val();
137	$('.enqform').slideUp();
138	$('#'+form).slideDown();
139	preselectOptions(form);
140})
141
142// Pre-select options (based on form type)
143function preselectOptions(form){
144
145	if(form == 'commercial-form'){
146		var preSelectedMaterial = getUrlParameter('material');
147		$('#material option[value="'+preSelectedMaterial+'"]').attr("selected", "selected");
148		set_segment();
149
150		var preSelectedSector = getUrlParameter('market_sector');
151		$('#market_sector option[value="'+preSelectedSector+'"]').attr("selected", "selected");
152	}
153
154	if(form == 'investor-form'){
155		var preSelectedOccupation = getUrlParameter('occupation');
156		$('#occupation option[value="'+preSelectedOccupation+'"]').attr("selected", "selected");
157	}
158}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.