function generateSelectData(quantity, stockLevel)
{
	var data = [];
	for(var i=1; i<=stockLevel; i++) {
		data.push({value: i, text: i});
	}
	quantity--;
	data[quantity].selected = true;
	//alert(data);
	return data;
}

function generateStockSelect(klasa, name, quantity, stockLevel)
{
	var out = '<select name="' + name + '">';
	for(var i=1; i<=stockLevel; i++) {
	   if( i == quantity )
		   out += '<option selected="selected" value="' + i + '">' + i + '</option>';
	   else
		   out += '<option value="' + i + '">' + i + '</option>';
	}
	out += '</select>';
	
	$('table.product-list-basket tr.' + klasa + ' span.' + klasa).html(out);
	
	//return out;
	//document.write(out);
}

function unBold(perPage, AllItems) {
  for(var i=0; i<Math.ceil(AllItems/perPage); i++)
  {
   document.getElementById('link_'+(i+1)).style.fontWeight='';
  }
}

function ShowPages(perPage, AllItems)
{
  for(var i=0; i<AllItems; i++)
  {
	 if( i>=0 && i<perPage )
    document.getElementById('s'+(i+1)).style.display='';
   else
    document.getElementById('s'+(i+1)).style.display='none';
  }

  var pages = '';
	for(var i=0; i<Math.ceil(AllItems/perPage); i++)
	{
		if( i == 0 )
			pages += '<a style="font-weight: bold; cursor: pointer;" id="link_' + (i+1) + '" onclick="unBold('+ perPage + ', ' + AllItems +');this.style.fontWeight=\'bold\';GoToPage(' + i + ', ' + perPage + ', ' + AllItems + ')">'+ (i+1) +'</a>  ';
    else
    	pages += '<a style="cursor: pointer;" id="link_' + (i+1) + '" onclick="unBold('+ perPage + ', ' + AllItems +');this.style.fontWeight=\'bold\';GoToPage(' + i + ', ' + perPage + ', ' + AllItems + ')">'+ (i+1) +'</a>  ';
  }
  document.write(pages);
}

function GoToPage(CurrentPage, perPage, AllItems)
{
	for(var i=0; i<AllItems; i++)
	{
	  if( i>=CurrentPage*perPage && i<(CurrentPage+1)*perPage )
    	document.getElementById('s'+(i+1)).style.display='';
    else
      document.getElementById('s'+(i+1)).style.display='none';
  }
}

function bookmark(){
    var title = 'Page Title';
    var url = 'http://webpage.pl/';

    if (window.sidebar) window.sidebar.addPanel(title, url,"");

    else if( window.opera && window.print )
    {
    var mbm = document.createElement('a');
    mbm.setAttribute('rel','sidebar');
    mbm.setAttribute('href',url);
    mbm.setAttribute('title',title);
    mbm.click();
    }

    else if( document.all ) window.external.AddFavorite( url, title);
}

