enladiana.es Open in urlscan Pro
2a00:4b40:aaaa:2008::6  Public Scan

Submitted URL: http://enladiana.es/wp-content/plugins/pointfindercoreelements/public/js/theme-scripts.js?ver=1.0.0
Effective URL: https://enladiana.es/wp-content/plugins/pointfindercoreelements/public/js/theme-scripts.js?ver=1.0.0
Submission: On November 10 via api from US — Scanned from ES

Form analysis 0 forms found in the DOM

Text Content

function number_format(e,t,n,r){e=(e+"").replace(/[^0-9+\-Ee.]/g,"");var i=!isFinite(+e)?0:+e,s=!isFinite(+t)?0:Math.abs(t),o=typeof r==="undefined"?",":r,u=typeof n==="undefined"?".":n,a="",f=function(e,t){var n=Math.pow(10,t);return""+(Math.round(e*n)/n).toFixed(t)};a=(s?f(i,s):""+Math.round(i)).split(".");if(a[0].length>3){a[0]=a[0].replace(/\B(?=(?:\d{3})+(?!\d))/g,o)}if((a[1]||"").length<s){a[1]=a[1]||"";a[1]+=(new Array(s-a[1].length+1)).join("0")}return a.join(u)}
jQuery.fn.center=function(absolute){return this.each(function(){var t=jQuery(this);t.css({position:absolute?'absolute':'fixed',left:'50%',top:'50%',zIndex:'99'}).css({marginLeft:'-'+(t.outerWidth()/2)+'px',marginTop:'-'+(t.outerHeight()/2)+'px'});if(absolute){t.css({marginTop:parseInt(t.css('marginTop'),10)+jQuery(window).scrollTop(),marginLeft:parseInt(t.css('marginLeft'),10)+jQuery(window).scrollLeft()})}})};
String.prototype.format||(String.prototype.format=function(){var t=arguments;return this.replace(/{(\d+)}/g,function(r,o){return void 0!==t[o]?t[o]:r})});


(function($) {
  "use strict";

	$.PFGetSubItems = function(pfcat,pformvalues,widgetpf,horpf){
		
		if(pfcat != null && pfcat != 'undefined' && pfcat != ''){
			if (pfcat.length !== 0) {
				$.ajax({
					beforeSend: function(){
					
					},
		            type: 'POST',
		            dataType: 'html',
		            url: theme_scriptspf.ajaxurl,
		            data: {
		                'action': 'pfget_searchitems',
		                'pfcat': pfcat,
		                'formvals': pformvalues,
		                'widget':widgetpf,
		                'hor':horpf,
		                'cl':theme_scriptspf.pfcurlang,
		                'security': theme_scriptspf.pfget_searchitems
		            },
		            success:function(data){
		            	if (data != '') {
							$('#pfsearchsubvalues').html(data);
						
							$('#pfsearchsubvalues').css('opacity',1).fadeIn('100');
							$('.pointfinder-mini-search').addClass('hassubvalues');
					

							$.pf_data_pfpcl_apply();

							if ($('.pfsearchresults-container').length > 0) {
								if ($('.pfsearchresults-container').data('sdata') != '' && typeof $('#pointfinder-search-form').data("changed") == 'undefined') {
									$.each($('.pfsearchresults-container').data('sdata'), function(index, val) {
										 if (val != '') {
										 	if ($("[name=\""+index+"\"]").length > 0) {
										 		if ($("input[name=\""+index+"\"]").attr('type') == 'text') {
										 			$("input[name=\""+index+"\"]").val(val);
										 		}else if($("label[for=\""+index+"\"]").hasClass('select')){
										 			$("[name=\""+index+"\"] option[value=\""+val+"\"]").prop('selected', true);
										 			if ($("[name=\""+index+"\"]").is(":hidden")) {
										 				$("[name=\""+index+"\"]").select2("val",val);
										 			}
										 		}else if ($("input[name=\""+index+"\"]").attr('type') == 'hidden' && $("input[name=\""+index+"\"]").hasClass('pfignorevalidation') ) {
										 			if ($("#"+index+"").hasClass('pfrangeorj')) {
										 				var exp_val = val.split(",");
										 				$("#"+index+"").slider("values",[parseInt(exp_val[0]),parseInt(exp_val[1])]);
										 				$("#"+index+"-view2").val([parseInt(exp_val[0]),parseInt(exp_val[1])]);
										 				$("#"+index+"-view").val([parseInt(exp_val[0]),parseInt(exp_val[1])]);
										 				$("[name=\""+index+"\"]").val([parseInt(exp_val[0]),parseInt(exp_val[1])]);
										 			}else{
										 				$("#"+index+"").slider("value",val);
											 			$("#"+index+"-view").val(val);
											 			$("[name=\""+index+"\"]").val(val);
										 			}
										 		}
										 	}
										 }
									});
								}
							}
						}
		            },
		            complete: function(){
		            
		            },
		        });
			};
		}else{
			$('#pfsearchsubvalues').html('');
		};
	};

	$.PFRenewFeatures = function(pfcat){
		if(pfcat != null && pfcat != 'undefined' && pfcat != ''){
			if (pfcat.length !== 0) {


				var rq = [];
				var fieldids_features = $.pffieldsids.features;
				var fieldids_itemtypes = $.pffieldsids.itemtypes;
				var fieldids_conditions = $.pffieldsids.conditions;
				var fieldids_mit = $.pffieldsids.mit;
				var fieldids_mfe = $.pffieldsids.mfe;
				var fieldids_mco = $.pffieldsids.mco;


				if (fieldids_features != '' && fieldids_features != 'undefined' && fieldids_features != null) {
					rq.push("features");
				}

				if (fieldids_itemtypes != '' && fieldids_itemtypes != 'undefined' && fieldids_itemtypes != null) {
					rq.push("itypes");
				}

				if (fieldids_conditions != '' && fieldids_conditions != 'undefined' && fieldids_conditions != null) {
					rq.push("conditions");
				}

				$.ajax({
					beforeSend: function(){
						$('.pfsearch-content').pfLoadingOverlay({action:'show',opacity:0.5});
					},
		            type: 'POST',
		            dataType: 'json',
		            url: theme_scriptspf.ajaxurl,
		            data: {
		                'action': 'pfget_featuresfilter',
		                'pfcat': pfcat,
		                'rq': rq,
		                'cl':theme_scriptspf.pfcurlang,
		                'security': theme_scriptspf.pfget_searchitems
		            },
		            success:function(data){

		            	if (fieldids_features != '' && fieldids_features != 'undefined' && fieldids_features != null) {
		            		if (fieldids_mfe != '1') {
		            			var features_append = '<option></option>';
		            		}else{
		            			var features_append = '';
		            		}
		            		$('#'+fieldids_features)
						    .find('option')
						    .remove()
						    .end()
						    .append(features_append+data['features']);
						    $('#'+fieldids_features).val('').trigger("change");
		            	}


		            	if (fieldids_itemtypes != '' && fieldids_itemtypes != 'undefined' && fieldids_itemtypes != null) {
		            		if (fieldids_mit != '1') {
		            			var itemtype_append = '<option></option>';
		            		}else{
		            			var itemtype_append = '';
		            		}
		            		$('#'+fieldids_itemtypes)
						    .find('option')
						    .remove()
						    .end()
						    .append(itemtype_append+data['itypes']);
						    $('#'+fieldids_itemtypes).val('').trigger("change");


						    if (data['itypes'] == null) {
						    	$('#'+fieldids_itemtypes+'_main').hide();
						    }else{
						    	$('#'+fieldids_itemtypes+'_main').show();
						    }
		            	}

		            	if (fieldids_conditions != '' && fieldids_conditions != 'undefined' && fieldids_conditions != null) {
		            		if (fieldids_mco != '1') {
		            			var conditions_append = '<option></option>';
		            		}else{
		            			var conditions_append = '';
		            		}
		            		$('#'+fieldids_conditions)
						    .find('option')
						    .remove()
						    .end()
						    .append(conditions_append+data['conditions']);
						    $('#'+fieldids_conditions).val('').trigger("change");

						    if (data['conditions'] == null) {
						    	$('#'+fieldids_conditions+'_main').hide();
						    }else{
						    	$('#'+fieldids_conditions+'_main').show();
						    }
		            	}

		            },
		            complete: function(){
		            	$('.pfsearch-content').pfLoadingOverlay({action:'hide'});
		            },
		        });
			};
		};
	};

	$.pfLoginwithAjax = function(vars,formtype){
		$.ajax({
			beforeSend: function(){
				$('#pf-membersystem-dialog').pfLoadingOverlay({action:'show'});
			},
            type: 'POST',
            dataType: 'json',
            url: theme_scriptspf.ajaxurl,
            data: {
                'action': 'pfget_usersystemhandler',
                'formtype': formtype,
                'vars': vars,
                'lang': theme_scriptspf.pfcurlang,
                'security': theme_scriptspf.pfget_usersystemhandler
            },
            success:function(data){
				var obj = [];
				$.each(data, function(index, element) {
					obj[index] = element;
				});


				// Social Login Form works ---------------------------------------------------
				if(formtype == 'createsocial'){
					var form = $('#pf-ajax-login-form');
					var pfreviewoverlay = $("#pflgcontainer-overlay");

					if(obj.status == 0){
						form.remove();
						pfreviewoverlay.append("<div class='pf-overlay-close'><i class='fas fa-times'></i></div><div class='pfrevoverlaytext pfoverlayapprove'><i class='fas fa-check-circle'></i><span>"+obj.mes+"</span></div>");
						pfreviewoverlay.show("slide",{direction : "up"},100);

						if (obj.auto == 1) {
							setTimeout(function() {
								$.pfOpenLogin('close');
							}, 3900);
							setTimeout(function() {
								window.location = obj.redirect;
							}, 4000);
						}
						pfreviewoverlay.on('click',function(){
							pfreviewoverlay.hide("slide",{direction : "up"},100);
							pfreviewoverlay.find('.pf-overlay-close').remove();
							pfreviewoverlay.find('.pfrevoverlaytext').remove();

							if(obj.status == 0 && obj.auto == 1){
								$.pfOpenLogin('close');
								window.location = obj.redirect;
							}

						});


					}else{
						form.remove();
						pfreviewoverlay.append("<div class='pf-overlay-close'><i class='fas fa-times'></i></div><div class='pfrevoverlaytext'><i class='fas fa-exclamation-triangle'></i><span>"+obj.mes+"</span></div>");
						pfreviewoverlay.show("slide",{direction : "up"},100);

						pfreviewoverlay.on('click',function(){
							pfreviewoverlay.hide("slide",{direction : "up"},100);
							pfreviewoverlay.find('.pf-overlay-close').remove();
							pfreviewoverlay.find('.pfrevoverlaytext').remove();

							$.pfOpenLogin('close');
							window.location.reload();

						})
					}

					$('.pf-overlay-close').on('click',function(){
						pfreviewoverlay.hide("slide",{direction : "up"},100);
						pfreviewoverlay.find('.pf-overlay-close').remove();
						pfreviewoverlay.find('.pfrevoverlaytext').remove();
						$.pfOpenLogin('close');
						if(obj.status == 0){
							setTimeout(function() {
								window.location = theme_scriptspf.homeurl;
							}, 4000);
						}
					});
				}

				if(formtype == 'connectsocial'){
					var form = $('#pf-ajax-login-form');
					var pfreviewoverlay = $("#pflgcontainer-overlay");

					if(obj.login == true){
						form.remove();
						pfreviewoverlay.append("<div class='pf-overlay-close'><i class='fas fa-times'></i></div><div class='pfrevoverlaytext pfoverlayapprove'><i class='fas fa-check-circle'></i><span>"+obj.mes+"</span></div>");
						pfreviewoverlay.show("slide",{direction : "up"},100);
						setTimeout(function() {
							$.pfOpenLogin('close');
						}, 4000);
						setTimeout(function() {
							window.location = obj.redirectpage;
						}, 4000);
					}else{
						form.remove();
						pfreviewoverlay.append("<div class='pf-overlay-close'><i class='fas fa-times'></i></div><div class='pfrevoverlaytext'><i class='fas fa-exclamation-triangle'></i><span>"+obj.mes+"</span></div>");
						pfreviewoverlay.show("slide",{direction : "up"},100);

						pfreviewoverlay.on('click',function(){
							pfreviewoverlay.hide("slide",{direction : "up"},100);
							pfreviewoverlay.find('.pf-overlay-close').remove();
							pfreviewoverlay.find('.pfrevoverlaytext').remove();

							if (typeof grecaptcha !== 'undefined') {
								var formid;

								if (typeof form.id != 'undefined') {
									formid = form.id;
								}else{
									formid = form[0].id;
								}
								$.reCAPTCHA_execute(formid);
							}
							form.find("textarea").val("");

						});
					}

					$('.pf-overlay-close').on('click',function(){
						pfreviewoverlay.hide("slide",{direction : "up"},100);
						pfreviewoverlay.find('.pf-overlay-close').remove();
						pfreviewoverlay.find('.pfrevoverlaytext').remove();
						$.pfOpenLogin('close');
					});
				}
				// Social Login Form works ---------------------------------------------------


				// Login Form works ---------------------------------------------------
				if(formtype == 'login'){
					var form = $('#pf-ajax-login-form');
					var pfreviewoverlay = $("#pflgcontainer-overlay");

					if(obj.login == true){
						form.remove();
						pfreviewoverlay.append("<div class='pf-overlay-close'><i class='fas fa-times'></i></div><div class='pfrevoverlaytext pfoverlayapprove'><i class='fas fa-check-circle'></i><span>"+obj.mes+"</span></div>");
						pfreviewoverlay.show("slide",{direction : "up"},100);
						setTimeout(function() {
							window.location = obj.redirectpage;
						}, 120);
					}else{
						form.remove();
						pfreviewoverlay.append("<div class='pf-overlay-close'><i class='fas fa-times'></i></div><div class='pfrevoverlaytext'><i class='fas fa-exclamation-triangle'></i><span>"+obj.mes+"</span></div>");
						pfreviewoverlay.show("slide",{direction : "up"},100);

						pfreviewoverlay.on('click',function(){
							$.pfOpenLogin('open','login');
						});
					}

					$('.pf-overlay-close').on('click',function(){
						$.pfOpenLogin('open','login');
					});

				}
				// Login Form works ---------------------------------------------------



				// Register Form works ---------------------------------------------------
				if(formtype == 'register'){

					var form = $('#pf-ajax-register-form');
					var pfreviewoverlay = $("#pflgcontainer-overlay");

					

					if(obj.status == 0){
						form.remove();
						pfreviewoverlay.append("<div class='pf-overlay-close'><i class='fas fa-times'></i></div><div class='pfrevoverlaytext pfoverlayapprove'><i class='fas fa-check-circle'></i><span>"+obj.mes+"</span></div>");
						pfreviewoverlay.show("slide",{direction : "up"},100);

						if (obj.auto == 1) {
							setTimeout(function() {
								$.pfOpenLogin('close');
							}, 4000);
							setTimeout(function() {
								window.location = obj.redirectpage;
							}, 4000);
						}
						if (obj.regsysx == 0) {
							pfreviewoverlay.on('click',function(){
								pfreviewoverlay.hide("slide",{direction : "up"},100);
								pfreviewoverlay.find('.pf-overlay-close').remove();
								pfreviewoverlay.find('.pfrevoverlaytext').remove();

								if(obj.status == 0 && obj.auto == 1){
									$.pfOpenLogin('close');
									window.location = obj.redirectpage;
								}

							});
						}else{
							pfreviewoverlay.on('click',function(){
								$.pfOpenLogin('open','login');
							});
						}


					}else{
						form.remove();
						pfreviewoverlay.append("<div class='pf-overlay-close'><i class='fas fa-times'></i></div><div class='pfrevoverlaytext'><i class='fas fa-exclamation-triangle'></i><span>"+obj.mes+"</span></div>");
						pfreviewoverlay.show("slide",{direction : "up"},100);

						if (obj.regsysx == 0) {
							pfreviewoverlay.on('click',function(){
								$.pfOpenLogin('open','register');
							});
						}else{
							pfreviewoverlay.on('click',function(){
								$.pfOpenLogin('open','register');
							});
						}
					}

					$('.pf-overlay-close').on('click',function(){
						pfreviewoverlay.hide("slide",{direction : "up"},100);
						pfreviewoverlay.find('.pf-overlay-close').remove();
						pfreviewoverlay.find('.pfrevoverlaytext').remove();
						if(obj.status == 0){
							setTimeout(function() {
								$.pfOpenLogin('close');
							}, 4000);
							if (obj.regsysx == 0) {
								setTimeout(function() {
									window.location = obj.redirectpage;
								}, 4000);
							}
						}else{
							$.pfOpenLogin('open','register');
						}
					});


				}
				// Register Form works ---------------------------------------------------



				// Lost Password Form works ---------------------------------------------------
				if(formtype == 'lp'){
					var form = $('#pf-ajax-lp-form');

					var pfreviewoverlay = $("#pflgcontainer-overlay");

					if(obj.status == 0){
						form.remove();
						pfreviewoverlay.append("<div class='pfrevoverlaytext pfoverlayapprove'><i class='fas fa-check-circle'></i><span>"+obj.mes+"</span></div>");
						pfreviewoverlay.show("slide",{direction : "up"},100);
						setTimeout(function() {
							$.pfOpenLogin('close');
						}, 10000);

						pfreviewoverlay.on('click',function(){
							pfreviewoverlay.hide("slide",{direction : "up"},100);
							pfreviewoverlay.find('.pf-overlay-close').remove();
							pfreviewoverlay.find('.pfrevoverlaytext').remove();
							if(obj.status == 0){
								$.pfOpenLogin('close');
							}
						});

					}else{
						form.remove();
						pfreviewoverlay.append("<div class='pfrevoverlaytext'><i class='fas fa-exclamation-triangle'></i><span>"+obj.mes+"</span></div>");
						pfreviewoverlay.show("slide",{direction : "up"},100);

						pfreviewoverlay.on('click',function(){
							$.pfOpenLogin('open','lp');
						});
					}

					$('.pf-overlay-close').on('click',function(){
						$.pfOpenLogin('close');
					});


				}
				// Lost Password Form works ---------------------------------------------------


				// Reset Form works ---------------------------------------------------
				if(formtype == 'reset'){
					var form = $('#pf-ajax-lpr-form');
					var pfreviewoverlay = $("#pflgcontainer-overlay");

					if(obj.reset == true){
						form.remove();
						pfreviewoverlay.append("<div class='pfrevoverlaytext pfoverlayapprove'><i class='fas fa-check-circle'></i><span>"+obj.mes+"</span></div>");
						pfreviewoverlay.show("slide",{direction : "up"},100);
						
						pfreviewoverlay.on('click',function(){
							pfreviewoverlay.hide("slide",{direction : "up"},100);
							pfreviewoverlay.find('form').remove();
							pfreviewoverlay.find('.pf-overlay-close').remove();
							pfreviewoverlay.find('.pfrevoverlaytext').remove();
							$.pfOpenLogin('close');
							setTimeout(function(){$.pfOpenLogin('open','login');},300)
						});
					}else{
						form.remove();
						pfreviewoverlay.append("<div class='pfrevoverlaytext'><i class='fas fa-exclamation-triangle'></i><span>"+obj.mes+"</span></div>");
						pfreviewoverlay.show("slide",{direction : "up"},100);

						pfreviewoverlay.on('click',function(){
							pfreviewoverlay.hide("slide",{direction : "up"},100);
							pfreviewoverlay.find('.pf-overlay-close').remove();
							pfreviewoverlay.find('.pfrevoverlaytext').remove();
						});
					}

					$('.pf-overlay-close').on('click',function(){
						pfreviewoverlay.hide("slide",{direction : "up"},100);
						pfreviewoverlay.find('.pf-overlay-close').remove();
						pfreviewoverlay.find('.pfrevoverlaytext').remove();
					});

				}
				// Reset Form works ---------------------------------------------------

            },
            error: function (request, status, error) {
                $("#pf-membersystem-dialog").html('Error:'+request.responseText);
            },
            complete: function(){
            	$('#pf-membersystem-dialog').pfLoadingOverlay({action:'hide'});
            },
        });
	};
	
	$.pfOpenLogin = function(status,modalname,errortext,errortype,redirectpage) {
		$.pfdialogstatus = '';
		if (modalname == 'terms') {var pid = $('.pftermshortc').data('pid');}else{var pid = '';}
		if (modalname != 'error' && modalname != 'scontent' && modalname != 'confirmaction' && modalname != 'lpr') {
			var errortext = '';
			var errortype = 0;
		};

		if (modalname == 'scontent') {
			var scontenttype = errortype;
			var scontenttext = errortext;
			var errortext = '';
			var errortype = 0;
		};

		if (modalname == 'confirmaction') {
			var scontenttext = errortext;
		}

		if(errortype != 2){
		    if(status == 'open'){

		    	if ($.pfdialogstatus == 'true') {$( "#pf-membersystem-dialog" ).dialog( "close" );}
		    	$('#pf-membersystem-dialog').pfLoadingOverlay({action:'show'});

	    		var minwidthofdialog = 380;
	    		if (modalname == 'terms') {minwidthofdialog = 650;}
	    		if(!$.pf_mobile_check()){ minwidthofdialog = 320;};

	    		$.ajax({
		            type: 'POST',
		            dataType: 'html',
		            url: theme_scriptspf.ajaxurl,
		            data: {
		                'action': 'pfget_usersystem',
		                'formtype': modalname,
		                'security': theme_scriptspf.pfget_usersystem,
		                'errortype': errortype,
		                'scontenttype': scontenttype,
		                'scontenttext': scontenttext,
		                'lang': theme_scriptspf.pfcurlang,
		                'redirectpage': redirectpage,
		                'pid':pid
		            },
		            success:function(data){

						$("#pf-membersystem-dialog").html(data);


						$('#pf-login-trigger-button-inner').on('click',function(){$.pfOpenLogin('open','login')});
						$('#pf-register-trigger-button-inner').on('click',function(){$.pfOpenLogin('open','register')});
						$('#pf-lp-trigger-button-inner').on('click',function(){$.pfOpenLogin('open','lp')});

						$('.pftermshortc').on('click', function(event) {
							setTimeout(function(){
								$.pfOpenLogin('open','terms');
							},0);
							return false;
						});
						
						$('#pf-ajax-terms-button').on('click', function(event) {
							$.pfOpenLogin('open','register');return false;
						});


						if (modalname == 'error') {
							$('#pf-ajax-cl-details').html(errortext);
						};

						if (modalname == 'lpr') {
							$('.pf-additional-detailsforlpr').html(errortext);
						};


						$('#pf-ajax-loginfacebook').on('click',function(){
							$('#pf-membersystem-dialog').pfLoadingOverlay({action:'show'});
						});

						$('#pf-ajax-logintwitter').on('click',function(){
							$('#pf-membersystem-dialog').pfLoadingOverlay({action:'show'});
						});

						$('#pf-ajax-logingoogle').on('click',function(){
							$('#pf-membersystem-dialog').pfLoadingOverlay({action:'show'});
						});

						// SOCIAL CONNECT FUNCTION STARTED --------------------------------------------------------------------------------------------
						$('#pfsocialconnectbutton').on('click',function(){
							var form = $('#pf-ajax-login-form');

							var pfsearchformerrors = form.find(".pfsearchformerrors");
							if ($.isEmptyObject($.pfAjaxUserSystemVars)) {
								$.pfAjaxUserSystemVars = {};
								$.pfAjaxUserSystemVars.username_err = 'Please write username';
								$.pfAjaxUserSystemVars.username_err2 = 'Please enter at least 3 characters for Username.';
								$.pfAjaxUserSystemVars.password_err = 'Please write password';
							}
							form.validate({
								  debug:false,
								  onfocus: false,
								  onfocusout: false,
								  onkeyup: false,
								  rules:{
								  	username:{
								      required: true,
								      minlength: 3
								    },
								  	password:"required"
								  },
								  messages:{
								  	username:{
								  		required:$.pfAjaxUserSystemVars.username_err,
								  		minlength:$.pfAjaxUserSystemVars.username_err2
								  	},
								  	password:$.pfAjaxUserSystemVars.password_err
								  },
								  validClass: "pfvalid",
								  errorClass: "pfnotvalid pfaddnotvalidicon",
								  errorElement: "li",
								  errorContainer: pfsearchformerrors,
								  errorLabelContainer: $("ul", pfsearchformerrors),
								  invalidHandler: function(event, validator) {
									var errors = validator.numberOfInvalids();
									if (errors) {
										pfsearchformerrors.show("slide",{direction : "up"},100);
										form.find(".pfsearch-err-button").on('click',function(){
											pfsearchformerrors.hide("slide",{direction : "up"},100);
											return false;
										});
									}else{
										pfsearchformerrors.hide("fade",300);
									}
								  }
							});

							if(form.valid()){
								$.pfLoginwithAjax(form.serialize(),'connectsocial');
							};
							return false;
						});
						// SOCIAL CONNECT FUNCTION FINISHED --------------------------------------------------------------------------------------------

						// SOCIAL CREATE FUNCTION STARTED --------------------------------------------------------------------------------------------
						$('#pfsocialnewaccountbutton').on('click',function(){
							var form = $('#pf-ajax-login-form');
							if (scontenttype == 2 || scontenttype == 4) {
								var pfsearchformerrors = form.find(".pfsearchformerrors");
								
								form.validate({
									  debug:false,
									  onfocus: false,
									  onfocusout: false,
									  onkeyup: false,
									  rules:{
									  	email_n:{
									      required: true,
									      email: true
									    }
									  },
									  messages:{
									  	email_n:{
									  		required:theme_scriptspf.email_err_social,
									  		email:theme_scriptspf.email_err_social2
									  	}
									  },
									  validClass: "pfvalid",
									  errorClass: "pfnotvalid pfaddnotvalidicon",
									  errorElement: "li",
									  errorContainer: pfsearchformerrors,
									  errorLabelContainer: $("ul", pfsearchformerrors),
									  invalidHandler: function(event, validator) {
										var errors = validator.numberOfInvalids();
										if (errors) {
											pfsearchformerrors.show("slide",{direction : "up"},100);
											form.find(".pfsearch-err-button").on('click',function(){
												pfsearchformerrors.hide("slide",{direction : "up"},100);
												return false;
											});
										}else{
											pfsearchformerrors.hide("fade",300);
										}
									  }
								});

								if(form.valid()){
									$.pfLoginwithAjax(form.serialize(),'createsocial');
								};
							} else {
								$.pfLoginwithAjax(form.serialize(),'createsocial');
							}
							return false;
						});
						// SOCIAL CREATE FUNCTION FINISHED --------------------------------------------------------------------------------------------



						// LOGIN FUNCTION STARTED --------------------------------------------------------------------------------------------
						$('#pf-ajax-login-button').on('click',function(){
							var form = $('#pf-ajax-login-form');


							var recaptchanum = form.find('#recaptcha_div_us .g-recaptcha-field').data('rekey');
							if (recaptchanum) {
								recaptchanum = $.recaptchanum;
								form.find('#g-recaptcha-response').text(grecaptcha.getResponse(recaptchanum));
							}


							var pfsearchformerrors = form.find(".pfsearchformerrors");

							if ($.isEmptyObject($.pfAjaxUserSystemVars)) {
								$.pfAjaxUserSystemVars = {};
								$.pfAjaxUserSystemVars.username_err = 'Please write username';
								$.pfAjaxUserSystemVars.username_err2 = 'Please enter at least 3 characters for Username.';
								$.pfAjaxUserSystemVars.password_err = 'Please write password';
							}
					
							form.validate({
								  debug:false,
								  onfocus: false,
								  onfocusout: false,
								  onkeyup: false,
								  rules:{
								  	username:{
								      required: true,
								      minlength: 3
								    },
								  	password:"required"
								  },
								  messages:{
								  	username:{
								  		required:$.pfAjaxUserSystemVars.username_err,
								  		minlength:$.pfAjaxUserSystemVars.username_err2
								  	},
								  	password:$.pfAjaxUserSystemVars.password_err
								  },
								  validClass: "pfvalid",
								  errorClass: "pfnotvalid pfaddnotvalidicon",
								  errorElement: "li",
								  errorContainer: pfsearchformerrors,
								  errorLabelContainer: $("ul", pfsearchformerrors),
								  invalidHandler: function(event, validator) {
									var errors = validator.numberOfInvalids();
									if (errors) {
										pfsearchformerrors.show("slide",{direction : "up"},100);
										form.find(".pfsearch-err-button").on('click',function(){
											pfsearchformerrors.hide("slide",{direction : "up"},100);
											return false;
										});
									}else{
										pfsearchformerrors.hide("fade",300);
									}
								  }
							});



							if(form.valid()){
								$.pfLoginwithAjax(form.serialize(),'login');
							}
							return false;
						});
						// LOGIN FUNCTION FINISHED --------------------------------------------------------------------------------------------



						// REGISTER FUNCTION STARTED --------------------------------------------------------------------------------------------
						$('#pf-ajax-register-button').on('click',function(){
							var form = $('#pf-ajax-register-form');


							var recaptchanum = form.find('#recaptcha_div_us .g-recaptcha-field').data('rekey');
							if (recaptchanum) {
								recaptchanum = $.recaptchanum;
								form.find('#g-recaptcha-response').text(grecaptcha.getResponse(recaptchanum));
							}

							var pfsearchformerrors = form.find(".pfsearchformerrors");
							if ($.isEmptyObject($.pfAjaxUserSystemVars2)) {
								$.pfAjaxUserSystemVars2 = {};
								$.pfAjaxUserSystemVars2.username_err = 'Please write username';
								$.pfAjaxUserSystemVars2.username_err2 = 'Please enter at least 3 characters for Username.';
								$.pfAjaxUserSystemVars2.email_err = 'Please write an email';
								$.pfAjaxUserSystemVars2.email_err2 = 'Your email address must be in the format of name@domain.com';
								
								$.pfAjaxUserSystemVars2.pass_err2 = 'Please enter password';
								$.pfAjaxUserSystemVars2.phn_err2 = 'Please enter phone.';
								$.pfAjaxUserSystemVars2.mbl_err2 = 'Please enter mobile.';
								$.pfAjaxUserSystemVars2.fn_err2 = 'Please enter first name.';
								$.pfAjaxUserSystemVars2.ln_err2 = 'Please enter last name.';
								$.pfAjaxUserSystemVars2.tnc_err2 = 'Please check terms and conditions checkbox.';

								$.pfAjaxUserSystemVars2.phn_req = false;
								$.pfAjaxUserSystemVars2.mbl_req = false;
								$.pfAjaxUserSystemVars2.fn_req = false;
								$.pfAjaxUserSystemVars2.ln_req = false;
							}
							form.validate({
								  debug:false,
								  onfocus: false,
								  onfocusout: false,
								  onkeyup: false,
								  rules:{
								  	username:{
								      required: true,
								      minlength: 3
								    },
								  	email:{
								  		required:true,
								  		email:true
								  	},
								  	pass:"required",
								  	phone:{required:$.pfAjaxUserSystemVars2.phn_req},
								  	mobile:{required:$.pfAjaxUserSystemVars2.mbl_req},
								  	firstname:{required:$.pfAjaxUserSystemVars2.fn_req},
								  	lastname:{required:$.pfAjaxUserSystemVars2.ln_req},
								  	pftermsofuser:"required"
								  },
								  messages:{
								  	username:{
									  	required:$.pfAjaxUserSystemVars2.username_err,
									  	minlength:$.pfAjaxUserSystemVars2.username_err2
								  	},
								  	email: {
									    required: $.pfAjaxUserSystemVars2.email_err,
									    email: $.pfAjaxUserSystemVars2.email_err2
								    },
								    pass:$.pfAjaxUserSystemVars2.pass_err2,
								  	phone:{required:$.pfAjaxUserSystemVars2.phn_err2},
								  	mobile:{required:$.pfAjaxUserSystemVars2.mbl_err2},
								  	firstname:{required:$.pfAjaxUserSystemVars2.fn_err2},
								  	lastname:{required:$.pfAjaxUserSystemVars2.ln_err2},
								  	pftermsofuser:$.pfAjaxUserSystemVars2.tnc_err2 
								  },
								  validClass: "pfvalid",
								  errorClass: "pfnotvalid pfaddnotvalidicon",
								  errorElement: "li",
								  errorContainer: pfsearchformerrors,
								  errorLabelContainer: $("ul", pfsearchformerrors),
								  invalidHandler: function(event, validator) {
									var errors = validator.numberOfInvalids();
									if (errors) {
										pfsearchformerrors.show("slide",{direction : "up"},100);
										form.find(".pfsearch-err-button").on('click',function(){
											pfsearchformerrors.hide("slide",{direction : "up"},100);
											return false;
										});
									}else{
										pfsearchformerrors.hide("fade",300);
									}
								  }
							});


							if(form.valid()){
								$.pfLoginwithAjax(form.serialize(),'register');
							}
							return false;
						});
						// REGISTER FUNCTION FINISHED --------------------------------------------------------------------------------------------



						// LOST PASSWORD FUNCTION STARTED --------------------------------------------------------------------------------------------
						$('#pf-ajax-lp-button').on('click',function(){
							var form = $('#pf-ajax-lp-form');

							var recaptchanum = form.find('#recaptcha_div_us .g-recaptcha-field').data('rekey');
							if (recaptchanum) {
								recaptchanum = $.widgetIdlp;
								form.find('.g-recaptcha-response').text(grecaptcha.getResponse(recaptchanum));
							}

							var pfsearchformerrors = form.find(".pfsearchformerrors");
							if ($.isEmptyObject($.pfAjaxUserSystemVars3)) {
								$.pfAjaxUserSystemVars3 = {};
								$.pfAjaxUserSystemVars3.username_err = 'Username or Email must be filled.';
								$.pfAjaxUserSystemVars3.username_err2 = 'Please enter at least 3 characters for Username.';
								$.pfAjaxUserSystemVars3.email_err2 = 'Your email address must be in the format of name@domain.com';
							}
							form.validate({
								  debug:false,
								  onfocus: false,
								  onfocusout: false,
								  onkeyup: false,
								  rules:{
								  	username:{
								    	minlength: 3
								    },
								  	email:{
								  		email:true
								  	}
								  },
								  messages:{
								  	username:{
									  	minlength:$.pfAjaxUserSystemVars3.username_err2
								  	},
								  	email: {
									    required: $.pfAjaxUserSystemVars3.email_err,
									    email: $.pfAjaxUserSystemVars3.email_err2
								    }
								  },
								  validClass: "pfvalid",
								  errorClass: "pfnotvalid pfaddnotvalidicon",
								  errorElement: "li",
								  errorContainer: pfsearchformerrors,
								  errorLabelContainer: $("ul", pfsearchformerrors),
								  invalidHandler: function(event, validator) {
									var errors = validator.numberOfInvalids();
									if (errors) {
										pfsearchformerrors.show("slide",{direction : "up"},100);
										form.find(".pfsearch-err-button").on('click',function(){
											pfsearchformerrors.hide("slide",{direction : "up"},100);
											return false;
										});
									}else{
										pfsearchformerrors.hide("fade",300);
									}
								  }
							});


							if(form.valid()){
								if(form.find("input[name=username]").val() != '' || form.find("input[name=email]").val() != ''){
									$.pfLoginwithAjax(form.serialize(),'lp');
								}else{

									$("ul", pfsearchformerrors).append('<li>'+$.pfAjaxUserSystemVars3.username_err+'</li>');
									$("ul", pfsearchformerrors).show();
									pfsearchformerrors.show("slide",{direction : "up"},100);
										form.find(".pfsearch-err-button").on('click',function(){
											pfsearchformerrors.hide("slide",{direction : "up"},100);
											return false;
										});
									return false;
								}

							}
							return false;
						});
						// LOST PASSWORD FUNCTION FINISHED --------------------------------------------------------------------------------------------


						// ERROR FUNCTION STARTED --------------------------------------------------------------------------------------------
						$('#pf-ajax-cl-button').on('click',function(){

							$.pfOpenLogin('close')
							return false;

						});
						// ERROR FUNCTION FINISHED --------------------------------------------------------------------------------------------



						// RESET FUNCTION STARTED --------------------------------------------------------------------------------------------
						$('#pf-ajax-lpr-button').on('click',function(){
							var form = $('#pf-ajax-lpr-form');

							var pfsearchformerrors = form.find(".pfsearchformerrors");

							if ($.isEmptyObject($.pfAjaxUserSystemVars)) {
								$.pfAjaxUserSystemVars = {};
								$.pfAjaxUserSystemVars.password_err = 'Please write password';
								$.pfAjaxUserSystemVars.password_err2 = 'Please enter at least 3 characters for password.';
								$.pfAjaxUserSystemVars.password2_err = 'Please write password';
								$.pfAjaxUserSystemVars.password2_err2 = 'Please enter at least 3 characters for password.';
								$.pfAjaxUserSystemVars.password2_err3 = 'The two passwords you entered don\'t match.';
							}
					
							form.validate({
								  debug:false,
								  onfocus: false,
								  onfocusout: false,
								  onkeyup: false,
								  rules:{
								  	password:{
								      required: true,
								      minlength: 3,
								    },
								  	password2:{
								      required: true,
								      minlength: 3,
								      equalTo: "#password"
								    },
								  },
								  messages:{
								  	password:{
								  		required:$.pfAjaxUserSystemVars.password_err,
								  		minlength:$.pfAjaxUserSystemVars.password_err2
								  	},
								  	password2:{
								  		required:$.pfAjaxUserSystemVars.password2_err,
								  		minlength:$.pfAjaxUserSystemVars.password2_err2,
								  		equalTo:$.pfAjaxUserSystemVars.password2_err3
								  	},
								  },
								  validClass: "pfvalid",
								  errorClass: "pfnotvalid pfaddnotvalidicon",
								  errorElement: "li",
								  errorContainer: pfsearchformerrors,
								  errorLabelContainer: $("ul", pfsearchformerrors),
								  invalidHandler: function(event, validator) {
									var errors = validator.numberOfInvalids();
									if (errors) {
										pfsearchformerrors.show("slide",{direction : "up"},100);
										form.find(".pfsearch-err-button").on('click',function(){
											pfsearchformerrors.hide("slide",{direction : "up"},100);
											return false;
										});
									}else{
										pfsearchformerrors.hide("fade",300);
									}
								  }
							});



							if(form.valid()){
								$.pfLoginwithAjax(form.serialize(),'reset');
							}
							return false;
						});
						// RESET FUNCTION FINISHED --------------------------------------------------------------------------------------------



		            },
		            error: function (request, status, error) {

	                	$("#pf-membersystem-dialog").html('Error:'+request.responseText);

		            },
		            complete: function(){

	            		$('#pf-membersystem-dialog').pfLoadingOverlay({action:'hide'});
						setTimeout(function(){$("#pf-membersystem-dialog").dialog({position:{my: "center", at: "center",collision:"fit"}});},500);
						$('.pointfinder-dialog').center(true);
		            },
		        });

	        	if(modalname != ''){
		        	$.widget("ui.dialog", $.ui.dialog, {
			            _allowInteraction: function (event) {
			                if (this._super(event)) {
			                    return true;
			                }
			                if (event.target.ownerDocument != this.document[0]) {
			                    return true;
			                }
			                if ($(event.target).closest("iframe").length) {
			                    return true;
			                }
			            }
			        });
				    $("#pf-membersystem-dialog").dialog({
				        resizable: false,
				        modal: true,
				        minWidth: minwidthofdialog,
				        show: { effect: "fade", duration: 100 },
				        dialogClass: 'pointfinder-dialog pointfinder-border-radius',
				        open: function() {
					        $('.ui-widget-overlay').addClass('pf-membersystem-overlay');
					    },
					    close: function() {
					        $('.ui-widget-overlay').removeClass('pf-membersystem-overlay');
					    },
					    position:{my: "center", at: "center", collision:"fit"}
				    });
				    $.pfdialogstatus = 'true';
				}

			}else{
				$( "#pf-membersystem-dialog" ).dialog( "destroy" );
				$.pfdialogstatus = '';
			}
		}

	};

	$.pfModalwithAjax = function(vars,formtype){
		$.ajax({
			beforeSend: function(){
				$('#pf-membersystem-dialog').pfLoadingOverlay({action:'show'});
			},
            type: 'POST',
            dataType: 'json',
            url: theme_scriptspf.ajaxurl,
            data: {
                'action': 'pfget_modalsystemhandler',
                'formtype': formtype,
                'vars': vars,
                'security': theme_scriptspf.pfget_modalsystemhandler,
                'lang': theme_scriptspf.pfcurlang
            },
            success:function(data){
				var obj = [];
				$.each(data, function(index, element) {
					obj[index] = element;
				});


				if (formtype == 'savesearch') {
					setTimeout(function(){

						$('.pfmodalclose').trigger('click');
					},3000);
				}


				// Contact Form works ---------------------------------------------------
				if(formtype == 'enquiryform'){
					var form = $('#pf-ajax-enquiry-form');
				}
				// Contact Form works ---------------------------------------------------



				// Author Form works ---------------------------------------------------
				if(formtype == 'enquiryformauthor'){
					var form = $('#pf-ajax-enquiry-form-author');

				}
				// Author Form works ---------------------------------------------------



				// Report Form works ---------------------------------------------------
				if(formtype == 'reportitem'){
					var form = $('#pf-ajax-report-form');
				}
				// Report Form works ---------------------------------------------------


				// Claim Form works ---------------------------------------------------
				if(formtype == 'claimitem'){
					var form = $('#pf-ajax-claim-form');
				}
				// Claim Form works ---------------------------------------------------



				// Flag Review Form works ---------------------------------------------------
				if(formtype == 'flagreview'){
					var form = $('#pf-ajax-flag-form');
				}
				// Flag Review Form works ---------------------------------------------------


				// Contact Form works ---------------------------------------------------
				if(formtype == 'contactform'){
					var form = $('#pf-contact-form');
				}
				// Contact Form works ---------------------------------------------------

				if(formtype == 'enquiryform'){
					var pfreviewoverlay = $("#pfmdcontainer-overlaynew");
				}else{
					var pfreviewoverlay = $("#pfmdcontainer-overlay");
				}


				if (typeof grecaptcha !== 'undefined' && typeof form != 'undefined') {
					var formid;

					if (typeof form.id != 'undefined') {
						formid = form.id;
					}else{
						formid = form[0].id;
					}
					$.reCAPTCHA_execute(formid);
				}

				if(obj.process == true){
					if (formtype == 'contactform') {
						pfreviewoverlay.pfLoadingOverlay({action:'hide'});
					}

					pfreviewoverlay.append("<div class='pf-overlay-close'><i class='fas fa-times-circle'></i></div><div class='pfrevoverlaytext pfoverlayapprove'><i class='fas fa-check-circle'></i><span>"+obj.mes+"</span></div>");
					pfreviewoverlay.show("slide",{direction : "up"},100);

					pfreviewoverlay.on('click',function(){
						pfreviewoverlay.hide("slide",{direction : "up"},100);
						pfreviewoverlay.find('.pf-overlay-close').remove();
						pfreviewoverlay.find('.pfrevoverlaytext').remove();
						if(obj.process == true && formtype != 'contactform' && formtype != 'enquiryform'){
							$.pfOpenModal('close');
							if (formtype == 'flagreview') {
								window.location.reload();
							}
						}else{

							if (formtype == 'enquiryform') {
								$('#pf-ajax-enquiry-button').attr('disabled',false);

							}
						}
					});

				}else{
					if (formtype == 'contactform') {
						pfreviewoverlay.pfLoadingOverlay({action:'hide'});
					}

					pfreviewoverlay.append("<div class='pf-overlay-close'><i class='fas fa-times-circle'></i></div><div class='pfrevoverlaytext'><i class='fas fa-exclamation-triangle'></i><span>"+obj.mes+"</span></div>");
					pfreviewoverlay.show("slide",{direction : "up"},100);

					pfreviewoverlay.on('click',function(){
						pfreviewoverlay.hide("slide",{direction : "up"},100);
						pfreviewoverlay.find('.pf-overlay-close').remove();
						pfreviewoverlay.find('.pfrevoverlaytext').remove();
						if (formtype == 'enquiryform') {
							$('#pf-ajax-enquiry-button').attr('disabled',false);
						}
						if(obj.process == true){
							form.find("textarea").val("");
						}
					});

				}


				$('.pf-overlay-close').on('click touchstart',function(){
					pfreviewoverlay.hide("slide",{direction : "up"},100);
					pfreviewoverlay.find('.pf-overlay-close').remove();
					pfreviewoverlay.find('.pfrevoverlaytext').remove();
					if(obj.process == true && formtype != 'contactform' && formtype != 'enquiryform'){
						$.pfOpenModal('close');
					}
					if (formtype == 'enquiryform') {
						$('#pf-ajax-enquiry-button').attr('disabled',false);

					}
					if (formtype == 'flagreview') {
						window.location.reload();
					}
				});

            },
            error: function (request, status, error) {
                $("#pf-membersystem-dialog").html('Error:'+request.responseText);
            },
            complete: function(){
            	$('#pf-membersystem-dialog').pfLoadingOverlay({action:'hide'});
            },
        });
	};

	$.pfOpenModal = function(status,modalname,errortext,errortype,itemid,userid) {
		$.pfdialogstatus = '';

		if (modalname != 'error') {
			var errortext = '';
			var errortype = 0;
		};
		if(errortype != 2){
		    if(status == 'open'){

		    	if ($.pfdialogstatus == 'true') {$( "#pf-membersystem-dialog" ).dialog( "close" );}
		    	$('#pf-membersystem-dialog').pfLoadingOverlay({action:'show'});
	    		var minwidthofdialog = 380;
	    		var maxwidthofdialog = 1140;

	    		if(!$.pf_mobile_check()){ minwidthofdialog = 320;};
	    		
	    		if($.pf_mobile_check() && modalname == 'quickpreview'){ minwidthofdialog = 1140;maxwidthofdialog = 1140;};

	    		var urlx = '';

	    		if (modalname == 'savesearch') {
	    			urlx = window.location.search;
	    		}

	    		$.ajax({
		            type: 'POST',
		            dataType: 'html',
		            url: theme_scriptspf.ajaxurl,
		            data: {
		                'action': 'pfget_modalsystem',
		                'formtype': modalname,
		                'itemid': itemid,
		                'userid': userid,
		                'security': theme_scriptspf.pfget_modalsystem,
		                'errortype': errortype,
		                'lang': theme_scriptspf.pfcurlang,
		                'url': urlx
		            },
		            success:function(data){

						$("#pf-membersystem-dialog").html(data);

						if (modalname == 'error') {
							$('#pf-ajax-cl-details').html(errortext);
						};

						$('.pftermshortc').on('click', function(event) {
							setTimeout(function(){
								$.pfOpenLogin('open','terms');
							},0);
							return false;
						});


						$(function(){
							if (modalname == 'quickpreview') {
								var lat = $(".pfquickviewmap").data('welat');
								var lng = $(".pfquickviewmap").data('welng');

								if (lat != '') {
									var quickmap = $.pointfinderbuildmap("pfquickviewmap");
									var marker = L.marker(
							          L.latLng(parseFloat(lat),parseFloat(lng)),
							          {
							            riseOnHover: true,
							            bubblingMouseEvents: true
							          }
							        );
						        }else{
						        	$(".pfquickviewmap").remove();
						        }

						        quickmap.addLayer(marker);
							}

						})

						// AUTHOR CONTACT FORM FUNCTION STARTED --------------------------------------------------------------------------------------------
						$('#pf-ajax-enquiry-button-author').on('click touchstart',function(){
							var form = $('#pf-ajax-enquiry-form-author');

							var recaptchanum = form.find('#recaptcha_div_mod .g-recaptcha-field').data('rekey');
							if (recaptchanum) {
								recaptchanum = $.recaptchanum;
								form.find('#g-recaptcha-response').text(grecaptcha.getResponse(recaptchanum));
							}

							var pfsearchformerrors = form.find(".pfsearchformerrors");
							form.validate({
								  debug:false,
								  onfocus: false,
								  onfocusout: false,
								  onkeyup: false,
								  rules:{
								  	name:"required",
								  	email:{
								  		required:true,
								  		email:true
								  	},
								  	msg:"required",
								  	pftermsofuser:"required"
								  },
								  messages:{
								  	name:theme_scriptspf.pfnameerr,
								  	email: {
									    required: theme_scriptspf.pfemailerr,
				    					email: theme_scriptspf.pfemailerr2
								    },
								    msg:theme_scriptspf.pfmeserr,
								    pftermsofuser:theme_scriptspf.tnc_err2
								  },
								  validClass: "pfvalid",
								  errorClass: "pfnotvalid pfaddnotvalidicon",
								  errorElement: "li",
								  errorContainer: pfsearchformerrors,
								  errorLabelContainer: $("ul", pfsearchformerrors),
								  invalidHandler: function(event, validator) {
									var errors = validator.numberOfInvalids();
									if (errors) {
										pfsearchformerrors.show("slide",{direction : "up"},100);
										form.find(".pfsearch-err-button").on('click',function(){
											pfsearchformerrors.hide("slide",{direction : "up"},100);
											return false;
										});
									}else{
										pfsearchformerrors.hide("fade",300);
									}
								  }
							});



							if(form.valid()){
								$.pfModalwithAjax(form.serialize(),'enquiryformauthor');
							}
							return false;
						});
						// AUTHOR CONTACT FORM FUNCTION FINISHED --------------------------------------------------------------------------------------------




						// REPORT FORM FUNCTION STARTED --------------------------------------------------------------------------------------------
						$('#pf-ajax-report-button').on('click',function(){
							var form = $('#pf-ajax-report-form');
							var pfsearchformerrors = form.find(".pfsearchformerrors");

							var recaptchanum = form.find('#recaptcha_div_mod .g-recaptcha-field').data('rekey');
							if (recaptchanum) {
								recaptchanum = $.recaptchanum;
								form.find('#g-recaptcha-response').text(grecaptcha.getResponse(recaptchanum));
							}

							form.validate({
								  debug:false,
								  onfocus: false,
								  onfocusout: false,
								  onkeyup: false,
								  rules:{
								  	name:"required",
								  	email:{
								  		required:true,
								  		email:true
								  	},
								  	msg:"required",
								  	pftermsofuser:"required"
								  },
								  messages:{
								  	name:theme_scriptspf.pfnameerr,
								  	email: {
									    required: theme_scriptspf.pfemailerr,
									    email: theme_scriptspf.pfemailerr2
								    },
								    msg:theme_scriptspf.pfmeserr2,
								    pftermsofuser:theme_scriptspf.tnc_err2
								  },
								  validClass: "pfvalid",
								  errorClass: "pfnotvalid pfaddnotvalidicon",
								  errorElement: "li",
								  errorContainer: pfsearchformerrors,
								  errorLabelContainer: $("ul", pfsearchformerrors),
								  invalidHandler: function(event, validator) {
									var errors = validator.numberOfInvalids();
									if (errors) {
										pfsearchformerrors.show("slide",{direction : "up"},100);
										form.find(".pfsearch-err-button").on('click',function(){
											pfsearchformerrors.hide("slide",{direction : "up"},100);
											return false;
										});
									}else{
										pfsearchformerrors.hide("fade",300);
									}
								  }
							});



							if(form.valid()){
								$.pfModalwithAjax(form.serialize(),'reportitem');
							}
							return false;
						});
						// REPORT FORM FUNCTION FINISHED --------------------------------------------------------------------------------------------



						// CLAIM FORM FUNCTION STARTED --------------------------------------------------------------------------------------------
						$('#pf-ajax-claim-button').on('click touchstart',function(){
							var form = $('#pf-ajax-claim-form');
							var pfsearchformerrors = form.find(".pfsearchformerrors");

							var recaptchanum = form.find('#recaptcha_div_mod .g-recaptcha-field').data('rekey');
							if (recaptchanum) {
								recaptchanum = $.recaptchanum;
								form.find('#g-recaptcha-response').text(grecaptcha.getResponse(recaptchanum));
							}

							form.validate({
								  debug:false,
								  onfocus: false,
								  onfocusout: false,
								  onkeyup: false,
								  rules:{
								  	name:"required",
								  	email:{
								  		required:true,
								  		email:true
								  	},
								  	msg:"required",
								  	pftermsofuser:"required"
								  },
								  messages:{
								  	name:theme_scriptspf.pfnameerr,
								  	email: {
									    required: theme_scriptspf.pfemailerr,
									    email: theme_scriptspf.pfemailerr2
								    },
								    msg:theme_scriptspf.pfmeserr2,
								    pftermsofuser:theme_scriptspf.tnc_err2
								  },
								  validClass: "pfvalid",
								  errorClass: "pfnotvalid pfaddnotvalidicon",
								  errorElement: "li",
								  errorContainer: pfsearchformerrors,
								  errorLabelContainer: $("ul", pfsearchformerrors),
								  invalidHandler: function(event, validator) {
									var errors = validator.numberOfInvalids();
									if (errors) {
										pfsearchformerrors.show("slide",{direction : "up"},100);
										form.find(".pfsearch-err-button").on('click',function(){
											pfsearchformerrors.hide("slide",{direction : "up"},100);
											return false;
										});
									}else{
										pfsearchformerrors.hide("fade",300);
									}
								  }
							});



							if(form.valid()){
								$.pfModalwithAjax(form.serialize(),'claimitem');
							}
							return false;
						});
						// CLAIM FORM FUNCTION FINISHED --------------------------------------------------------------------------------------------




						// FLAG REVIEW FORM FUNCTION STARTED --------------------------------------------------------------------------------------------
						$('#pf-ajax-flag-button').on('click touchstart',function(){
							var form = $('#pf-ajax-flag-form');
							var pfsearchformerrors = form.find(".pfsearchformerrors");

							var recaptchanum = form.find('#recaptcha_div_mod .g-recaptcha-field').data('rekey');
							if (recaptchanum) {
								recaptchanum = $.recaptchanum;
								form.find('#g-recaptcha-response').text(grecaptcha.getResponse(recaptchanum));
							}

							form.validate({
								  debug:false,
								  onfocus: false,
								  onfocusout: false,
								  onkeyup: false,
								  rules:{
								  	name:"required",
								  	email:{
								  		required:true,
								  		email:true
								  	},
								  	msg:"required",
								  	pftermsofuser:"required"
								  },
								  messages:{
								  	name:theme_scriptspf.pfnameerr,
								  	email: {
									    required: theme_scriptspf.pfemailerr,
									    email: theme_scriptspf.pfemailerr2
								    },
								    msg:theme_scriptspf.pfmeserr,
								    pftermsofuser:theme_scriptspf.tnc_err2
								  },
								  validClass: "pfvalid",
								  errorClass: "pfnotvalid pfaddnotvalidicon",
								  errorElement: "li",
								  errorContainer: pfsearchformerrors,
								  errorLabelContainer: $("ul", pfsearchformerrors),
								  invalidHandler: function(event, validator) {
									var errors = validator.numberOfInvalids();
									if (errors) {
										pfsearchformerrors.show("slide",{direction : "up"},100);
										form.find(".pfsearch-err-button").on('click',function(){
											pfsearchformerrors.hide("slide",{direction : "up"},100);
											return false;
										});
									}else{
										pfsearchformerrors.hide("fade",300);
									}
								  }
							})



							if(form.valid()){
								$.pfModalwithAjax(form.serialize(),'flagreview');
							};
							return false;
						});
						// FLAG REVIEW FORM FUNCTION FINISHED --------------------------------------------------------------------------------------------





						// ERROR FUNCTION STARTED --------------------------------------------------------------------------------------------
						$('#pf-ajax-cl-button').on('click',function(){

							$.pfOpenModal('close');
							return false;

						});
						// ERROR FUNCTION FINISHED --------------------------------------------------------------------------------------------



		            },
		            error: function (request, status, error) {

	                	$("#pf-membersystem-dialog").html('Error:'+request.responseText);

		            },
		            complete: function(){

	            		$('#pf-membersystem-dialog').pfLoadingOverlay({action:'hide'});

	            		setTimeout(function(){$("#pf-membersystem-dialog").dialog({position:{my: "center", at: "center",collision:"fit"}});},500);
		            	$('.pointfinder-dialog').center(true);
		            },
		        });

	        	if(modalname != ''){
				    $("#pf-membersystem-dialog").dialog({
				        resizable: false,
				        modal: true,
				        minWidth: minwidthofdialog,
				        maxWidth: maxwidthofdialog,
				        show: { effect: "fade", duration: 100 },
				        dialogClass: 'pointfinder-dialog',
				        open: function() {
					        $('.ui-widget-overlay').addClass('pf-membersystem-overlay');
					    },
					    close: function() {
					        $('.ui-widget-overlay').removeClass('pf-membersystem-overlay');
					    },
					    position:{my: "center", at: "center",collision:"fit"}
				    });
				    $.pfdialogstatus = 'true';

				   
			    	if(!$.pf_tablet_check() && modalname == 'quickpreview'){
			    		$( "#pf-membersystem-dialog" ).dialog( "option", "width", 'calc(100vw - 40px)' );
		    	 	}
			 
				}

			}else{

				if ($("#pf-membersystem-dialog").length > 0) {
				    $("#pf-membersystem-dialog").dialog("destroy");
				}

				if($('.pfquickpreviewmain').length > 0){
					$('.pfquickpreviewmain').remove();
				}
				$.pfdialogstatus = '';
	
			}
		}

	};

	$(function(){

		if ($("#commentform #submit").length > 0) {
	  		$("#commentform #submit").addClass('button');
	  	}

		$('body').on('click', '.pfquickview', function(event) {
	  		event.preventDefault();
	  		$.pfOpenModal('open','quickpreview','','',$(this).attr('data-pfitemid'));
	  	});
	  	$('body').on('click', '.pfquickclose', function(event) {
	  		event.preventDefault();
	  		$.pfOpenModal('close');
	  	});

	  	$('#pfpostitemlink a').on('click', function(event) {
			if (theme_scriptspf.userlog != 1) {
				$.pfOpenLogin('open','login','','',2);
				return false;
			}

		});

	  	$('body').on('click', '.pfclicktoshowphone', function(event) {
	  		event.preventDefault();
	  		var link = $(this).parent().find('a[rel="nofollow"]');
	  		var content2 = link.data('mx');
	  		var content1 = link.data('mxe');
	  		var lcontent = link.data('mxt');
	  		var icontent = link.data('mxi');
	  		$(this).remove();
			  if(lcontent === 'tel'){
				  link.attr('href', lcontent+':'+content1+content2);
			  }else{
				  link.attr('href', lcontent+'://'+content1+content2);
			  }
	  		link.html('<i class="'+icontent+'"></i> '+content1+content2);

	  	});

		if ($(".pointfinder-terms-archive").length>0) {
			$(".pointfinder-terms-archive").isotope({
				layoutMode: "fitRows",
				itemSelector: ".pf-grid-item",
				percentPosition: false
		    });
		}

		$('body').on('click','.pfButtons a',function() {
			if($(this).attr('data-pf-link')){
				$.magnificPopup.open({
				  items: {
				    src: ''+$(this).attr('data-pf-link')+''
				  },
				  type: ''+$(this).attr('data-pf-type')+'',
				  iframe: {
					patterns: {
						youtube_short: {
						  index: 'youtu.be/',
						  id: 'youtu.be/',
						  src: '//www.youtube.com/embed/%id%?autoplay=1' // URL that will be set as a source for iframe.
						}
					}
				}
				});
			}
		});

		$(".pftermshortc2").magnificPopup({
			type: "ajax",
			overflowY: "scroll"
		});


		$('.pfnot-err-button').on('click',function(){$.pftogglewnotificationclear();});

		$('body').on('click','.pf-favorites-link',function(){
			$.maindivfav = $(this);

			$.maindivfav.children('i').switchClass('fa-heart','fa-spinner fa-spin');

			setTimeout(function(){
				$.ajax({
		            type: 'POST',
		            dataType: 'json',
		            url: theme_scriptspf.ajaxurl,
		            data: {
		                'action': 'pfget_favorites',
		                'item': $.maindivfav.attr('data-pf-num'),
		                'active':$.maindivfav.attr('data-pf-active'),
		                'security': theme_scriptspf.pfget_favorites
		            },
		            success:function(data){
						var obj = [];
						$.each(data, function(index, element) {
							obj[index] = element;
						});

						if (!$.isEmptyObject(obj)) {

							if (obj.user == 0) {
								$.pfOpenLogin('open','login');
							}else{
								if (obj.active == 'true') {
									var datatextfv = 'true';
								}else{
									var datatextfv = 'false';
								};
								$.maindivfav.attr('data-pf-active',datatextfv);
								$.maindivfav.attr('title',obj.favtext);
								
								if ($.maindivfav.data('pf-item') == true) {
									$.maindivfav.children('#itempage-pffav-text').html(obj.favtext);
								};
							};
						};

		            },
		            complete:function(){
		            	$.maindivfav.children('i').removeClass('fa-spinner fa-spin').addClass('fa-heart');
		            }
		        });
			},1000);
		});

		$('body').on('click','#pf-search-button-manual',function(){
			var form = $('#pointfinder-search-form-manual');

			if (typeof $('#pointfinder_google_search_coord').attr("value") == 'undefined' || $('#pointfinder_google_search_coord').attr("value") == '') {
				$('#pointfinder_google_search_coord').attr("value",'');$('#pointfinder_areatype').attr("value",'');
				$('input[name=ne]').attr("value",'');$('input[name=ne2]').attr("value",'');$('input[name=sw]').attr("value",'');$('input[name=sw2]').attr("value",'');
			}
			if (typeof $.pfsliderdefaults == 'undefined') {
				$.pfsliderdefaults = {};$.pfsliderdefaults.fields = Array();
			}
			
			form.validate();

			var temp = ['input[name=pointfinder_areatype]','input[name=pointfinder_radius_search]', 'input[name=ne]', 'input[name=ne2]', 'input[name=sw]', 'input[name=sw2]']

			form.find("div:hidden[id$='_main']").each(function(){
				$(this).find('input[type=hidden]').not(temp.join(',')).attr("value","");
				$(this).find('input[type=text]').attr("value",$.pfsliderdefaults.fields[$(this).attr('id')]);
				$(this).find('.slider-wrapper .ui-slider-range').css('width','0%');
				$(this).find('.slider-wrapper a:nth-child(2)').css('left','0%');
				$(this).find('.slider-wrapper a:nth-child(3)').css('left','100%');
			});

			if(form.valid()){
				form.submit();
			};
			return false;
		});

		$(".pointfinderexfooterclassx").appendTo(".wpf-footer-row-move");

		$('#pf-login-trigger-button').on('click',function(){$.pfOpenLogin('open','login')});
		$('#pf-login-trigger-button-mobi').on('click',function(){$.pfOpenLogin('open','login')});
		$('.pf-login-modal').on('click',function(){$.pfOpenLogin('open','login')});


		$('#pf-register-trigger-button').on('click',function(){$.pfOpenLogin('open','register')});
		$('#pf-register-trigger-button-mobi').on('click',function(){$.pfOpenLogin('open','register')});
		$('#pf-lp-trigger-button').on('click',function(){$.pfOpenLogin('open','lp')});
		$('#pf-lp-trigger-button-mobi').on('click',function(){$.pfOpenLogin('open','lp')});
		$('body').on('click','.pf-membersystem-overlay',function(){$.pfOpenLogin('close')});
		$('body').on('click','.pfmodalclose',function(){$.pfOpenLogin('close');});
		$('body').on('click','.pf-membersystem-overlaymodal',function(){$.pfOpenModal('close')});

		$( "#pfccs_changer" ).change(function() {

		   var selected_value_pfcss = $(this).val();

		   $.ajax({
	            type: 'POST',
	            dataType: 'json',
	            url: theme_scriptspf.ajaxurl,
	            data: {
	                'action': 'pfget_currencychange',
	                'security': theme_scriptspf.pfget_modalsystemhandler,
	                'value': selected_value_pfcss
	            },
	            complete:function(){
	            	window.location = theme_scriptspf.pfcurrentpage+"/?c_code="+selected_value_pfcss;
	            }
           });
		});
	});

})(jQuery);