Subversion Repositories SmartDukaan

Rev

Rev 8934 | Rev 9301 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
6967 kshitij.so 1
function toggle(containerId){
8976 kshitij.so 2
	var divC = document.getElementById(containerId);
3
	if (divC.style.display == 'none') {
4
		divC.style.display = 'block';
5
	} else if (divC.style.display == 'block'){
6
		divC.style.display = 'none';
7
	}
8
	else {
9
		divC.style.display = 'none';
10
	}
11
}
6967 kshitij.so 12
 
8976 kshitij.so 13
function checkEmiObject (value) {
14
	if (value==undefined) {
15
		return "1";
16
	} else {
17
		return "2";
18
	}
19
}
20
 
4126 varun.gupt 21
$(function(){
4984 varun.gupt 22
	function CollapsibleWidget(container)	{
8976 kshitij.so 23
 
4984 varun.gupt 24
		this.widgetContainer = container;
25
		this.collapsbiles = $(container).children('.common-widget-control-bar, .common-widget-content-area');
26
		this.isCollapsed = null;
8976 kshitij.so 27
 
4984 varun.gupt 28
		this.collapse = function()	{
29
			$(this.collapsbiles).each(function()	{
30
				$(this).slideUp();
31
			});
32
			this.isCollapsed = true;
33
		};
8976 kshitij.so 34
 
4984 varun.gupt 35
		this.open = function()	{
36
			$(this.collapsbiles).each(function()	{
37
				$(this).slideDown();
38
			});
39
			this.isCollapsed = false;
40
		};
8976 kshitij.so 41
 
4984 varun.gupt 42
		this.test = function()	{
43
		};
44
	}
8976 kshitij.so 45
 
4984 varun.gupt 46
	ResearchWidget.prototype = new CollapsibleWidget();
47
	ResearchWidget.prototype.constructor = CollapsibleWidget;
8976 kshitij.so 48
 
4984 varun.gupt 49
	function ResearchWidget(container)	{
50
		CollapsibleWidget.call(this, container);
51
	}
8976 kshitij.so 52
 
4798 varun.gupt 53
	function updateCompareCount()	{
54
		$('#research_compare_count').html($('#myresearch input[type="checkbox"]:checked').length);
55
	}
8976 kshitij.so 56
 
4126 varun.gupt 57
	/** Sidebar Widgets **/
8976 kshitij.so 58
 
6840 kshitij.so 59
	$('#otg_know_more,.otg_know_more').click(function(){
6552 kshitij.so 60
		$.colorbox({
8976 kshitij.so 61
			width: "490px",
62
			height: "420px",
63
			inline: true,
64
			href: "<h3 style='text-align: center; margin: 18px; font-size: 14px;'>On Time Guarantee, We Pay if we Delay</h3>" +
65
			"<p style='text-align: justify; margin-left: 12px; margin-right: 12px; margin-bottom: 9px; line-height: 22px;'>Saholic stands for 100% on time delivery. We ensure all your orders reach your doorstep on or "+
66
			"before the promised delivery date. In the rare case that we deliver an order later than promised "+
67
			"we will compensate you.This Guarantee is Valid on"+
68
			"</p>" +
69
			"<ul style='list-style: disc none none; margin-left: 25px; text-align: justify; margin-right:12px; line-height: 22px;'><li>All Mobiles, Cameras, Laptops, Tablets and Accessories above Rs. 2000 in value."+
70
			"</li>"+
71
			"<li>Orders Placed using Credit/Debit Card, Net Banking, EMI, Prepaid Cash Cards."+
72
			"</li>"+
73
			"</ul>"+
74
			"<p style='text-align: justify; line-height: 22px; margin: 12px;'>Compensation for delay is in the form of Gift Vouchers at the rate of Rs. 50 per business day. " +
75
			"GV can be applied to ANY product on Saholic.com without limitation.</p>"+
76
			"<span class='right'><a target='_blank' href='/static/on-time-guarantee' style='margin-right: 12px; color: #006699';>Detailed Terms & Conditions</a></span>",
77
			onComplete: function(){
78
				trackEventWithGA('Widget', 'OTG Know More is clicked', '');
6552 kshitij.so 79
			}
8976 kshitij.so 80
		});
6552 kshitij.so 81
	});
7680 rajveer 82
 
7809 rajveer 83
	$('#cod_know_more,.cod_know_more').click(function(){
7680 rajveer 84
		$.colorbox({
8976 kshitij.so 85
			width: "400px",
86
			height: "200px",
87
			inline: true,
88
			href: "<ul style='list-style:inside; margin-left: 25px; margin-right:12px; font-size:15px; line-height: 22px;'>"
89
				+ "Expected Delivery Date for "
90
				+"<li list-style:inside>Prepaid orders is " + $("#shipping_time .red").html() + "</li>"+
91
				"<li list-style:inside>" + $("#shipping_time .cod").html() + "</li>"+
92
				"</ul>",
93
				onComplete: function(){
94
					trackEventWithGA('Widget', 'COD Know More is clicked', '');
95
				}
96
		});
7680 rajveer 97
	});
98
 
8976 kshitij.so 99
 
4237 varun.gupt 100
	$('#shoppingExpInfo').click(function(){
101
		$.colorbox({
8976 kshitij.so 102
			width: "550px",
103
			height: "320px",
104
			inline: true,
105
			href: "<h3>Shopping with Saholic.com is completely safe</h3><br />" +
106
			"<b>1.</b> We are part of Spice Group - India's # 1 Mobile retailer.<br /><br />" +
107
			"<b>2.</b> We procure directly from the Manufacturers - Hence we only sell genuine products with full Manufacturer Warranty.<br /><br />" +
108
			"<b>3.</b> We provide free Next Day Delivery to most locations - You can check the delivery time to your location by entering your pin code on the product page.<br /><br />" +
109
			"<b>4.</b> We use the best Internet Security technology - Your payment is 100% secure.<br />",
4372 varun.gupt 110
			onComplete: function(){
6261 amit.gupta 111
				trackEventWithGA('Widget', 'Safe shopping sticky banner is clicked', '');
4372 varun.gupt 112
			}
8976 kshitij.so 113
		});
4237 varun.gupt 114
	});
8976 kshitij.so 115
 
8434 kshitij.so 116
	$('#promotion-diwali').click(function(){
117
		$.colorbox({
8976 kshitij.so 118
			width: "550px",
119
			height: "280px",
120
			inline: true,
121
			href: "<h3 style='font-size:15px; text-align:center; font-weight:bold; margin-left:15px; margin-top:5px;margin-bottom:10px'>Terms and Conditions</h3>" +
122
			"<ul style='text-align: justify; padding-right: 10px; width: 93%; padding-left: 16px; line-height: 25px;'>"+
123
			"<li>The offer is valid on all accessories.</li>"+
124
			"<li>A discount of 10% (upto a maximum of Rs.500) will be applicable.</li>"+
125
			"<li>The discount can be enjoyed upon using the coupon code: <b>saholicdiwali</b></li>"+
126
			"<li> The offer is also valid on Cash on Delivery (COD) orders.</li>"+ 
127
			"<li>Only one order per person will be accepted.</li>"+
128
			"<li>The offer is valid till November 12, 2013 or till stocks last.</li>"+
129
			"<li>Saholic reserves the right to end promotion without any notice.</li>"+ 
130
			"</ul>",
8434 kshitij.so 131
			onComplete: function(){
132
				trackEventWithGA('Widget', 'Saholic Diwali sticky banner is clicked', '');
133
			}
8976 kshitij.so 134
		});
8434 kshitij.so 135
	});
8976 kshitij.so 136
 
137
 
138
 
6970 kshitij.so 139
	$('.insuranceInfo').click(function(){
140
		$.colorbox({
8976 kshitij.so 141
			width: "520px",
142
			height: "280px",
143
			inline: true,
144
			href: "<h3 style='font-size:15px; text-align:center; font-weight:bold; margin-left:15px; margin-top:5px;margin-bottom:10px'>Exclusively at Saholic</h3>" +
145
			"<ul style='text-align: justify; padding-right: 10px; width: 93%; padding-left: 16px; line-height: 25px;'>"+
146
			"<li>Only Saholic brings to you an option to protect your smartphone against theft and burglary.</li>"+
147
			"<li>While buying your favourite mobile from Saholic, you can opt for 1 year WorldWide theft insurance.</li>"+
148
			"<li>Introductory offer - You can opt for insurance by paying an all inclusive nominal fee of 1.5% of price of your mobile.</li>"+
149
			"<a target='_blank' href='/static/insurance-terms' style='float: right; text-decoration: none;color:#006699';>Detailed Terms and Conditions</a>"+
150
			"</ul>",
6970 kshitij.so 151
			onComplete: function(){
152
				trackEventWithGA('Widget', 'Insurance sticky banner is clicked', '');
153
			}
8976 kshitij.so 154
		});
6970 kshitij.so 155
	});
8976 kshitij.so 156
 
6959 kshitij.so 157
	$('.emiInfo').click(function(){
8976 kshitij.so 158
		jQuery.ajax({
159
			type : "GET",
160
			url : "/emi-info",
161
			cache: false,
162
			success : function(json){
163
				var emiPopUp = jQuery("#emi_pop_up_upper");
164
				var emiPopUpLower = jQuery("#emi_pop_up_lower");
165
				var parsedData = JSON.parse(json);
166
				var emiPopUpTd=[];
167
				var emiPopUpLowerTd=[];
168
				jQuery("#emi_pop_up_upper tr.emi_pop_up_emirow").remove();
169
				jQuery("#emi_pop_up_lower tr.emi_pop_up_emirow_lower").remove();
170
				emiPopUp.find("tr.emi_pop_up_mk_tenure").after('<tr class="emi_pop_up_emirow"></tr>');
171
				emiPopUpLower.find("tr.emi_pop_up_mk_tenure_lower").after('<tr class="emi_pop_up_emirow_lower"></tr>');
172
				for (var i=0; i<parsedData.Value.length; i++){
173
					emiPopUpTd.push('<tr class="emi_pop_up_emirow"><td><span style="font-size:11px;font-weight:normal;">' +parsedData.Value[i].Bank+ '</span></td>');
174
					if (checkEmiObject(parsedData.Value[i].T3Months)==1){
175
						emiPopUpTd.push('<td><span style="font-size:11px"><b>' +'-'+ '</b></span></td>');
176
					}
177
					else{
178
						emiPopUpTd.push('<td><span style="font-size:11px" class="rupee-icon"><b>' +parsedData.Value[i].T3Months+ '</b></span></td>');
179
					}
180
					if (checkEmiObject(parsedData.Value[i].T6Months)==1){
181
						emiPopUpTd.push('<td><span style="font-size:11px"><b>' +'-'+ '</b></span></td>');
182
					}
183
					else{
184
						emiPopUpTd.push('<td><span style="font-size:11px" class="rupee-icon"><b>' +parsedData.Value[i].T6Months+ '</b></span></td>');
185
					}
186
					if (checkEmiObject(parsedData.Value[i].T9Months)==1){
187
						emiPopUpTd.push('<td><span style="font-size:11px"><b>' +'-'+ '</b></span></td>');
188
					}
189
					else{
190
						emiPopUpTd.push('<td><span style="font-size:11px" class="rupee-icon"><b>' +parsedData.Value[i].T9Months+ '</b></span></td>');
191
					}
192
					if (checkEmiObject(parsedData.Value[i].T12Months)==1){
193
						emiPopUpTd.push('<td><span style="font-size:11px"><b>' +'-'+ '</b></span></td>');
194
					}
195
					else{
196
						emiPopUpTd.push('<td><span style="font-size:11px" class="rupee-icon"><b>' +parsedData.Value[i].T12Months+ '</b></span></td>');
197
					}
198
					if (checkEmiObject(parsedData.Value[i].T18Months)==1){
199
						emiPopUpTd.push('<td><span style="font-size:11px"><b>' +'-'+ '</b></span></td></tr>');
200
					}
201
					else{
202
						emiPopUpTd.push('<td><span style="font-size:11px" class="rupee-icon"><b>' +parsedData.Value[i].T18Months+ '</b></span></td></tr>');
203
					}
204
 
205
				}
206
				emiPopUp.find("tr.emi_pop_up_emirow").after(emiPopUpTd.join(""));
207
				for (var i=0; i<parsedData.BankCharges.length; i++){
208
					emiPopUpLowerTd.push('<tr class="emi_pop_up_emirow_lower"><td><span style="font-size:11px;font-weight:normal;">' +parsedData.BankCharges[i].Bank+ '</span></td>');
209
					if (checkEmiObject(parsedData.BankCharges[i].T3Months)==1){
210
						emiPopUpLowerTd.push('<td><span style="font-size:11px"><b>' +'-'+ '</b></span></td>');
211
					}
212
					else{
213
						emiPopUpLowerTd.push('<td><span style="font-size:11px"><b>' +parsedData.BankCharges[i].T3Months+'%'+ '</b></span></td>');
214
					}
215
					if (checkEmiObject(parsedData.BankCharges[i].T6Months)==1){
216
						emiPopUpLowerTd.push('<td><span style="font-size:11px"><b>' +'-'+ '</b></span></td>');
217
					}
218
					else{
219
						emiPopUpLowerTd.push('<td><span style="font-size:11px"><b>' +parsedData.BankCharges[i].T6Months+'%'+ '</b></span></td>');
220
					}
221
					if (checkEmiObject(parsedData.BankCharges[i].T9Months)==1){
222
						emiPopUpLowerTd.push('<td><span style="font-size:11px"><b>' +'-'+ '</b></span></td>');
223
					}
224
					else{
225
						emiPopUpLowerTd.push('<td><span style="font-size:11px"><b>' +parsedData.BankCharges[i].T9Months+'%'+ '</b></span></td>');
226
					}
227
					if (checkEmiObject(parsedData.BankCharges[i].T12Months)==1){
228
						emiPopUpLowerTd.push('<td><span style="font-size:11px"><b>' +'-'+ '</b></span></td>');
229
					}
230
					else{
231
						emiPopUpLowerTd.push('<td><span style="font-size:11px"><b>' +parsedData.BankCharges[i].T12Months+'%'+ '</b></span></td>');
232
					}
233
					if (checkEmiObject(parsedData.Value[i].T18Months)==1){
234
						emiPopUpLowerTd.push('<td><span style="font-size:11px"><b>' +'-'+ '</b></span></td></tr>');
235
					}
236
					else{
237
						emiPopUpLowerTd.push('<td><span style="font-size:11px"><b>' +parsedData.BankCharges[i].T18Months+'%'+'</b></span></td></tr>');
238
					}
239
				}
240
				emiPopUpLower.find("tr.emi_pop_up_emirow_lower").after(emiPopUpLowerTd.join(""));
241
			}
242
		});
6453 kshitij.so 243
		$.colorbox({
8976 kshitij.so 244
			inline:true, 
245
			href:"#emiPopUp",
246
			width:"600px",
247
			height:"410px",
248
 
6453 kshitij.so 249
			onComplete: function(){
8976 kshitij.so 250
				$('#emiPopUp').show();
251
			},
252
			onCleanup: function(){
253
				$('#emiPopUp').hide();
6453 kshitij.so 254
			}
8976 kshitij.so 255
		});
256
		trackEventWithGA('Widget', 'Emi info widget is clicked', '');
6453 kshitij.so 257
	});
8976 kshitij.so 258
 
6792 vikram.rag 259
	$('a.mk_best_deal_detail').live('click', function(){
260
		var offerLinkHtml = '';
261
		if(OFFER_HELP_LINK!='$OFFER_DETAIL_LINK') {
6795 vikram.rag 262
			offerLinkHtml = '<a target="_blank" href="' +OFFER_HELP_LINK + '" style="z-index: 1; float: right; bottom: 0px; right: 0px; margin: 15px; position: relative;">More</a></span>';
6792 vikram.rag 263
		}
264
		$.colorbox({
265
			width: "550px",
8976 kshitij.so 266
			height: "300px",
267
			inline: true,
268
			href: '<h3 style="text-align: left; padding: 10px;">Offer Details</h3>' +
269
			'<p style="text-align: justify; line-height: 22px; margin: 12px;">' + OFFER_HELP_TEXT +
270
			'</p><span class="right">' + offerLinkHtml 
6792 vikram.rag 271
		});
272
	});
8976 kshitij.so 273
 
274
 
6245 kshitij.so 275
	$('#pickupstoreInfo').click(function(){
276
		$.colorbox({
8976 kshitij.so 277
			width: "550px",
278
			height: "370px",
279
			inline: true,
280
			href: "<h3>Frequently Asked Questions</h3><br />" +
281
			"<b style='color: black; cursor: default;'>Q)</b> What is 'Buy Online & Pickup in Store' ?<br /><br />" +
282
			"<b style='color: black; cursor: default;'>A)</b> Buy Online from Saholic.Com and pickup your product from the nearest Spice Hotspot Retail Store.<br /><br />" +
283
			"<b style='color: black; cursor: default;'>Q)</b> How do i avail this facility ?<br /><br />" +
284
			"<b style='color: black; cursor: default;'>A)</b> Simply select Pickup In Store On the Shipping Page and select your nearest store. Please note this facility is available only in Delhi/NCR.</a><br /><br />"+
285
			"<b style='color: black; cursor: default;'>Q)</b> When will the product be available for pickup ?<br /><br />" +
286
			"<b style='color: black; cursor: default;'>A)</b> You can enter your pin code on the Product Page to find estimated time to deliver. After placing the order we will also give you the estimated date for pickup.</a><br /><br />",
287
 
6245 kshitij.so 288
			onComplete: function(){
6262 amit.gupta 289
				var ev = "Product Page";
6303 amit.gupta 290
				var label = window.location.pathname;
6264 amit.gupta 291
				if (label=="" || label=="#")
6261 amit.gupta 292
				{
6303 amit.gupta 293
					label = "";
6262 amit.gupta 294
					ev = "Home Page";
6261 amit.gupta 295
				}
6262 amit.gupta 296
				else if (label.indexOf("shipping") != -1){
297
					ev = "Shipping Page";
298
					var blkstr = [];
6263 amit.gupta 299
					jQuery("#cartDetail").find("span.cart-item-name").each(function(key,str){
6262 amit.gupta 300
						blkstr.push(str);
301
					});
6303 amit.gupta 302
					label = blkstr.join(", ");
303
				} else if (label.substr(label.lastIndexOf('/') + 1).length==5 && typeof label.substr(label.lastIndexOf('/') + 1) =="number") {
304
					ev = "Category Page";
305
				} else if (label.substr(label.lastIndexOf('-') + 1).length==7  && typeof label.substr(label.lastIndexOf('-') + 1) =="number") {
306
					ev = "Product Page";
6262 amit.gupta 307
				}
6261 amit.gupta 308
				trackEventWithGA('Pickup in Store LightBox', ev, label);
6245 kshitij.so 309
			}
8976 kshitij.so 310
		});
6245 kshitij.so 311
	});
4126 varun.gupt 312
 
5420 amit.gupta 313
	$('.common-widget-top-bar').live('click', function(e, callback){
4126 varun.gupt 314
		var isColapsed = $(this).data('is_colapsed') == true ? true : false;
315
		var widgetBox = $(this).siblings('.common-widget-content-area');
316
		var controlBox = $(this).siblings('.common-widget-control-bar');
317
		var controlBoxArrowImg = $(this).find('img');
8976 kshitij.so 318
 
4126 varun.gupt 319
		if (isColapsed)	{
320
			if(controlBox.length > 0)	{
321
				$(controlBox).slideDown('fast', function(){
5420 amit.gupta 322
					$(widgetBox).slideDown('fast', callback);
4126 varun.gupt 323
					$(controlBoxArrowImg).attr('src', '/images/IconDownArrow_UnselectedTab.png');
324
				});
325
			} else	{
326
				$(widgetBox).slideDown();
327
				$(controlBoxArrowImg).attr('src', '/images/IconDownArrow_UnselectedTab.png');
328
			}
329
		} else	{
330
			$(widgetBox).slideUp(function(){
331
				$(controlBox).slideUp('fast');
332
				$(controlBoxArrowImg).attr('src', '/images/IconRightArrow_UnselectedTab.png');
333
			});
334
		}
335
		$(this).data('is_colapsed', !isColapsed);
336
	});
8976 kshitij.so 337
 
4126 varun.gupt 338
	/**
339
	 * Update count of products checked for comparison
340
	 **/
341
	$('#myresearch input[type="checkbox"]').live('click', function(){
4798 varun.gupt 342
		updateCompareCount();
4126 varun.gupt 343
	});
8976 kshitij.so 344
 
4126 varun.gupt 345
	$("#research_compare").live('click', function(){
346
		var seldata = "";
5322 amit.gupta 347
		var prodnames = "";
4126 varun.gupt 348
		var tot = 1;
349
		var saprt = "";
350
		var par = $('#myresearch').find('input[type=checkbox]:checked');
4926 varun.gupt 351
		var haveSameProductType = true;
352
		var productType = null;
8976 kshitij.so 353
 
4126 varun.gupt 354
		$(par).each(function(){
8976 kshitij.so 355
 
4926 varun.gupt 356
			if(productType != null && productType != $(this).attr('producttype'))	{
357
				haveSameProductType = false;
358
			}
359
			productType = $(this).attr('producttype');
8976 kshitij.so 360
 
4126 varun.gupt 361
			if(tot == 1)	{
5358 amit.gupta 362
				prodnames += $(this).attr("title").replace(/ +/g, '-').replace(/\/+/g,'-').replace(/-+/g,'-').toLowerCase();
4126 varun.gupt 363
				seldata += "p" + tot + "=" + $(this).val();
364
			} else	{
365
				seldata += "&p" + tot + "=" + $(this).val();
5358 amit.gupta 366
				prodnames += "-vs-" + $(this).attr("title").replace(/ +/g, '-').replace(/\/+/g,'-').replace(/-+/g,'-').toLowerCase();
4126 varun.gupt 367
			}
368
			tot ++;
369
		});
8976 kshitij.so 370
 
4926 varun.gupt 371
		if(! haveSameProductType)	{
372
			alert("Only products of same category can be compared");
373
		} else if(tot > 6)	{
4126 varun.gupt 374
			alert("Can compare upto five products only.");
375
		} else if(tot > 2)	{
5552 phani.kuma 376
			window.location = "/compare-" + productType.replace(/ +/g, '-').toLowerCase() + "/" + prodnames + "?" + seldata+"&fromsrc=comparison_widget";
4126 varun.gupt 377
		} else	{
378
			alert("Please select atleast two products");
379
		}
380
	});
8976 kshitij.so 381
 
4126 varun.gupt 382
	$("#research_delete").live('click', function(){
383
		var research_tot = $("#research_total").val();
384
		var seldata = [];
385
		var tot = 0;
386
		var saprt = "";
387
		var par = $('#myresearch').find('input[type=checkbox]:checked');
388
 
389
		$(par).each(function(){
390
			seldata.unshift($(this).val());
391
			tot ++;
392
		});
393
 
394
		if(tot > 0)	{
395
			var t = (research_tot * 1) - (tot * 1);
396
			$("#research_total").val(t);
397
 
398
			jQuery.ajax({
399
				type: "GET",
400
				url: "/deletefromresearch/[" + seldata + "]?_method=delete",
401
				success: function(msg)	{
402
					jQuery.each(seldata, function(intIndex, objValue){
403
						delete_from_storage_set("resitems", objValue);
404
						$("#myresearch").find("#" + objValue).fadeOut('slow', function() {
405
							$(this).remove();
406
							if(t === 0)	{
407
								$("#research_default").css("display", "block");
408
							}
409
						});
410
					});
8976 kshitij.so 411
 
4922 varun.gupt 412
					//Updating the count
413
					$('#research_compare_count').html($('#myresearch input[type="checkbox"]:checked').length - seldata.length);
8976 kshitij.so 414
 
4984 varun.gupt 415
					if ($('#myresearch input[type="checkbox"]').length - seldata.length <= 0)	{
416
						$("#myresearch").children(".common-widget-top-bar").trigger('click');
417
					}
4126 varun.gupt 418
				}
419
			});
420
		} else	{
421
			alert("Please select atleast one product");
422
		}
423
	});
8976 kshitij.so 424
 
4126 varun.gupt 425
	// No uid cookie
426
	if (!$.cookie("uid"))	{
427
		// No uid in storage
428
		if (!$.Storage.get("uid"))	{
429
			if (!$.Storage.get("resitems"))	{
430
				$.Storage.set("resitems", "[]");
431
			}
432
			if (!$.Storage.get("histitems"))	{
433
				$.Storage.set("histitems", "[]");
434
			}
435
		}
436
		else	{			// uid in storage : logout
437
			$.Storage.remove("uid");
438
			$.Storage.set("resitems", "[]");
439
			$.Storage.set("histitems", "[]");
440
		}
441
		load_research_widget();
442
		load_history_widget();
443
	}
444
	else	{				// With uid cookie
445
		var cookie = $.cookie("uid");
446
		// Just logged in merge storage items
447
		if (!$.Storage.get("uid"))	{
448
			$.Storage.set("uid", cookie);
449
			merge_history_items();
450
			load_research_items();
451
		}
452
		else	{
453
			// UID changed
454
			if ( cookie != $.Storage.get("uid"))	{
455
				$.Storage.set("uid", cookie);
456
				$.Storage.set("resitems", "[]");
457
				$.Storage.set("histitems", "[]");
458
				merge_history_items();
459
				load_research_items();
460
			}
461
			else	{		// Uid is same
462
				if (!$.Storage.get("resitems"))	{
463
					$.Storage.set("resitems", "[]");
464
					load_research_items();
465
				}
466
				else	{
467
					load_research_widget();
468
				}
8976 kshitij.so 469
 
4126 varun.gupt 470
				if (!$.Storage.get("histitems"))	{
471
					$.Storage.set("histitems", "[]");
472
					merge_history_items();
473
				}
474
				else	{
475
					load_history_widget();
476
				}
477
			}
478
		}
479
	}
8976 kshitij.so 480
 
4798 varun.gupt 481
	function load_research_items(){
482
		jQuery.ajax({
483
			type: "GET",
484
			url: "/myresearch",
485
			cache: false,
486
			success: function(json) {
8976 kshitij.so 487
				$.Storage.set("resitems", json);
488
				load_research_widget();
489
			}
4798 varun.gupt 490
		});
491
	}
492
 
493
	function load_research_widget(){
494
		var myResearchWidgetContainer = $("#myresearch");
8976 kshitij.so 495
 
4798 varun.gupt 496
		if($(myResearchWidgetContainer).length == 0) {
497
			return;
498
		}
499
		var resitems = $.Storage.get("resitems");
8976 kshitij.so 500
 
4798 varun.gupt 501
		if (resitems == "[]") {
502
			var emptyResWidgetHtml = '<table border="0" width="100%" cellspacing="1" cellpadding="0" id="research_default">\
8976 kshitij.so 503
				<tbody>\
504
				<tr><td align="center"><b>Add items to compare list</b></td></tr>\
505
				</tbody>\
506
				</table>';
4798 varun.gupt 507
			$(myResearchWidgetContainer).find(".common-widget-content-area").html(emptyResWidgetHtml);
508
			$(myResearchWidgetContainer).children(".common-widget-top-bar").trigger('click');
509
			return;
510
		}
511
		var params = "/" + resitems;
8976 kshitij.so 512
 
4798 varun.gupt 513
		jQuery.ajax({
514
			type : "GET",
515
			url : "/myresearch" + params,
516
			cache: true,
517
			success : function(html) {
8976 kshitij.so 518
				$("#myresearch").html(html);
519
				updateCompareCount();
4798 varun.gupt 520
 
8976 kshitij.so 521
				// Product Title
522
				$("#myresearch table td div a.truncate").each(function() {
523
					$(this).truncate({addtitle : true});
524
				});
4798 varun.gupt 525
 
8976 kshitij.so 526
				// Product Price
527
				$("#myresearch table td div div.price").each(function() {
528
					$(this).truncate({addtitle : true});
4798 varun.gupt 529
				});
530
 
8976 kshitij.so 531
				// Product Details
532
				$("#myresearch table td div div.text").each(function() {
533
					$(this).truncate( {addtitle : true});
4798 varun.gupt 534
				});
8976 kshitij.so 535
			}
4798 varun.gupt 536
		});
537
	}
7846 rajveer 538
});
539
 
7849 rajveer 540
function displayCod(item_id)	{
7846 rajveer 541
	$.colorbox({
7872 rajveer 542
		width: "400px",
543
		height: "200px",
7846 rajveer 544
		inline: true,
7873 rajveer 545
		href: "<ul style='list-style:inside; margin-left: 25px; text-align: justify; margin-right:12px; font-size:15px; line-height: 22px;'>"
7872 rajveer 546
			+ "Expected Delivery Date for "
7873 rajveer 547
			+"<li list-style:inside>Prepaid orders is " + $('#days_' + item_id).html() + "</li>"+
7879 rajveer 548
			"<li list-style:inside>Cash On Delivery orders is " + $('#coddays_' + item_id).html() + "</li>"+
8976 kshitij.so 549
			"</ul>",
550
			onComplete: function(){
551
				trackEventWithGA('Widget', 'COD Know More is clicked', '');
552
			}
7846 rajveer 553
	});
554
}