Subversion Repositories SmartDukaan

Rev

Rev 1922 | Rev 2228 | 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 output = "";
43
		var itemid = $("#colorselector option:selected").val();
44
 
45
		$('#sp').html(PARAMETERS[itemid].SP);
46
		$('#mrp').html(PARAMETERS[itemid].MRP);
47
		$('#saving').html(PARAMETERS[itemid].SAVING);
48
		$("#item_id").val(itemid);
49
		updateEstimate(itemid);
50
		return false;
51
	});
52
 
53
	$("a.colorselector").click(function() {
54
		$('.a.colorselector').addClass('deselect');
55
		$(this).addClass('deselect');
1567 vikas 56
		var itemid = $(this).attr('itemid');
1456 varun.gupt 57
		$('#sp').html(" "+PARAMETERS[itemid].SP);
58
		$('#mrp').html(" "+PARAMETERS[itemid].MRP);
59
		$('#saving').html(PARAMETERS[itemid].SAVING);
60
		$("#item_id").val(itemid);
61
		return false;
62
	});
63
});
64
 
65
function changeSignInClass(){
66
	if(document.getElementById("signinClass").className.indexOf("signin1") > -1)	{
67
		document.getElementById("signinClass").className = 'signin';
68
	} else	{
69
		document.getElementById("signinClass").className = 'signin1';
70
	}
71
}
72
 
73
function updateEstimate(itemId)	{
74
	itemId = itemId || $("#item_id").val();
75
 
76
	jQuery.ajax({
77
		type: "GET",
1919 rajveer 78
		url: "/estimate/" + $("#zipcode").val() + "_" + itemId,
1456 varun.gupt 79
		beforeSend: function()	{
80
			$("#days").html("<img src='../images/loader_l.gif'>");
81
		},
82
		success: function(msg)	{
83
			$("#shipping_time").html(msg);
84
		}
85
	});
86
}