-
Notifications
You must be signed in to change notification settings - Fork 0
/
9.js
255 lines (204 loc) · 7.47 KB
/
9.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
$(document).ready(function() {
$('.quote_message_error').css('display', 'none');
$('.contact_message_error').css('display', 'none');
$('.dropdown-list li').click(function() {
$('input#quote_hidden_budget').val($(this).text());
});
$('a.to-top').click(function () {
$('body,html').animate({
scrollTop: 0
}, 700);
return false;
});
$('.dropdown').click(function (e) {
e.preventDefault();
$('.dropdown-list').slideToggle(200);
});
$(document).bind('click', function(e) {
var $clicked = $(e.target);
if (! $clicked.parents().hasClass('dropdown-holder'))
$('.dropdown-list').slideUp(200);
});
$('.dropdown-list li a').click(function(e) {
e.preventDefault();
var text = $(this).text();
$('.value').text(text);
$('.dropdown-list').slideUp(200);
});
$(".fancybox").fancybox({
'padding' : 0,
'autoSize' : false,
'width' : '580',
'height' : 'auto',
'scrolling' : 'yes',
'titleShow' : false,
'helpers' : {
overlay : {
locked: true
}
}
});
$(window).bind('resize', positionBranding);
positionBranding();
$("form").submit(function(event) {
var form_name = $(this).attr('id');
event.preventDefault();
//$('.quote_message_error').show();
var hasError = false;
if ((form_name == "frm_quote") || (form_name == "frm_quote_fr")) {
var quote_name = $('input#quote_name').val();
if (quote_name == "") {
hasError = true;
$('#quote_name').attr("class", "input required");
}
var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
var quote_email = $('input#quote_email').val();
if (quote_email == "") {
hasError = true;
$('#quote_email').attr("class", "input required");
}
else if(!emailReg.test(quote_email)) {
hasError = true;
if (form_name == "frm_quote")
$('.quote_message_error').html('Hm, something’s not right... Email is not valid');
else
$('.quote_message_error').html('Mm, quelque chose cloche... Le courriel n\'est pas valide');
$('#quote_email').attr("class", "input required");
$('input#quote_email').focus();
}
var quote_url = $('input#quote_url').val();
if (quote_url != '') {
var urlregex = new RegExp('^(http:\/\/www.|https:\/\/www.|ftp:\/\/www.|www.){1}([0-9A-Za-z]+\.)');
var quote_url = $('input#quote_url').val();
if(!urlregex.test(quote_url)) {
hasError = true;
if (form_name == "frm_quote")
$('.quote_message_error').html('Hm, something’s not right... URL is not valid');
else
$('.quote_message_error').html('Mm, quelque chose cloche... L\'URL n\'est pas valide');
$('#quote_url').attr("class", "input required");
$('input#quote_url').focus();
}
}
var quote_budget = $('input#quote_hidden_budget').val();
var quote_interest = "No interest has been selected.";
if ($('input:radio[name=quote_interest]').is(':checked')) {
quote_interest = $('input:radio[name=quote_interest]:checked').val();
}
var quote_message = $('#quote_message').val();
if (hasError == false) {
var dataString = 'quote_name=' + quote_name + '"e_email=' + quote_email + '"e_url=' + quote_url + '"e_budget=' + quote_budget + '"e_interest=' + quote_interest + '"e_message=' + quote_message;
//alert (dataString); return false;
$.ajax({
type: "POST",
url: "../inc/send_quote_info.php",
data: dataString,
success: function() {
$('html,body').animate({ scrollTop: 0 }, 'slow');
$('.quote_message_error').show();
if (form_name == "frm_quote")
$('.quote_message_error').html('Thank you for contacting us, we will be in touch within the next 24 hours.');
else
$('.quote_message_error').html('Merci, nous allons rentrer en contact avec vous d\'ici les prochaines 24 heure.');
$('.quote_message_error').css('background', '#5a8203');
$('input#quote_name').val('');
$('input#quote_email').val('');
$('input#quote_url').val('');
$('#quote_message').val('');
$('#sbt_quote').attr("disabled", "disabled");
setTimeout('$.fancybox.close();', 2000);
},
error: function(xhr,err){
alert("readyState: "+xhr.readyState+"\nstatus: "+xhr.status);
alert("responseText: "+xhr.responseText);
}
});
}
else {
$('.quote_message_error').show();
$('input#quote_name').focus();
return false;
}
}
else {
var contact_name = $('input#contact_name').val();
if (contact_name == "") {
hasError = true;
$('#contact_name').attr("class", "input required");
}
var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
var contact_email = $('input#contact_email').val();
if (contact_email == "") {
hasError = true;
$('#contact_email').attr("class", "input required");
}
else if(!emailReg.test(contact_email)) {
hasError = true;
if (form_name == "frm_contact")
$('.contact_message_error').html('Hm, something’s not right... Email is not valid');
else
$('.contact_message_error').html('Mm, quelque chose cloche... Le courriel n\'est pas valide');
$('#contact_email').attr("class", "input required");
$('input#contact_email').focus();
}
var contact_url = $('input#contact_url').val();
if (contact_url != '') {
var urlregex = new RegExp('^(http:\/\/www.|https:\/\/www.|ftp:\/\/www.|www.){1}([0-9A-Za-z]+\.)');
var contact_url = $('input#contact_url').val();
if(!urlregex.test(contact_url)) {
hasError = true;
if (form_name == "frm_contact")
$('.contact_message_error').html('Hm, something’s not right... URL is not valid');
else
$('.contact_message_error').html('Mm, quelque chose cloche... L\'URL n\'est pas valide');
$('#contact_url').attr("class", "input required");
$('input#contact_url').focus();
}
}
var contact_message = $('#contact_message').val();
if (hasError == false) {
var dataString = 'contact_name=' + contact_name + '&contact_email=' + contact_email + '&contact_url=' + contact_url + '&contact_message=' + contact_message;
//alert (dataString); return false;
$.ajax({
type: 'POST',
url: '../inc/send_contact_info.php',
data: dataString,
success: function() {
$('.contact_message_error').show();
if (form_name == "frm_contact")
$('.contact_message_error').html('Thank you for contacting us, we will be in touch shortly.');
else
$('.contact_message_error').html('Merci, nous allons rentrer en contact avec vous d\'ici les prochaines 24 heures.');
$('.contact_message_error').css('background', '#5a8203');
$('input#contact_name').val('');
$('input#contact_email').val('');
$('input#contact_url').val('');
$('#contact_message').val('');
},
error: function(xhr,err){
alert('readyState: '+xhr.readyState+'\nstatus: '+xhr.status);
alert('responseText: '+xhr.responseText);
}
});
}
else {
$('.contact_message_error').show();
$('input#contact_name').focus();
return false;
}
}
});
$(window).on('scroll', function(){
if ( $(window).scrollTop() > 700 ) {
$('.to-top').fadeIn();
} else {
$('.to-top').fadeOut();
}
});
});
function positionBranding () {
var pageWidth = 980;
var windowWidth = $(window).width();
var space = (windowWidth - pageWidth) / 2;
$('.get-a-quote').css({right: (space)+'px'});
}