
$(document).ready(function(){
	$('#checkAvailMatress').click(function(){
		
		$.getJSON("/"+lang+"/products/fetchavail/size:"+$('#bask_variant')[0].value+"/id:"+$('#product-id')[0].value,
        function(data){
        	
          $('#selectedStyle').html(data.size);
          if( data.amount > 0 && data.amount < 3) {
          	$('#limited').show();
          	$('#instore').hide();
          	$('#outstore').hide();
          } else if( data.amount >= 3 ){
          	$('#limited').hide();
          	$('#instore').show();
          	$('#outstore').hide();
          } else if( data.amount <= 0 ) {
          	$('#outstore').show();
          	$('#instore').hide();
          	$('#limited').hide();
          }
          $('div#availbox').show(); 
        });
		
	});
	$('a.print').click(function(){
		window.open($(this).get(0).href, 'print', 'scrollbars=yes,width=660,height=600');
		return false;
	})
	
	$('select#model.extract').change(function(){
		$.getJSON('/'+lang+'/products/getsizes/matress:'+$(this).val(), function(json){
			var sel = $('select#size.extract');
			sel.html('');
			for(var t in json)  sel.addOption(t, json[t]);
		})
	})
	try {
		$('select#model.extract').trigger('change');
	} catch( e ) {}
	
});
