Subversion Repositories SmartDukaan

Rev

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