Subversion Repositories SmartDukaan

Rev

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

Rev Author Line No. Line
1456 varun.gupt 1
$(function(){
2
	$('#loopedSlider').loopedSlider();
3
 
4
	runEffect();
5
 
6
	$(".controls").tabs();
7
 
8
	$('#forgot_username_link').tipsy({gravity: 'w'});
9
 
10
	$("#zipcode").val($("#defaultpincode").val());
11
 
12
    updateEstimate();
13
 
1761 vikas 14
    var prodid = $("#product_id").val();
15
 
16
	add_to_storage_set("histitems", prodid);
17
 
1623 rajveer 18
    load_history_widget();
1761 vikas 19
 
1922 varun.gupt 20
    /**
21
     * Code to track user clicks on Product slides and 'Proceed to Payment' option
22
     */
23
	$('a.vt').click(function(){
24
		trackEventWithGA('Product', $(this).children('span').text(), $('title').text().split('|')[0].trim());
25
	});
26
 
1761 vikas 27
    $("#addcart").click(function(){
1456 varun.gupt 28
		jQuery.ajax({
29
			type: "POST",
1614 rajveer 30
			url: "/addtocart",
1456 varun.gupt 31
			data: "productid=" + $("#item_id").val(),
32
			success: function(msg)	{
2036 rajveer 33
	   			 if(msg==""){
34
					 window.location = "/cart";
35
				 }else{
36
					 alert(msg);
37
				 }			}
1456 varun.gupt 38
		});
39
	});
40
 
41
	$("#colorselector").change(function(){
42
		var itemid = $("#colorselector option:selected").val();
43
 
44
		$('#sp').html(PARAMETERS[itemid].SP);
45
		$('#mrp').html(PARAMETERS[itemid].MRP);
46
		$('#saving').html(PARAMETERS[itemid].SAVING);
47
		$("#item_id").val(itemid);
48
		updateEstimate(itemid);
49
		return false;
50
	});
51
 
52
	$("a.colorselector").click(function() {
53
		$('.a.colorselector').addClass('deselect');
54
		$(this).addClass('deselect');
1567 vikas 55
		var itemid = $(this).attr('itemid');
1456 varun.gupt 56
		$('#sp').html(" "+PARAMETERS[itemid].SP);
57
		$('#mrp').html(" "+PARAMETERS[itemid].MRP);
58
		$('#saving').html(PARAMETERS[itemid].SAVING);
59
		$("#item_id").val(itemid);
60
		return false;
61
	});
2228 rajveer 62
 
63
	$("#util_compare").click(function() {
64
		$.fn.colorbox({inline:true, href:".colorSelLightBoxColor", open:true, onComplete:function(){
65
			var posLeft = (document.documentElement.clientWidth / 2) - (parseInt($('#colorbox').css('width')) / 2);
66
			var posTop = (document.documentElement.clientHeight / 2) - (parseInt($('#colorbox').css('height')) / 2);
67
 
68
			$('#colorbox').css('top', posTop);
69
			$('#colorbox').css('left', posLeft);
70
		}});
71
	});
72
 
73
	/* This code is for compare with button */
74
	var availableNames = [];
75
	for (var k in productIdNames)availableNames.push(k);
2235 rajveer 76
    $("#mobilename").autocomplete({  autoFocus: true, minLength: 3, 
2228 rajveer 77
        source: availableNames
78
    });
79
 
80
 
81
    $("#compare_continue").click(function() {
82
    	var productName = $("#mobilename").val();
83
    	var productTwo = productIdNames[productName];
84
    	if(typeof productTwo == 'undefined'){
85
    		alert("Please select a valid product");
86
    		return;
87
    	}
88
    	var productOne = $("#catelog_id").val();
89
    	window.location = "/compare-mobile-phones?p1="+productOne+"&p2="+productTwo;	
90
    });
91
 
1456 varun.gupt 92
});
93
 
94
function changeSignInClass(){
95
	if(document.getElementById("signinClass").className.indexOf("signin1") > -1)	{
96
		document.getElementById("signinClass").className = 'signin';
97
	} else	{
98
		document.getElementById("signinClass").className = 'signin1';
99
	}
100
}
101
 
2228 rajveer 102
 
1456 varun.gupt 103
function updateEstimate(itemId)	{
104
	itemId = itemId || $("#item_id").val();
105
 
106
	jQuery.ajax({
107
		type: "GET",
1919 rajveer 108
		url: "/estimate/" + $("#zipcode").val() + "_" + itemId,
1456 varun.gupt 109
		beforeSend: function()	{
110
			$("#days").html("<img src='../images/loader_l.gif'>");
111
		},
112
		success: function(msg)	{
113
			$("#shipping_time").html(msg);
114
		}
115
	});
2228 rajveer 116
}
117