Subversion Repositories SmartDukaan

Rev

Rev 8976 | Rev 9355 | 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
	});
9301 kshitij.so 156
 
157
	$('.one_assist_know_more').click(function(){
158
		$.colorbox({
159
			width: "520px",
160
			height: "240px",
161
			inline: true,
162
			href: "<h3 style='font-size:15px; text-align:center; font-weight:bold; margin-left:15px; margin-top:5px;margin-bottom:10px'>An exclusive offer from Saholic</h3>" +
163
			"<ul style='text-align: justify; padding-right: 10px; width: 93%; padding-left: 16px; line-height: 25px;'>"+
164
			"<li>Saholic brings to you a solution to protect your smartphone data against theft, loss and other unfortunate incidents.</li>"+
165
			"<li>While buying your favourite mobile from Saholic, you can opt for 3 months free data backup and SIM-blocking service from OneAssist.</li>"+
166
			"<a target='_blank' href='/static/oneassist-terms' style='float: right; text-decoration: none;color:#006699';>Know More</a>"+
167
			"</ul>",
168
			onComplete: function(){
169
				trackEventWithGA('Widget', 'One assist know more is clicked', '');
170
			}
171
		});
172
	});
8976 kshitij.so 173
 
6959 kshitij.so 174
	$('.emiInfo').click(function(){
8976 kshitij.so 175
		jQuery.ajax({
176
			type : "GET",
177
			url : "/emi-info",
178
			cache: false,
179
			success : function(json){
180
				var emiPopUp = jQuery("#emi_pop_up_upper");
181
				var emiPopUpLower = jQuery("#emi_pop_up_lower");
182
				var parsedData = JSON.parse(json);
183
				var emiPopUpTd=[];
184
				var emiPopUpLowerTd=[];
185
				jQuery("#emi_pop_up_upper tr.emi_pop_up_emirow").remove();
186
				jQuery("#emi_pop_up_lower tr.emi_pop_up_emirow_lower").remove();
187
				emiPopUp.find("tr.emi_pop_up_mk_tenure").after('<tr class="emi_pop_up_emirow"></tr>');
188
				emiPopUpLower.find("tr.emi_pop_up_mk_tenure_lower").after('<tr class="emi_pop_up_emirow_lower"></tr>');
189
				for (var i=0; i<parsedData.Value.length; i++){
190
					emiPopUpTd.push('<tr class="emi_pop_up_emirow"><td><span style="font-size:11px;font-weight:normal;">' +parsedData.Value[i].Bank+ '</span></td>');
191
					if (checkEmiObject(parsedData.Value[i].T3Months)==1){
192
						emiPopUpTd.push('<td><span style="font-size:11px"><b>' +'-'+ '</b></span></td>');
193
					}
194
					else{
195
						emiPopUpTd.push('<td><span style="font-size:11px" class="rupee-icon"><b>' +parsedData.Value[i].T3Months+ '</b></span></td>');
196
					}
197
					if (checkEmiObject(parsedData.Value[i].T6Months)==1){
198
						emiPopUpTd.push('<td><span style="font-size:11px"><b>' +'-'+ '</b></span></td>');
199
					}
200
					else{
201
						emiPopUpTd.push('<td><span style="font-size:11px" class="rupee-icon"><b>' +parsedData.Value[i].T6Months+ '</b></span></td>');
202
					}
203
					if (checkEmiObject(parsedData.Value[i].T9Months)==1){
204
						emiPopUpTd.push('<td><span style="font-size:11px"><b>' +'-'+ '</b></span></td>');
205
					}
206
					else{
207
						emiPopUpTd.push('<td><span style="font-size:11px" class="rupee-icon"><b>' +parsedData.Value[i].T9Months+ '</b></span></td>');
208
					}
209
					if (checkEmiObject(parsedData.Value[i].T12Months)==1){
210
						emiPopUpTd.push('<td><span style="font-size:11px"><b>' +'-'+ '</b></span></td>');
211
					}
212
					else{
213
						emiPopUpTd.push('<td><span style="font-size:11px" class="rupee-icon"><b>' +parsedData.Value[i].T12Months+ '</b></span></td>');
214
					}
215
					if (checkEmiObject(parsedData.Value[i].T18Months)==1){
216
						emiPopUpTd.push('<td><span style="font-size:11px"><b>' +'-'+ '</b></span></td></tr>');
217
					}
218
					else{
219
						emiPopUpTd.push('<td><span style="font-size:11px" class="rupee-icon"><b>' +parsedData.Value[i].T18Months+ '</b></span></td></tr>');
220
					}
221
 
222
				}
223
				emiPopUp.find("tr.emi_pop_up_emirow").after(emiPopUpTd.join(""));
224
				for (var i=0; i<parsedData.BankCharges.length; i++){
225
					emiPopUpLowerTd.push('<tr class="emi_pop_up_emirow_lower"><td><span style="font-size:11px;font-weight:normal;">' +parsedData.BankCharges[i].Bank+ '</span></td>');
226
					if (checkEmiObject(parsedData.BankCharges[i].T3Months)==1){
227
						emiPopUpLowerTd.push('<td><span style="font-size:11px"><b>' +'-'+ '</b></span></td>');
228
					}
229
					else{
230
						emiPopUpLowerTd.push('<td><span style="font-size:11px"><b>' +parsedData.BankCharges[i].T3Months+'%'+ '</b></span></td>');
231
					}
232
					if (checkEmiObject(parsedData.BankCharges[i].T6Months)==1){
233
						emiPopUpLowerTd.push('<td><span style="font-size:11px"><b>' +'-'+ '</b></span></td>');
234
					}
235
					else{
236
						emiPopUpLowerTd.push('<td><span style="font-size:11px"><b>' +parsedData.BankCharges[i].T6Months+'%'+ '</b></span></td>');
237
					}
238
					if (checkEmiObject(parsedData.BankCharges[i].T9Months)==1){
239
						emiPopUpLowerTd.push('<td><span style="font-size:11px"><b>' +'-'+ '</b></span></td>');
240
					}
241
					else{
242
						emiPopUpLowerTd.push('<td><span style="font-size:11px"><b>' +parsedData.BankCharges[i].T9Months+'%'+ '</b></span></td>');
243
					}
244
					if (checkEmiObject(parsedData.BankCharges[i].T12Months)==1){
245
						emiPopUpLowerTd.push('<td><span style="font-size:11px"><b>' +'-'+ '</b></span></td>');
246
					}
247
					else{
248
						emiPopUpLowerTd.push('<td><span style="font-size:11px"><b>' +parsedData.BankCharges[i].T12Months+'%'+ '</b></span></td>');
249
					}
250
					if (checkEmiObject(parsedData.Value[i].T18Months)==1){
251
						emiPopUpLowerTd.push('<td><span style="font-size:11px"><b>' +'-'+ '</b></span></td></tr>');
252
					}
253
					else{
254
						emiPopUpLowerTd.push('<td><span style="font-size:11px"><b>' +parsedData.BankCharges[i].T18Months+'%'+'</b></span></td></tr>');
255
					}
256
				}
257
				emiPopUpLower.find("tr.emi_pop_up_emirow_lower").after(emiPopUpLowerTd.join(""));
258
			}
259
		});
6453 kshitij.so 260
		$.colorbox({
8976 kshitij.so 261
			inline:true, 
262
			href:"#emiPopUp",
263
			width:"600px",
264
			height:"410px",
265
 
6453 kshitij.so 266
			onComplete: function(){
8976 kshitij.so 267
				$('#emiPopUp').show();
268
			},
269
			onCleanup: function(){
270
				$('#emiPopUp').hide();
6453 kshitij.so 271
			}
8976 kshitij.so 272
		});
273
		trackEventWithGA('Widget', 'Emi info widget is clicked', '');
6453 kshitij.so 274
	});
8976 kshitij.so 275
 
6792 vikram.rag 276
	$('a.mk_best_deal_detail').live('click', function(){
277
		var offerLinkHtml = '';
278
		if(OFFER_HELP_LINK!='$OFFER_DETAIL_LINK') {
6795 vikram.rag 279
			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 280
		}
281
		$.colorbox({
282
			width: "550px",
8976 kshitij.so 283
			height: "300px",
284
			inline: true,
285
			href: '<h3 style="text-align: left; padding: 10px;">Offer Details</h3>' +
286
			'<p style="text-align: justify; line-height: 22px; margin: 12px;">' + OFFER_HELP_TEXT +
287
			'</p><span class="right">' + offerLinkHtml 
6792 vikram.rag 288
		});
289
	});
8976 kshitij.so 290
 
291
 
6245 kshitij.so 292
	$('#pickupstoreInfo').click(function(){
293
		$.colorbox({
8976 kshitij.so 294
			width: "550px",
295
			height: "370px",
296
			inline: true,
297
			href: "<h3>Frequently Asked Questions</h3><br />" +
298
			"<b style='color: black; cursor: default;'>Q)</b> What is 'Buy Online & Pickup in Store' ?<br /><br />" +
299
			"<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 />" +
300
			"<b style='color: black; cursor: default;'>Q)</b> How do i avail this facility ?<br /><br />" +
301
			"<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 />"+
302
			"<b style='color: black; cursor: default;'>Q)</b> When will the product be available for pickup ?<br /><br />" +
303
			"<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 />",
304
 
6245 kshitij.so 305
			onComplete: function(){
6262 amit.gupta 306
				var ev = "Product Page";
6303 amit.gupta 307
				var label = window.location.pathname;
6264 amit.gupta 308
				if (label=="" || label=="#")
6261 amit.gupta 309
				{
6303 amit.gupta 310
					label = "";
6262 amit.gupta 311
					ev = "Home Page";
6261 amit.gupta 312
				}
6262 amit.gupta 313
				else if (label.indexOf("shipping") != -1){
314
					ev = "Shipping Page";
315
					var blkstr = [];
6263 amit.gupta 316
					jQuery("#cartDetail").find("span.cart-item-name").each(function(key,str){
6262 amit.gupta 317
						blkstr.push(str);
318
					});
6303 amit.gupta 319
					label = blkstr.join(", ");
320
				} else if (label.substr(label.lastIndexOf('/') + 1).length==5 && typeof label.substr(label.lastIndexOf('/') + 1) =="number") {
321
					ev = "Category Page";
322
				} else if (label.substr(label.lastIndexOf('-') + 1).length==7  && typeof label.substr(label.lastIndexOf('-') + 1) =="number") {
323
					ev = "Product Page";
6262 amit.gupta 324
				}
6261 amit.gupta 325
				trackEventWithGA('Pickup in Store LightBox', ev, label);
6245 kshitij.so 326
			}
8976 kshitij.so 327
		});
6245 kshitij.so 328
	});
4126 varun.gupt 329
 
5420 amit.gupta 330
	$('.common-widget-top-bar').live('click', function(e, callback){
4126 varun.gupt 331
		var isColapsed = $(this).data('is_colapsed') == true ? true : false;
332
		var widgetBox = $(this).siblings('.common-widget-content-area');
333
		var controlBox = $(this).siblings('.common-widget-control-bar');
334
		var controlBoxArrowImg = $(this).find('img');
8976 kshitij.so 335
 
4126 varun.gupt 336
		if (isColapsed)	{
337
			if(controlBox.length > 0)	{
338
				$(controlBox).slideDown('fast', function(){
5420 amit.gupta 339
					$(widgetBox).slideDown('fast', callback);
4126 varun.gupt 340
					$(controlBoxArrowImg).attr('src', '/images/IconDownArrow_UnselectedTab.png');
341
				});
342
			} else	{
343
				$(widgetBox).slideDown();
344
				$(controlBoxArrowImg).attr('src', '/images/IconDownArrow_UnselectedTab.png');
345
			}
346
		} else	{
347
			$(widgetBox).slideUp(function(){
348
				$(controlBox).slideUp('fast');
349
				$(controlBoxArrowImg).attr('src', '/images/IconRightArrow_UnselectedTab.png');
350
			});
351
		}
352
		$(this).data('is_colapsed', !isColapsed);
353
	});
8976 kshitij.so 354
 
4126 varun.gupt 355
	/**
356
	 * Update count of products checked for comparison
357
	 **/
358
	$('#myresearch input[type="checkbox"]').live('click', function(){
4798 varun.gupt 359
		updateCompareCount();
4126 varun.gupt 360
	});
8976 kshitij.so 361
 
4126 varun.gupt 362
	$("#research_compare").live('click', function(){
363
		var seldata = "";
5322 amit.gupta 364
		var prodnames = "";
4126 varun.gupt 365
		var tot = 1;
366
		var saprt = "";
367
		var par = $('#myresearch').find('input[type=checkbox]:checked');
4926 varun.gupt 368
		var haveSameProductType = true;
369
		var productType = null;
8976 kshitij.so 370
 
4126 varun.gupt 371
		$(par).each(function(){
8976 kshitij.so 372
 
4926 varun.gupt 373
			if(productType != null && productType != $(this).attr('producttype'))	{
374
				haveSameProductType = false;
375
			}
376
			productType = $(this).attr('producttype');
8976 kshitij.so 377
 
4126 varun.gupt 378
			if(tot == 1)	{
5358 amit.gupta 379
				prodnames += $(this).attr("title").replace(/ +/g, '-').replace(/\/+/g,'-').replace(/-+/g,'-').toLowerCase();
4126 varun.gupt 380
				seldata += "p" + tot + "=" + $(this).val();
381
			} else	{
382
				seldata += "&p" + tot + "=" + $(this).val();
5358 amit.gupta 383
				prodnames += "-vs-" + $(this).attr("title").replace(/ +/g, '-').replace(/\/+/g,'-').replace(/-+/g,'-').toLowerCase();
4126 varun.gupt 384
			}
385
			tot ++;
386
		});
8976 kshitij.so 387
 
4926 varun.gupt 388
		if(! haveSameProductType)	{
389
			alert("Only products of same category can be compared");
390
		} else if(tot > 6)	{
4126 varun.gupt 391
			alert("Can compare upto five products only.");
392
		} else if(tot > 2)	{
5552 phani.kuma 393
			window.location = "/compare-" + productType.replace(/ +/g, '-').toLowerCase() + "/" + prodnames + "?" + seldata+"&fromsrc=comparison_widget";
4126 varun.gupt 394
		} else	{
395
			alert("Please select atleast two products");
396
		}
397
	});
8976 kshitij.so 398
 
4126 varun.gupt 399
	$("#research_delete").live('click', function(){
400
		var research_tot = $("#research_total").val();
401
		var seldata = [];
402
		var tot = 0;
403
		var saprt = "";
404
		var par = $('#myresearch').find('input[type=checkbox]:checked');
405
 
406
		$(par).each(function(){
407
			seldata.unshift($(this).val());
408
			tot ++;
409
		});
410
 
411
		if(tot > 0)	{
412
			var t = (research_tot * 1) - (tot * 1);
413
			$("#research_total").val(t);
414
 
415
			jQuery.ajax({
416
				type: "GET",
417
				url: "/deletefromresearch/[" + seldata + "]?_method=delete",
418
				success: function(msg)	{
419
					jQuery.each(seldata, function(intIndex, objValue){
420
						delete_from_storage_set("resitems", objValue);
421
						$("#myresearch").find("#" + objValue).fadeOut('slow', function() {
422
							$(this).remove();
423
							if(t === 0)	{
424
								$("#research_default").css("display", "block");
425
							}
426
						});
427
					});
8976 kshitij.so 428
 
4922 varun.gupt 429
					//Updating the count
430
					$('#research_compare_count').html($('#myresearch input[type="checkbox"]:checked').length - seldata.length);
8976 kshitij.so 431
 
4984 varun.gupt 432
					if ($('#myresearch input[type="checkbox"]').length - seldata.length <= 0)	{
433
						$("#myresearch").children(".common-widget-top-bar").trigger('click');
434
					}
4126 varun.gupt 435
				}
436
			});
437
		} else	{
438
			alert("Please select atleast one product");
439
		}
440
	});
8976 kshitij.so 441
 
4126 varun.gupt 442
	// No uid cookie
443
	if (!$.cookie("uid"))	{
444
		// No uid in storage
445
		if (!$.Storage.get("uid"))	{
446
			if (!$.Storage.get("resitems"))	{
447
				$.Storage.set("resitems", "[]");
448
			}
449
			if (!$.Storage.get("histitems"))	{
450
				$.Storage.set("histitems", "[]");
451
			}
452
		}
453
		else	{			// uid in storage : logout
454
			$.Storage.remove("uid");
455
			$.Storage.set("resitems", "[]");
456
			$.Storage.set("histitems", "[]");
457
		}
458
		load_research_widget();
459
		load_history_widget();
460
	}
461
	else	{				// With uid cookie
462
		var cookie = $.cookie("uid");
463
		// Just logged in merge storage items
464
		if (!$.Storage.get("uid"))	{
465
			$.Storage.set("uid", cookie);
466
			merge_history_items();
467
			load_research_items();
468
		}
469
		else	{
470
			// UID changed
471
			if ( cookie != $.Storage.get("uid"))	{
472
				$.Storage.set("uid", cookie);
473
				$.Storage.set("resitems", "[]");
474
				$.Storage.set("histitems", "[]");
475
				merge_history_items();
476
				load_research_items();
477
			}
478
			else	{		// Uid is same
479
				if (!$.Storage.get("resitems"))	{
480
					$.Storage.set("resitems", "[]");
481
					load_research_items();
482
				}
483
				else	{
484
					load_research_widget();
485
				}
8976 kshitij.so 486
 
4126 varun.gupt 487
				if (!$.Storage.get("histitems"))	{
488
					$.Storage.set("histitems", "[]");
489
					merge_history_items();
490
				}
491
				else	{
492
					load_history_widget();
493
				}
494
			}
495
		}
496
	}
8976 kshitij.so 497
 
4798 varun.gupt 498
	function load_research_items(){
499
		jQuery.ajax({
500
			type: "GET",
501
			url: "/myresearch",
502
			cache: false,
503
			success: function(json) {
8976 kshitij.so 504
				$.Storage.set("resitems", json);
505
				load_research_widget();
506
			}
4798 varun.gupt 507
		});
508
	}
509
 
510
	function load_research_widget(){
511
		var myResearchWidgetContainer = $("#myresearch");
8976 kshitij.so 512
 
4798 varun.gupt 513
		if($(myResearchWidgetContainer).length == 0) {
514
			return;
515
		}
516
		var resitems = $.Storage.get("resitems");
8976 kshitij.so 517
 
4798 varun.gupt 518
		if (resitems == "[]") {
519
			var emptyResWidgetHtml = '<table border="0" width="100%" cellspacing="1" cellpadding="0" id="research_default">\
8976 kshitij.so 520
				<tbody>\
521
				<tr><td align="center"><b>Add items to compare list</b></td></tr>\
522
				</tbody>\
523
				</table>';
4798 varun.gupt 524
			$(myResearchWidgetContainer).find(".common-widget-content-area").html(emptyResWidgetHtml);
525
			$(myResearchWidgetContainer).children(".common-widget-top-bar").trigger('click');
526
			return;
527
		}
528
		var params = "/" + resitems;
8976 kshitij.so 529
 
4798 varun.gupt 530
		jQuery.ajax({
531
			type : "GET",
532
			url : "/myresearch" + params,
533
			cache: true,
534
			success : function(html) {
8976 kshitij.so 535
				$("#myresearch").html(html);
536
				updateCompareCount();
4798 varun.gupt 537
 
8976 kshitij.so 538
				// Product Title
539
				$("#myresearch table td div a.truncate").each(function() {
540
					$(this).truncate({addtitle : true});
541
				});
4798 varun.gupt 542
 
8976 kshitij.so 543
				// Product Price
544
				$("#myresearch table td div div.price").each(function() {
545
					$(this).truncate({addtitle : true});
4798 varun.gupt 546
				});
547
 
8976 kshitij.so 548
				// Product Details
549
				$("#myresearch table td div div.text").each(function() {
550
					$(this).truncate( {addtitle : true});
4798 varun.gupt 551
				});
8976 kshitij.so 552
			}
4798 varun.gupt 553
		});
554
	}
7846 rajveer 555
});
556
 
7849 rajveer 557
function displayCod(item_id)	{
7846 rajveer 558
	$.colorbox({
7872 rajveer 559
		width: "400px",
560
		height: "200px",
7846 rajveer 561
		inline: true,
7873 rajveer 562
		href: "<ul style='list-style:inside; margin-left: 25px; text-align: justify; margin-right:12px; font-size:15px; line-height: 22px;'>"
7872 rajveer 563
			+ "Expected Delivery Date for "
7873 rajveer 564
			+"<li list-style:inside>Prepaid orders is " + $('#days_' + item_id).html() + "</li>"+
7879 rajveer 565
			"<li list-style:inside>Cash On Delivery orders is " + $('#coddays_' + item_id).html() + "</li>"+
8976 kshitij.so 566
			"</ul>",
567
			onComplete: function(){
568
				trackEventWithGA('Widget', 'COD Know More is clicked', '');
569
			}
7846 rajveer 570
	});
571
}