Rev 5234 | Rev 5358 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
$(function(){$('#loopedSlider').loopedSlider();runEffect();$(".controls").tabs();$('#forgot_username_link').tipsy({gravity: 'w'});$("#zipcode").val($("#defaultpincode").val());if(typeof Entity != 'undefined'){var select = $("#colorSelector");if(Entity.orderededItems){$.each(Entity.orderedItems, function(index, sort) {select.find('option[value="' + sort + '"]').appendTo(select);});$("#item_id").val(Entity.orderedItems[0]);}select.find("option:eq(0)").remove();updateEstimate(getSeletectedItemId());}var prodid = $("#product_id").val();add_to_storage_set("histitems", prodid);load_accessories_widget();load_most_compared_widget();myNotes.getNotes();// Fix to always show first image's title on page loadif ("undefined" != typeof(title_1)){$('.slides .modelName').html(title_1[0]);}function getSeletectedItemId(){return $("#item_id").val();}/*** Code to track user clicks on Product slides and 'Proceed to Payment' option*/$('a.vt').click(function(){trackEventWithGA('Product', $(this).children('span').text(), $('title').text().split('|')[0].trim());});$('#computeShippingEstimate').click(function(){updateEstimate(getSeletectedItemId());});$("#addToCart").click(function(){jQuery.ajax({type: "POST",url: "/addtocart",data: "productid=" + getSeletectedItemId(),success: function(msg) {if(msg == "") {trackEventWithGA('Order', 'Add to Cart', getSeletectedItemId() + '');window.location = "/cart";} else {var productDetail = $("#productDetail");var prodInfo = $(productDetail).find("span.brand").html() + $(productDetail).find("span.product-name").html();displayRelatedProducts(msg);trackEventWithGA('Order', 'OOS Lightbox', prodInfo);}}});});$("#colorSelector").change(function(){var itemid = $("#colorSelector option:selected").val();$('#sp').html(PARAMETERS[itemid].SP);$('#mrp').html(PARAMETERS[itemid].MRP);$('#saving').html(PARAMETERS[itemid].SAVING);$("#item_id").val(itemid);updateEstimate(itemid);return false;});$(".util_compare").click(function() {$.colorbox({inline:true,href:"#compareLightBox",width:"350px",height:"230px",onComplete: function(){$('#compareLightBox').show();},onCleanup: function(){$('#compareLightBox').hide();}});});$('.util_addnewresearch').click(function(){addResearch('', 'single');});$('#mobilename').keypress(function(e) {if(e.keyCode == 13) {return compareProducts($("#compare_continue").attr("producttype"));}});$("#compare_continue").click(function() {return compareProducts($(this).attr("producttype"));});$('.tooltip').click(function() {trackEventWithGA('Product', 'Helpdoc Click', $(this).attr('name'));});$('.tooltip').each(function(index) {$(this).qtip({style: { width: 300, overflow: 'auto',tip: { corner: 'topLeft' },border: { width: 2, radius: 2, color: '#DDDDDD' } },show: { when: { event: 'click' } },content: { url: "/helpdocs/" + $(this).attr('name'), title: { text: ' ', button: 'Close'} },hide: { when: { event: 'unfocus' } },position: { adjust: {screen: true} }});});function compareProducts(productType){var hyphenatedProductType = productType.replace(/ +/g, '-').toLowerCase();var productName = $("#mobilename").val();var hypenatedNameTwo = productName.replace(/ +/g, '-').toLowerCase();var productTwo = productIdNames[productType][productName];if(typeof productTwo == 'undefined'){alert("Please select a valid product");return false;}var productOne = $("#catalog_id").val();var prodDetail = $("#productDetail");var productNameOne = $(prodDetail).find("span.brand").html() + " " + $(prodDetail).find("span.product-name").html();var hyphenateNameOne = productNameOne.replace(/ +/g, '-').toLowerCase();window.location = "/compare-" + hyphenatedProductType + "/"+ hyphenateNameOne + "-vs-" + hypenatedNameTwo + "?p1="+productOne+"&p2="+productTwo;}$("#accessories table td div a").live('click', function() {var productId = $(this).parent().parent().parent().children().find('input[type=checkbox]').val();trackEventWithGA('Widget', 'Accessory Click', productId);});});function changeSignInClass(){if(document.getElementById("signinClass").className.indexOf("signin1") > -1) {document.getElementById("signinClass").className = 'signin';} else {document.getElementById("signinClass").className = 'signin1';}}function updateEstimate(itemId) {itemId = itemId || $("#colorSelector option:selected").val();jQuery.ajax({type: "GET",url: "/estimate/" + $("#zipcode").val() + "_" + itemId,beforeSend: function() {$("#shipping_time").show();$("#shipping_time_1").hide();$("#shipping_time .red").html("<img src='/images/loader_l.gif'> business days");},success: function(msg) {var response = eval('(' + msg + ')');var deliveryEstimate = parseInt(response['delivery_estimate']);var isCODAvailableForLocation = (response['is_cod_available_for_location'] === 'true');if(deliveryEstimate == -1) {$("#shipping_time").hide();$("#shipping_time_1").show();} else {$("#shipping_time .red").html(deliveryEstimate + ' Business Days');}if (isCODAvailableForLocation) {$('#cod').show();} else {$('#cod').hide();}}});}function load_most_compared_widget(){jQuery.ajax({type : "GET",url : "/most-compared-products/" + $("#product_id").val(),cache: false,success : function(html) {$("#mostcompared").html(html);// Product Title$("#mostcompared table td div a").each(function() {$(this).truncate({addtitle : true});});// Product Price$("#mostcompared table td div div.price").each(function() {$(this).truncate({addtitle : true});});// Product Details$("#mostcompared table td div div.text").each(function() {$(this).truncate( {addtitle : true});});}});}