function formatCurrency(num) {
num = num.toString().replace(/\$|\,/g,'');
if(isNaN(num))
num = "0";
sign = (num == (num = Math.abs(num)));
num = Math.floor(num*100+0.50000000001);
cents = num%100;
num = Math.floor(num/100).toString();
if(cents<10)
cents = "0" + cents;
for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
num = num.substring(0,num.length-(4*i+3))+','+
num.substring(num.length-(4*i+3));
return (((sign)?'':'-') + num + '.' + cents);
}
$(function(){
$('.wb-submit').click(function() {
var thisBtn = $(this);
thisBtn.attr('disabled',true)
var required;
var type;
var inputType;
var title;
var value;
var dataString = '';
var arrayString = new Array();
var countError = 0;
var errorString = '
';
var fromEmail;
var siteId = '38';
var submittedFormId = $("#submitted-form-id").val();
var thisForm = $(this);
var timestamp = new Date().getTime();
var remoteIp = $('#wb-remote-ip').val();
var token = $('#wb-form-token').val();
var httpReferer = escape($('#http-referer').val());
var parent = '';
var target;
var dataLength = 0;
var j = 0;
var f = 0;
var intlCode = '';
var files = new Array();
$(".contact-form").find(".seeker").each(function(i) {
parent = $(this).closest('span');
target = $(this).next();
title = target.attr("title");
if(typeof title === 'undefined') {
target = target.find('input');
title = target.attr("title");
}
if(typeof title === 'undefined') {
target = target.find('selected');
title = target.attr("title");
}
type = target.attr("type");
inputType = target.attr('data-type');
if(type=='checkbox') {
value = (target.is(':checked'))? 'Yes':'No';
} else {
value = target.val();
}
required = ($(this).hasClass('required')) ? 1 : 0;
if(!value)
value = '';
dataLength += parseInt(value.length);
if(required && (value.length==0 || value=='No') && title != 'employerId') {
countError++;
errorString +='- '+title+' is required
';
} else if(type !='checkbox' && value.length) {
if(type == 'tel') {
intlTelParent = target.closest('.allow-dropdown');
intlTelTitle = intlTelParent.find('.selected-flag').attr('title');
if(typeof intlTelTitle !== 'undefined') {
intlCode = '+'+intlTelTitle.replace(/\D/g,'');
//value = intlCode+value.toString();
}
}
if(value.length) {
if(type == 'email' || title.match(/email/i)) {
fromEmail = value;
if(value.search(/[\w-\.]{1,}@([\w-]{2,}\.)*([\w-]{2,}\.)[\w-]{2,4}/i)){
countError++;
errorString +='- Invalid Email Address
';
}
} else if((type == 'tel' || title.match(/phone/i) || title.match(/tel/))
&& value.search(/^\+?(\d[\d\-\+\(\) ]{5,}\d$)/)) {
countError++;
errorString +='- Invalid Phone Number'+value+'
';
} else if((type == 'number' || inputType == 'number') && isNaN(value.replace(/[, ]+/g,'').trim())) {
countError++;
errorString +='- Invalid '+title+'
';
}
}
}
if(title!='undefined') {
if(value == 'undefined')
value = '';
dataString += title+':'+value+'\n
';
if(type!='file') {
arrayString[j]= '"'+title+'":"'+escape(value)+'"';
j++;
} else {
files[f] = escape(value);
f++;
}
}
});
if(countError) {
thisBtn.attr('disabled',false)
errorString +='
';
$("#response").html(errorString);
return;
}
if(dataLength<1) {
thisBtn.attr('disabled',false)
$("#response").html('');
return;
}
$('#response').html("Sending...")
//$(thisForm).attr('disabled',true);
files = JSON.stringify(files.filter(Boolean));
arrayString[j]= '"intlCode":"'+escape(intlCode)+'"';
j++;
arrayString[j]= '"files":'+files;
var jsonData = '{'+arrayString.join(',')+'}';
var json = '{"siteId":"'+siteId+'","fromEmail":"'+fromEmail+'","submittedFormId":"'+submittedFormId+
'","dataString":"'+escape(dataString)+'","jsonData":'+jsonData+',"timestamp":"'+timestamp+'","remoteIp":"'+remoteIp+
'","httpReferer":"'+httpReferer+'","newVersion":"1","odPath":"../../wingubox.com/html"}';
$.ajax({
type: "POST",
url: "submit.php",
dataType: 'json',
data: {json:json},
success: function(data){
thisBtn.attr('disabled',false)
if(data.success) {
$('#response').html('Verifying...');
if(document.URL.indexOf('#') !== -1)
var path = document.URL.split("?");
else
var path = document.URL.split("#");
var url = path[0]+'?wbFormToken='+data.msg+'#response';
if(data.tokenTitle == 'wbJobsToken') {
$('#wbJobsToken').val(data.msg);
document.getElementById('wb-job-application-form').submit();
return;
}
self.location.href = url;
} else {
$(thisForm).attr('disabled',false);
$('#response').html(data.msg);
}
}
});
});
// resize images
$(".wb-fit-image").each(function(i) {
var bgSpread = ($(this).hasClass('wb-bg-contain'))? 'contain':'cover';
var style = $(this).attr('data-style');
var img = $(this).attr('src');
var imgClass = '';
var imgId = '';
imgId = (typeof this.id !== 'undefined')? this.id:'';
if(imgId.length) {
imgId = imgId.replace('wb-custom-id-','');
}
imgClasses = (typeof $(this).attr('class') !== 'undefined')? $(this).attr('class'):'';
if(typeof style !== 'undefined') {
$(this).wrap('');
} else {
$(this).wrap('');
var height = $(this).height();
$(this).closest('div').css('height',height);
var width = $(this).width();
$(this).closest('div').css('width',width);
}
if(imgClasses.length)
$(this).closest('div').addClass(imgClasses);
$(this).closest('div').css('background','url('+img+') no-repeat');
$(this).closest('div').css('background-size',bgSpread);
$(this).closest('div').css('background-position','center');
$(this).closest('div')
$(this).addClass('');
});
//EqualHeight Function
var highestBox = 0;
$('.equal-block').each(function() {
if ($(this).height() > highestBox) {
highestBox = $(this).height();
}
});
$('.equal-block').height(highestBox);
//=====
var highestBox_1 = 0;
$('.row .equal-box').each(function() {
if ($(this).height() > highestBox_1) {
highestBox_1 = $(this).height();
}
});
$('.equal-box ').height(highestBox_1);
});