/*
$(function(){
	jQuery('.bgso_attrslider').jcarousel({
        // Configuration goes here
        easing:'easeOutQuart',
        scroll:1
    });
});



//Easing equation, borrowed from jQuery easing plugin
//http://gsgd.co.uk/sandbox/jquery/easing/
jQuery.easing.easeOutQuart = function (x, t, b, c, d) {
	return -c * ((t=t/d-1)*t*t*t - 1) + b;
};
*/

$(function(){
	$('a[@id^=aleaf]') 
		.livequery('click', function(event) { 
		$.getJSON("index.php?page=callback&page_action=bg_smartoptions",{
                id: $(this).attr('id'),
                ajax: 'true',
                type:'leafchange',
                price: $('input#bgso_price').val(),
                price_otax: $('input#bgso_price_otax').val(),
                products_id: $('input#bgso_products_id').val(),
                tax: $('input#bgso_tax').val()
            }, function(j){
			$.each(j.insert, function(key,val){
				$("a#aleaf-"+j.nodeid+"-"+val[0]).html(val[1]);
			}); 
			$("div#bgso_info-" + j.nodeid).html(j.yourchoice);
			$('p.price').html(j.sumprice);
            $('div#graduated_table').html(j.graduated_table);
		})
	})
});

$(function(){
	  $('select[@id^=selectnode]').livequery('change', function(event){
				$.getJSON("index.php?page=callback&page_action=bg_smartoptions",{id: $(this).attr('id'),
																							value: $(this).val(), 
																							selectedIndex:$(this).attr('selectedIndex') , 
																							ajax: 'true', 
																							type:'selectnode', 
																							options: $(this).attr('options'),
																							price: $('input#bgso_price').val(),
																							price_otax: $('input#bgso_price_otax').val(),
                                                                                            products_id: $('input#bgso_products_id').val(),
																							tax: $('input#bgso_tax').val()

																							}, function(j){
				$.each(j.cmd_order, function(key, val){
					//alert(key + " - " + val + " - " + j.cmd_value[key]);
					switch (val) {
						case 'remove':
							$('div#'+ j.cmd_value[key]).remove();
							break;
						case 'add':
							$("form#frmbgso").append(j.cmd_value[key]);
							break;
						case 'initjcarousel':
							jQuery('#'+j.cmd_value[key]).jcarousel({
						        // Configuration goes here
						        easing:'easeOutQuart',
						        scroll:1
						    });

							break;
						case 'setchoice':
							$("div#bgso_info-" + j.nodeid).html(j.cmd_value[key]);
							break;
						case 'setprice':
							$('p.price').html(j.cmd_value[key]);
							break;
						case 'graduated_table':
							$('div#graduated_table').html(j.cmd_value[key]);
							break;
						case 'setaddcartbutton':
							$("div#bgsoaddtocartbutton").html(j.cmd_value[key]);
							break;
					}
					
				});
	    })
	  })
	});



$(function(){
  $("select#ctlCategory").change(function(){
    $.getJSON("setmaker.php",{id: $(this).val(),  ajax: "true", type:"category"}, function(j){
      var options = '';
      for (var i = 0; i < j['motives'].length; i++) {
        options += '<option value="' + j['motives'][i].id + '">' + j['motives'][i].name + '</option>';
      }
      $("select#ctlMotive").html(options);
	  $("select#ctlMotive > option").removeAttr("selected");
	  $("div#categorydescription").html(j['categorydescription']);
	  $("div#motivedescription").html(j['motivedescription']);
	  $("div#innercontent").html(j['innercontent']);
	
    })
  })
})

$(function(){
  $("select#ctlMotive").change(function(){
    $.getJSON("setmaker.php",{id: $(this).val(), ajax: 'true', type:'motive'}, function(j){
	  $("div#motivedescription").html(j['motivedescription']);
	  $("div#innercontent").html(j['innercontent']);
    })
  })
})



$(function(){
$('input[@name=intoset]') 
    .livequery('keyup', function(event) { 
		$.getJSON("setmaker.php",{value: $(this).val(), ajax: 'true', type:'intoset', id:$(this).attr('id') }, function(j){
		$("div#contentsofset").html(j['contentsofset']);
		})
    });
});


$(function(){
$('select#select_manufacturers')
    .livequery('change', function(event) { 

		//location.href = "http://homeconcept24.com/index.php?page=manufacturers&mnf=" + $('select#select_manufacturers').val();
		location.href = "index.php?page=manufacturers&mnf=" + $('select#select_manufacturers').val();

    });
});

$(function() {
	var options = {
	    zoomWidth: 400,
	    zoomHeight: 400
};
	$(".jqzoom").jqzoom(options);
});