");
jQuery("#comments_name").removeAttr('value');
jQuery("#author_comment").removeAttr('value');
jQuery("#captchaInputValue").removeAttr('value');
jQuery("#captchaInputValue").attr("placeholder",response.captcha1 +" + "+response.captcha2 + " = ?");
jQuery("#captchaInputValue").parent().find(".invalid").text("");
}
if(response.index == 2){
jQuery("#captchaInputValue").parent().find(".invalid").text("Invalid Captcha").css({ "color" : "#E22828" });
}
});
return false;
}
});
jQuery('.order_popup_submit_close').click(function(e){
e.preventDefault();
var user_name = jQuery("#catalog-order-popup-1 .asc_seller_name").val();
var user_mail = jQuery("#catalog-order-popup-1 .asc_seller_mail").val();
var user_phone = jQuery("#catalog-order-popup-1 .asc_seller_phone").val();
var user_massage = jQuery("#catalog-order-popup-1 .asc_seller_massage").val();
var user_product_id = jQuery("#catalog-order-popup-1 .asc_seller_product_id").val();
var user_spam = jQuery("#catalog-order-popup-1 .asc_seller_spam").val();
var captcha_val = jQuery("#catalog-order-popup-1 .captchaInputValue").val();
var product_name = jQuery(".right-block .title-block h2").text();
var user_ip = jQuery("#catalog-order-popup-1 .huge_it_catalog_product_ip").val();
var captchaSum = jQuery("#catalog-order-popup-1 #captcha_sum").val();
var emailCheck=/^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?$/i;
if(user_name == "" || user_mail == "" || user_phone == "" || user_massage == "" || user_product_id == "" || captcha_val == "" || captcha_val != 7){
jQuery("#catalog-order-popup-1 input[type=text], #catalog-order-popup-1 textarea").each(function(){
if(!jQuery(this).val()){ // alert(jQuery(this).attr("name"));
jQuery(this).addClass("empty");
}
else{ jQuery(this).removeClass("empty"); }
});
if(captcha_val != 7){
jQuery("#catalog-order-popup-1").find(".invalid").text("Invalid Captcha").css({ "color" : "#E22828" });
}
return false;
}
else{
var email_path = jQuery("#catalog-order-popup-1 .asc_seller_mail");
if(!(emailCheck.test(user_mail))){
jQuery(email_path).val("").attr("placeholder", "Invalid Email").addClass("empty");
return false;
}
else{
jQuery(email_path).removeClass("empty").attr("placeholder", "Your E-mail");
var data = {
action: 'my_action',
post: 'applyproductascsellerfromuser',
user_name: user_name,
user_mail: user_mail,
user_phone: user_phone,
user_product_id: user_product_id,
user_massage: user_massage,
user_spam: user_spam,
user_ip: user_ip,
captcha_val: captcha_val,
product_name: product_name,
captcha_sum: captchaSum
};
jQuery.post("https://www.avalondairy.com/wp-admin/admin-ajax.php", data, function(response) { // alert(response);
response = JSON.parse(response);
if(response.index == 1){
if( jQuery(".reviews-block .review").text().length == 0 ) { jQuery(".reviews-block").text(""); }
jQuery("#catalog-order-popup-1 .asc_seller_name").removeAttr('value');
jQuery("#catalog-order-popup-1 .asc_seller_mail").removeAttr('value');
jQuery("#catalog-order-popup-1 .asc_seller_phone").removeAttr('value');
jQuery("#catalog-order-popup-1 .asc_seller_massage").removeAttr('value');
jQuery("#catalog-order-popup-1 .captchaInputValue").val("").attr("placeholder",response.captcha1 +" + "+response.captcha2 + " = ?").parent().find(".invalid").text("");
jQuery("#catalog-order-popup-1 input[type=text]").each(function(){
jQuery(this).removeClass("empty");
});
window.location = jQuery('.order_popup_submit_close').attr("href");
// jQuery(".modalDialog").css({ opacity: 0 });
// jQuery(".modalDialog ").find("a.catalog-order-popup-close").click();
}
if(response.index == 2){
jQuery("#catalog-order-popup-1").find(".invalid").text("Invalid Captcha").css({ "color" : "#E22828" });
return false;
}
});
}
}
jQuery(".modalDialog").css({ 'opacity': '0','pointer-events':'none' });
});
jQuery(".rating-stars li").hover(function() {
var rate_val = jQuery(this).find("input").val();
var background_margin = (rate_val * 15);
jQuery(this).parent().css({
'background-position' : '0px -' + background_margin + 'px'
});
},function(){
if(jQuery(this).parent().hasClass('rated')){
var rateis=jQuery(this).parent().attr('data-rateis')*15;
jQuery(this).parent().css({
'background-position' : '0px -'+rateis+'px'
});
}else{
jQuery(this).parent().css({
'background-position' : '0px -15px'
});
}
});
jQuery(".rating-stars li input[type='radio']").click(function(){
var strthis=jQuery(this);
var rate_val = jQuery(this).val();
var ip = jQuery(".huge_it_catalog_product_ip").val();
var spam = jQuery(".huge_it_catalog_spam").val();
var product_id = jQuery(".huge_it_catalog_product_id").val();
var data = {
action: 'my_action',
post: 'productratingfromuser',
spam: spam,
ip: ip,
product_id: product_id,
rate_val: rate_val
};
// alert(ip + " " + spam + " " + product_id); return false;
jQuery.post("https://www.avalondairy.com/wp-admin/admin-ajax.php", data, function(response) { // alert(response.index);
response = JSON.parse(response);
// alert(response.index);
// alert(response.rating);
if(response.index == 1){
var newrate = response.rating; // alert(newrate);
jQuery(strthis).parent().parent().addClass('rated').attr('data-rateis',newrate);
jQuery(strthis).parent().parent().css({
'background-position' : '0px -' + newrate*15 + 'px'
});
}
});
});
});
window.twttr=(function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],t=window.twttr||{};if(d.getElementById(id))return t;js=d.createElement(s);js.id=id;js.src="https://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);t._e=[];t.ready=function(f){t._e.push(f);};return t;}(document,"script","twitter-wjs"));
Share = {
url: "",
vkontakte: function(purl, ptitle, pimg, text) {
url = 'http://vkontakte.ru/share.php?';
url += 'url=' + encodeURIComponent(purl);
url += '&title=' + encodeURIComponent(ptitle);
url += '&description=' + encodeURIComponent(text);
url += '&image=' + encodeURIComponent(pimg);
url += '&noparse=true';
Share.popup(url);
},
odnoklassniki: function(purl, text) {
url = 'http://www.odnoklassniki.ru/dk?st.cmd=addShare&st.s=1';
url += '&st.comments=' + encodeURIComponent(text);
url += '&st._surl=' + encodeURIComponent(purl);
Share.popup(url);
},
facebook: function(purl, ptitle, pimg, text) {
url = 'http://www.facebook.com/sharer.php?s=100';
url += '&p[title]=' + encodeURIComponent(ptitle);
url += '&p[summary]=' + encodeURIComponent(text);
url += '&p[url]=' + encodeURIComponent(purl);
url += '&p[images][0]=' + encodeURIComponent(pimg);
console.log(url);
Share.popup(url);
},
twitter: function(purl, ptitle) {
url = 'http://twitter.com/share?';
url += 'text=' + encodeURIComponent(ptitle);
url += '&url=' + encodeURIComponent(purl);
url += '&counturl=' + encodeURIComponent(purl);
Share.popup(url);
},
mailru: function(purl, ptitle, pimg, text) {
url = 'http://connect.mail.ru/share?';
url += 'url=' + encodeURIComponent(purl);
url += '&title=' + encodeURIComponent(ptitle);
url += '&description=' + encodeURIComponent(text);
url += '&imageurl=' + encodeURIComponent(pimg);
Share.popup(url)
},
google: function(purl) {
url = 'https://plus.google.com/share?';
url += '&url=' + encodeURIComponent(purl);
Share.popup(url);
},
popup: function(url) {
window.open(url,'','toolbar=0,status=0,width=626,height=436');
}
};