$(document).ready(function(){$.ajaxSetup({headers:{'X-CSRF-Token':$('meta[name=_token]').attr('content')}});marketPlaceChangeHandler();initializeUsernameCheck();$(".affiliateProgram").click(function(){var modelId=$(this).data('id');var url='/affiliateProgram/manageAffiliateProgram';$.ajax({url:url,type:"post",data:"modelId="+modelId,success:function(data){location.reload();}});});$(".markAsBanner").click(function(){var modelId=$(this).data('id');var modelName=$(this).data('name');var model=$(this).data('model');var url="";if(model==='deal'){url='/deal/dealBanner';}else if(model==='sale'){url='/sale/saleBanner';}else if(model==='voucher'){url='/voucher/voucherBanner';}$.ajax({url:url,type:"post",data:"modelId="+modelId,success:function(data){location.reload();}});});$(".markAsPopular").click(function(){var modelId=$(this).data('id');var url="/tag/tagPopular";$.ajax({url:url,type:"post",data:"modelId="+modelId,success:function(data) {location.reload();}});});var categoryName=$("#category_filter_form ul").find("[data-value='"+global_php_vars.category+"']").text();$("#category_filter_form").find('button').html(categoryName+' ');$('.sign-up-btn').click(function(e){openPopUp('registration');return false;});$('.sign-in-btn').click(function(e){openPopUp('signin');return false;});$('#contact-us').click(function(e){openPopUp('contact');return false;});$('.reply-contact-us').click(function(e){var email=$(this).data('email');var id=$(this).data('id');var name=$(this).data('name');var subject=$(this).data('subject');$.ajax({url:'/contact-reply',type:"post",success:function(data){$('.modal-content').html(data);$('#modal-box').modal('show');$('#modal-box #email').val(email);$('#modal-box #parentId').val(id);$('#modal-box #name').val(name);$('#modal-box #subject').val('RE:'+subject);},});return false;});$(document).on('submit','#sign-up',function(e){e.preventDefault(e);$.ajax({type:"POST",url:'/customRegister',data:$(this).serialize(),dataType:'json',success:function(data){if(data.fail==true){$('.help-block').html('');$("#sign-up #email, #sign-up #password, #sign-up #username").parent().removeClass('has-error');$.each(data.errors,function(index,value){var errorDiv='.'+index+'_error';if(index=='email'||index=='username'){$("#sign-up #"+index).parent().removeClass('has-success');$("#sign-up #"+index).parent().addClass('has-error');}$(errorDiv).parent().addClass('has-error');$(errorDiv).empty().append(value);});if(!$("#sign-up #email").parent().hasClass('has-error')){$("#sign-up #email").parent().addClass('has-success');}if(!$("#sign-up #password").parent().hasClass('has-error')){$("#sign-up #password").parent().addClass('has-success');}}if(data.success==true)window.location.reload();}})});$(document).on('submit','#sign-in',function(e){e.preventDefault(e);$.ajax({type:"POST",url:'/customLogin',data:$(this).serialize(),dataType:'json',success:function(data){if(data.fail==true){$('.help-block').html('');$.each(data.errors,function(index,value){var errorDiv='.'+index+'_error';$(errorDiv).parent().addClass('has-error');$(errorDiv).empty().append(value);});}if(data.success==true)window.location.reload();if(data.flash==true){$('.help-block').html('');$('.flash-error').html(data.message);}}})});$(document).on('submit','#contact-us-form',function(e){e.preventDefault(e);$.ajax({type:"POST",url:'/customContactUs',data:$(this).serialize(),dataType:'json',success:function(data){if(data.fail==true){$('.help-block').html('');$("#contact-us-form #name, #contact-us-form #email, #contact-us-form #subject , #contact-us-form #description").parent().removeClass('has-error');$.each(data.errors,function(index,value){var errorDiv='.'+index+'_error';if(index=='email'||index=='name'||index=='subject'||index=='description'){$("#contact-us-form #"+index).parent().removeClass('has-success');$("#contact-us-form #"+index).parent().addClass('has-error');}$(errorDiv).parent().addClass('has-error');$(errorDiv).empty().append(value);});if(!$("#contact-us-form #email").parent().hasClass('has-error')){$("#contact-us-form #email").parent().addClass('has-success');}if(!$("#contact-us-form #subject").parent().hasClass('has-error')){$("#contact-us-form #subject").parent().addClass('has-success');}}if(data.success==true){window.location.reload();}}})});$(document).on('submit','#contact-us-reply-form',function(e){e.preventDefault(e);$.ajax({type:"POST",url:'/customContactUsReply',data:$(this).serialize(),dataType:'json',success:function(data){if(data.fail==true){$('.help-block').html('');$("#contact-us-form #name, #contact-us-form #email, #contact-us-form #subject , #contact-us-form #description").parent().removeClass('has-error');$.each(data.errors,function(index,value){var errorDiv='.'+index+'_error';if(index=='email'||index=='name'||index=='subject'||index=='description'){$("#contact-us-form #"+index).parent().removeClass('has-success');$("#contact-us-form #"+index).parent().addClass('has-error');}$(errorDiv).parent().addClass('has-error');$(errorDiv).empty().append(value);});if(!$("#contact-us-form #email").parent().hasClass('has-error')){$("#contact-us-form #email").parent().addClass('has-success');}if(!$("#contact-us-form #subject").parent().hasClass('has-error')){$("#contact-us-form #subject").parent().addClass('has-success');}}if(data.success==true){window.location.reload();}}})});$(document).on('submit','#updateprofile_form',function(e){e.preventDefault(e);$.ajax({type:"POST",url:'/updateProfileWindow',data:new FormData(this),processData:false,contentType:false,dataType:'json',success:function(data){if(data.fail==true){$('.help-block').html('');$.each(data.errors,function(index,value){var errorDiv='.'+index+'_error';$(errorDiv).parent().addClass('has-error');$(errorDiv).empty().append(value);});}if(data.success==true){$(document).find("."+data.id).html(data.inputVal);$('#modal-box').modal('toggle');}}})});$(document).on('click','.submitDeal',function(e){e.preventDefault(e);$.ajax({type:"POST",url:'/deal/validate',data:$('#deal-form').serialize(),dataType:'json',beforeSend:function(){$(".spinner").show();},success:function(data){if(data.status==true){$('.submitDeal').prop('disabled',true);$('#deal-form').submit();}else{$('input').removeClass('deal-error');$('.help-block').empty();$.each(data.errors,function(index,value){var index=index.split(".");var errorDiv="[name='deal["+index[1]+"]["+index[2]+"]']";$(errorDiv).addClass('deal-error');$(errorDiv).next('.help-block').empty().append(value);$('#'+index).addClass('deal-error');$('#'+index).next('.help-block').empty().append(value);});}},complete:function(){$(".spinner").hide();}})});$(document).on('change','.image',function(e){var currentDealId=$("#"+$(this).closest('.cloneya').attr('id'));var file_data=$(this).prop("files")[0];var form_data=new FormData();form_data.append("file",file_data) $.ajax({type:"POST",url:'/deal/uploadDealImage',data:form_data,processData:false,contentType:false,dataType:'json',success:function(data){if(data.status==false){$.each(data.errors,function(index,value){img.parent().find('.help-block').empty().show().append(value);});}else{currentDealId.find('.image_url').val(data.imagePath);currentDealId.find('.browse-field').find('label img').hide();currentDealId.find('.browse-field').find('label .item-image').remove();currentDealId.find('.browse-field label').prepend(data.image);}}})});$(document).on('click','.submitSale',function(e){e.preventDefault(e);$.ajax({type:"POST",url:'/sale/validate',data:$('#sale-form').serialize(),dataType:'json',beforeSend:function(){$(".spinner").show();},success:function(data){if(data.status==true){$('.submitSale').prop('disabled',true);$('#sale-form').submit();}else{$('input').removeClass('sale-error');$('.help-block').empty();$.each(data.errors,function(index,value){var index=index.split(".");var errorDiv="[name='sale["+index[1]+"]["+index[2]+"]']";$(errorDiv).addClass('sale-error');$(errorDiv).next('.help-block').empty().append(value);$('#'+index).addClass('sale-error');$('#'+index).next('.help-block').empty().append(value);});}},complete:function(){$(".spinner").hide();}})});$(document).on('change','.saleimage',function(e){var currentDealId=$("#"+$(this).closest('.cloneya').attr('id'));var file_data=$(this).prop("files")[0];var form_data=new FormData();form_data.append("file",file_data) $.ajax({type:"POST",url:'/sale/uploadSaleImage',data:form_data,processData:false,contentType:false,dataType:'json',success:function(data){if(data.status==false){$.each(data.errors,function(index,value){img.parent().find('.help-block').empty().show().append(value);});}else{currentDealId.find('.image_url').val(data.imagePath);currentDealId.find('.browse-field').find('label img').hide();currentDealId.find('.browse-field').find('label .item-image').remove();currentDealId.find('.browse-field label').prepend(data.image);}}})});$(document).on('change','.apply_shipping',function(e){var saleId=$(this).attr('name');var saleIndex=parseInt(saleId.match(/\d+/)[0],10);if(this.value=='enter_shipping_price'){$("input[type='text'][name='sale["+saleIndex+"][shipping_price]']").parent('div').show();$("input[type='checkbox'][name='sale["+saleIndex+"][international_shipping_charge]']").parent('div').parent('div').parent('div').removeClass('col-md-12');$("input[type='checkbox'][name='sale["+saleIndex+"][international_shipping_charge]']").parent('div').parent('div').parent('div').addClass('col-md-6');}else{$("input[type='text'][name='sale["+saleIndex+"][shipping_price]']").parent('div').hide();if($("input[type='checkbox'][name='sale["+saleIndex+"][international_shipping_charge]']").parent('div').parent('div').parent('div').hasClass('col-md-6')){$("input[type='checkbox'][name='sale["+saleIndex+"][international_shipping_charge]']").parent('div').parent('div').parent('div').removeClass('col-md-6');$("input[type='checkbox'][name='sale["+saleIndex+"][international_shipping_charge]']").parent('div').parent('div').parent('div').addClass('col-md-12');}}});$(document).on('click','.submit-message',function(e){e.preventDefault(e);$.ajax({type:"POST",url:'/messages/validate',data:$('#message-form').serialize(),dataType:'json',success:function(data){if(data.status==true){$('#message-form').submit();}else{$('.help-block').html('');$.each(data.errors,function(index,value){var index=index.split(".");var errorDiv='.'+index[0]+'_error';$(errorDiv).parent().addClass('has-error');$(errorDiv).empty().append(value);});}}})});$(document).on('change','.image_url_text_box',function(){var url=$(this).val();if((url.match(/\.(jpeg|jpg|png)$/)!=null)){$(this).removeClass('deal-error');$(this).closest('.cloneya').find('.image_url').val(url);}else{$(this).addClass('deal-error');$(this).closest('.cloneya').find('.image_url').val('');}});$(document).on('change','.shipping',function(){if($(this).val()!=''&&$(this).val()!="0.00"&&$.isNumeric($(this).val()))$(this).closest('.cloneya').find('.isfreeshipping').val('N');else $(this).closest('.cloneya').find('.isfreeshipping').val('Y');});$(document).on('change','.select_currency',function(){$(this).closest('.cloneya').find('.currency').val($(this).val());});$(document).on('change',".international_shipping_charge",function(){if(this.checked)$(this).closest('.cloneya').find('.isInternationalShippingCharge').val('Y');else $(this).closest('.cloneya').find('.isInternationalShippingCharge').val('N');});$('div.alert').not('.alert-important').delay(3000).fadeOut(350); var owl=$("#owl-demo");owl.owlCarousel({items:4,loop:true,autoplay:true});$(".next").click(function(){owl.trigger('owl.next');});$(".prev").click(function(){owl.trigger('owl.prev');}) var owl1=$("#owl-tag");owl1.owlCarousel({itemsTablet:[700,2.5],itemsMobile:[497,2.5],singleItem:false,items:2.5,loop:!0,autoplay:!0,responsive:{0:{items: 2.5,nav: true},600: {items: 2.5,nav: true},1000: {items: 2.5,nav: true,loop: false}} }),$(".next-tag").click(function(){owl1.trigger("owl.next")}),$(".prev-tag").click(function(){owl1.trigger("owl.prev")}); var owlS=$("#owl-store");owlS.owlCarousel({itemsTablet:[700,2.5],itemsMobile:[497,2.5],singleItem:false,items:2.5,loop:!0,autoplay:!0,responsive:{0:{items: 2.5,nav: true},600: {items: 2.5,nav: true},1000: {items: 2.5,nav: true,loop: false}} }),$(".next-store").click(function(){owlS.trigger("owl.next")}),$(".prev-store").click(function(){owlS.trigger("owl.prev")}); var owlSR=$("#owl-store-right");owlSR.owlCarousel({singleItem:false,items:1,loop:!0,autoplay:!0,responsive:{0:{items: 1,nav: true},600: {items: 1,nav: true},1000: {items: 1,nav: true,loop: false}} }),$(".prev-store-right").css('marginRight', $("#owl-store-right .owl-pagination").outerWidth() +3),$(".next-store-right").click(function(){owlSR.trigger("owl.next")}),$(".prev-store-right").click(function(){owlSR.trigger("owl.prev")}); var owlTR=$("#owl-tag-right");owlTR.owlCarousel({singleItem:false,items:1,loop:!0,autoplay:!0,responsive:{0:{items: 1,nav: true},600: {items: 1,nav: true},1000: {items: 1,nav: true,loop: false}} }),$(".prev-tag-right").css('marginRight', $("#owl-tag-right .owl-pagination").outerWidth() +3),$(".next-tag-right").click(function(){owlTR.trigger("owl.next")}),$(".prev-tag-right").click(function(){owlTR.trigger("owl.prev")}); $('.flag-btn').click(function(e){$.ajax({url:'/report/new',type:"post",data:{id:$(this).attr('data-id'),type:$(this).attr('data-type')},success:function(data){$('.modal-content').html(data);$('#modal-box').modal('show');}});return false;});$('.grab-code-visit-site-btn').click(function(e){$.ajax({url:'/voucher/grabcode',type:"post",data:{id:$(this).attr('data-id'),type:$(this).attr('data-type')},success:function(data){$('.modal-content').html(data);$('#modal-box').modal('show');}});return false;});$(document).on('submit','#flag-form',function(e){e.preventDefault(e);$.ajax({type:"POST",url:'/report/flag',data:$(this).serialize(),dataType:'json',success:function(data){if(data.fail==true){$('.help-block').html('');$.each(data.errors,function(index,value){var errorDiv='.'+index+'_error';$(errorDiv).parent().addClass('has-error');$(errorDiv).empty().append(value);});}if(data.flash==true){$('.help-block').html('');$('.flash-error').html(data.message);}if(data.success==true){window.location.reload();}}});});$(document).on('submit','#profile-complete',function(e){e.preventDefault(e);$.ajax({type:"POST",url:'/completeProfile',data:$(this).serialize(),dataType:'json',success:function(data){if(data.fail==true){$('.help-block').html('');$.each(data.errors,function(index,value){var errorDiv='.'+index+'_error';$(errorDiv).parent().addClass('has-error');$(errorDiv).empty().append(value);});}if(data.success==true)window.location.reload();}})});$('.like-btn').click(function(e){if(global_php_vars.isUserLoggedIn==false){openPopUp('signin');return false;}var dataId=$(this).attr('data-id');var linkObj=$(this);$.ajax({url:'/data/like',type:"post",data:{id:$(this).attr('data-id'),type:$(this).attr('data-type')},success:function(data){var likeCount=0;if(linkObj.html().toLowerCase()=='like'){linkObj.html('Unlike');if($("#like-"+dataId+" .like-count").html()){likeCount=parseInt($("#like-"+dataId+" .like-count").html())+1;}else{likeCount=1;}}else{linkObj.html('Like');if($("#like-"+dataId+" .like-count").html()){likeCount=parseInt($("#like-"+dataId+" .like-count").html())-1;}}if(likeCount=='0'){$("#like-"+dataId+" .like-count").html("");$("#like-"+dataId+" .like-count").next(".like-text").html("");}else{$("#like-"+dataId+" .like-count").html(likeCount);$("#like-"+dataId+" .like-count").next(".like-text").html((likeCount>1)?'likes':'like');}}});});if(global_php_vars.isUserLoggedIn){if(!global_php_vars.isProfileComplete){openPopUp('profile');return false;}}$("#deal-form .right-panel #email, #voucher-form .right-panel #email").typeWatch({callback:function(value){checkEmailAlreadyExist(value);},wait:750,highlight:true,allowSubmit:false,captureLength:2});$(document).on("focusout",".bootstrap-tagsinput input",function(){if($(this).parent().find("span").length){$(this).removeAttr("placeholder");}else{$(this).attr("placeholder","Add Related Keywords");}});$(document).on("focus",".bootstrap-tagsinput input",function(){$(this).addClass("activeInput");});$(document).on("blur",".bootstrap-tagsinput input",function(){if($('.bootstrap-tagsinput').find('span.tag').length==0){$(".bootstrap-tagsinput input").removeClass("activeInput");}});$(document).on('click','.variousdeal',function(){var dealType=$(this).attr('value');if(dealType=='deal'){dealType='deal/new';}$.ajax({type:"GET",url:'/'+dealType,dataType:'json',beforeSend:function(){$(".spinner").show();},success:function(data){if(data.status==true){$('#dealtypeContainer').html(data.html);}},complete:function(){$(".spinner").hide();}})});$(document).on('click','.submitVoucher',function(e){e.preventDefault(e);$.ajax({type:"POST",url:'/voucher/validate',data:$('#voucher-form').serialize(),dataType:'json',beforeSend:function(){$(".spinner").show();},success:function(data){if(data.status==true){$('.submitVoucher').prop('disabled',true);$('#voucher-form').submit();}else{$('input').removeClass('voucher-error');$('.help-block').empty();$.each(data.errors,function(index,value){var index=index.split(".");var errorDiv="[name='voucher["+index[1]+"]["+index[2]+"]']";$(errorDiv).addClass('voucher-error');$(errorDiv).next('.help-block').empty().append(value);$('#'+index).addClass('voucher-error');$('#'+index).next('.help-block').empty().append(value);});}},complete:function(){$(".spinner").hide();}})});$(document).on('change','.voucherimage',function(e){var currentDealId=$("#"+$(this).closest('.cloneya').attr('id'));var file_data=$(this).prop("files")[0];var form_data=new FormData();form_data.append("file",file_data) $.ajax({type:"POST",url:'/voucher/uploadVoucherImage',data:form_data,processData:false,contentType:false,dataType:'json',success:function(data){if(data.status==false){$.each(data.errors,function(index,value){img.parent().find('.help-block').empty().show().append(value);});}else{currentDealId.find('.image_url').val(data.imagePath);currentDealId.find('.browse-field').find('label img').hide();currentDealId.find('.browse-field').find('label .item-image').remove();currentDealId.find('.browse-field label').prepend(data.image);}}})});$(".ebaySwitch .compare-product-list li").slice(0,10).removeClass('hidden');$(".amazonSwitch .compare-product-list li").slice(0,10).removeClass('hidden');$(".etseySwitch .compare-product-list li").slice(0,10).removeClass('hidden');$("#loadMore").on('click',function(e){e.preventDefault();$(".ebaySwitch .compare-product-list li:hidden").slice(0,10).removeClass('hidden');$(".amazonSwitch .compare-product-list li:hidden").slice(0,10).removeClass('hidden');$(".etseySwitch .compare-product-list li:hidden").slice(0,10).removeClass('hidden');if($(".ebaySwitch .compare-product-list li:hidden").length==0&&$(".amazonSwitch .compare-product-list li:hidden").length==0&&$(".etseySwitch .compare-product-list li:hidden").length==0){$("#loadMore").fadeOut('slow');}});$('a[href=#top]').click(function(){$('body,html').animate({scrollTop:0},600);return false;});$(window).scroll(function(){if($(this).scrollTop()>50){$('.totop a').fadeIn();}else{$('.totop a').fadeOut();}});});function autoHeight(){$('.main-wrapper').css('min-height',0);$('.main-wrapper').css('min-height',($(document).height()-$('.footer').innerHeight()));}function editPopUp(action,relation,fieldType){$.ajax({url:'/editWindow',type:"post",data:"action="+action+"&relation="+relation+"&fieldType="+fieldType,success:function(data){$('.modal-content').html(data);$('#modal-box').modal('show');}});}function perFormFetchItem(dealId){var dealIndex=parseInt(dealId.match(/\d+/)[0],10);var $currentDeal=$("#"+dealId);var $this=$("#"+dealId).find(".link");$currentDeal.find(".item-image").remove();if($this.val()==''){clearForm(dealId);return false;}if(dealIndex==0)var serializedId='';else var serializedId=dealIndex;marketplace_field_handler(dealId);var host=$this.val().replace('http://','').replace('https://','').replace('m.','').replace('www.','').split(/[/?.#]/)[0];if(host=="ebay"||host=="amazon"||host=="etsy"){$("input[type='radio'][name='deal["+dealIndex+"][marketplace_id]'][data-slug="+host+"]").prop('checked',true);$currentDeal.find(".marketplace_dependent:not('.image_url_field')").show();$currentDeal.find(".default-deal-photo").hide();$currentDeal.find('.browse-field').find('label .item-image').remove();}else{$("input[type='radio'][name='deal["+dealIndex+"][marketplace_id]'][data-slug='other-website']").prop('checked',true);marketplace_field_handler(dealId,"other-website");$currentDeal.find(".default-deal-photo").show();}itemAjax(dealIndex,$this,$currentDeal,serializedId);}function itemAjax(dealIndex,$this,$currentDeal,serializedId){$.ajax({type:"POST",url:'/deal/fetchItem',async:false,data:'marketPlace_id='+$("input[type='radio'][name='deal["+dealIndex+"][marketplace_id]']:checked").val()+"&link="+encodeURIComponent($this.val()),dataType:'json',context:$currentDeal,beforeSend:function(){$("#error").html('');$(".spinner").show();},success:function(data){$.each(data,function(index,value){var inputId='#'+index+serializedId;if(index=='error'){$(".spinner").hide();clearForm($currentDeal['0']['id']);$currentDeal.find(inputId).html(value);return false;}if($currentDeal.find(inputId).attr('type')=="select"){$currentDeal.find("input[type='select'][name='deal["+dealIndex+"]["+index+"]'][value="+value+"]").prop('selected',true).change();}else if($currentDeal.find(inputId).attr('type')=="checkbox"||$(inputId).attr('type')=="radio"){$currentDeal.find("input[name='deal["+dealIndex+"]["+index+"]']").val(value);}else{$currentDeal.find(inputId).val(value);}if(index=="shipping"&&value=="Y")$currentDeal.find("#shipping"+serializedId).prop("checked",true);if(index=="international_shipping_charge"&&value=="Y")$currentDeal.find("#international_shipping_charge"+serializedId).prop("checked",true);if(index=="item-image")$currentDeal.find(".browse-field").append(value);if(index=="currency")$currentDeal.find("#select_currency"+serializedId).val(value).prop('selected',true).change();if(index=="changePriceForm"){if(value=='From'){$currentDeal.find("#is_variant"+serializedId).val('Y').prop('checked',true);$currentDeal.find(".fromPrice").remove();$('
'+value+'
').insertBefore(".priceWrapper");}else{$currentDeal.find(".fromPrice").remove();$currentDeal.find("#is_variant"+serializedId).val('N').prop('checked',true);$currentDeal.find(".price_wrap label").html(value);}}if(index=="itemId")$currentDeal.find("#item_id"+serializedId).val(value);});},complete:function(){$(".spinner").hide();}})}function openPopUp(action){$.ajax({url:'/'+action,type:"post",success:function(data){$('.modal-content').html(data);$('#modal-box').modal('show');if(action=='registration'){$('body').append("");$('.modal-dialog').css('max-width','400px');}if(action=='mobilebanner'){$('body').append("");$('.modal-dialog').css('max-width','369px');}if(action=='signin'){$('body').append("");$('.modal-dialog').css('max-width','369px');}if(action=='contact'){$('body').append("");$('.modal-dialog').css('max-width','400px');}}});}function dealSpeed(dealId,status){if(global_php_vars.isUserLoggedIn==false){openPopUp('signin');return false;}$.ajax({type:"POST",url:'/deal/dealSpeed',async:false,data:{dealId:dealId,status:status},dataType:'json',success:function(data){if(data.status=="error"){return false;}else{var currentDealSpeed=$('.speed-'+dealId+' .progress-pie-chart');currentDealSpeed.data("percent",data.height);generateSpeedCircle(currentDealSpeed);$(".up-"+dealId).addClass('up');$(".down-"+dealId).addClass('down');$("#deal-"+dealId).find('.deal-detail .mbft').html(data.height);}}});}function saleSpeed(saleId,status){if(global_php_vars.isUserLoggedIn==false){openPopUp('signin');return false;}$.ajax({type:"POST",url:'/sale/saleSpeed',async:false,data:{saleId:saleId,status:status},dataType:'json',success:function(data){if(data.status=="error"){return false;}else{var currentSaleSpeed=$('.speed-'+saleId+' .progress-pie-chart');currentSaleSpeed.data("percent",data.height);generateSpeedCircle(currentSaleSpeed);$(".up-"+saleId).addClass('up');$(".down-"+saleId).addClass('down');$("#sale-"+saleId).find('.deal-detail .mbft').html(data.height);}}});}function saveDeal(dealId){if(global_php_vars.isUserLoggedIn==false){openPopUp('signin');return false;}$.ajax({type:"POST",url:'/deal/saveDeal',async:false,data:{dealId:dealId},dataType:'json',success:function(data){if(data.status=="error")return false;else $('.pro-wishlist').html(data.innerText);$('.pro-deal-social.for-only-mobile .pro-wishlist').html(data.innerText);}});}function saveVoucher(voucherId){if(global_php_vars.isUserLoggedIn==false){openPopUp('signin');return false;}$.ajax({type:"POST",url:'/voucher/saveVoucher',async:false,data:{voucherId:voucherId},dataType:'json',success:function(data){if(data.status=="error")return false;else $('.pro-wishlist').html(data.innerText);$('.pro-deal-social.for-only-mobile .pro-wishlist').html(data.innerText);}});}function saveSale(saleId){if(global_php_vars.isUserLoggedIn==false){openPopUp('signin');return false;}$.ajax({type:"POST",url:'/sale/saveSale',async:false,data:{saleId:saleId},dataType:'json',success:function(data){if(data.status=="error")return false;else $('.pro-wishlist').html(data.innerText);$('.pro-deal-social.for-only-mobile .pro-wishlist').html(data.innerText);}});}function subscribeDeal(dealId){if(global_php_vars.isUserLoggedIn==false){openPopUp('signin');return false;}$.ajax({type:"POST",url:'/deal/subscribeDeal',async:false,data:{dealId:dealId},dataType:'json',success:function(data){if(data.status=="error")return false;else $('.subscribeDeal').text("Deal Subscribed");}});}function clearForm(dealId){var $currentDeal=$("#"+dealId);$currentDeal.find(".item-image").remove();$currentDeal.find("input[type='text'],textarea").not(":button, :submit, :reset").val('');$currentDeal.find('select').removeAttr('selected').find('option:first').prop('selected','selected');$currentDeal.find(".price_wrap label").html('Price');$currentDeal.find(".help-block").html('');$currentDeal.find("input[type='checkbox']").val('N').prop('checked',false);$currentDeal.find(".marketplace_dependent").hide();$currentDeal.find(".default-deal-photo").show();$currentDeal.find(".default-deal-photo").show();$currentDeal.find('.browse-field').find('label .item-image').remove();$currentDeal.find(".bootstrap-tagsinput input[type='text']").val('');$currentDeal.find(".bootstrap-tagsinput span").remove();$currentDeal.find(".item_id").html('');$currentDeal.find("#is_variant").val('N').prop('checked',false);}function marketplace_field_handler(dealId,marketplace_slug){var $currentDeal=$("#"+dealId);if(marketplace_slug!=''&&marketplace_slug!='other-website'){$currentDeal.find(".marketplace_dependent").hide();$currentDeal.find(".api_fields :input").each(function(index){if($(this).attr('type')=='checkbox'||$(this).is('select')){$(this).attr("disabled",true);}else{$(this).attr("readonly",true);}});}else{$currentDeal.find(".marketplace_dependent").show();$currentDeal.find(".marketplace_dependent_field").attr("readonly",false);$currentDeal.find(".marketplace_dependent_field").attr("disabled",false);}}function expendThis(section){$("#"+section+" .deal-hide").toggle();if($("#"+section+" .view-more").text()=="View More")$("#"+section+" .view-more").html("View Less");else $("#"+section+" .view-more").html("View More");}function marketPlaceChangeHandler(){$("#deal-form .com-check").on('click',"img",function(){var marketPlace=$(this).attr('data-mp-id');var dealId=$(this).closest('.cloneya').attr('id');clearForm(dealId);marketplace_field_handler(dealId,$(this).attr("data-slug"));});}function checkEmailAlreadyExist(email){$.ajax({type:"POST",url:'/user/checkIfEmailExist',async:false,data:{email:email},dataType:'json',success:function(data){if(data.status==false){$("#deal-form #username, #voucher-form #username").val('');$("#deal-form .username_wrap .help-block, #voucher-form .username_wrap .help-block").empty();$("#deal-form .username_wrap input, #voucher-form .username_wrap input").removeClass('deal-error');$("#deal-form .username_wrap,#voucher-form .username_wrap").show();}else{$("#deal-form .username_wrap, #voucher-form .username_wrap").hide();$("#deal-form #username,#voucher-form #username").val(data.username);}}});}function initializeUsernameCheck(){$('.check-username').on('focusout blur',function(e){var Obj=$(this);$.ajax({type:"POST",url:'/user/checkIfUserNameExist',async:false,data:{username:Obj.val()},dataType:'json',beforeSend:function(){Obj.parent().removeClass('has-success');Obj.parent().removeClass('has-error');},success:function(data){if(data.status){Obj.parent().addClass('has-error');$(".username_error").parent("div").removeClass("has-success");$(".username_error").parent("div").addClass("has-error");}else{$(".username_error").parent("div").removeClass("has-error");$(".username_error").parent("div").addClass("has-success");Obj.parent().addClass('has-success');}$(".username_error").html(data.message);}});});}function voucherSpeed(voucherId,status){if(global_php_vars.isUserLoggedIn==false){openPopUp('signin');return false;}$.ajax({type:"POST",url:'/voucher/voucherSpeed',async:false,data:{voucherId:voucherId,status:status},dataType:'json',success:function(data){if(data.status=="error"){return false;}else{var currentVoucherSpeed=$('.speed-'+voucherId+' .progress-pie-chart');currentVoucherSpeed.data("percent",data.height);generateSpeedCircle(currentVoucherSpeed);$(".up-"+voucherId).addClass('up');$(".down-"+voucherId).addClass('down');$("#voucher-"+voucherId).find('.deal-detail .mbft').html(data.height);}}});} $(".markStore").click(function(){var modelId=$(this).data('id');var modelColumn=$(this).data('column');var url="/store/markstore";$.ajax({url:url,type:"post",data:"modelId="+modelId+"&modelColumn="+modelColumn, success:function(data) {location.reload();}});}); setTimeout(function() {openPopUp("mobilebanner")}, 3000);