Rev 11325 | Rev 11558 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
window.onload=function(){var pheight = Math.max(document.documentElement.clientHeight, window.innerHeight || 0);if(document.getElementsByClassName('cart-cont')[0] != undefined){document.getElementsByClassName('cart-cont')[0].style.minHeight = pheight - 235 +'px';}};function clearmsg(){if(document.getElementById('coupon-msg').style.display == 'block')document.getElementById('coupon-msg').style.display = 'none';}function applycoupon(){var coupon = document.getElementById('couponcode').value;if(coupon.length <= 0){if(document.getElementById('error').style.display == 'block'){document.getElementById('error').style.display = "none";}var bRed = document.getElementById('couponcode');bRed.style.border = 'red solid 1px';bRed.style.color = 'red';bRed.value = 'Please enter the coupon code!';setTimeout(function(){bRed.style.border = '';bRed.style.color = '';bRed.value = '';},3000);return false;}else{if(document.getElementById('error').style.display == 'block'){document.getElementById('error').style.display = "none";}var url = base_url+'cart/coupon/'+coupon;//window.location.href = a;microAjax(url, function (res) {var data = JSON.parse(res);var message = data.message;if(message.length > 0){message = message.split(':');message = message[1];}document.getElementById('coupon-msg').style.display = 'block';if(message.length == 0){document.getElementById('coupon-msg').innerHTML = 'Coupon Applied';}else{document.getElementById('coupon-msg').innerHTML = message;return false;}if(data.discountedPrice != undefined && parseInt(data.discountedPrice) >=0){document.getElementById('addCoupon').style.display = 'none';document.getElementById('removeCoupon').style.display = 'block';if(data.couponCode.length > 0){document.getElementById('removeCoupon').innerHTML = 'Remove Coupon: '+data.couponCode;}document.getElementById('discount').style.display = 'block';var discount = parseInt(data.totalPrice) - parseInt(data.discountedPrice);document.getElementById('discountAmt').innerHTML = discount;document.getElementById('discountPrice').style.display = 'block';document.getElementById('discountedPrice').innerHTML = parseInt(document.getElementById('total').innerHTML)-discount;}});}}function clearcoupon(code){var url = base_url+'cart/couponClear/'+code;//window.location.href = a;microAjax(url, function (res) {var data = JSON.parse(res);var message = data.message;var total = data.totalPrice;document.getElementById('addCoupon').style.display = 'block';document.getElementById('removeCoupon').style.display = 'none';document.getElementById('discount').style.display = 'none';document.getElementById('discountPrice').style.display = 'none';document.getElementById('coupon-msg').style.display = 'none';document.getElementById('couponcode').value = '';var finalinsurance = 0;if(insuredItems.length > 0){for(j=0;j<insuredItems.length;j++){var insurance = insuredItems[j]+'theft';var cost = document.getElementById(insurance).innerHTML;finalinsurance = finalinsurance + parseInt(cost);}}if(parseInt(finalinsurance) > 0){total = parseInt(total) + parseInt(finalinsurance);document.getElementById('total').innerHTML = total;}});}function updateQty(e){var oldValue = e.currentTarget.getAttribute('data-value');var newvalue = e.currentTarget.value;if(parseInt(newvalue) != parseInt(oldValue)){var url = base_url+'cart/update/'+e.currentTarget.id+'/'+newvalue;window.location.href = url;}}function removeItem(itemId){var url = base_url+'cart/delete/'+itemId;window.location.href = url;}var insuredItems = new Array();function teftinsure(e){var key = e.currentTarget.getAttribute('data-key');if(key == 'ins'){if(document.getElementById('error').style.display == "block"){document.getElementById('error').style.display = "none";}var id = e.currentTarget.id;var insure = document.getElementById(id).checked;var itemId = e.currentTarget.getAttribute('data-value');var tnc = itemId+'tnc';var tc = itemId+'tc';tncChkd = document.getElementById(tnc).checked;var theft = itemId+'theft';var theft = document.getElementById(theft).innerHTML;theft = parseInt(theft);var total = document.getElementById('total').innerHTML;total = parseInt(total);if(insure == true){insuredItems.push(itemId);if(typeof _gaq != "undefined" && _gaq != null) {_gaq.push(['_trackEvent', 'insurance', 'Want Insurance',itemId]);}if(document.getElementById('discountPrice').style.display == 'block'){var discountPrice = document.getElementById('discountedPrice').innerHTML;discountPrice = parseInt(discountPrice);document.getElementById('discountedPrice').innerHTML = discountPrice+theft;}else{document.getElementById('total').innerHTML = total+theft;}}if(insure == false){if(document.getElementById('error').style.display == "block"){document.getElementById('error').style.display = "none";}if(document.getElementById(tc).style.display == 'block'){document.getElementById(tc).style.display = 'none';}var ind = insuredItems.indexOf(itemId);insuredItems.splice(ind,1);if(document.getElementById('discountPrice').style.display == 'block'){var discountPrice = document.getElementById('discountedPrice').innerHTML;discountPrice = parseInt(discountPrice);document.getElementById('discountedPrice').innerHTML = discountPrice-theft;}else{document.getElementById('total').innerHTML = total-theft;}}}if(key == 'tnc'){if(document.getElementById('error').style.display == "block"){document.getElementById('error').style.display = "none";}var id = e.currentTarget.id;var tncChkd = document.getElementById(id).checked;var itemId = e.currentTarget.getAttribute('data-value');var insurance = itemId+'insurance'var tc = itemId+'tc';var insure = document.getElementById(insurance).checked;}if(insure == true && tncChkd == false){if(document.getElementById('error').style.display == "block"){document.getElementById('error').style.display = "none";}if(document.getElementById(tc).style.display == 'block'){var url = base_url+'cart/insure/'+itemId+'/'+tncChkd+'/1';microAjax(url, function (res) {var data = JSON.parse(res);data = data.status;if(data == true){}if(data == false){alert(data);}});}else{document.getElementById(tc).style.display = 'block';}}else if(insure == true && tncChkd == true){if(typeof _gaq != "undefined" && _gaq != null) {_gaq.push(['_trackEvent', 'Insurance', 'Agreed to Terms',itemId]);}var url = base_url+'cart/insure/'+itemId+'/'+insure+'/1';microAjax(url, function (res) {var data = JSON.parse(res);data = data.status;if(data == true){}if(data == false){alert(data);}});}else if(insure == false && tncChkd == true){var url = base_url+'cart/insure/'+itemId+'/'+insure+'/1';microAjax(url, function (res) {var data = JSON.parse(res);data = data.status;if(data == true){document.getElementById(tnc).checked = false;document.getElementById(tc).style.display = 'none';}if(data == false){alert(data);}});}else if(insure == false && tncChkd == true){var url = base_url+'cart/insure/'+itemId+'/'+insure+'/1';microAjax(url, function (res) {var data = JSON.parse(res);data = data.status;if(data == true){document.getElementById(tnc).checked = false;document.getElementById(tc).style.display = 'none';}if(data == false){alert(data);}});}}function dataprotection(e){var id = e.currentTarget.id;var protection = document.getElementById(id).checked;var itemId = e.currentTarget.getAttribute('data-value');var url = base_url+'cart/insure/'+itemId+'/'+protection+'/2';microAjax(url, function (res) {var data = JSON.parse(res);data = data.status;if(data == true){// document.getElementById(tnc).checked = false;// document.getElementById(tc).style.display = 'none';}if(data == false){//alert(data);}});}function checkout(){var chx = document.getElementsByClassName('checkbox');for (var i=0; i<chx.length; i++) {if (chx[i].type == 'checkbox' && chx[i].checked) {var id = chx[i].getAttribute('data-value');var tnc = id+'tnc';if(document.getElementById(tnc).checked == false){if(typeof _gaq != "undefined" && _gaq != null) {_gaq.push(['_trackEvent', 'Insurance', 'Alert for tnc']);}document.getElementById('error').style.display = "block";document.getElementById('error').innerHTML ='Please agree to the terms and conditions to get insurance';window.scrollTo(0,0);return false;break;}}}if(locationServicable == false){var pincode = document.getElementById('pincode').value;if(typeof _gaq != "undefined" && _gaq != null) {_gaq.push(['_trackEvent', 'Cart', 'Location not serviceable',pincode]);}document.getElementById('error').style.display = "block";if(itemsNotServicable == items.length){document.getElementById('error').innerHTML ='Location not servicable. Please try a diferent pincode';}else if(itemsNotServicable != items.length){document.getElementById('error').innerHTML ='Location not servicable for one of the products. Please try a diferent pincode or try removing the product';}window.scrollTo(0,0);return false;}if((notServiceableLocation != undefined) && (notServiceableLocation != 0)){var pincode = document.getElementById('pincode').value;if(typeof _gaq != "undefined" && _gaq != null) {_gaq.push(['_trackEvent', 'Cart', 'Location not serviceable',pincode]);}document.getElementById('error').style.display = "block";if(notServiceableLocation == items.length){document.getElementById('error').innerHTML ='Location not servicable. Please try a diferent pincode';}else if(notServiceableLocation != items.length){document.getElementById('error').innerHTML ='Location not servicable for one of the products. Please try a diferent pincode or try removing the product';}window.scrollTo(0,0);return false;}window.location.href = base_url+'shipping';}var j=0;var locationServicable;var itemsNotServicable=0;function checkShipping(){if(j != 0){j = 0;}var pincode = document.getElementById('pincode').value;if(/^\d+$/.test(pincode) && pincode.length == 6){if(document.getElementById('error')){document.getElementById('error').style.display = 'none';}for(i=0;i<items.length;i++){itemId = items[i].idvar url = base_url+'productinfo/getDeliveryDetails/'+itemId+'/'+pincode;j=i;microAjax(url, function(res){//console.log(res);if(res!=''){data = JSON.parse(res);days = data.business_days;if(days >= 0){var service = items[j].id+'service';document.getElementById(service).style.display = 'none';var delivery = items[j].id+'delivery';if(document.getElementById(delivery)){document.getElementById(delivery).style.display = 'block';var del = items[j].id+'del';document.getElementById(del).innerHTML = data.delivery_estimate;}if(data.is_cod_available_for_location == true){var cod = items[j].id+'cod';if(document.getElementById(cod).style.display == 'none'){document.getElementById(cod).style.display = 'block'}}if(data.on_time_guarantee == true){var otg = items[j].id+'otg';if(document.getElementById(otg).style.display == 'none'){document.getElementById(otg).style.display = 'block'}}}else{var del = items[j].id+'delivery';document.getElementById(del).style.display = 'none';var cod = items[j].id+'cod';document.getElementById(cod).style.display = 'none';var otg = items[j].id+'otg';document.getElementById(otg).style.display = 'none';var service = items[j].id+'service';document.getElementById(service).style.display = 'block';document.getElementById(service).innerHTML = 'Location is not serviceable';locationServicable = false;itemsNotServicable++;}j--;}});}}else{document.getElementById('error').style.display = 'block';document.getElementById('error').innerHTML = 'Invalid pincode!'}}function shomoreredirect(){window.location.href = base_url;}