function afterSiteLoad(){ //add datepicker to all date fields $.datepicker.setDefaults({ showOn: 'both', buttonImageOnly: true, buttonImage: '../images/img_calendar.gif', buttonText: 'Calendar', dateFormat: 'dd/mm/yy' }); $(".dateinput").datepicker({ onClose: function() {$(this).valid();} }); $.validator.addMethod("onlyLatin", function(value, element) { re = new RegExp('[^a-zA-Z ]+'); return this.optional(element) || !re.test(value); }, jQuery.validator.messages.onlyLatin ); $.validator.addClassRules("onlyLatin", { onlyLatin: true}); $.validator.addMethod("notGreek", function(value, element) { re = new RegExp('.*[α-ωΑ-Ω ]+.*'); return (this.optional(element) && value == "") || !re.test(value); }, jQuery.validator.messages.notGreek ); //This validation is based on PnrdMethods.checkValidityBeforeBooking $.validator.addMethod("invalidName", function(value, element) { return (value != "Adult" && value != "ADULT" && value != "adult" && value != "Child" && value != "child" && value != "CHILD" && value != "Infant" && value != "INFANT" && value != "infant"); }, jQuery.validator.messages.invalidName ); $.validator.addMethod("onlyGreek", function(value, element) { re = new RegExp('[^α-ωΑ-Ω ]+'); return this.optional(element) || !re.test(value); }, jQuery.validator.messages.onlyGreek ); $.validator.addClassRules("onlyGreek", { onlyGreek: true}); $.validator.addClassRules("onlyGreek", { onlyGreek: true}); $.validator.addMethod("passwordCheck", function(value, element) { re = new RegExp('[^0-9a-zA-Z !@#\$\^\*\(\)]+'); return this.optional(element) || !re.test(value); }, jQuery.validator.messages.passwordCheck ); $.validator.addClassRules("passwordCheck", { passwordCheck: true , minlength: 5}); $.validator.addClassRules("cvv2", { digits:true ,maxlength: 4}); $.validator.addClassRules("name", {minlength: 2}); } function expandCollapse(tableId,collapseMSG,obj){ $("tr[collapsable='true'][groupId='"+tableId+"']").each( function(){ if(this.style.display=='none'){ this.style.display=''; }else this.style.display='none'; } ); var newMSG=(obj.opp)?obj.opp:collapseMSG; obj.opp=obj.innerHTML; obj.innerHTML=newMSG; } function shareFB(){ window.open("http://www.facebook.com/share.php?u="+ window.location); } function shareTwitter(){ window.open("http://twitter.com/home/?status="+ window.location); } function shareLinkedIn(){ window.open("http://www.linkedin.com/shareArticle?mini=true&url="+ window.location); } String.format = function( text ) { //check if there are two arguments in the arguments list if ( arguments.length <= 1 ) { //if there are not 2 or more arguments there’s nothing to replace //just return the original text return text; } //decrement to move to the second argument in the array var tokenCount = arguments.length - 2; for( var token = 0; token <= tokenCount; token++ ) { //iterate through the tokens and replace their placeholders from the original text in order text = text.replace( new RegExp( "\\{" + token + "\\}", "gi" ), arguments[ token + 1 ] ); } return text; }; /* function doLogin(){ if ($("#frmLogin").valid()) { $("#frmLogin #submit").click(); return true; } else { return false; } } */ function doFullTextSearch(){ if (trim($("#terms").val()) == "") { alert(emptyTerms); return false; } else { return true; } } function doNewsletterSubscription(){ if ($("#frmNewsletter").valid()) { $("#frmNewsletter #submit").click(); } else { return false; } } function loadAutocomplete(targetIds , jsonSource , lenght){ /* $(targetIds).autocomplete({ source: jsonSource, minLength: lenght, focus: function(event, ui) {$("#" + event.target.name).val(ui.item.label);return false; }, select: function(event, ui) { $("#" + event.target.name).val(ui.item.label); $("#" + event.target.name).attr("title",(ui.item.label)); $("#" + event.target.name + "_id").val(ui.item.value); return false; } });*/ } function trim(str) { return str.replace(/^\s\s*/, '').replace(/\s\s*$/, ''); }