0)?'+'+n:n;
},
inRange:function(d,start,end) {
// Checks if date in d is between dates in start and end.
// Returns a boolean or NaN:
// true : if d is between start and end (inclusive)
// false : if d is before start or after end
// NaN : if one or more of the dates is illegal.
// NOTE: The code inside isFinite does an assignment (=).
return (
isFinite(d=this.convert(d).valueOf()) &&
isFinite(start=this.convert(start).valueOf()) &&
isFinite(end=this.convert(end).valueOf()) ?
start <= d && d <= end :
NaN
);
}
}
/*
* Validate Form
*/
function validateReferenceNumber(ref){
ref = ''+ref;
if(ref.length!=6){
return false;
}
var preCheck = ref.substr(ref.length-1, ref.length);
ref = ref.substr(0,(ref.length -1));
var weigths = [7, 3, 1];
var sl = ref.length;
var st = ref.length;
var total = 0;
while(sl > 0 && ref.substr(--sl, 1) >='0'){
total += ref.substr((st-1)-sl, 1)*weigths[(sl%3)];
}
var check = ((Math.ceil((total/10))*10)-total);
if(check == preCheck){
return true;
}else{
return false;
}
}
$.fn.validateForm = function () {
let reqElements = $(this).find('input.required,textarea.required,select.required');
var thisForm = $(this);
reqElements.each(function () {
var thisItem = $(this);
//var thisRequiredItem = thisForm.find('.required[data-rel]');
let requiredItem = thisForm.find('.required[data-rel="'+thisItem.attr('id')+'"]');
if(!requiredItem.length){
requiredItem = thisItem.parents('.item').eq(0).find('span.required');
}
let requiredMessage = thisForm.find('.requiredMessage[data-rel='+thisItem.attr('id')+']');
if ((thisItem.val() && !thisItem.hasClass('noValue') && !thisItem.is(':radio') && !thisItem.is(':checkbox')) || thisItem.is(':checked')) {
if(thisItem.data('type')=='email'){
if(validateMail(thisItem) && thisItem.val()){
thisItem.removeClass('failed').addClass('ok');
if(requiredItem){
requiredItem.removeClass('failed').addClass('ok');
requiredItem.parents('.item').removeClass('failed').addClass('ok');
}
requiredMessage.slideUp(500);
}
}else if(thisItem.data('type')=='phone'){
if(validatePhone(thisItem) && thisItem.val()){
thisItem.removeClass('failed').addClass('ok');
thisItem.parents('.item').removeClass('failed').addClass('ok');
if(requiredItem){
requiredItem.removeClass('failed').addClass('ok');
requiredItem.parents('.item').removeClass('failed').addClass('ok');
}
requiredMessage.slideUp(500);
}
}
else if(thisItem.data('type')=='number'){
if(thisItem.val() && $.isNumeric(thisItem.val())){
thisItem.removeClass('failed').addClass('ok');
thisItem.parents('.item').removeClass('failed').addClass('ok');
requiredItem.removeClass('failed').addClass('ok');
requiredItem.parents('.item').removeClass('failed').addClass('ok');
requiredMessage.slideUp(500);
}
}else if(thisItem.data('type')=='reference'){
if(thisItem.val() && $.isNumeric(thisItem.val()) && validateReferenceNumber(thisItem.val())){
thisItem.removeClass('failed').addClass('ok');
thisItem.parents('.item').removeClass('failed').addClass('ok');
requiredItem.removeClass('failed').addClass('ok');
requiredItem.parents('.item').removeClass('failed').addClass('ok');
requiredMessage.slideUp(500);
}
}
else
{
thisItem.removeClass('failed').addClass('ok');
thisItem.parents('.item').removeClass('failed').addClass('ok');
requiredItem.removeClass('failed').addClass('ok');
requiredItem.parents('.item').removeClass('failed').addClass('ok');
requiredMessage.slideUp(500);
}
}
else if (thisItem.is(':radio') && thisItem.is(':checked')) {
requiredItem.removeClass('failed').addClass('ok');
requiredItem.parents('.item').removeClass('failed').addClass('ok');
thisItem.removeClass('failed').addClass('ok');
thisItem.parents('.item').removeClass('failed').addClass('ok');
thisItem.parents('.item').eq(0).find('.failed').removeClass('failed').addClass('ok');
requiredMessage.slideUp(500);
}
});
reqElements.on('change',function () {
let error = false;
let requiredItem = thisForm.find('.required[data-rel="'+$(this).attr('id')+'"]');
if(!requiredItem.length){
requiredItem = $(this).parents('.item').eq(0).find('span.required');
}
let requiredMessage = thisForm.find('.requiredMessage[data-rel='+$(this).attr('id')+']');
if (!$(this).val() || ($(this).is(':checkbox') && !$(this).is(':checked'))) {
error = true;
requiredItem.removeClass('ok').addClass('failed');
requiredItem.parents('.item').removeClass('ok').addClass('failed');
$(this).addClass('failed').removeClass('ok');
$(this).parents('.item').addClass('failed').removeClass('ok');
requiredMessage.fadeIn(500);
}
else if ($(this).is(':radio') && !$(this).is(':checked')) {
requiredItem.addClass('failed').removeClass('ok');
$(this).parents('.item').eq(0).find('.required').addClass('failed').removeClass('ok');
$(this).addClass('failed').removeClass('ok');
$(this).parents('.item').addClass('failed').removeClass('ok');
}
else {
$(this).parents('.item').eq(0).find('.required, .failed').removeClass('failed').addClass('ok');
requiredItem.removeClass('failed').addClass('ok');
requiredItem.parents('.item').removeClass('failed').addClass('ok');
$(this).removeClass('failed').addClass('ok');
$(this).parents('.item').removeClass('failed').addClass('ok');
requiredMessage.slideUp(500);
error = false;
}
});
thisForm.find('input[data-type="email"]').on('change',function () {
let requiredItem = thisForm.find('.required[data-rel="'+$(this).attr('id')+'"]');
if(!requiredItem.length){
requiredItem = $(this).parents('.item').find('span.required');
}
let requiredMessage = thisForm.find('.requiredMessage[data-rel='+$(this).attr('id')+']');
if (validateMail($(this)) && $(this).val()) {
$(this).removeClass('failed').addClass('ok');
$(this).parents('.item').removeClass('failed').addClass('ok');
requiredItem.removeClass('failed').addClass('ok');
requiredItem.parents('.item').removeClass('failed').addClass('ok');
requiredMessage.fadeOut(500);
}
else if($(this).val()){
$(this).addClass('failed').removeClass('ok');
$(this).parents('.item').addClass('failed').removeClass('ok');
requiredItem.removeClass('ok').addClass('failed');
requiredItem.parents('.item').removeClass('ok').addClass('failed');
requiredMessage.fadeIn(500);
}
else if(!$(this).hasClass('required')) {
$(this).removeClass('failed').removeClass('ok');
requiredMessage.fadeIn(500);
}
});
thisForm.find('input[data-type="phone"]').on('change',function () {
let requiredItem = thisForm.find('.required[data-rel="'+$(this).attr('id')+'"]');
if(!requiredItem.length){
requiredItem = $(this).parents('.item').find('span.required');
}
let requiredMessage = thisForm.find('.requiredMessage[data-rel='+$(this).attr('id')+']');
if (validatePhone($(this)) && $(this).val()) {
$(this).removeClass('failed').addClass('ok');
$(this).parents('.item').removeClass('failed').addClass('ok');
requiredItem.removeClass('failed').addClass('ok');
requiredItem.parents('.item').removeClass('failed').addClass('ok');
requiredMessage.fadeOut(500);
}
else if($(this).val()){
$(this).addClass('failed').removeClass('ok');
$(this).parents('.item').addClass('failed').removeClass('ok');
requiredItem.removeClass('ok').addClass('failed');
requiredItem.parents('.item').removeClass('ok').addClass('failed');
requiredMessage.fadeIn(500);
}
else if(!$(this).hasClass('required')) {
$(this).removeClass('failed').removeClass('ok');
requiredMessage.fadeIn(500);
}
});
thisForm.find('input[data-type="date"], input[type="date"]').on('change',function () {
var thisVal = $(this).val();
if(dates.convert(thisVal) != 'NaN' && dates.convert(thisVal) != 'Invalid Date'){
$(this).removeClass('failed').addClass('ok');
$(this).parents('.item').removeClass('failed').addClass('ok');
if($(this).attr('min') || $(this).attr('max')){
if(dates.inRange(thisVal,$(this).attr('min'),$(this).attr('max'))){
$(this).removeClass('failed').addClass('ok');
$(this).parents('.item').removeClass('failed').addClass('ok');
}
else{
$(this).addClass('failed').removeClass('ok');
$(this).parents('.item').addClass('failed').removeClass('ok');
}
}
}
else{
$(this).addClass('failed').removeClass('ok');
$(this).parents('.item').addClass('failed').removeClass('ok');
}
}
);
thisForm.find('input[data-type="number"],input[type="number"]').on('change',function () {
var thisVal = $(this).val();
if(!$.isNumeric(thisVal) && thisVal){
$(this).addClass('failed').removeClass('ok');
$(this).parents('.item').addClass('failed').removeClass('ok');
}else{
if($(this).attr('min') || $(this).attr('max')){
if(thisVal < parseInt($(this).attr('min')) || thisVal > parseInt($(this).attr('max'))){
$(this).addClass('failed').removeClass('ok');
$(this).parents('.item').addClass('failed').removeClass('ok');
}
else{
$(this).removeClass('failed').addClass('ok');
$(this).parents('.item').removeClass('failed').addClass('ok');
}
}
}
}).keydown(function (e) {
if(e.keyCode == 190){
if($(this).val().indexOf('.') != -1){
e.preventDefault();
return;
}
}
if(e.keyCode == 188 || e.keyCode == 110){
if($(this).val().indexOf('.') == -1){
$(this).val($(this).val()+'.');
}
e.preventDefault();
return;
}
if ($.inArray(e.keyCode, [46, 8, 9, 27, 13, 110, 190, 188]) !== -1 ||
(e.keyCode == 65 && e.ctrlKey === true) ||
(e.keyCode >= 35 && e.keyCode <= 39)) {
return;
}
if ((e.shiftKey || (e.keyCode < 48 || e.keyCode > 57)) && (e.keyCode < 96 || e.keyCode > 105)) {
e.preventDefault();
}
});
thisForm.find('input[data-type="reference"]').on('change',function () {
var thisVal = $(this).val();
if(!$.isNumeric(thisVal) || thisVal && !validateReferenceNumber(thisVal)){
$(this).addClass('failed').removeClass('ok');
$(this).parents('.item').addClass('failed').removeClass('ok');
}else{
$(this).addClass('ok').removeClass('failed');
$(this).parents('.item').addClass('ok').removeClass('failed');
}
if($(this).val().length==0 && !$(this).hasClass('required')){
$(this).removeClass('failed');
}
}).keydown(function (e) {
if(e.keyCode == 190 || e.keyCode == 188){
e.preventDefault();
return;
}
if ($.inArray(e.keyCode, [46, 8, 9, 27, 13, 110, 190, 188]) !== -1 ||
(e.keyCode == 65 && e.ctrlKey === true) ||
(e.keyCode >= 35 && e.keyCode <= 39)) {
return;
}
if ((e.shiftKey || (e.keyCode < 48 || e.keyCode > 57)) && (e.keyCode < 96 || e.keyCode > 105)) {
e.preventDefault();
}
});
};
/* scroll */
$.fn.scrollGo=function() {
o = $(this).offset();
if(o){
var x = o.top - 100;
$('html,body').animate({scrollTop: x}, 500);
}
}
/**/
$.fn.checkForm = function(){
var parentForm = $(this);
var reqElements = parentForm.find('input.required,textarea.required,select.required,input.failed');
parentForm.find('.requiredMessage').remove();
parentForm.find(reqElements).not('.ok').each(function(){
var reqItem = $(this);
if($(this).is(':radio')){
if(!$(this).parents('.item').eq(0).find('input:checked').length){
$(this).parents('.item').eq(0).find('label, input:radio').addClass('failed');
}else{
$(this).parents('.item').eq(0).find('label, input:radio').removeClass('failed').addClass('ok')
}
}
else{
reqItem.addClass('failed');
reqItem.parents('.item').addClass('failed');
}
if(reqItem.data('required-msg')){
reqItem.parent().append(''+reqItem.data('required-msg')+'
');
}
if($(this).is(':radio')){
if(!$(this).parents('.item').eq(0).find('input:checked').length){
$(this).change();
}else{
$(this).parents('.item').eq(0).find('input:checked').change();
}
}else if(!reqItem.hasClass('noValue')){
$(this).change();
}
});
parentForm.find('.requiredMessage').eq(0).fadeIn(500);
if($(reqElements).not('.ok').length==0 && $(reqElements).find('.failed').length==0){return true;}
else{
parentForm.find(".showRequiredError").fadeIn(300);
parentForm.find(reqElements).not('.ok').first().scrollGo();
return false;
}
};
/**/
var defaultValues = new Array();
$.fn.focusValue=function(cssClass){$(this).each(function(){cssClass=(cssClass)?cssClass:'focus';$(this).addClass('noValue').focus(function(){$(this).addClass(cssClass);if(!defaultValues[$(this).attr('id')]){defaultValues[$(this).attr('id')]=this.value;}if(this.value==defaultValues[$(this).attr('id')]){this.value="";}$(this).blur(function(){$(this).removeClass(cssClass);if(this.value==""){this.value=defaultValues[$(this).attr('id')];$(this).addClass('noValue');}else{$(this).removeClass('noValue');}});});});};
/**/
function doPostBack(value,url){url=(url)?url:'';$(document.body).append('');$('#doPostBack').submit();}
/**/
function logIn(url, hash){$.get("./engine/forms/logIn.php",{url:url, hash:hash},function(data){$(data).appendTo('body');/*$('#logInCont').overlay({speed:'slow',top:'30%',mask:{opacity:0.6,color:null},api: true}).load();*/$("#username").focus();});}
/**/
$.fn.designTable=function(arg){if(typeof arg == 'undefined'){arg=new Object();}if(typeof arg.highlight == 'undefined'){arg.highlight=true;}$(this).attr('cellspacing','1');$(this).attr('cellpadding','0');var designItem = ($(this).find('tbody').length)?'tbody > tr':'tr';$(this).find(designItem+':even').addClass('table-even');$(this).find(designItem+':odd').addClass('table-odd');if(arg.highlight){$(this).find(designItem).hover(function(){$(this).addClass('table-hover');},function(){$(this).removeClass('table-hover');});}}
/**/
$.fn.designList=function(){$(this).find('li:even').addClass('li-even');$(this).find('li:odd').addClass('li-odd');$(this).find('li').hover(function(){$(this).addClass('li-hover');},function(){$(this).removeClass('li-hover');});}
/**/
$.fn.delay=function(t,n){return this.queue((n||"fx"),function(){var s=this;setTimeout(function(){$.dequeue(s);},t);});}
/**/
$.preloadImages = function(){for(var i = 0; i").attr("src",arguments[i]);}}
/*browser warning*/
function browserWarning(header,msg,linkName)
{
$('body').append('');
$("#browserWarningClose a").on('click',function(){$("#browserWarning").hide();return false;});
}
/*videoconverter*/
function convertVideo(a){if((a+"").indexOf("youtu")>=0){videoName=a.split("v=");if(videoName.length>1){videoName=videoName[1].split("&");a="https://www.youtube.com/embed/"+videoName[0]}else{a=a.replace("youtu.be/","www.youtube.com/embed/")}a=a+"?wmode=transparent&autoplay=1&autohide=1&acontrols=1&showinfo=1"}else if((a+"").indexOf("vimeo")>=0 && (a+"").indexOf("vimeo.com/user")==0){a=a.replace("vimeo.com/","player.vimeo.com/video/")+"?title=0&byline=0&portrait=0&autoplay=1"}return a}
/*!
* jQuery Cookie Plugin v1.4.0
* https://github.com/carhartl/jquery-cookie
*
* Copyright 2013 Klaus Hartl
* Released under the MIT license
*/
(function(e){if(typeof define==="function"&&define.amd){define(["jquery"],e)}else if(typeof exports==="object"){e(require("jquery"))}else{e(jQuery)}})(function(e){function n(e){return u.raw?e:encodeURIComponent(e)}function r(e){return u.raw?e:decodeURIComponent(e)}function i(e){return n(u.json?JSON.stringify(e):String(e))}function s(e){if(e.indexOf('"')===0){e=e.slice(1,-1).replace(/\\"/g,'"').replace(/\\\\/g,"\\")}try{e=decodeURIComponent(e.replace(t," "));return u.json?JSON.parse(e):e}catch(n){}}function o(t,n){var r=u.raw?t:s(t);return e.isFunction(n)?n(r):r}var t=/\+/g;var u=e.cookie=function(t,s,a){if(s!==undefined&&!e.isFunction(s)){a=e.extend({},u.defaults,a);if(typeof a.expires==="number"){var f=a.expires,l=a.expires=new Date;l.setTime(+l+f*864e5)}return document.cookie=[n(t),"=",i(s),a.expires?"; expires="+a.expires.toUTCString():"",a.path?"; path="+a.path:"",a.domain?"; domain="+a.domain:"",a.secure?"; secure":""].join("")}var c=t?undefined:{};var h=document.cookie?document.cookie.split("; "):[];for(var p=0,d=h.length;p' + serverVariables['cookieAlertButtonText'] + '