var gPage, gId;
var pPage, pId;
var xt;
var xs;
var swfu;
var fid=Math.floor(Math.random()*10000000);
var gList;
var gListC;
var gId1;
var gId2;
var gId3;
var gId4;
var gId5;
var gId6;
var fromswf=0;

//init text field & select field
xt=new xText();
xs=new xSelect();

//page initialization scripts
function start()
{
 //banner init
 flash=new SWFObject(root+'main.swf?gateway='+gateway, "mainBanner", "100%", "100%", "8", "#ffffff");
 flash.write('divBanner');
 setTimeout('mainSwf=thisMovie(\'mainBanner\')', 500);
 setTimeout('gEBI(\'divHtml\').onmouseover=function() {try{mainSwf.mouseLost()} catch(e){}}', 800);
 
 //first page load
 loadP(id1, id2, id3, id4, id5, id6);
 
 //html editor init
 setTimeout(function() {
	 var sBasePath = root+'js/fckeditor/';
	 oFCKeditor = new FCKeditor('input_komentarz') ;
	 oFCKeditor.BasePath	= sBasePath ;
	 oFCKeditor.Width	= 580 ;
	 oFCKeditor.Height	= 140 ;
	 oFCKeditor.Value	= '' ;
	 oFCKeditor.ToolbarSet = 'Danone';
	 oFCKeditor.ReplaceTextarea();
	 
	 oFCKeditor2 = new FCKeditor('input_komentarzOpisbloga') ;
	 oFCKeditor2.BasePath	= sBasePath ;
	 oFCKeditor2.Width	= 316 ;
	 oFCKeditor2.Height	= 140 ;
	 oFCKeditor2.Value	= '' ;
	 oFCKeditor2.ToolbarSet = 'Danone';
	 oFCKeditor2.ReplaceTextarea();
 }, 500);
 
 setTimeout('gEBI(\'input_komentarz2\').focus()', 600);
 
 SWFAddress.onChange=loadInternal;
}

//get flash object for js-swf communication
function thisMovie(movieName) 
{
 if (navigator.appName.indexOf("Microsoft") != -1) 
 {
  return window[movieName]
 }
 else 
 {
  return document[movieName]
 }
}

var mainSwf;

//loading subpages
function loadP(page, id, id2, id3, id4, id5)
{
 //external pages
 if(page==30) document.location='/zdrowieodpierwszychchwil';
 else if(page==100) document.location='/zdrowieodpierwszychchwil/podsumowanie';
 else if(page==200) document.location='/wolewode';
 if(page==101) document.location='/doszkoly';
 else
 {
  //internal subpages
  urlTmp=pages[page]+'';
  if(id && id!='undefined' && page!='0') urlTmp+='/'+(id+'').replace(' ', '');
  if(id2 && id2!='undefined' && page!='0') urlTmp+='/'+(id2+'').replace(' ', '');
  if(id3 && id3!='undefined' && page!='0') urlTmp+='/'+(id3+'').replace(' ', '').replace('01.2020', '0');
  if(id4 && id4!='undefined' && page!='0') urlTmp+='/'+(id4+'').replace(' ', '').replace('01.2000', '0');
  if(id5 && id5!='undefined' && page!='0') urlTmp+='/'+(id5+'').replace(' ', '');
  try{
	if(SWFAddress.getValue()=='/'+urlTmp) SWFAddress.setValue('wczytywanie...');
	SWFAddress.setValue(urlTmp);
  }
  catch(e){
  }
 }
}

//subpages
 pages=new Array;
 pages[0]='.';
 pages[1]='o_wodzie';
 pages[2]='artykuly';
 pages[3]='artykul';
 pages[4]='bloglista';
 pages[5]='bloggaleria';
 pages[6]='blogszczegoly';
 pages[7]='blogedycja';
 pages[8]='blogpierwszy';
 pages[9]='zapytajeksperta';
 pages[10]='zapytajszczegoly';
 pages[11]='zapytaj';
 pages[12]='przybornik';
 pages[13]='warunkikorzystania';
 pages[14]='politykaprywatnosci';
 pages[15]='kontakt';
 pages[16]='woda';
 pages[17]='rejestracja';
 pages[18]='konfiguracja';
 pages[19]='szczepieniegaleria';
 pages[20]='szczepienieszczegoly';
 pages[21]='szczepienieedycja';
 pages[22]='szczepieniepierwszy';
 pages[23]='siatkagaleria';
 pages[24]='siatkaszczegoly';
 pages[25]='siatkaedycja';
 pages[26]='siatkapierwszy';
 pages[27]='oserwisie';
 pages[28]='pomoc';
 pages[29]='pomoc2';
 pages[31]='komentarzwszystkie';
 pages[32]='komentarzdodaj';
 pages[33]='blogzestawienie';
 pages[34]='profil1';
 pages[35]='profil2';
 pages[36]='profil3';
 pages[37]='dietagaleria';
 pages[38]='dietaszczegoly';
 pages[39]='dietaedycja';
 pages[40]='dietapierwszy';
 pages[41]='potwierdzenie';
 pages[42]='blogostatnie';
 
function loadInternal() 
{
 idTmp=SWFAddress.getValue().split('/');
 
 if(idTmp[1]!='wczytywanie...') 
 {
  pageName=idTmp[1];
  id=idTmp[2];
  id2=idTmp[3];
  id3=idTmp[4];
  id4=idTmp[5];
  id5=idTmp[6];
 
  page=0;
 
  for(var i=0; i<=pages.length; i++)
  {
   if(pageName==pages[i]) page=i;
  }
 
  if(id=='undefined') id=0;
  if(id2=='undefined') id2=0;
  if(id3=='undefined') id3=0;
  if(id4=='undefined') id4=0;
  if(id5=='undefined') id5=0;
 
  pPage=gPage;
  pId=gId;
  scrollUp();
  if(gEBI('articleheaderflash'))
  gEBI('articleheaderflash').innerHTML='';
  
  //hide html editors
  gEBI('div_komentarz').style.left='-1000px';
  gEBI('div_komentarz').style.top='720px';
  gEBI('div_komentarzOpisbloga').style.left='-1000px';
  gEBI('div_komentarzOpisbloga').style.top='610px';
  
  //loading new subpage & hiding old
  gEBI('divBody').style.display='none';
  gEBI('divLoader').style.display='block';
 
  if(!page) page=0;
  if(!id) id=0;
  oiframePreload=document.getElementById('iframePreload');
  cSrc=root+'tresc/'+pages[page]+'/'+id;
  if(id2 && id2>0) cSrc=cSrc+'/'+id2;
  if(id3 && id2>0) cSrc=cSrc+'/'+id3;
  if(id4 && id2>0) cSrc=cSrc+'/'+id4;
  if(id5 && id2>0 && id5!='0') cSrc=cSrc+'/'+id5;
 
  jsFile=cSrc;
  lanceRequete();
 }
}

//display new subpage
function showContent(x, y, y2, y3, y4, y5)
{
 //hide html editors
 gEBI('div_komentarz').style.left='-1000px';
 gEBI('div_komentarzOpisbloga').style.left='-1000px';
 
 //scroll up page
 scrollUp();
 
 //copy content to body
 content=out;
 dBody=document.getElementById('divBody');
 dBody.innerHTML=content;
 setTimeout('executeScripts(\''+x+'\', \''+y+'\')', 500);
 gEBI('divLoader').style.display='none';
 gEBI('divBody').style.display='block';
 gPage=x;
 gId=y;
 gEBI('divBody').style.position='static';
 if(!y2) y2=0;
 if(!y3) y3=0;
 if(!y4) y4=0;
 if(!y5) y5=0;
 gId1=x;
 gId2=y;
 gId3=y2;
 gId4=y3;
 gId5=y4;
 gId6=y5;
 
 eval(scripts);
}

//scroll up page
function scrollUp()
{
 var step=2000;
 var delay=10;
 var y=getScrollY();
 if(y>0)
 {
  if((y-step)<0) window.scroll(0, 0);
  else
  {
   window.scroll(0, y-step);
   setTimeout('scrollUp()', delay);
  }
 }
}

//get scroll position
function getScrollY()
{
 var scrOfY=0;
 if(typeof(window.pageYOffset)=='number') 
 {
  //Netscape compliant
  scrOfY=window.pageYOffset;
 }
 else if(document.body && (document.body.scrollLeft || document.body.scrollTop))
 {
  //DOM compliant
  scrOfY = document.body.scrollTop;
 }
 else if(document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop))
 {
  //IE6 standards compliant mode
  scrOfY=document.documentElement.scrollTop;
 }
 return scrOfY;
}

//subpage initialization scripts
function executeScripts(x, y)
{
 //make img label for ff
 imgTmp=document.getElementsByTagName('img');
 for(i=0; i<imgTmp.length; i++)
 {
  imgTmp[i].title=imgTmp[i].alt;
 }
 
 //text field
 if(gEBI('areaWarnPowod'))
 {
  if(gEBI('inputWarnEmail')) xt.textCreate('inputWarnEmail', 'xWarnEmail', 212);
  xt.areaCreate('areaWarnPowod', 'xWarnPowod', 533, 63);
 }
 if(gEBI('txt_dietWaga'))
 {
  xt.textCreate('txt_dietWaga', 'xWaga', 77);
  xt.textCreate('txt_dietWzrost', 'xWzrost', 77);
  gEBI('xWaga').value=dietWaga;
  gEBI('xWzrost').value=dietWzrost;
  gEBI('xWaga').style.textAlign='right';
  gEBI('xWzrost').style.textAlign='right';
 }
 if(gEBI('txt_dietWaga2'))
 {
  xt.textCreate('txt_dietWaga2', 'xWaga', 60);
  xt.textCreate('txt_dietWzrost2', 'xWzrost', 60);
  gEBI('xWaga').style.textAlign='right';
  gEBI('xWzrost').style.textAlign='right';
 }
 
 //set main banner menu
 swfSetMenu(x);
 
 //set png images for ie
 makePng(1);
}

//setting main banner menu
function swfSetMenu(id)
{
 swfId=new Array;
 swfId[0]=1;
 swfId[1]=2;
 swfId[2]=3;
 swfId[3]=3;
 swfId[4]=5;
 swfId[5]=6;
 swfId[6]=6;
 swfId[7]=6;
 swfId[8]=6;
 swfId[9]=4;
 swfId[10]=4;
 swfId[11]=4;
 swfId[12]=5;
 swfId[13]=1;
 swfId[14]=1;
 swfId[15]=1;
 swfId[16]=2;
 swfId[17]=0;
 swfId[18]=0;
 swfId[19]=7;
 swfId[20]=7;
 swfId[21]=7;
 swfId[22]=0;
 swfId[23]=9;
 swfId[24]=9;
 swfId[25]=9;
 swfId[26]=0;
 swfId[27]=0;
 swfId[28]=0;
 swfId[29]=0;
 swfId[30]=0;
 swfId[31]=6;
 swfId[32]=6;
 swfId[33]=5;
 swfId[34]=0;
 swfId[35]=0;
 swfId[36]=0;
 swfId[37]=8;
 swfId[38]=8;
 swfId[39]=8;
 
 swfSize=new Array;
 swfSize[0]=2;
 swfSize[1]=1;
 swfSize[2]=1;
 swfSize[3]=1;
 swfSize[4]=1;
 swfSize[5]=2;
 swfSize[6]=2;
 swfSize[7]=2;
 swfSize[8]=2;
 swfSize[9]=1;
 swfSize[10]=1;
 swfSize[11]=1;
 swfSize[12]=1;
 swfSize[13]=2;
 swfSize[14]=2;
 swfSize[15]=2;
 swfSize[16]=1;
 swfSize[17]=0;
 swfSize[18]=0;
 swfSize[19]=2;
 swfSize[20]=2;
 swfSize[21]=2;
 swfSize[22]=0;
 swfSize[23]=2;
 swfSize[24]=2;
 swfSize[25]=2;
 swfSize[26]=0;
 swfSize[27]=0;
 swfSize[28]=0;
 swfSize[29]=0;
 swfSize[30]=0;
 swfSize[31]=2;
 swfSize[32]=2;
 swfSize[33]=1;
 swfSize[34]=0;
 swfSize[35]=0;
 swfSize[36]=0;
 swfSize[37]=2;
 swfSize[38]=2;
 swfSize[39]=2;
 
 if(fromswf==0 && swfId[id]!=0)
 {
  try{mainSwf.setMenu(swfId[id]);}
  catch(e){}
  if(id==5)
  {
   try{mainSwf.setMenu(666);}
   catch(e){}
  }
 }
 fromswf=0;
 if(swfSize[id]!=0)
 {
  setSize(swfSize[id]);
 }
}

//get dom element
function gEBI(id)
{
 obj=document.getElementById(id);
 return obj;
}

//make png for ie
function makePng(x)
{
 var arVersion=navigator.appVersion.split("MSIE");
 var version=parseFloat(arVersion[1]);

 if((version>=5.5) && (document.body.filters))
 {
  if(gEBI('png1'))
  {
  gEBI('png1').innerHTML='';
  setFilter('png1', 'gr_preview_top.png');
  gEBI('png3').innerHTML='';
  setFilter('png3', 'gr_preview_bottom.png');
  gEBI('png2').style.backgroundImage='';
  setFilter('png2', 'bg_preview_right.png');
  
  gEBI('png12').innerHTML='';
  setFilter('png12', 'gr_preview_top.png');
  gEBI('png32').innerHTML='';
  setFilter('png32', 'gr_preview_bottom.png');
  gEBI('png22').style.backgroundImage='';
  setFilter('png22', 'bg_preview_right.png');
  }
  if(gEBI('png12spec'))
  {
  gEBI('png12spec').innerHTML='';
  setFilter('png12spec', 'gr_preview_top_mamdziecko.png');
  gEBI('png32spec').innerHTML='';
  setFilter('png32spec', 'gr_preview_bottom_mamdziecko.png');
  gEBI('png22spec').style.backgroundImage='';
  setFilter('png22spec', 'bg_preview_right_mamdziecko.png');
  }
  if(gEBI('dietProductPng1'))
  {
  gEBI('dietProductPng1').innerHTML='';
  setFilter('dietProductPng1', 'gr_diet_top.png');
  gEBI('dietProductPng2').style.backgroundImage='';
  setFilter('dietProductPng2', 'gr_diet_md.png');
  gEBI('dietProductPng3').innerHTML='';
  setFilter('dietProductPng3', 'gr_diet_dn.png');
  }
  if(gEBI('opisPng1'))
  {
  gEBI('opisPng1').innerHTML='';
  setFilter('opisPng1', 'gr_editinfo_top.png');
  gEBI('opisPng3').innerHTML='';
  setFilter('opisPng3', 'gr_editinfo_bottom.png');
  gEBI('opisPng2').style.backgroundImage='';
  setFilter('opisPng2', 'bg_editinfo.png');
  }
  if(gEBI('warnPng1'))
  {
  gEBI('warnPng1').innerHTML='';
  setFilter('warnPng1', 'gr_warning_top.png');
  gEBI('warnPng3').innerHTML='';
  setFilter('warnPng3', 'gr_warning_bottom.png');
  gEBI('warnPng2').style.backgroundImage='';
  setFilter('warnPng2', 'bg_warning.png');
  }
  if(gEBI('aboutPng1'))
  {
  gEBI('aboutPng1').innerHTML='';
  setFilter('aboutPng1', 'gr_userinfo_top.png');
  gEBI('aboutPng3').innerHTML='';
  setFilter('aboutPng3', 'gr_userinfo_bottom.png');
  gEBI('aboutPng2').style.backgroundImage='';
  setFilter('aboutPng2', 'bg_userinfo.png');
  }
  if(gEBI('h'+x+'a'))
  {
  gEBI('h'+x+'a').innerHTML='<img src="'+root+'graph/spacer.gif" width="1" height="1" alt="" />';
  setFilter('h'+x+'a', 'gr_help_preview_top.png');
  gEBI('h'+x+'c').innerHTML='';
  setFilter('h'+x+'c', 'gr_help_preview_bottom.png');
  gEBI('h'+x+'b').style.backgroundImage='';
  setFilter('h'+x+'b', 'gr_help_preview_center.png');
  }
  if(gEBI('dPng1'))
  {
  gEBI('dPng1').innerHTML='';
  setFilter('dPng1', 'gr_addphoto_top.png');
  gEBI('dPng2').innerHTML='';
  setFilter('dPng2', 'gr_addphoto_bottom.png');
  gEBI('dPng3').style.backgroundImage='';
  setFilter('dPng3', 'bg_addphoto_left.png');
  gEBI('dPng4').style.backgroundImage='';
  setFilter('dPng4', 'bg_addphoto_right.png');
  }
  if(gEBI('cPng1'))
  {
  gEBI('cPng1').innerHTML='';
  setFilter('cPng1', 'gr_addphoto_top.png');
  gEBI('cPng4').innerHTML='';
  setFilter('cPng4', 'gr_addphoto_bottom.png');
  gEBI('cPng2').style.backgroundImage='';
  setFilter('cPng2', 'bg_addphoto_left.png');
  gEBI('cPng3').style.backgroundImage='';
  setFilter('cPng3', 'bg_addphoto_right.png');
  }
  if(gEBI('wPng1'))
  {
  gEBI('wPng1').innerHTML='';
  setFilter('wPng1', 'gr_addphoto_top.png');
  gEBI('wPng4').innerHTML='';
  setFilter('wPng4', 'gr_addphoto_bottom.png');
  gEBI('wPng2').style.backgroundImage='';
  setFilter('wPng2', 'bg_addphoto_left.png');
  gEBI('wPng3').style.backgroundImage='';
  setFilter('wPng3', 'bg_addphoto_right.png');
  }
  if(gEBI('linkPng1'))
  {
  gEBI('linkPng1').style.backgroundImage='';
  setFilter('linkPng1', 'bg_link.png');
  }
  if(gEBI('tour_png1'))
  {
  gEBI('tour_png1').innerHTML='';
  setFilter('tour_png1', 'gr_tour_top.png');
  gEBI('tour_png2').innerHTML='';
  setFilter('tour_png2', 'gr_tour_bottom.png');
  gEBI('tour_png3').style.backgroundImage='';
  setFilter('tour_png3', 'bg_tour.png');
  }
  if(gEBI('warningDatePng'))
  {
  gEBI('warningDatePng').style.backgroundImage='';
  setFilter('warningDatePng', 'bg_link.png');
  }
 }
}

function setFilter(id, file)
{
 gEBI(id).style.filter='progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\''+root+'graph/'+file+'\', sizingMethod=\'scale\')';
}

//set input element value
function setInput(obj, txt)
{
 if(obj.value=='') obj.value=txt;
}

//clear input element value
function unsetInput(obj, txt)
{
 if(obj.value==txt) obj.value='';
}

//show & hide tooltip
var tthidePrevent=false;
var ttObj;
var ttC;
function ttshow(obj, txt, obj2, c, mode)
{
 if(mode==2)
 {
  if(gEBI('tooltip2spec')) gEBI('tooltip2spec').style.display='none';
  ttObj=obj2;
  ttC=c;
  x=obj.offsetLeft-95;
  y=obj.offsetTop+7;
  gEBI('tooltip2').style.left=x+'px';
  gEBI('tooltip2').style.top=y+'px';
  gEBI('tooltipContent2').innerHTML=txt;
  gEBI('tooltip2').style.display='block';
 }
 else if(mode==3)
 {
  var i=0;
  if(gEBI('div_lista3').style.display=='none') i=1;
  else i=3;
  x=(obj.offsetLeft-95)+gEBI('div_lista'+i).offsetLeft+gEBI('div_addProduct').offsetLeft;
  y=(obj.offsetTop+7)+gEBI('div_lista'+i).offsetTop+gEBI('div_addProduct').offsetTop-gEBI('div_lista'+i).scrollTop;
  gEBI('tooltip').style.left=x+'px';
  gEBI('tooltip').style.top=y+'px';
  gEBI('tooltipContent').innerHTML=txt;
  gEBI('tooltip').style.display='block';
 }
 else if(mode==4)
 {
  x=gEBI('div_addProduct').offsetLeft+obj.offsetLeft-95;
  y=gEBI('div_addProduct').offsetTop+obj.offsetTop+7;
  gEBI('tooltip').style.left=x+'px';
  gEBI('tooltip').style.top=y+'px';
  gEBI('tooltipContent').innerHTML=txt;
  gEBI('tooltip').style.display='block';
 }
 else if(mode==5)
 {
  x=obj.offsetLeft-95+gEBI('div_addProduct').offsetLeft+36;
  y=obj.offsetTop+7+gEBI('div_addProduct').offsetTop+70;
  gEBI('tooltip').style.left=x+'px';
  gEBI('tooltip').style.top=y+'px';
  gEBI('tooltipContent').innerHTML=txt;
  gEBI('tooltip').style.display='block';
 }
 else if(mode==6)
 {
  x=obj.offsetLeft-43;
  y=obj.offsetTop+17;
  gEBI('tooltip').style.left=x+'px';
  gEBI('tooltip').style.top=y+'px';
  gEBI('tooltipContent').innerHTML='<div style="text-align: center"><img src="'+root+txt+'" /></div>';
  gEBI('tooltip').style.display='block';
 }
 if(mode==7)
 {
  if(gEBI('tooltip2')) gEBI('tooltip2').style.display='none';
  ttObj=obj2;
  ttC=c;
  x=obj.offsetLeft-95;
  y=obj.offsetTop+7;
  gEBI('tooltip2spec').style.left=x+'px';
  gEBI('tooltip2spec').style.top=y+'px';
  gEBI('tooltipContent2spec').innerHTML=txt;
  gEBI('tooltip2spec').style.display='block';
 }
 else
 {
  x=obj.offsetLeft-95;
  y=obj.offsetTop+7;
  gEBI('tooltip').style.left=x+'px';
  gEBI('tooltip').style.top=y+'px';
  gEBI('tooltipContent').innerHTML=txt;
  gEBI('tooltip').style.display='block';
 }
}
function tthide()
{
 setTimeout('tthideCont()', 1);
 document.onmousemove = null;
}
function tthide2()
{
 setTimeout('tthideCont2()', 1);
}
function tthide2spec()
{
 setTimeout('tthideCont2spec()', 1);
}
function tthideCont()
{
 if(!tthidePrevent)
 {
  gEBI('tooltip').style.display='none';
  gEBI('tooltipContent').innerHTML='';
  gEBI('tooltip').style.left='0px';
  gEBI('tooltip').style.top='0px';
  try
  {
   gEBI(gList).style.backgroundColor=gListC;
  }
  catch(e){}
 }
 tthideCont2();
 tthideCont2spec();
}
function tthideCont2()
{
 if(!tthidePrevent)
 {
  if(gEBI(ttObj)) gEBI(ttObj).style.backgroundColor=ttC;
  gEBI('tooltip2').style.display='none';
  gEBI('tooltipContent2').innerHTML='';
  gEBI('tooltip2').style.left='0px';
  gEBI('tooltip2').style.top='0px';
 }
}
function tthideCont2spec()
{
 if(!tthidePrevent)
 {
  if(gEBI(ttObj)) gEBI(ttObj).style.backgroundColor=ttC;
  gEBI('tooltip2spec').style.display='none';
  gEBI('tooltipContent2spec').innerHTML='';
  gEBI('tooltip2spec').style.left='0px';
  gEBI('tooltip2spec').style.top='0px';
 }
}
//show & hide blog entry
function blogContentToggle(x, txt)
{
 content1=gEBI('blogContent'+x);
 info1=gEBI('imgBlogInfo'+x);
 if(content1.style.display=='none')
 {
  info1.style.display='none';
  content1.style.display='block';
  changeImg('imgBlogToggle'+x,'ic_strzalka_down');
  gEBI('listB'+x).style.backgroundColor=gListC;
  if(gEBI('comment1_'+x))
  {
   gEBI('comment1_'+x).style.display='none';
   gEBI('comment2_'+x).style.display='inline';
  }
  if(gEBI('spanTitle'+x))
  {
   gEBI('spanTitle'+x).style.display='none';
  }
 }
 else
 {
  if(txt!='') info1.style.display='block';
  content1.style.display='none';
  changeImg('imgBlogToggle'+x,'ic_strzalka_right');
  if(gEBI('comment1_'+x))
  {
   gEBI('comment1_'+x).style.display='inline';
   gEBI('comment2_'+x).style.display='none';
  }
  if(gEBI('spanTitle'+x))
  {
   gEBI('spanTitle'+x).style.display='inline';
  }
 }
}

//show all blog entries
function blogOpenAll()
{
 i=1;
 while(obj=gEBI('blogContent'+i))
 {
  obj.style.display='block';
  gEBI('imgBlogInfo'+i).style.display='none';
  changeImg('imgBlogToggle'+i,'ic_strzalka_down');
  i++;
 }
}

//search blog entries by dates
//from html
function loadBlogDates()
{
 d1=gEBI('2').value;
 d2=gEBI('3').value;
 if(d1=='') d1='1';
 if(d2=='') d2='1';
 if(gPage==19 || gPage==20 || gPage==21) p=19;
 else if(gPage==23 || gPage==24 || gPage==25) p=23;
 else if(gPage==37 || gPage==38 || gPage==39) p=37;
 else p=5;
 loadP(p, id1, 1, d1, d2);
}
//from swf
function swfBlog(d1, d2)
{
 fromswf=1;
 if(gPage==19 || gPage==20 || gPage==21) p=19;
 else if(gPage==23 || gPage==24 || gPage==25) p=23;
 else if(gPage==37 || gPage==38 || gPage==39) p=37;
 else p=5;
 loadP(p, gId, 1, d1.toString().replace(/"/g, ''), d2.toString().replace(/"/g, ''));
}


//set importance radio button
function setWaga(x)
{
 gEBI('input_waga').value=x;
 changeImg('rd1', 'bt_off');
 changeImg('rd2', 'bt_off');
 changeImg('rd3', 'bt_off');
 
 if(x==1) changeImg('rd1', 'bt_low');
 if(x==2) changeImg('rd2', 'bt_medium');
 if(x==3) changeImg('rd3', 'bt_high');
}

//set type radio button
function setTyp(x)
{
 gEBI('input_typ').value=x;
 changeImg('rt1', 'bt_r_off');
 changeImg('rt2', 'bt_r_off');
 
 if(x==1)
 {
  changeImg('rt1', 'bt_r_on');
  gEBI('divZdjeciaPanel').style.display='none';
 }
 if(x==2)
 {
  changeImg('rt2', 'bt_r_on');
  gEBI('divZdjeciaPanel').style.display='block';
 }
}

//swf upload init
function uploadInit() 
{
 try{
 swfu=new SWFUpload({
		flash_url : root+"SWFUpload.swf",
				upload_url: "imageupload.php?fid="+fid,
				file_size_limit : "3 MB",
				file_types : "*.gif;*.jpg;*.png",
				file_types_description : "obrazki",
				file_upload_limit : 100,
				file_queue_limit : 0,
				debug: false,
				button_image_url: root+"graph/bt_right.gif",
				button_width: "27",
				button_height: "23",
				button_placeholder_id: "SWFUploadTarget",
				button_window_mode : SWFUpload.WINDOW_MODE.TRANSPARENT,
				file_queued_handler : startUpload1,
				file_queue_error_handler : emptyF,
				file_dialog_complete_handler : emptyF,
				upload_start_handler : uploadStart,
				upload_progress_handler : uploadProgressFunction,
				upload_error_handler : emptyF,
				upload_success_handler : emptyF,
				upload_complete_handler : uploadEnd,
				queue_complete_handler : emptyF
	})
 }
 catch(e){}
}
function startUpload1()
{
 swfu.startUpload();
}
function uploadInit2() 
{
 try{
 swfu2=new SWFUpload({
		flash_url : root+"SWFUpload.swf",
				upload_url: "photoupload.php?mode=1&fid="+fid,
				file_size_limit : "3 MB",
				file_types : "*.gif;*.jpg;*.png",
				file_types_description : "obrazki",
				file_upload_limit : 100,
				file_queue_limit : 0,
				debug: false,
				button_image_url: root+"graph/bt_right.gif",
				button_width: "27",
				button_height: "23",
				button_placeholder_id: "SWFUploadTarget2",
				button_window_mode : SWFUpload.WINDOW_MODE.TRANSPARENT,
				file_queued_handler : startUpload2,
				file_queue_error_handler : emptyF,
				file_dialog_complete_handler : emptyF,
				upload_start_handler : uploadStart2,
				upload_progress_handler : uploadProgressFunction2,
				upload_error_handler : emptyF,
				upload_success_handler : emptyF,
				upload_complete_handler : uploadEnd2,
				queue_complete_handler : emptyF
	})
 }
 catch(e){}
}
function startUpload2()
{
 swfu2.startUpload();
}
//show upload progress
function uploadProgressFunction(file, bytesloaded, bytestotal)
{
 var percent=Math.ceil((bytesloaded / bytestotal) * 100 * 0.9);
 gEBI('divProgress').innerHTML=percent+'%';
}
function uploadProgressFunction2(file, bytesloaded, bytestotal)
{
 var percent=Math.ceil((bytesloaded / bytestotal) * 100 * 0.9);
 gEBI('opisblogaInfo').innerHTML='Trwa przesyłanie pliku na serwer...<br /><span class="boxTxtBlue">'+percent+'%</span>';
}

//on upload start
function uploadStart(file)
{
 gEBI('xFile').value=(file.name.split('.'))[0];
 gEBI('uploadHidder').style.display='block';
}
function uploadStart2(file)
{
 gEBI('uploadHidder2').style.display='block';
}

//on upload end
function uploadEnd()
{
 gEBI('uploadHidder').style.display='none';
 jsrsPOST=true;
 jsrsExecute(root+'jsremote.php', setImageId, "getImageId", fid.toString());
 gEBI('divProgress').innerHTML='100%';
}
function uploadEnd2()
{
 gEBI('uploadHidder2').style.display='none';
 jsrsPOST=true;
 jsrsExecute(root+'jsremote.php', setImageId2, "getImageId2", fid.toString());
 gEBI('opisblogaInfo').innerHTML='Plik został przesłany';
}

//set image id after upload
function setImageId(out)
{
 outTmp=out.split(';');
 gEBI('inputId1').value=outTmp[0];
 gEBI('inputId2').value=outTmp[1];
 gEBI('inputId3').value=outTmp[2];
 gEBI('inputFilename').value=outTmp[3];
 if(out==0)
 {
  gEBI('uploadHidder').style.display='block';
  gEBI('warning').style.display='block';
 }
}
function setImageId2(out)
{
 outTmp=out.split(';');
 gEBI('inputId12').value=outTmp[0];
}

//make list of uploaded photos
function setFotoList()
{
 okladka=0;
 lHtml='';
 for(i=0; i<fotoList.length; i++)
 {
  lHtml=lHtml+'<div style="width: 580px; height: 30px">';
  lHtml=lHtml+'<div><div style="position: absolute; margin-top: 8px; width: 21px; text-align: right" class="standard">'+(i+1)+'.</div></div>';
  lHtml=lHtml+'<div><div style="position: absolute; margin-top: 8px; margin-left: 30px" class="standard">'+fotoList[i][0].substr(0,17)+'</div></div>';
  lHtml=lHtml+'<div><div style="position: absolute; margin-top: 8px; margin-left: 131px" onmouseover="ttshow(this, \'<div style=text-align:center><img src='+root+fotoList[i][1]+' alt=></div>\')" onmouseout="tthidePrevent=false; tthide()"><img src="'+root+'graph/bt_info.gif" alt="" /></div></div>';
  lHtml=lHtml+'<div><div style="position: absolute; margin-top: 9px; margin-left: 164px" onclick="fotoSetDefault('+i+')"><img id="imgDefault'+i+'" src="'+root+'graph/ic_albumflag_';
  if(fotoList[i][2]==1)
  {
   lHtml=lHtml+'on';
   okladka=1;
   imgOkladka=i;
  }
  else lHtml=lHtml+'off';
  lHtml=lHtml+'.gif" alt="zaznacz, aby zdjęcie było okładką albumu" title="zaznacz, aby zdjęcie było okładką albumu" /></div></div>';
  lHtml=lHtml+'<div><div style="position: absolute; margin-top: 8px; margin-left: 194px" class="standard">'+fotoList[i][3].substr(0,40);
  if(fotoList[i][3].length>40)
  lHtml=lHtml+'...';
  lHtml=lHtml+'</div></div>';
  lHtml=lHtml+'<div><div style="position: absolute; margin-top: 11px; margin-left: 457px"><img src="'+root+'graph/hd_edytuj.gif" alt="edytuj" /></div></div>';
  lHtml=lHtml+'<div><div style="position: absolute; margin-top: 3px; margin-left: 491px"><img onclick="editFoto('+i+')" onmouseover="changeImg(this, \'bt_edit_ov\');" onmouseout="changeImg(this, \'bt_edit\');" onmousedown="changeImg(this, \'bt_edit_dn\');" onmouseup="changeImg(this, \'bt_edit_ov\');" src="'+root+'graph/bt_edit.gif" alt="" /></div></div>';
  lHtml=lHtml+'<div><div style="position: absolute; margin-top: 11px; margin-left: 525px"><img src="'+root+'graph/hd_usun.gif" alt="usuń" /></div></div>';
  lHtml=lHtml+'<div><div style="position: absolute; margin-top: 3px; margin-left: 550px"><img onclick="deleteFoto('+i+')" onmouseover="changeImg(this, \'bt_delete_ov\');" onmouseout="changeImg(this, \'bt_delete\');" onmousedown="changeImg(this, \'bt_delete_dn\');" onmouseup="changeImg(this, \'bt_delete_ov\');" src="'+root+'graph/bt_delete.gif" alt="" /></div></div>';
  lHtml=lHtml+'<div><div style="position: static; margin-top: 0px; margin-left: 550px; height: 30px"><!-- --></div></div>';
  lHtml=lHtml+'</div>';
 }
 gEBI('divFotoList').innerHTML=lHtml;
 if(gEBI('divFotoList').innerHTML=='') gEBI('divFotoList').style.display='none';
 else gEBI('divFotoList').style.display='block';
 if(okladka==0) fotoSetDefault(0);
}

//set default photo
var imgOkladka=0;
function fotoSetDefault(x)
{
 if(fotoList.length>0)
 {
  i=0;
  while(obj=gEBI('imgDefault'+i))
  {
   changeImg(obj, 'defaultOff');
   fotoList[i][2]=0;
   i++;
  }
  changeImg('imgDefault'+x, 'defaultOn');
  fotoList[x][2]=1;
  imgOkladka=x;
 }
}

//edit uploaded photo
var photoEdit;
function editFoto(x)
{
 photoEdit=true;
 gEBI('uploadHidder').style.display='none';
 gEBI('itemId').value=x;
 gEBI('inputFilename').value=fotoList[x][1];
 gEBI('inputId1').value=fotoList[x][4];
 gEBI('inputId2').value=fotoList[x][5];
 gEBI('inputId3').value=fotoList[x][6];
 gEBI('xFile').value=fotoList[x][0];
 gEBI('xOpis').value=fotoList[x][3];
 gEBI('divUpload').style.display='block';
 gEBI('hidder').style.display='block';
 setTimeout('uploadInit()', 700);
 setTimeout('uploadInit()', 1000);
}

//delete uploaded photo
function deleteFoto(x)
{
 fotoList.splice(x, 1);
 setFotoList();
}

//show add new photo tab
function addFoto(x)
{
 gEBI('itemId').value=0;
 gEBI('uploadHidder').style.display='block';
 gEBI('inputId1').value=0;
 gEBI('inputId2').value=0;
 gEBI('inputId3').value=0;
 gEBI('xFile').value='';
 gEBI('xOpis').value='';
 gEBI('hidder').style.display='block';
 gEBI('divUpload').style.display='block';
 setTimeout('uploadInit()', 700);
 setTimeout('uploadInit()', 1000);
}

//cancel adding new photo
function uploadAnuluj()
{
 photoEdit=false;
 gEBI('hidder').style.display='none';
 gEBI('divUpload').style.display='none';
}

//add new photo
function uploadDodaj()
{
 itemId1=gEBI('itemId').value;
 itemTmp=new Array;
 itemTmp[0]=gEBI('xFile').value;
 itemTmp[1]=gEBI('inputFilename').value;
 itemTmp[2]=0;
 itemTmp[3]=gEBI('xOpis').value;
 itemTmp[4]=gEBI('inputId1').value;
 itemTmp[5]=gEBI('inputId2').value;
 itemTmp[6]=gEBI('inputId3').value;
 if(!photoEdit) fotoList.push(itemTmp);
 else fotoList[itemId1]=itemTmp;
 gEBI('hidder').style.display='none';
 gEBI('divUpload').style.display='none';
 setFotoList();
 photoEdit=false;
}

//add new entry
function dodajWpis()
{
 id=id2;
 if(id<1) id=0;
 date=gEBI('2').value+'.'+gEBI('3').value+'.'+gEBI('4').value;
 weight=gEBI('input_waga').value;
 title=gEBI('xTytul').value;
 
 d1=parseInt(gEBI('4').value);
 d2tmp=gEBI('3').value;
 if((d2tmp.length==2) && d2tmp.charAt(0)=='0') d2=parseInt(d2tmp.charAt(1));
 else d2=parseInt(d2tmp);
 d3tmp=gEBI('2').value;
 if((d3tmp.length==2) && d3tmp.charAt(0)=='0') d3=parseInt(d3tmp.charAt(1));
 else d3=parseInt(d3tmp);
 
 var settedDate=new Date();
 settedDate.setFullYear(d1,(d2-1),(d3-1));
 
 if(settedDate>today)
 {
  window.scroll(0, 470);
  gEBI('warningDate').style.display='block';
 }
 else
 {
 if(id1==39)
 {
  //diet
  posilek=new Array;
  for(var j=1; j<6; j++)
  {
   posilek[j]='';
   for(var i=0; i<dieta[j].length; i++)
   {
    if(posilek[j]!='') posilek[j]=posilek[j]+'~.~';
    posilek[j]=posilek[j]+dieta[j][i][0]+'~,~'+dieta[j][i][17]+'~,~'+dieta[j][i][18];
   }
  }
  cposilek=posilek[1]+'~/~'+posilek[2]+'~/~'+posilek[3]+'~/~'+posilek[4]+'~/~'+posilek[5];
  data=id+'~*~'+date+'~*~'+weight+'~*~'+title+'~*~'+cposilek;
 }
 else
 {
  //others
  if(gEBI('input_typ')) type=gEBI('input_typ').value;
  else type=0;
  txt=FCKeditorAPI.GetInstance('input_komentarz').GetHTML();
  txt=(txt.replace(/\"/g, '&quot;'));
  id_mainfoto=imgOkladka;
  foto='';
  for(i=0; i<fotoList.length; i++)
  {
   if(foto!='') foto=foto+'~/~';
   foto=foto+fotoList[i][0]+'~,~';
   foto=foto+fotoList[i][3]+'~,~';
   foto=foto+fotoList[i][4]+'~,~';
   foto=foto+fotoList[i][5]+'~,~';
   foto=foto+fotoList[i][6];
  }
  if(foto=='') type=1;
  tags=gEBI('xTagi').value;
  if(gEBI('5')) profil=gEBI('5').value;
  else profil=0;
 
  if(gEBI('xVWaga')) vWaga1=gEBI('xVWaga').value.replace(',','.');
  else vWaga1=0;
  if(gEBI('xVWzrost')) vWzrost1=gEBI('xVWzrost').value.replace(',','.');
  else vWzrost1=0;
  if(gEBI('xVObwod')) vObwod1=gEBI('xVObwod').value.replace(',','.');
  else vObwod1=0;
 
  if(isNaN(vWaga1)) vWaga1=0;
  if(isNaN(vWzrost1)) vWzrost1=0;
  if(isNaN(vObwod1)) vObwod1=0;
 
  data=id+'~*~'+date+'~*~'+weight+'~*~'+title+'~*~'+type+'~*~'+txt+'~*~'+id_mainfoto+'~*~'+foto+'~*~'+tags+'~*~'+profil+'~*~'+vWaga1+'~*~'+vWzrost1+'~*~'+vObwod1;
 }
 
 jsrsPOST=true;
 if(gPage==21) f='saveInjectionUser';
 else if(gPage==25) f='saveNetUser';
 else if(gPage==39) f='saveDietUser';
 else f='saveBlogUser';
  
 jsrsExecute(root+'jsremote.php', dodajWpisEnd, f, data.toString());
 
 if(gEBI('divBody').style.display=='block')
 gEBI('divBody').style.display='none';
 if(gEBI('divLoader').style.display=='none')
 gEBI('divLoader').style.display='block';
 gEBI('div_komentarz').style.left='-1000px';
 
 swfClearCache();
 }
}
function dodajWpisEnd(out)
{
 if(gPage==19 || gPage==20 || gPage==21) p=19;
 else if(gPage==23 || gPage==24 || gPage==25) p=23;
 else if(gPage==37 || gPage==38 || gPage==39) p=37;
 else p=5;
 loadP(p);
 
 var y=date.getYear()+1900;
 if(y>3000) y=y-1900;
 var nDate=date.getDate()+'.'+(date.getMonth()+1)+'.'+y;
 try
 {
  mainSwf.centerTimeline(nDate);
 }
 catch(e)
 {}
 if(out==0) urchinTracker('/pierwszy-wpis.html');
}

//remove entry
function usunWpis()
{
 id=id2;
 if(id<1) id=0;
 data=id;
 jsrsPOST=true;
 if(gPage==19 || gPage==20 || gPage==21) f='delInjectionUser';
 else if(gPage==23 || gPage==24 || gPage==25) f='delNetUser';
 else if(gPage==37 || gPage==38 || gPage==39) f='delDietUser';
 else f='delBlogUser';
 jsrsExecute(root+'jsremote.php', dodajWpisEnd, f, data.toString());
 
 if(gEBI('divBody').style.display=='block')
 gEBI('divBody').style.display='none';
 if(gEBI('divLoader').style.display=='none')
 gEBI('divLoader').style.display='block';
 gEBI('div_komentarz').style.left='-1000px';
 
 swfClearCache();
}

//cancel entry
function anulujWpis()
{
 if(gPage==21) p=19;
 else if(gPage==25) p=23;
 else if(gPage==39) p=37;
 else p=5;
 loadP(p);
}

//make temporary gallery
function galleryTmp()
{
 foto='';
 for(i=0; i<fotoList.length; i++)
 {
  if(foto!='') foto=foto+'~/~';
  foto=foto+fotoList[i][0]+'~,~';
  foto=foto+fotoList[i][3]+'~,~';
  foto=foto+fotoList[i][4]+'~,~';
  foto=foto+fotoList[i][5]+'~,~';
  foto=foto+fotoList[i][6];
 }
 tags=gEBI('xTagi').value;
 
 jsrsPOST=true;
 jsrsExecute(root+'jsremote.php', gallery, "saveGalleryTmp", foto.toString());
}

//show gallery
function gallery(x)
{
 gEBI('hidder').style.display='block';
 gEBI('divGallery').style.display='block';
}

//close gallery
function galleryClose()
{
 gEBI('hidder').style.display='none';
 gEBI('divGallery').innerHTML='';
 gEBI('divGallery').style.display='none';
}

//search
function szukaj()
{
 txt=gEBI('xSzukaj').value;
 okres=gEBI('1').value;
 if(okres=='') okres=1;
 pattern=/&/g;
 txt=escape(txt.replace(pattern, '*'));
 if(gPage==19 || gPage==20 || gPage==21) p=19;
 else if(gPage==23 || gPage==24 || gPage==25) p=23;
 else if(gPage==37 || gPage==38 || gPage==39) p=37;
 else p=5;
 if(txt.length>2) loadP(p, id2, 1, okres, okres, txt);
}

//set main banner size
function setSize(x)
{
 if(x==1) setTimeout('bannerUp()', 500);
 else if(x==2) setTimeout('bannerDown()', 500);
}
function bannerDown()
{
 gEBI('divBanner').style.height='470px';
}
function bannerUp()
{
 gEBI('divBanner').style.height='230px';
}

//first entry mode
var blogFirstMode;
blogFirstMode=1;
function blogFirstGo()
{
 akcept=gEBI('input_akcept').checked;
 if(akcept)
 {
  jsrsPOST=true;
  jsrsExecute(root+'jsremote.php', blogFirstGoCont, "blogFirst", blogFirstMode.toString());
  
  if(gEBI('divBody').style.display=='block')
  gEBI('divBody').style.display='none';
  if(gEBI('divLoader').style.display=='none')
  gEBI('divLoader').style.display='block';
 }
}
function blogFirstGo2()
{
 akcept=gEBI('input_akcept').checked;
 if(akcept)
 {
  dietSaveUserData();
  jsrsPOST=true;
  jsrsExecute(root+'jsremote.php', blogFirstGo2Cont, "blogFirst2");
  
  if(gEBI('divBody').style.display=='block')
  gEBI('divBody').style.display='none';
  if(gEBI('divLoader').style.display=='none')
  gEBI('divLoader').style.display='block';
 }
}
function blogFirstGoCont(out)
{
 loadP(5);
}
function blogFirstGo2Cont(out)
{
 loadP(37);
}
function chBlogFirst(mode)
{
 blogFirstMode=mode;
 if(mode==1)
 {
  changeImg('rd1f', 'bt_r_on');
  changeImg('rd2f', 'bt_r_off');
 }
 else if(mode==2)
 {
  changeImg('rd2f', 'bt_r_on');
  changeImg('rd1f', 'bt_r_off');
 }
}

//select onchange event
function selectEvent(id)
{
 if(gPage==9)
 {
  x=gEBI('1').value;
  loadP(10, x);
 }
 if(gPage==19 || gPage==20 || gPage==21)
 {
  if(gEBI('1').value!='')
  {
   loadP(19, 0, 1, gEBI('1').value.toString(), gEBI('1').value.toString());
  }
 }
 if(gPage==23 || gPage==24 || gPage==25)
 {
  if(gEBI('1').value!='')
  {
   loadP(23, 0, 1, gEBI('1').value.toString(), gEBI('1').value.toString());
  }
 }
 if(gPage==5 || gPage==6 || gPage==7)
 {
  if(gEBI('1').value!='')
  {
   loadP(5, 0, 1, gEBI('1').value.toString(), gEBI('1').value.toString());
  }
 }
 if(gPage==39 && gEBI('div_addProduct').style.display=='block')
 {
  if(gEBI('select_kategoria').style.diplay='block') dietGetCategory(gEBI(5).value);
  if(gEBI('select_kategoriaz').style.diplay='block') dietGetCategory3(gEBI(6).value);
  if(id>1000000000)
  {
   pId=(id-1000728381)/1000000;
   if(gEBI(1000+pId).value==1) gEBI('xIlosc1_'+pId).value=100;
   else gEBI('xIlosc1_'+pId).value=1;
  }
 }
}

//main banner menu click
function swfMenu(x)
{
 fromswf=1;
 if(x==1) loadP(0);
 if(x==2) loadP(1);
 if(x==3) loadP(2, 1);
 if(x==4) loadP(9);
 if(x==5) loadP(12);
 if(x==6) 
 {
  fromswf=0;
  goMyblog();
 }
 if(x==7) loadP(19);
 if(x==8) loadP(37);
 if(x==9) loadP(23);
 if(x==10) loadP(2, 2);
 if(x==11) loadP(2, 3);
 if(x==12) loadP(2, 4);
 if(x==33) loadP(33);
}

//back to my blog
function goMyblog()
{
 jsrsPOST=true;
 jsrsExecute(root+'jsremote.php', goMyblogCont, "goMyblog");
 
 swfClearCache();
}
function goMyblogCont()
{
 loadP(5);
}

//expert send question
function askExpert()
{
 txt=gEBI('xPytanie').value;
 txt2=gEBI('xPytanie2').value;
 if(txt2.length<1)
 {
  gEBI('wT').innerHTML='Uwaga: podaj wiek dziecka, by wysłać wiadomość. Uzupełnij pole i spróbuj jeszcze raz.';
  gEBI('warning').style.display='block';
 }
 else
 {
 txt=txt+'~*~'+txt2;
 if(txt.length>1)
 {
  jsrsPOST=true;
  jsrsExecute(root+'jsremote.php', askExpertCont, "askExpert", txt.toString());
 }
 }
}
function askExpertCont(out)
{
 gEBI('wT').innerHTML='Twoje pytanie zostało wysłane.';
 gEBI('warning').style.display='block';
}
function askExpertCont2()
{
 if(gEBI('wT').innerHTML=='Twoje pytanie zostało wysłane.') loadP(9);
 else gEBI('warning').style.display='none';
}

//init swf mini gallery
function initGallery(x)
{
 if(!gEBI('flashGallery'+x))
 {
  flash=new SWFObject(root+'gallery.swf?gateway='+gateway+'&id='+x, "flashGallery"+x, "100%", "100%", "8", "#ffffff");
  flash.addParam("wmode", "transparent");
  flash.write('divGallery'+x); 
 }
}

//send link to article
function sendArticle(x)
{
 id=x.toString();
 email=gEBI('xEmail').value;
 komentarz=gEBI('xKomentarz').value;
 
 emailReg=/^[\w-_.]*[\w-_.]@[\w].+[\w]+[\w]$/;
 
 if(emailReg.exec(email))
 {
  data=id+';'+email+';'+komentarz;
  jsrsPOST=true;
  
  if(gPage==16) jsrsExecute(root+'jsremote.php', sendArticleCont, "sendArticleWater", data);
  else jsrsExecute(root+'jsremote.php', sendArticleCont, "sendArticle", data);
 }
}
function sendArticleCont()
{
 gEBI('divPolec').style.display='none';
}

//send link to blog
function blogPolec(x)
{
 if(x==2)
 {
  email=gEBI('xPolec').value;
  emailReg=/^[\w-_.]*[\w-_.]@[\w].+[\w]+[\w]$/;
 
  if(emailReg.exec(email))
  {
   gEBI('divPolec1').style.display='none';
   gEBI('divPolec2').style.display='block';
  }
 }
 if(x==1)
 {
  email=gEBI('xPolec').value;
  komentarz=gEBI('xPolec2').value;
  if(komentarz=='Twój komentarz') komentarz='';
  gEBI('divPolec2').style.display='none';
  gEBI('divPolec1').style.display='block';
  
  data=email+';'+komentarz;
  jsrsPOST=true;
  jsrsExecute(root+'jsremote.php', sendBlogCont, "sendBlog", data);
 }
}
function sendBlogCont(out)
{
 gEBI('warning').style.display='block';
}

//video mini/full mode
function videoToggle(id, file, pic)
{
 if(pic!='' && pic!='undefined') pic='&pic='+pic;
 if(gEBI('divVideo').style.display=='none')
 {
  flash=new SWFObject(root+'videoPlayer.swf?file='+file+'&size=1&id='+id+pic, 'player'+id, "100%", "100%", "8", "#000000"); 
  flash.addParam("wmode", "transparent"); 
  flash.write('divVideo'+id);
  
  flash=new SWFObject(root+'videoPlayerBig.swf?file1='+file+'&size=2&id='+id+pic, 'player2'+id, "100%", "100%", "8", "#000000"); 
  flash.addParam("wmode", "transparent"); 
  flash.write('divVideo');
 
  gEBI('divVideo').style.display='block';
 }
 else
 {
  flash=new SWFObject(root+'videoPlayer.swf?file='+file+'&size=1&id='+id+pic, 'player'+id, "100%", "100%", "8", "#000000"); 
  flash.addParam("wmode", "transparent"); 
  gEBI('divVideo').innerHTML='';;
  gEBI('divVideo').style.display='none';
 }
}

//unselect list box item
function unselectLast(id)
{
 if(gList!=id)
 {
  try
  {
   gEBI(gList).style.backgroundColor=bListC;
  }
  catch(e)
  {}
 }
}

//after logout go-to
function afterLogout()
{
 if(gPage=='blogszczegoly') gPage='bloggaleria';
 if(gPage==6) gPage=5;
 if(gPage==7) gPage=5;
 if(gPage==8) gPage=5;
 if(gPage==19) gPage=19;
 if(gPage==20) gPage=19;
 if(gPage==21) gPage=19;
 if(gPage==22) gPage=19;
 if(gPage==23) gPage=23;
 if(gPage==24) gPage=23;
 if(gPage==25) gPage=23;
 if(gPage==26) gPage=23;
 if(gPage==17) gPage=0;
 if(gPage==18) gPage=0;
 if(gPage==38) gPage=37;
 if(gPage==39) gPage=37;
 if(gPage==40) gPage=37;
 loadP(gPage, gId);
 
 swfClearCache();
}

//get window width & height
function getWidth()
{
 if (parseInt(navigator.appVersion)>3) 
 {
  if (navigator.appName.indexOf("Microsoft")!=-1) 
  {
  winW = document.body.offsetWidth;
  }
  else
  {
   winW = window.innerWidth;
  }
 }
 return winW;
}
function getHeight()
{
 winH=gEBI('tdFooter').offsetTop;
 return winH;
}

//after register go-to
function afterRegister()
{
 if(pPage==17 || pPage==18) pPage=0;
 loadP(pPage, pId);
}

//after config go-to
function afterConfig()
{
 if(pPage==17 || pPage==18) pPage=0;
 loadP(pPage, pId);
}

//register & config page
function beforeRegister()
{
 loadP(17);
}
function beforeConfig()
{
 loadP(18);
}

//full gallery mode
function fullGallery(id)
{
 gEBI('divBanner').style.height='1px';
 gEBI('divFullGallery').style.height=getHeight()+'px';
 gEBI('divFullGallery').style.display='block';
}

//search blog entry by tag
function tagSearch(tag)
{
 tag=tag.toString();
 if(gPage==19 || gPage==20 || gPage==21) p=19;
 else if(gPage==23 || gPage==24 || gPage==25) p=23;
 else p=5;
 loadP(p, id2, 1, 1, 1, tag);
}

//bookmark page
function bookmark(title, url)
{
 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);
}

//show link to page
function showLink(url)
{
 gEBI('divBlogLink').style.display='block';
 gEBI('xLink').readOnly='readonly';
 gEBI('xLink').value=url;
}

//change public blog mode
function changePublic(obj)
{
 var p=0;
 if(obj.checked) p=1;
 else p=0;
 
 jsrsPOST=true;
 jsrsExecute(root+'jsremote.php', emptyF, "changePublic", p.toString());
}

//go to my blog
function toMyBlog()
{
 jsrsPOST=true;
 jsrsExecute(root+'jsremote.php', toMyBlogEnd, "toMyBlog");
 
 if(gEBI('divBody').style.display=='block')
 gEBI('divBody').style.display='none';
 if(gEBI('divLoader').style.display=='none')
 gEBI('divLoader').style.display='block';
 
 swfClearCache();
}
function toMyBlogEnd()
{
 loadP(5);
}

//show gallery in edit mode
function galleryEditMode()
{
 var data='';
 for(i=0; i<fotoList.length; i++)
 {
  if(data!='') data=data+'~*~';
  data=data+fotoList[i][3]+'~/~'+fotoList[i][4]+'~/~'+fotoList[i][5]+'~/~'+fotoList[i][6];
 }
 jsrsPOST=true;
 jsrsExecute(root+'jsremote.php', galleryEditModeEnd, "galleryEditMode", data.toString());
}
function galleryEditModeEnd()
{
 showGallery(0);
}

//show & hide gallery
function showGallery(id)
{
 gEBI('divBanner').style.height='1px';
 scrollUp();
 document.body.style.overflow='hidden';
 gEBI('divFullGallery').style.display='block';
 flash=new SWFObject(root+'galleryBig.swf?id='+id+'&gateway='+gateway, "galleryBig", "100%", "100%", "8", "#000000");
 flash.write('divFullGallery');
}
function closeGallery()
{
 scrollUp();
 document.body.style.overflow='auto';
 gEBI('divFullGallery').innerHTML='';
 gEBI('divFullGallery').style.display='none';
 setTimeout(function(){try{mainSwf.setMenu(6)} catch(e){}}, 1000);
 gEBI('divBanner').style.height='470px';
}

//show & hide print version
function showPrint(type)
{
 scrollUp();
 document.body.style.overflow='hidden';
 gEBI('divFullGallery').style.display='block';
 flash=new SWFObject(root+'print.swf?type='+type+'&gateway='+gateway, "galleryBig", "550", "650", "8", "#ffffff");
 flash.write('divFullGallery');
}
function closePrint()
{
 scrollUp();
 document.body.style.overflow='auto';
 gEBI('divFullGallery').innerHTML='';
 gEBI('divFullGallery').style.display='none';
 setTimeout(function(){try{mainSwf.setMenu(9)}catch(e){}}, 1000);
}

//refresh page
function refresh()
{
 loadP(id1, id2);
}

//go to tool
function goTools(x)
{
 if(x==1)
 {
  if(id1==5) window.scroll(0, 450);
  else loadP(5);
 }
 else if(x==2)
 {
  if(id1==19) window.scroll(0, 450);
  else loadP(19);
 }
 else if(x==3)
 {
  if(id1==23) window.scroll(0, 450);
  else loadP(23);
 }
}

//go to add blog entry page
function addBlog()
{
 if(id1==5 || id1==6 || id1==7 || id1==8) loadP(7);
 if(id1==19 || id1==20 || id1==21 || id1==22) loadP(21);
 if(id1==23 || id1==24 || id1==25 || id1==26) loadP(25);
}

//go to help page
function goHelp(id)
{
 loadP(28, id);
}

//refresh session
function setSession()
{
 jsrsPOST=true;
 jsrsExecute(root+'jsremote.php', emptyF, "setSession");
}

//add comment
function dodajKomentarz()
{
 gEBI('divCaptchaWarn').style.display='none';
 fileCaptcha=gEBI('captchaDiv').innerHTML;
 captcha=gEBI('xKod').value;
 
 if(comment1=='')
 {
  txt=fileCaptcha+'~*~'+captcha;
  jsrsPOST=true;
  jsrsExecute(root+'jsremote.php', dodajKomentarzCont, "checkCaptcha", txt);
 }
 else
 {
  dodajKomentarzCont(1);
 }
 
 swfClearCache();
}
function dodajKomentarzCont(x)
{
 if(x==1)
 {
  txt='';
  idBlog=id2;
  idComment=id3;
  comment=FCKeditorAPI.GetInstance('input_komentarz').GetHTML();
  nick=gEBI('xNick').value;
  fileCaptcha=gEBI('captchaDiv').innerHTML;
  captcha=gEBI('xKod').value;
  comment=(comment.replace(/\"/g, '&quot;'));
  nick=(nick.replace(/\"/g, '&quot;'));
  
  if(comment1=='')
  {
   txt=idBlog+'~*~'+comment+'~*~'+nick+'~*~'+fileCaptcha+'~*~'+captcha;
   jsrsPOST=true;
   jsrsExecute(root+'jsremote.php', dodajKomentarzCont2, "addCommentUser", txt);
  }
  else
  {
   txt=idComment+'~*~'+comment;
   jsrsPOST=true;
   jsrsExecute(root+'jsremote.php', dodajKomentarzCont2, "editCommentUser", txt);
  }
 
  if(gEBI('divBody').style.display=='block')
  gEBI('divBody').style.display='none';
  if(gEBI('divLoader').style.display=='none')
  gEBI('divLoader').style.display='block';
  gEBI('div_komentarz').style.left='-1000px';
 }
 else
 {
  gEBI('divCaptchaWarn').style.display='block';
 }
 /*
 if(gPage==31) loadP(31, id2);
 else loadP(6, id2);
 */
}

function dodajKomentarzCont2()
{
 if(gPage==31) loadP(31, id2);
 else loadP(6, id2);
}

//remove comment
function usunKomentarz()
{
 idComment=id3;
 jsrsPOST=true;
 jsrsExecute(root+'jsremote.php', dodajKomentarzCont, "delCommentUser", idComment);
 
 if(gEBI('divBody').style.display=='block')
 gEBI('divBody').style.display='none';
 if(gEBI('divLoader').style.display=='none')
 gEBI('divLoader').style.display='block';
 gEBI('div_komentarz').style.left='-1000px';
 
 swfClearCache();
}
function usunKomentarz2(idComment)
{
 jsrsPOST=true;
 jsrsExecute(root+'jsremote.php', dodajKomentarzCont, "delCommentUser", idComment.toString());
 
 if(gEBI('divBody').style.display=='block')
 gEBI('divBody').style.display='none';
 if(gEBI('divLoader').style.display=='none')
 gEBI('divLoader').style.display='block';
 gEBI('div_komentarz').style.left='-1000px';
 
 swfClearCache();
}

//cancel comment
function anulujKomentarz()
{
 loadP(6, id2);
}

//change comment
function changeComment(obj)
{
 var t=0;
 if(obj.checked) t=1;
 jsrsPOST=true;
 jsrsExecute(root+'jsremote.php', emptyF, "changeComment", t.toString());
 
 swfClearCache();
}

//change common blog mode
function setWspolny(type)
{
 changeImg('rw1', 'bt_r_off');
 changeImg('rw2', 'bt_r_off');
 changeImg('rw'+type, 'bt_r_on');
 jsrsPOST=true;
 jsrsExecute(root+'jsremote.php', emptyF, "setWspolny", type.toString());
 
 swfClearCache();
}

//show & hide change blog description tab
function opisblogaOtworz()
{
 gEBI('opisblogaInfo').innerHTML='Wskaż plik graficzny, który będzie wizytówką Twojego<br />bloga (JPG, GIF, PNG, nie większy niż 1024x768px)';
 gEBI('divOpisbloga').style.display='block';
 setTimeout('uploadInit2()', 100);
 setTimeout('uploadInit2()', 500);
 FCKeditorAPI.GetInstance('input_komentarzOpisbloga').SetHTML(gEBI('divOpisblogaTresc').innerHTML);
 gEBI('div_komentarzOpisbloga').style.left=((getWidth()/2)-310)+'px';
}
function opisblogaAnuluj()
{
 gEBI('div_komentarzOpisbloga').style.left='-1000px';
 gEBI('divOpisbloga').style.display='none';
}

//save blog description
function opisblogaZapisz()
{
 txt=FCKeditorAPI.GetInstance('input_komentarzOpisbloga').GetHTML();
 txt=(txt.replace(/\"/g, '&quot;'));
 idFoto=gEBI('inputId12').value; 
 
 jsrsPOST=true;
 jsrsExecute(root+'jsremote.php', opisblogaZapiszCont, "opisblogaSave", idFoto+'~/~'+txt);
 
 if(gEBI('divBody').style.display=='block')
 gEBI('divBody').style.display='none';
 if(gEBI('divLoader').style.display=='none')
 gEBI('divLoader').style.display='block';
 gEBI('div_komentarz').style.left='-1000px';
}
function opisblogaZapiszCont(output)
{
 loadP(5);
}

//show report violation window
function zglosNaruszenie(obj, comment)
{
 x=obj.offsetLeft;
 y=obj.offsetTop;
 if(y<674) y=674;
 gEBI('divWarn').style.left=(x-553)+'px';
 gEBI('divWarn').style.top=(y-184)+'px';
 gEBI('inputWarnId').value=comment;
 gEBI('xWarnPowod').value='';
 if(gEBI('xWarnEmail')) gEBI('xWarnEmail').value='';
 gEBI('warnError').style.display='none';
 gEBI('divWarn').style.display='block';
}

//send report violation
function zglosWyslij()
{
 tresc=gEBI('xWarnPowod').value;
 id_comment=gEBI('inputWarnId').value;
 id_commentTmp=id_comment.split('_');
 if(id_commentTmp[1]=='1') action='zglosWyslijBlog';
 else action='zglosWyslij';
 id_comment=id_commentTmp[0];
 
 if(gEBI('xWarnEmail'))
 {
 email=gEBI('xWarnEmail').value;
 }
 else email='';
 
 emailReg=/^[\w-_.]*[\w-_.]@[\w].+[\w]+[\w]$/;
 
 if(emailReg.exec(email) || !gEBI('xWarnEmail'))
 {
  gEBI('divWarn').style.display='none';
  tresc=(tresc);
  email=(email);
  jsrsPOST=true;
  jsrsExecute(root+'jsremote.php', emptyF, action, tresc+'~/~'+email+'~/~'+id_comment);
 }
 else
 {
  gEBI('warnError').style.display='block';
 }
}

//show & hide user decription
function showAbout(obj, nazwa, plec, miejscowosc, opis, dzieci, foto)
{
 x=obj.offsetLeft+10;
 y=obj.offsetTop+10;
 gEBI('divAbout').style.left=x+'px';
 gEBI('divAbout').style.top=y+'px';
 
 if(plec==1) miejscowosc='kobieta, '+miejscowosc;
 if(plec==2) miejscowosc='mężczyzna, '+miejscowosc;
 if(dzieci!='')
 opis=opis+'<br /><br />'+'Dzieci (zarejestrowane na serwisie)'+'<br />'+dzieci;
 if(foto!='') foto='<img src="'+root+foto+'" alt="" />';
 else
 {
  if(plec==2) foto='<img src="'+root+'graph/ic_userprofile_default_man.gif" alt="" />';
  else foto='<img src="'+root+'graph/ic_userprofile_default_woman.gif" alt="" />';
 }
 gEBI('aboutNazwa').innerHTML=nazwa;
 gEBI('aboutPlec').innerHTML=miejscowosc;
 gEBI('aboutOpis').innerHTML=opis;
 gEBI('aboutFoto').innerHTML=foto;
 gEBI('divAbout').style.display='block';
}
function hideAbout()
{
 gEBI('divAbout').style.display='none';
}

//change user data
function zmienDane()
{
 try{mainSwf.setRegisterView();}
 catch(e){}
 loadP(18);
}

//show & hide meal details
function toggle_posilek(id)
{
 if(gEBI('tbl_danie'+id).style.display=='none')
 {
  gEBI('tbl_danie'+id).style.display='block';
  changeImg('img_posilekToggle'+id,'ic_slide1');
 }
 else
 {
  gEBI('tbl_danie'+id).style.display='none';
  changeImg('img_posilekToggle'+id,'ic_slide2');
 }
}

//refresh meals list
function refreshDiet()
{
 var posilek=new Array;
 var grey=false;
 var tt;
 var k=0;
 var wartosc=new Array;
 var cwartosc=new Array;
 
 for(var i=0; i<8; i++)
 {
  cwartosc[i]=0;
 }
 
 for(var j=1; j<6; j++)
 {
  for(var i=0; i<8; i++)
  {
   wartosc[i]=0;
  }
  
  k++;
  
  posilek[j]='';
  posilek[j]=posilek[j]+'<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" style=\"margin-top: 13px;\">';
  posilek[j]=posilek[j]+'<tr>';
  posilek[j]=posilek[j]+'<td height=\"1\" bgcolor=\"#b2b2b2\" width=\"522\" colspan=\"8\"></td>';
  posilek[j]=posilek[j]+'</tr>';
    
  for(var i=0; i<dieta[j].length; i++)
  {
   tt='';
   tt=tt+'<div style=width:166px;text-align:center;margin-top:12px;margin-bottom:12px class=dGrey1>'+dieta[j][i][2].replace(/\"/g, '')+'</div>';
   tt=tt+'<table border=0 cellpadding=0 cellspacing=0>';
   tt=tt+'<tr>';
   tt=tt+'<td width=98 class=dGrey2>';
   tt=tt+'energia (kcal):';
   tt=tt+'</td>';
   tt=tt+'<td width=68 class=dGrey2 align=right>';
   tt=tt+Math.round(((dieta[j][i][17]*dieta[j][i][3])/100));
   tt=tt+'</td>';
   tt=tt+'</tr>';
   tt=tt+'<tr>';
   tt=tt+'<td class=dGrey2>';
   tt=tt+'białko (g):';
   tt=tt+'</td>';
   tt=tt+'<td class=dGrey2 align=right>';
   tt=tt+Math.round(((dieta[j][i][17]*dieta[j][i][4])/100));
   tt=tt+'</td>';
   tt=tt+'</tr>';
   tt=tt+'<tr>';
   tt=tt+'<td class=dGrey2>';
   tt=tt+'tłuszcz (g):';
   tt=tt+'</td>';
   tt=tt+'<td class=dGrey2 align=right>';
   tt=tt+Math.round(((dieta[j][i][17]*dieta[j][i][5])/100));
   tt=tt+'</td>';
   tt=tt+'</tr>';
   tt=tt+'<tr>';
   tt=tt+'<td class=dGrey2>';
   tt=tt+'węglowodany (g):';
   tt=tt+'</td>';
   tt=tt+'<td class=dGrey2 align=right>';
   tt=tt+Math.round(((dieta[j][i][17]*dieta[j][i][6])/100));
   tt=tt+'</td>';
   tt=tt+'</tr>';
   tt=tt+'<tr>';
   tt=tt+'<td class=dGrey2>';
   tt=tt+'błonnik (g):';
   tt=tt+'</td>';
   tt=tt+'<td class=dGrey2 align=right>';
   tt=tt+Math.round(((dieta[j][i][17]*dieta[j][i][7])/100));
   tt=tt+'</td>';
   tt=tt+'</tr>';
   tt=tt+'<tr>';
   tt=tt+'<td class=dGrey2>';
   tt=tt+'kwas foliowy (&micro;g):';
   tt=tt+'</td>';
   tt=tt+'<td class=dGrey2 align=right>';
   tt=tt+Math.round(((dieta[j][i][17]*dieta[j][i][8])/100));
   tt=tt+'</td>';
   tt=tt+'</tr>';
   tt=tt+'<tr>';
   tt=tt+'<td class=dGrey2>';
   tt=tt+'wapń (mg):';
   tt=tt+'</td>';
   tt=tt+'<td class=dGrey2 align=right>';
   tt=tt+Math.round(((dieta[j][i][17]*dieta[j][i][9])/100));
   tt=tt+'</td>';
   tt=tt+'</tr>';
   tt=tt+'<tr>';
   tt=tt+'<td class=dGrey2>';
   tt=tt+'żelazo (mg):';
   tt=tt+'</td>';
   tt=tt+'<td class=dGrey2 align=right>';
   tt=tt+Math.round(((dieta[j][i][17]*dieta[j][i][10])/100));
   tt=tt+'</td>';
   tt=tt+'</tr>';
   tt=tt+'</table>';
   
   if(!grey) grey=true;
   else grey=false;
  
   posilek[j]=posilek[j]+'<tr';
   if(grey) posilek[j]=posilek[j]+' bgcolor=\"#f7f7f7\"';
   posilek[j]=posilek[j]+'>';
   posilek[j]=posilek[j]+'<td height=\"30\" width=\"21\" align=\"right\" class=\"standard\" style=\"text-align: right\">'+(i+1)+'.</td>';
   posilek[j]=posilek[j]+'<td width=\"11\"></td>';
   posilek[j]=posilek[j]+'<td width=\"234\" class=\"standard\">'+dieta[j][i][2]+'</td>';
   posilek[j]=posilek[j]+'<td width=\"111\" class=\"standard\">';
   if(dieta[j][i][18]>0) posilek[j]=posilek[j]+dieta[j][i][18]+' '+dieta[j][i][11]+' ('+dieta[j][i][17]+'g)';
   else posilek[j]=posilek[j]+dieta[j][i][17]+'g';
   posilek[j]=posilek[j]+'</td>';
   posilek[j]=posilek[j]+'<td width=\"51\" class=\"standard\" style=\"text-align: right\">'+Math.round(((dieta[j][i][17]*dieta[j][i][3])/100))+' kcal</td>';
   posilek[j]=posilek[j]+'<td width=\"7\"></td>';
   posilek[j]=posilek[j]+'<td width=\"23\" valign=\"top\"><div style=\"position: absolute; margin-top: 8px\" onmouseover=\"ttshow(this, \''+tt+'\')\" onmouseout=\"tthidePrevent=false; tthide()\"><img src=\"'+root+'graph/ic_info.gif\" alt=\"\" /></div></td>';
   posilek[j]=posilek[j]+'<td width=\"64\" valign=\"top\">';
   posilek[j]=posilek[j]+'<div><div style=\"width: 1px; height: 12px; background-color: #b9b9b9; position: absolute; margin-top: 11px\"><!-- --></div></div>';
   posilek[j]=posilek[j]+'<div><div style=\"position: absolute; margin-top: 9px; margin-left: 9px\"><img src=\"'+root+'graph/hd_usun.gif\" alt=\"usuń\" /></div></div>';
   posilek[j]=posilek[j]+'<div><div style=\"position: absolute; margin-top: 2px; margin-left: 34px\"><img onmouseover=\"changeImg(this, \'bt_delete_ov\')\" onmouseout=\"changeImg(this, \'bt_delete\')\" onmousedown=\"changeImg(this, \'bt_delete_dn\')\" onmouseup=\"changeImg(this, \'bt_delete_ov\')\" src=\"'+root+'graph/bt_delete.gif\" alt=\"usuń pozycję\" onclick="dietaDelProdukt('+j+','+i+')" /></div></div>';
   posilek[j]=posilek[j]+'</td>';
   posilek[j]=posilek[j]+'</tr>';
   
   wartosc[0]=wartosc[0]+((dieta[j][i][17]*dieta[j][i][3])/100);
   wartosc[1]=wartosc[1]+((dieta[j][i][17]*dieta[j][i][4])/100);
   wartosc[2]=wartosc[2]+((dieta[j][i][17]*dieta[j][i][5])/100);
   wartosc[3]=wartosc[3]+((dieta[j][i][17]*dieta[j][i][6])/100);
   wartosc[4]=wartosc[4]+((dieta[j][i][17]*dieta[j][i][7])/100);
   wartosc[5]=wartosc[5]+((dieta[j][i][17]*dieta[j][i][8])/100);
   wartosc[6]=wartosc[6]+((dieta[j][i][17]*dieta[j][i][9])/100);
   wartosc[7]=wartosc[7]+((dieta[j][i][17]*dieta[j][i][10])/100);
  }
  i++;
  posilek[j]=posilek[j]+'<tr';
  if(!grey) posilek[j]=posilek[j]+' bgcolor=\"#f7f7f7\"';
  posilek[j]=posilek[j]+'>';
  posilek[j]=posilek[j]+'<td height=\"30\" width=\"21\" align=\"right\" class=\"standard\" style=\"text-align: right\">'+(i)+'.</td>';
  posilek[j]=posilek[j]+'<td width=\"11\"></td>';
  posilek[j]=posilek[j]+'<td width=\"234\" valign=\"top\">';
  if(i>1)
  {
   posilek[j]=posilek[j]+'<div style=\"position: absolute; margin-top: 10px\"><img src=\"'+root+'graph/hd_editProduct.gif\" alt=\"edytuj/dodaj produkty\" /></div>';
   posilek[j]=posilek[j]+'<div style=\"position: absolute; margin-top: 2px; margin-left: 104px\"><img onclick="dietEdit('+j+')" onmouseover=\"changeImg(this, \'bt_edit_ov\')" onmouseout=\"changeImg(this, \'bt_edit\')\" onmousedown=\"changeImg(this, \'bt_edit_dn\')\" onmouseup=\"changeImg(this, \'bt_edit_ov\')\" src=\"'+root+'graph/bt_edit.gif\" alt=\"edytuj\" /></div>';
  }
  else
  {
   posilek[j]=posilek[j]+'<div style=\"position: absolute; margin-top: 10px\"><img src=\"'+root+'graph/hd_addProduct.gif\" alt=\"dodaj produkty\" /></div>';
   posilek[j]=posilek[j]+'<div style=\"position: absolute; margin-top: 2px; margin-left: 69px\"><img onclick="dietEdit('+j+')" onmouseover=\"changeImg(this, \'bt_edit_ov\')" onmouseout=\"changeImg(this, \'bt_edit\')\" onmousedown=\"changeImg(this, \'bt_edit_dn\')\" onmouseup=\"changeImg(this, \'bt_edit_ov\')\" src=\"'+root+'graph/bt_edit.gif\" alt=\"edytuj\" /></div>';
  }
  posilek[j]=posilek[j]+'</td>';
  posilek[j]=posilek[j]+'<td width=\"111\" class=\"standard\"></td>';
  posilek[j]=posilek[j]+'<td width=\"145\" valign=\"top\" colspan=\"4\">';
  if(i>1)
  {
   posilek[j]=posilek[j]+'<div style=\"position: absolute; margin-top: 9px; margin-left: 49px\"><img src=\"'+root+'graph/hd_deleteAll.gif\" alt=\"usuń wszystko\" /></div>';
   posilek[j]=posilek[j]+'<div style=\"position: absolute; margin-top: 2px; margin-left: 115px\"><img onmouseover=\"changeImg(this, \'bt_deleteAll_ov\')\" onmouseout=\"changeImg(this, \'bt_deleteAll\')\" onmousedown=\"changeImg(this, \'bt_deleteAll_dn\')\" onmouseup=\"changeImg(this, \'bt_deleteAll_ov\')\" src=\"'+root+'graph/bt_deleteAll.gif\" alt=\"usuń wszystko\" onclick="dietaDelAllProdukt('+j+')" /></div>';
  }
  posilek[j]=posilek[j]+'</td>';
  posilek[j]=posilek[j]+'</tr>';
  posilek[j]=posilek[j]+'<tr>';
  posilek[j]=posilek[j]+'<td height=\"1\" bgcolor=\"#b2b2b2\" width=\"522\" colspan=\"8\"></td>';
  posilek[j]=posilek[j]+'</tr>';
    
  tt='';
  tt=tt+'<div style=width:166px;text-align:center;margin-top:12px;margin-bottom:12px class=dGrey1>';
  if(j==1) tt=tt+'śniadanie';
  else if(j==2) tt=tt+'drugie śniadanie';
  else if(j==3) tt=tt+'obiad';
  else if(j==4) tt=tt+'podwieczorek';
  else if(j==5) tt=tt+'kolacja';
  tt=tt+'</div>';
  tt=tt+'<table border=0 cellpadding=0 cellspacing=0>';
  tt=tt+'<tr>';
  tt=tt+'<td width=98 class=dGrey2>';
  tt=tt+'energia (kcal):';
  tt=tt+'</td>';
  tt=tt+'<td width=68 class=dGrey2 align=right>';
  tt=tt+Math.round(wartosc[0]);
  tt=tt+'</td>';
  tt=tt+'</tr>';
  tt=tt+'<tr>';
  tt=tt+'<td class=dGrey2>';
  tt=tt+'białko (g):';
  tt=tt+'</td>';
  tt=tt+'<td class=dGrey2 align=right>';
  tt=tt+Math.round(wartosc[1]);
  tt=tt+'</td>';
  tt=tt+'</tr>';
  tt=tt+'<tr>';
  tt=tt+'<td class=dGrey2>';
  tt=tt+'tłuszcz (g):';
  tt=tt+'</td>';
  tt=tt+'<td class=dGrey2 align=right>';
  tt=tt+Math.round(wartosc[2]);
  tt=tt+'</td>';
  tt=tt+'</tr>';
  tt=tt+'<tr>';
  tt=tt+'<td class=dGrey2>';
  tt=tt+'węglowodany (g):';
  tt=tt+'</td>';
  tt=tt+'<td class=dGrey2 align=right>';
  tt=tt+Math.round(wartosc[3]);
  tt=tt+'</td>';
  tt=tt+'</tr>';
  tt=tt+'<tr>';
  tt=tt+'<td class=dGrey2>';
  tt=tt+'błonnik (g):';
  tt=tt+'</td>';
  tt=tt+'<td class=dGrey2 align=right>';
  tt=tt+Math.round(wartosc[4]);
  tt=tt+'</td>';
  tt=tt+'</tr>';
  tt=tt+'<tr>';
  tt=tt+'<td class=dGrey2>';
  tt=tt+'kwas foliowy (&micro;g):';
  tt=tt+'</td>';
  tt=tt+'<td class=dGrey2 align=right>';
  tt=tt+Math.round(wartosc[5]);
  tt=tt+'</td>';
  tt=tt+'</tr>';
  tt=tt+'<tr>';
  tt=tt+'<td class=dGrey2>';
  tt=tt+'wapń (mg):';
  tt=tt+'</td>';
  tt=tt+'<td class=dGrey2 align=right>';
  tt=tt+Math.round(wartosc[6]);
  tt=tt+'</td>';
  tt=tt+'</tr>';
  tt=tt+'<tr>';
  tt=tt+'<td class=dGrey2>';
  tt=tt+'żelazo (mg):';
  tt=tt+'</td>';
  tt=tt+'<td class=dGrey2 align=right>';
  tt=tt+Math.round(wartosc[7]);
  tt=tt+'</td>';
  tt=tt+'</tr>';
  tt=tt+'</table>';
   
  if(wartosc[0]>0)
  {
   posilek[j]=posilek[j]+'<tr>';
   posilek[j]=posilek[j]+'<td height=\"30\" width=\"21\"></td>';
   posilek[j]=posilek[j]+'<td width=\"11\"></td>';
   posilek[j]=posilek[j]+'<td width=\"234\"></td>';
   posilek[j]=posilek[j]+'<td width=\"162\" class=\"standard\" style=\"text-align: right\" colspan=\"2\">energia '+Math.round(wartosc[0])+' kcal</td>';
   posilek[j]=posilek[j]+'<td width=\"7\"></td>';
   posilek[j]=posilek[j]+'<td width=\"23\" valign=\"top\"><div style=\"position: absolute; margin-top: 8px\" onmouseover=\"ttshow(this, \''+tt+'\')\" onmouseout=\"tthidePrevent=false; tthide()\"><img src=\"'+root+'graph/ic_info.gif\" alt=\"\" /></div></td>';
   posilek[j]=posilek[j]+'<td width=\"64\" valign=\"top\">';
   posilek[j]=posilek[j]+'</td>';
   posilek[j]=posilek[j]+'</tr>';
  }
  posilek[j]=posilek[j]+'</table>';
  
  for(var i=0; i<8; i++)
  {
   cwartosc[i]=cwartosc[i]+wartosc[i];
  }
  gEBI('tbl_danie'+j).innerHTML=posilek[j];
  
  
  if(dieta[5].length>0)
  {
   gEBI('tbl_danie5').style.display='block';
   changeImg('img_posilekToggle5','ic_slide1');
  }
  else if(dieta[4].length>0)
  {
   gEBI('tbl_danie4').style.display='block';
   changeImg('img_posilekToggle4','ic_slide1');
   gEBI('tbl_danie5').style.display='block';
   changeImg('img_posilekToggle5','ic_slide1');
  }
  else if(dieta[3].length>0)
  {
   gEBI('tbl_danie3').style.display='block';
   changeImg('img_posilekToggle3','ic_slide1');
   gEBI('tbl_danie4').style.display='block';
   changeImg('img_posilekToggle4','ic_slide1');
  }
  else if(dieta[2].length>0)
  {
   gEBI('tbl_danie2').style.display='block';
   changeImg('img_posilekToggle2','ic_slide1');
   gEBI('tbl_danie3').style.display='block';
   changeImg('img_posilekToggle3','ic_slide1');
  }
  else if(dieta[1].length>0)
  {
   gEBI('tbl_danie1').style.display='block';
   changeImg('img_posilekToggle1','ic_slide1');
   gEBI('tbl_danie2').style.display='block';
   changeImg('img_posilekToggle2','ic_slide1');
  }
  else
  {
   gEBI('tbl_danie1').style.display='block';
   changeImg('img_posilekToggle1','ic_slide1');
  }
 }
 for(var i=0; i<8; i++)
 {
  gEBI('div_wartosc'+i).innerHTML=Math.round(cwartosc[i]);
 }
}

//delete product from meal
function dietaDelProdukt(j, i)
{
 dieta[j].splice(i, 1);
 refreshDiet();
}

//delete all products from meal
function dietaDelAllProdukt(j)
{
 dieta[j]=new Array;
 refreshDiet();
}

//make list of products
function dietMakeList1()
{
 tt='';
 tt=tt+'<div style=width:166px;text-align:center;margin-top:12px;margin-bottom:12px class=dGrey1>';
 tt=tt+'*1*';
 tt=tt+'</div>';
 tt=tt+'<table border=0 cellpadding=0 cellspacing=0>';
 tt=tt+'<tr>';
 tt=tt+'<td width=98 class=dGrey2>';
 tt=tt+'energia (kcal):';
 tt=tt+'</td>';
 tt=tt+'<td width=68 class=dGrey2 align=right>';
 tt=tt+'*2*';
 tt=tt+'</td>';
 tt=tt+'</tr>';
 tt=tt+'<tr>';
 tt=tt+'<td class=dGrey2>';
 tt=tt+'białko (g):';
 tt=tt+'</td>';
 tt=tt+'<td class=dGrey2 align=right>';
 tt=tt+'*3*';
 tt=tt+'</td>';
 tt=tt+'</tr>';
 tt=tt+'<tr>';
 tt=tt+'<td class=dGrey2>';
 tt=tt+'tłuszcz (g):';
 tt=tt+'</td>';
 tt=tt+'<td class=dGrey2 align=right>';
 tt=tt+'*4*';
 tt=tt+'</td>';
 tt=tt+'</tr>';
 tt=tt+'<tr>';
 tt=tt+'<td class=dGrey2>';
 tt=tt+'węglowodany (g):';
 tt=tt+'</td>';
 tt=tt+'<td class=dGrey2 align=right>';
 tt=tt+'*5*';
 tt=tt+'</td>';
 tt=tt+'</tr>';
 tt=tt+'<tr>';
 tt=tt+'<td class=dGrey2>';
 tt=tt+'błonnik (g):';
 tt=tt+'</td>';
 tt=tt+'<td class=dGrey2 align=right>';
 tt=tt+'*6*';
 tt=tt+'</td>';
 tt=tt+'</tr>';
 tt=tt+'<tr>';
 tt=tt+'<td class=dGrey2>';
 tt=tt+'kwas foliowy (&micro;g):';
 tt=tt+'</td>';
 tt=tt+'<td class=dGrey2 align=right>';
 tt=tt+'*7*';
 tt=tt+'</td>';
 tt=tt+'</tr>';
 tt=tt+'<tr>';
 tt=tt+'<td class=dGrey2>';
 tt=tt+'wapń (mg):';
 tt=tt+'</td>';
 tt=tt+'<td class=dGrey2 align=right>';
 tt=tt+'*8*';
 tt=tt+'</td>';
 tt=tt+'</tr>';
 tt=tt+'<tr>';
 tt=tt+'<td class=dGrey2>';
 tt=tt+'żelazo (mg):';
 tt=tt+'</td>';
 tt=tt+'<td class=dGrey2 align=right>';
 tt=tt+'*9*';
 tt=tt+'</td>';
 tt=tt+'</tr>';
 tt=tt+'</table>';
 
 out='';
 out=out+'<tr id=\"tr_dietList1_*1*\" onmouseover=\"this.style.backgroundColor=\'#bceeff\'\" onmouseout=\"if(gEBI(\'div_selectedItem1Id\').value!=*2*){this.style.backgroundColor=\'\'\}else{this.style.backgroundColor=\'#b9daff\'\}">';
 out=out+'<td width=\"24\" height=\"29\"><div style=\"width: 24px; text-align: center\"><img id="imgFav1_*17*" style=\"cursor: pointer\" onclick=\"dietSetFav(this, *3*)\" src=\"'+root+'graph/ic_favorities_';
 out=out+'*4*';
 out=out+'.gif\" alt=\"dodaj/usuń do ulubionych\" title=\"dodaj/usuń do ulubionych\" /></div></td>';
 out=out+'<td width=\"235\" class=\"standard\" onclick=\"dietSetItem1(*5*, *6*)\" style=\"cursor: pointer\">';
 out=out+'*7*';
 out=out+'</td>';
 out=out+'<td width=\"43\" style=\"text-align: right\" class=\"standard\">';
 if(gEBI('div_listValue').value==1) out=out+'*8*';
 else if(gEBI('div_listValue').value==2) out=out+'*9*';
 else if(gEBI('div_listValue').value==3) out=out+'*10*';
 else if(gEBI('div_listValue').value==4) out=out+'*11*';
 else if(gEBI('div_listValue').value==5) out=out+'*12*';
 else if(gEBI('div_listValue').value==6) out=out+'*13*';
 else if(gEBI('div_listValue').value==7) out=out+'*14*';
 else if(gEBI('div_listValue').value==8) out=out+'*15*';
 out=out+'</td>';
 out=out+'<td width=\"67\" valign=\"top\">';
 out=out+'<div style=\"position: absolute; margin-left: 27px; margin-top: 8px\" onmouseover="ttshow(this, \'*16*\',0,0,3)\" onmouseout=\"tthidePrevent=false; tthide()\"><img src=\"'+root+'graph/ic_info.gif\" alt=\"\" /></div>';
 out=out+'</td>';
 out=out+'</tr>';
 out=out+'<tr bgcolor=\"#ffffff\">';
 out=out+'<td height=\"1\" width=\"369\" colspan=\"4\"></td>';
 out=out+'</tr>';

 out2='';
 out2=out2+'<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\">';
 for(var i=0; i<lista1.length; i++)
 {
  tt1=tt.replace('*1*', lista1[i][2].replace(/\"/g, ''));
  tt1=tt1.replace('*2*', Math.round(lista1[i][3]));
  tt1=tt1.replace('*3*', Math.round(lista1[i][4]));
  tt1=tt1.replace('*4*', Math.round(lista1[i][5]));
  tt1=tt1.replace('*5*', Math.round(lista1[i][6]));
  tt1=tt1.replace('*6*', Math.round(lista1[i][7]));
  tt1=tt1.replace('*7*', Math.round(lista1[i][8]));
  tt1=tt1.replace('*8*', Math.round(lista1[i][9]));
  tt1=tt1.replace('*9*', Math.round(lista1[i][10]));
  
  out1=out;
  out1=out1.replace('*1*', lista1[i][0]);
  out1=out1.replace('*2*', lista1[i][0]);
  out1=out1.replace('*3*', lista1[i][0]);
  if(lista1[i][1]==1) out1=out1.replace('*4*', 'on');
  else out1=out1.replace('*4*', 'of');
  out1=out1.replace('*5*', lista1[i][0]);
  out1=out1.replace('*6*', i);
  if(lista1[i][14]>0) out1=out1.replace('*7*', '<div id=\"ttMy1_'+i+'\" style=\"display: none; position: absolute; margin-top: 15px; margin-left: 15px; width: 190px; border-width: 1px; border-color: #000000; border-style: solid; background-color: #FFFFE1; z-index: 100 \">&nbsp;produkt dodany przez użytkownika</div><b onmouseover=\"gEBI(\'ttMy1_'+i+'\').style.display=\'block\'\" onmouseout=\"gEBI(\'ttMy1_'+i+'\').style.display=\'none\'\">'+lista1[i][2]+' <span style=\"font-size: 14px\">+</span></b>');
  else out1=out1.replace('*7*', lista1[i][2]);
  out1=out1.replace('*8*', lista1[i][3].toString().replace('.', ','));
  out1=out1.replace('*9*', lista1[i][4].toString().replace('.', ','));
  out1=out1.replace('*10*', lista1[i][5].toString().replace('.', ','));
  out1=out1.replace('*11*', lista1[i][6].toString().replace('.', ','));
  out1=out1.replace('*12*', lista1[i][7].toString().replace('.', ','));
  out1=out1.replace('*13*', lista1[i][8].toString().replace('.', ','));
  out1=out1.replace('*14*', lista1[i][9].toString().replace('.', ','));
  out1=out1.replace('*15*', lista1[i][10].toString().replace('.', ','));
  out1=out1.replace('*16*', tt1);
  out1=out1.replace('*17*', lista1[i][0]);
  out2=out2+out1;
 }
 out2=out2+'</table>';
 gEBI('div_lista1').innerHTML=out2;
 
 dietCheckMyProduct(); 
}

//change products category
function dietGetCategory(c)
{
 gEBI('div_selectedItem1Id').value=0;
 if(gEBI('div_category').value!=c)
 {
  gEBI('div_category').value=c;
  lista1=new Array;
  if(c==0) lista1=lista;
  else
  { 
   var j=0;
   for(var i=0; i<lista.length; i++)
   {
    if(lista[i][12]==c)
    {
     lista1[j]=lista[i];
     j++;
    }
   }
  }
  dietMakeList1();
 }
}

//change products sets category
function dietGetCategory3(c)
{
 if(gEBI('div_category3').value!=c)
 {
  gEBI('div_category3').value=c;
  lista3=new Array;
  if(c==0) lista3=listaz;
  else
  {
   var j=0;
   for(var i=0; i<listaz.length; i++)
   {
    if(listaz[i][4]==c)
    {
     lista3[j]=listaz[i];
     j++;
    }
   }
  }
  dietMakeList3();
 }
}

//search product
function dietProductSearch()
{
 txt=gEBI('xWyszukiwanie').value;
 listaTmp=new Array;
 dietGetCategory(gEBI(5).value);
 
 listaTmp=lista1;
 lista1=new Array;
 if(txt=='') lista1=listaTmp;
 else
 {
  pattern=new RegExp(txt, "i");
  var j=0;
  for(var i=0; i<listaTmp.length; i++)
  {
   if(listaTmp[i][2].search(pattern)>-1)
   {
    lista1[j]=listaTmp[i];
    j++;
   }
  }
 }
 dietMakeList1();
}

//sort products
function sortFunc(index, dir)
{
 return (function(a, b)
 {
  var x = a[index];
  var y = b[index];
  return ((x < y) ? -dir : ((x > y) ? dir : 0));
 });
}
function dietProductSort(index, dir)
{
 gEBI('div_dietSort1').innerHTML='<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td valign=\"middle\" align=\"center\" height=\"14\" width=\"21\"><img style=\"cursor: pointer\" src=\"'+root+'graph/gr_filtr_disabled.gif\" onclick=\"dietProductSort(1, -1)\" alt="" /></td></tr></table>';
 gEBI('div_dietSort2').innerHTML='<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td valign=\"middle\" align=\"center\" height=\"14\" width=\"21\"><img style=\"cursor: pointer\" src=\"'+root+'graph/gr_filtr_disabled.gif\" onclick=\"dietProductSort(2, 1)\" alt="" /></td></tr></table>';
 gEBI('div_dietSort3').innerHTML='<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td valign=\"middle\" align=\"center\" height=\"14\" width=\"21\"><img style=\"cursor: pointer\" src=\"'+root+'graph/gr_filtr_disabled.gif\" onclick=\"dietProductSort('+gEBI('input_dietProductValue').value+', 1)\" alt="" /></td></tr></table>';
 
 if(index==1)
 {
  if(dir==1) gEBI('div_dietSort1').innerHTML='<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td valign=\"middle\" align=\"center\" height=\"14\" width=\"21\"><img style=\"cursor: pointer\" src=\"'+root+'graph/gr_filtr_down.gif\" onclick=\"dietProductSort(1, -1)\" alt="" /></td></tr></table>';
  else gEBI('div_dietSort1').innerHTML='<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td valign=\"middle\" align=\"center\" height=\"14\" width=\"21\"><img style=\"cursor: pointer\" src=\"'+root+'graph/gr_filtr_up.gif\" onclick=\"dietProductSort(1, 1)\" alt="" /></td></tr></table>';
 }
 else if(index==2)
 {
  if(dir==1) gEBI('div_dietSort2').innerHTML='<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td valign=\"middle\" align=\"center\" height=\"14\" width=\"21\"><img style=\"cursor: pointer\" src=\"'+root+'graph/gr_filtr_up.gif\" onclick=\"dietProductSort(2, -1)\" alt="" /></td></tr></table>';
  else gEBI('div_dietSort2').innerHTML='<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td valign=\"middle\" align=\"center\" height=\"14\" width=\"21\"><img style=\"cursor: pointer\" src=\"'+root+'graph/gr_filtr_down.gif\" onclick=\"dietProductSort(2, 1)\" alt="" /></td></tr></table>';
 }
 else if(index==3)
 {
  if(dir==1) gEBI('div_dietSort3').innerHTML='<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td valign=\"middle\" align=\"center\" height=\"14\" width=\"21\"><img style=\"cursor: pointer\" src=\"'+root+'graph/gr_filtr_up.gif\" onclick=\"dietProductSort(3, -1)\" alt="" /></td></tr></table>';
  else gEBI('div_dietSort3').innerHTML='<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td valign=\"middle\" align=\"center\" height=\"14\" width=\"21\"><img style=\"cursor: pointer\" src=\"'+root+'graph/gr_filtr_down.gif\" onclick=\"dietProductSort(3, 1)\" alt="" /></td></tr></table>';
 } 
 else if(index==4)
 {
  if(dir==1) gEBI('div_dietSort3').innerHTML='<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td valign=\"middle\" align=\"center\" height=\"14\" width=\"21\"><img style=\"cursor: pointer\" src=\"'+root+'graph/gr_filtr_up.gif\" onclick=\"dietProductSort(4, -1)\" alt="" /></td></tr></table>';
  else gEBI('div_dietSort3').innerHTML='<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td valign=\"middle\" align=\"center\" height=\"14\" width=\"21\"><img style=\"cursor: pointer\" src=\"'+root+'graph/gr_filtr_down.gif\" onclick=\"dietProductSort(4, 1)\" alt="" /></td></tr></table>';
 }
 else if(index==5)
 {
  if(dir==1) gEBI('div_dietSort3').innerHTML='<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td valign=\"middle\" align=\"center\" height=\"14\" width=\"21\"><img style=\"cursor: pointer\" src=\"'+root+'graph/gr_filtr_up.gif\" onclick=\"dietProductSort(5, -1)\" alt="" /></td></tr></table>';
  else gEBI('div_dietSort3').innerHTML='<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td valign=\"middle\" align=\"center\" height=\"14\" width=\"21\"><img style=\"cursor: pointer\" src=\"'+root+'graph/gr_filtr_down.gif\" onclick=\"dietProductSort(5, 1)\" alt="" /></td></tr></table>';
 }
 else if(index==6)
 {
  if(dir==1) gEBI('div_dietSort3').innerHTML='<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td valign=\"middle\" align=\"center\" height=\"14\" width=\"21\"><img style=\"cursor: pointer\" src=\"'+root+'graph/gr_filtr_up.gif\" onclick=\"dietProductSort(6, -1)\" alt="" /></td></tr></table>';
  else gEBI('div_dietSort3').innerHTML='<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td valign=\"middle\" align=\"center\" height=\"14\" width=\"21\"><img style=\"cursor: pointer\" src=\"'+root+'graph/gr_filtr_down.gif\" onclick=\"dietProductSort(6, 1)\" alt="" /></td></tr></table>';
 }
 else if(index==7)
 {
  if(dir==1) gEBI('div_dietSort3').innerHTML='<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td valign=\"middle\" align=\"center\" height=\"14\" width=\"21\"><img style=\"cursor: pointer\" src=\"'+root+'graph/gr_filtr_up.gif\" onclick=\"dietProductSort(7, -1)\" alt="" /></td></tr></table>';
  else gEBI('div_dietSort3').innerHTML='<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td valign=\"middle\" align=\"center\" height=\"14\" width=\"21\"><img style=\"cursor: pointer\" src=\"'+root+'graph/gr_filtr_down.gif\" onclick=\"dietProductSort(7, 1)\" alt="" /></td></tr></table>';
 }
 else if(index==8)
 {
  if(dir==1) gEBI('div_dietSort3').innerHTML='<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td valign=\"middle\" align=\"center\" height=\"14\" width=\"21\"><img style=\"cursor: pointer\" src=\"'+root+'graph/gr_filtr_up.gif\" onclick=\"dietProductSort(8, -1)\" alt="" /></td></tr></table>';
  else gEBI('div_dietSort3').innerHTML='<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td valign=\"middle\" align=\"center\" height=\"14\" width=\"21\"><img style=\"cursor: pointer\" src=\"'+root+'graph/gr_filtr_down.gif\" onclick=\"dietProductSort(8, 1)\" alt="" /></td></tr></table>';
 }
 else if(index==9)
 {
  if(dir==1) gEBI('div_dietSort3').innerHTML='<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td valign=\"middle\" align=\"center\" height=\"14\" width=\"21\"><img style=\"cursor: pointer\" src=\"'+root+'graph/gr_filtr_up.gif\" onclick=\"dietProductSort(8, -1)\" alt="" /></td></tr></table>';
  else gEBI('div_dietSort3').innerHTML='<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td valign=\"middle\" align=\"center\" height=\"14\" width=\"21\"><img style=\"cursor: pointer\" src=\"'+root+'graph/gr_filtr_down.gif\" onclick=\"dietProductSort(9, 1)\" alt="" /></td></tr></table>';
 }
 else if(index==10)
 {
  if(dir==1) gEBI('div_dietSort3').innerHTML='<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td valign=\"middle\" align=\"center\" height=\"14\" width=\"21\"><img style=\"cursor: pointer\" src=\"'+root+'graph/gr_filtr_up.gif\" onclick=\"dietProductSort(10, -1)\" alt="" /></td></tr></table>';
  else gEBI('div_dietSort3').innerHTML='<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td valign=\"middle\" align=\"center\" height=\"14\" width=\"21\"><img style=\"cursor: pointer\" src=\"'+root+'graph/gr_filtr_down.gif\" onclick=\"dietProductSort(10, 1)\" alt="" /></td></tr></table>';
 }
 
 lista1=lista1.sort(sortFunc(index, dir));
 dietMakeList1();
}

//sort products sets
function dietProductSort3(index, dir)
{
 gEBI('div_dietSort2z').innerHTML='<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td valign=\"middle\" align=\"center\" height=\"14\" width=\"21\"><img style=\"cursor: pointer\" src=\"'+root+'graph/gr_filtr_disabled.gif\" onclick=\"dietProductSort3(1, 1)\" alt="" /></td></tr></table>';
 gEBI('div_dietSort3z').innerHTML='<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td valign=\"middle\" align=\"center\" height=\"14\" width=\"21\"><img style=\"cursor: pointer\" src=\"'+root+'graph/gr_filtr_disabled.gif\" onclick=\"dietProductSort3('+gEBI('input_dietProductValue3').value+', 1)\" alt="" /></td></tr></table>';
 
 if(index==1)
 {
  if(dir==1) gEBI('div_dietSort2z').innerHTML='<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td valign=\"middle\" align=\"center\" height=\"14\" width=\"21\"><img style=\"cursor: pointer\" src=\"'+root+'graph/gr_filtr_up.gif\" onclick=\"dietProductSort3(1, -1)\" alt="" /></td></tr></table>';
  else gEBI('div_dietSort2z').innerHTML='<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td valign=\"middle\" align=\"center\" height=\"14\" width=\"21\"><img style=\"cursor: pointer\" src=\"'+root+'graph/gr_filtr_down.gif\" onclick=\"dietProductSort3(1, 1)\" alt="" /></td></tr></table>';
 }
 else if(index==5)
 {
  if(dir==1) gEBI('div_dietSort3z').innerHTML='<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td valign=\"middle\" align=\"center\" height=\"14\" width=\"21\"><img style=\"cursor: pointer\" src=\"'+root+'graph/gr_filtr_up.gif\" onclick=\"dietProductSort3(5, -1)\" alt="" /></td></tr></table>';
  else gEBI('div_dietSort3z').innerHTML='<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td valign=\"middle\" align=\"center\" height=\"14\" width=\"21\"><img style=\"cursor: pointer\" src=\"'+root+'graph/gr_filtr_down.gif\" onclick=\"dietProductSort3(5, 1)\" alt="" /></td></tr></table>';
 }
 else if(index==6)
 {
  if(dir==1) gEBI('div_dietSort3z').innerHTML='<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td valign=\"middle\" align=\"center\" height=\"14\" width=\"21\"><img style=\"cursor: pointer\" src=\"'+root+'graph/gr_filtr_up.gif\" onclick=\"dietProductSort3(6, -1)\" alt="" /></td></tr></table>';
  else gEBI('div_dietSort3z').innerHTML='<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td valign=\"middle\" align=\"center\" height=\"14\" width=\"21\"><img style=\"cursor: pointer\" src=\"'+root+'graph/gr_filtr_down.gif\" onclick=\"dietProductSort3(6, 1)\" alt="" /></td></tr></table>';
 }
 else if(index==7)
 {
  if(dir==1) gEBI('div_dietSort3z').innerHTML='<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td valign=\"middle\" align=\"center\" height=\"14\" width=\"21\"><img style=\"cursor: pointer\" src=\"'+root+'graph/gr_filtr_up.gif\" onclick=\"dietProductSort3(7, -1)\" alt="" /></td></tr></table>';
  else gEBI('div_dietSort3z').innerHTML='<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td valign=\"middle\" align=\"center\" height=\"14\" width=\"21\"><img style=\"cursor: pointer\" src=\"'+root+'graph/gr_filtr_down.gif\" onclick=\"dietProductSort3(7, 1)\" alt="" /></td></tr></table>';
 }
 else if(index==8)
 {
  if(dir==1) gEBI('div_dietSort3z').innerHTML='<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td valign=\"middle\" align=\"center\" height=\"14\" width=\"21\"><img style=\"cursor: pointer\" src=\"'+root+'graph/gr_filtr_up.gif\" onclick=\"dietProductSort3(8, -1)\" alt="" /></td></tr></table>';
  else gEBI('div_dietSort3z').innerHTML='<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td valign=\"middle\" align=\"center\" height=\"14\" width=\"21\"><img style=\"cursor: pointer\" src=\"'+root+'graph/gr_filtr_down.gif\" onclick=\"dietProductSort3(8, 1)\" alt="" /></td></tr></table>';
 }
 else if(index==9)
 {
  if(dir==1) gEBI('div_dietSort3z').innerHTML='<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td valign=\"middle\" align=\"center\" height=\"14\" width=\"21\"><img style=\"cursor: pointer\" src=\"'+root+'graph/gr_filtr_up.gif\" onclick=\"dietProductSort3(8, -1)\" alt="" /></td></tr></table>';
  else gEBI('div_dietSort3z').innerHTML='<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td valign=\"middle\" align=\"center\" height=\"14\" width=\"21\"><img style=\"cursor: pointer\" src=\"'+root+'graph/gr_filtr_down.gif\" onclick=\"dietProductSort3(9, 1)\" alt="" /></td></tr></table>';
 }
 else if(index==10)
 {
  if(dir==1) gEBI('div_dietSort3z').innerHTML='<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td valign=\"middle\" align=\"center\" height=\"14\" width=\"21\"><img style=\"cursor: pointer\" src=\"'+root+'graph/gr_filtr_up.gif\" onclick=\"dietProductSort3(10, -1)\" alt="" /></td></tr></table>';
  else gEBI('div_dietSort3z').innerHTML='<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td valign=\"middle\" align=\"center\" height=\"14\" width=\"21\"><img style=\"cursor: pointer\" src=\"'+root+'graph/gr_filtr_down.gif\" onclick=\"dietProductSort3(10, 1)\" alt="" /></td></tr></table>';
 }
 else if(index==11)
 {
  if(dir==1) gEBI('div_dietSort3z').innerHTML='<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td valign=\"middle\" align=\"center\" height=\"14\" width=\"21\"><img style=\"cursor: pointer\" src=\"'+root+'graph/gr_filtr_up.gif\" onclick=\"dietProductSort3(10, -1)\" alt="" /></td></tr></table>';
  else gEBI('div_dietSort3z').innerHTML='<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td valign=\"middle\" align=\"center\" height=\"14\" width=\"21\"><img style=\"cursor: pointer\" src=\"'+root+'graph/gr_filtr_down.gif\" onclick=\"dietProductSort3(10, 1)\" alt="" /></td></tr></table>';
 }
 else if(index==12)
 {
  if(dir==1) gEBI('div_dietSort3z').innerHTML='<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td valign=\"middle\" align=\"center\" height=\"14\" width=\"21\"><img style=\"cursor: pointer\" src=\"'+root+'graph/gr_filtr_up.gif\" onclick=\"dietProductSort3(10, -1)\" alt="" /></td></tr></table>';
  else gEBI('div_dietSort3z').innerHTML='<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td valign=\"middle\" align=\"center\" height=\"14\" width=\"21\"><img style=\"cursor: pointer\" src=\"'+root+'graph/gr_filtr_down.gif\" onclick=\"dietProductSort3(10, 1)\" alt="" /></td></tr></table>';
 }
 
 lista3=lista3.sort(sortFunc(index, dir));
 dietMakeList3();
}

//set & unset product as favourite
function dietSetFav(obj, id)
{
 set=0;
 srcTmp1=gEBI('imgFav1_'+id).src.split('_');
 var srcTmp=srcTmp1[(srcTmp1.length-1)];
 
 if(srcTmp=='of.gif')
 {
  if(gEBI('imgFav1_'+id)) gEBI('imgFav1_'+id).src=root+'graph/ic_favorities_on.gif';
  if(gEBI('imgFav2_'+id)) gEBI('imgFav2_'+id).src=root+'graph/ic_favorities_on.gif';
  set=1;
 }
 else
 {
  if(gEBI('imgFav1_'+id)) gEBI('imgFav1_'+id).src=root+'graph/ic_favorities_of.gif';
  if(gEBI('imgFav2_'+id)) gEBI('imgFav2_'+id).src=root+'graph/ic_favorities_of.gif';
  set=0;
 }
 
 for(i=0; i<lista1.length; i++)
 {
  if(lista1[i][0]==id)
  {
   if(lista1[i][1]==1) lista1[i][1]=0;
   else lista1[i][1]=1;
  }
 }
 
 jsrsPOST=true;
 jsrsExecute(root+'jsremote.php', emptyF, "dietSetFav", set.toString()+'_'+id);
}

//set product on products list
function dietSetItem1(p_id, index)
{
 if(gEBI('div_selectedItem1Id').value>0) gEBI('tr_dietList1_'+gEBI('div_selectedItem1Id').value).style.backgroundColor='';
 gEBI('tr_dietList1_'+p_id).style.backgroundColor='#b9daff';
 gEBI('div_selectedItem1Id').value=p_id;
 gEBI('div_selectedItem1Index').value=index;
 
 if(gEBI('div_selectedItem1Id').value>0) gEBI('div_productRight').innerHTML='<img onclick="dietAddItem()" onmouseover=\"changeImg(this,\'bt_2right_ov\')\" onmouseout=\"changeImg(this,\'bt_2right\')\" src=\"'+root+'graph/bt_2right.gif\" alt=\"\" />';
 dietCheckMyProduct();
}

//set product on selected products list
function dietSetItem2(p_id, index)
{
 if(gEBI('div_selectedItem2Id').value>0) gEBI('tr_dietList2_'+gEBI('div_selectedItem2Id').value).style.backgroundColor='';
 gEBI('tr_dietList2_'+p_id).style.backgroundColor='#b9daff';
 gEBI('div_selectedItem2Id').value=p_id;
 gEBI('div_selectedItem2Index').value=index;
 
 if(gEBI('div_selectedItem2Id').value>0) gEBI('div_productLeft').innerHTML='<img onclick="dietRemoveItem()" onmouseover=\"changeImg(this,\'bt_2left_ov\')\" onmouseout=\"changeImg(this,\'bt_2left\')\" src=\"'+root+'graph/bt_2left.gif\" alt=\"\" />';
 gEBI('div_productNazwa').innerHTML=lista2[index][2];
 if(gEBI('div_listValue2').value==1)
 {
  gEBI('div_productWartosc1').innerHTML=Math.round(lista2[index][3]);
  gEBI('div_productWartosc2').innerHTML=Math.round(lista2[index][4]);
  gEBI('div_productWartosc3').innerHTML=Math.round(lista2[index][5]);
  gEBI('div_productWartosc4').innerHTML=Math.round(lista2[index][6]);
  gEBI('div_productWartosc5').innerHTML=Math.round(lista2[index][7]);
  gEBI('div_productWartosc6').innerHTML=Math.round(lista2[index][8]);
  gEBI('div_productWartosc7').innerHTML=Math.round(lista2[index][9]);
  gEBI('div_productWartosc8').innerHTML=Math.round(lista2[index][10]);
 }
}

//select products set on products set list
function dietSetItem3(p_id, index)
{
 if(gEBI('div_selectedItem3Id').value>0) gEBI('tr_dietList3_'+gEBI('div_selectedItem3Id').value).style.backgroundColor='';
 gEBI('tr_dietList3_'+p_id).style.backgroundColor='#b9daff';
 gEBI('div_selectedItem3Id').value=p_id;
 gEBI('div_selectedItem3Index').value=index;
 
 if(gEBI('div_selectedItem3Id').value>0) gEBI('div_productRight2').innerHTML='<img onclick="dietAddItem2()" onmouseover=\"changeImg(this,\'bt_2right_ov\')\" onmouseout=\"changeImg(this,\'bt_2right\')\" src=\"'+root+'graph/bt_2right.gif\" alt=\"\" />';
}

function dietMakeList2()
{
 for(var i=0; i<lista2.length; i++)
 {
  if(obj=gEBI('xIlosc1_'+lista2[i][0])) lista2[i][15]=obj.value;
  if(obj=gEBI(1000+lista2[i][0])) lista2[i][16]=obj.value;
 }

 out='';
 out=out+'<tr id=\"tr_dietList2_*1*\" onmouseover=\"this.style.backgroundColor=\'#bceeff\'\" onmouseout=\"if(gEBI(\'div_selectedItem2Id\').value!=*2*){this.style.backgroundColor=\'\'\}else{this.style.backgroundColor=\'#b9daff\'\}">';
 out=out+'<td width=\"24\" height=\"29\"><div style=\"width: 24px; text-align: center\"><img id="imgFav2_*11*" style=\"cursor: pointer\" onclick=\"dietSetFav(this, *3*)\" src=\"'+root+'graph/ic_favorities_';
 out=out+'*4*';
 out=out+'.gif\" alt=\"dodaj/usuń do ulubionych\" title=\"dodaj/usuń do ulubionych\" /></div></td>';
 out=out+'<td width=\"172\" class=\"standard\" onclick=\"dietSetItem2(*5*, *6*)\" style=\"cursor: pointer\">';
 out=out+'*7*';
 out=out+'</td>';
 out=out+'<td width=\"46\" class=\"standard\" valign=\"top\"><div><div style=\"position: absolute; margin-top: 3px\" id=\"txt_ilosc1_*8*\"></div></div><div style=\"width: 46px\"></div></td>';
 out=out+'<td width=\"127\" valign=\"top\"><div><div style=\"position: absolute; margin-top: 3px; z-index: *9*\" id=\"select_ilosc2_*10*\"></div></div><div style=\"width: 127px\"></div></td>';
 out=out+'</tr>';
 out=out+'<tr bgcolor=\"#ffffff\">';
 out=out+'<td height=\"1\" width=\"369\" colspan=\"4\"></td>';
 out=out+'</tr>';

 miara=new Array;
 out2='';
 out2=out2+'<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\">';
 for(var i=0; i<lista2.length; i++)
 {
  out1=out;
  
  out1=out1.replace('*1*', lista2[i][0]);
  out1=out1.replace('*2*', lista2[i][0]);
  out1=out1.replace('*3*', lista2[i][0]);
  if(lista2[i][1]==1) out1=out1.replace('*4*', 'on');
  else out1=out1.replace('*4*', 'of');
  out1=out1.replace('*5*', lista2[i][0]);
  out1=out1.replace('*6*', i);
  if(lista2[i][14]>0) out1=out1.replace('*7*', '<div id=\"ttMy2_'+i+'\" style=\"display: none; position: absolute; margin-top: 15px; margin-left: 15px; width: 190px; border-width: 1px; border-color: #000000; border-style: solid; background-color: #FFFFE1; z-index: 100 \">&nbsp;produkt dodany przez użytkownika</div><b onmouseover=\"gEBI(\'ttMy2_'+i+'\').style.display=\'block\'\" onmouseout=\"gEBI(\'ttMy2_'+i+'\').style.display=\'none\'\">'+lista2[i][2]+' <span style=\"font-size: 14px\">+</span></b>');
  else out1=out1.replace('*7*', lista2[i][2]);
  out1=out1.replace('*8*', lista2[i][0]);
  out1=out1.replace('*9*', lista2.length-i+1);
  out1=out1.replace('*10*', lista2[i][0]);
  out1=out1.replace('*11*', lista2[i][0]);
 
  out2=out2+out1;
  
  miara[(lista2[i][0])]=new Array;
  miara[(lista2[i][0])][0]='gram';
  miara[(lista2[i][0])][1]='gram|1';
  if(lista2[i][11]!='') miara[(lista2[i][0])][2]=lista2[i][11]+'|2';
 }
 out2=out2+'<tr>';
 out2=out2+'<td height=\"60\" width=\"369\" colspan=\"4\"></td>';
 out2=out2+'</tr>';
 out2=out2+'</table>';
 
 gEBI('div_lista2').innerHTML=out2;
 
 for(var i=0; i<lista2.length; i++)
 {
  xt.textCreate('txt_ilosc1_'+lista2[i][0], 'xIlosc1_'+lista2[i][0], 40);
  gEBI('xIlosc1_'+lista2[i][0]).value=lista2[i][15];
  xs.selectCreate(1000+lista2[i][0], miara[(lista2[i][0])], 'select_ilosc2_'+lista2[i][0], 90);
  gEBI(1000+lista2[i][0]).value=lista2[i][16];
  gEBI('selectInput'+(1000+lista2[i][0])+'728381').value=((miara[(lista2[i][0])][(lista2[i][16])]).split('|'))[0];
 }
}

//add product to selected products list
function dietAddItem()
{
 var allow=true;
 for(var i=0; i<lista2.length; i++)
 {
  if(lista2[i][0]==gEBI('div_selectedItem1Id').value) allow=false;
 }
 if(allow)
 {
  lista2.push(lista1[gEBI('div_selectedItem1Index').value]);
  gEBI('div_selectedItem1Id').value=0;
  gEBI('div_selectedItem1Index').value=0;
  gEBI('div_selectedItem2Id').value=0;
  gEBI('div_selectedItem2Index').value=0;
  gEBI('div_productRight').innerHTML='<img src=\"'+root+'graph/bt_2right_of.gif\" alt=\"\" />';
  gEBI('div_productLeft').innerHTML='<img src=\"'+root+'graph/bt_2left_of.gif\" alt=\"\" />';
  dietMakeList2();
  dietCountList2();
 }
}

//add products from products sets list to selected products list
function dietAddItem2()
{
 produkty=(lista3[(gEBI('div_selectedItem3Index').value)][3]).split(',');
 for(var j=0; j<produkty.length; j++)
 {
  id_produkt=(produkty[j].split(':'))[0];
  ilosc=(produkty[j].split(':'))[1];
  
  var allow=true;
  for(var i=0; i<lista2.length; i++)
  {
   if(lista2[i][0]==id_produkt) allow=false;
  }
  if(allow)
  {
   for(var k=0; k<lista.length; k++)
   {
    if(lista[k][0]==id_produkt)
    {
     lista2.push(lista[k]);
     lista2[(lista2.length)-1][15]=ilosc;
    }
   }
  }
 }
 gEBI('div_selectedItem1Id').value=0;
 gEBI('div_selectedItem1Index').value=0;
 gEBI('div_selectedItem2Id').value=0;
 gEBI('div_selectedItem2Index').value=0;
 gEBI('div_productRight').innerHTML='<img src=\"'+root+'graph/bt_2right_of.gif\" alt=\"\" />';
 gEBI('div_productLeft').innerHTML='<img src=\"'+root+'graph/bt_2left_of.gif\" alt=\"\" />';
 dietMakeList2();
 dietCountList2();
}

//remove product from selected products list
function dietRemoveItem()
{
 lista2.splice(gEBI('div_selectedItem2Index').value, 1);
 gEBI('div_selectedItem2Id').value=0;
 gEBI('div_selectedItem2Index').value=0;
 gEBI('div_selectedItem1Id').value=0;
 gEBI('div_selectedItem1Index').value=0;
 gEBI('div_productRight').innerHTML='<img src=\"'+root+'graph/bt_2right_of.gif\" alt=\"\" />';
 gEBI('div_productLeft').innerHTML='<img src=\"'+root+'graph/bt_2left_of.gif\" alt=\"\" />';
 dietMakeList2();
 dietCountList2();
}

//change nutritive value label on products list
function dietChangeValueList1(x)
{
 var i=1;
 while(obj=gEBI('img_dietCheck'+i))
 {
  obj.style.display='none';
  i++;
 }
 gEBI('img_dietCheck'+x).style.display='block';
 gEBI('div_listValue').value=x;
 gEBI('div_listValue3').value=x;
 gEBI('div_valueList1').style.display='none';
 if(x==1)
 {
  gEBI('div_dietSortLabel').innerHTML='energia (kcal/100g)';
  gEBI('div_dietSort3').innerHTML='<img style=\"cursor: pointer\" src=\"'+root+'graph/gr_filtr_disabled.gif\" onclick=\"dietProductSort(3, 1)\" alt="" />';
  gEBI('div_dietSort3z').innerHTML='<img style=\"cursor: pointer\" src=\"'+root+'graph/gr_filtr_disabled.gif\" onclick=\"dietProductSort3(5, 1)\" alt="" />';
 }
 else if(x==2)
 {
  gEBI('div_dietSortLabel').innerHTML='białko (g/100g)';
  gEBI('div_dietSort3').innerHTML='<img style=\"cursor: pointer\" src=\"'+root+'graph/gr_filtr_disabled.gif\" onclick=\"dietProductSort(4, 1)\" alt="" />';
  gEBI('div_dietSort3z').innerHTML='<img style=\"cursor: pointer\" src=\"'+root+'graph/gr_filtr_disabled.gif\" onclick=\"dietProductSort3(6, 1)\" alt="" />';
 }
 else if(x==3)
 {
  gEBI('div_dietSortLabel').innerHTML='tłuszcz (g/100g)';
  gEBI('div_dietSort3').innerHTML='<img style=\"cursor: pointer\" src=\"'+root+'graph/gr_filtr_disabled.gif\" onclick=\"dietProductSort(5, 1)\" alt="" />';
  gEBI('div_dietSort3z').innerHTML='<img style=\"cursor: pointer\" src=\"'+root+'graph/gr_filtr_disabled.gif\" onclick=\"dietProductSort3(7, 1)\" alt="" />';
 }
 else if(x==4)
 {
  gEBI('div_dietSortLabel').innerHTML='węglowodany (g/100g)';
  gEBI('div_dietSort3').innerHTML='<img style=\"cursor: pointer\" src=\"'+root+'graph/gr_filtr_disabled.gif\" onclick=\"dietProductSort(6, 1)\" alt="" />';
  gEBI('div_dietSort3z').innerHTML='<img style=\"cursor: pointer\" src=\"'+root+'graph/gr_filtr_disabled.gif\" onclick=\"dietProductSort3(8, 1)\" alt="" />';
 }
 else if(x==5)
 {
  gEBI('div_dietSortLabel').innerHTML='błonnik (g/100g)';
  gEBI('div_dietSort3').innerHTML='<img style=\"cursor: pointer\" src=\"'+root+'graph/gr_filtr_disabled.gif\" onclick=\"dietProductSort(7, 1)\" alt="" />';
  gEBI('div_dietSort3z').innerHTML='<img style=\"cursor: pointer\" src=\"'+root+'graph/gr_filtr_disabled.gif\" onclick=\"dietProductSortz(9, 1)\" alt="" />';
 }
 else if(x==6)
 {
  gEBI('div_dietSortLabel').innerHTML='k.foliowy (&micro;g/100g)';
  gEBI('div_dietSort3').innerHTML='<img style=\"cursor: pointer\" src=\"'+root+'graph/gr_filtr_disabled.gif\" onclick=\"dietProductSort(8, 1)\" alt="" />';
  gEBI('div_dietSort3z').innerHTML='<img style=\"cursor: pointer\" src=\"'+root+'graph/gr_filtr_disabled.gif\" onclick=\"dietProductSort3(10, 1)\" alt="" />';
 }
 else if(x==7)
 {
  gEBI('div_dietSortLabel').innerHTML='wapń (mg/100g)';
  gEBI('div_dietSort3').innerHTML='<img style=\"cursor: pointer\" src=\"'+root+'graph/gr_filtr_disabled.gif\" onclick=\"dietProductSort(9, 1)\" alt="" />';
  gEBI('div_dietSort3z').innerHTML='<img style=\"cursor: pointer\" src=\"'+root+'graph/gr_filtr_disabled.gif\" onclick=\"dietProductSortz(11, 1)\" alt="" />';
 }
 else if(x==8)
 {
  gEBI('div_dietSortLabel').innerHTML='żelazo (mg/100g)';
  gEBI('div_dietSort3').innerHTML='<img style=\"cursor: pointer\" src=\"'+root+'graph/gr_filtr_disabled.gif\" onclick=\"dietProductSort(10, 1)\" alt="" />';
  gEBI('div_dietSort3z').innerHTML='<img style=\"cursor: pointer\" src=\"'+root+'graph/gr_filtr_disabled.gif\" onclick=\"dietProductSortz(12, 1)\" alt="" />';
 }
 dietMakeList1();
 dietMakeList3();
}

//change nutritive value label product description box
function dietChangeValueList2(x)
{
 var i=1;
 while(obj=gEBI('img_dietChecka'+i))
 {
  obj.style.display='none';
  i++;
 }
 gEBI('img_dietChecka'+x).style.display='block';
 gEBI('div_listValue2').value=x;
 gEBI('div_valueList2').style.display='none';
 if(x==1)
 {
  gEBI('div_listaValue2Label').innerHTML='pożywność produktu (na 100g)';
  
  gEBI('div_productWartosc1').innerHTML=0;
  gEBI('div_productWartosc2').innerHTML=0;
  gEBI('div_productWartosc3').innerHTML=0;
  gEBI('div_productWartosc4').innerHTML=0;
  gEBI('div_productWartosc5').innerHTML=0;
  gEBI('div_productWartosc6').innerHTML=0;
  gEBI('div_productWartosc7').innerHTML=0;
  gEBI('div_productWartosc8').innerHTML=0;
 }
 dietCountList2();
}

//count nutritive value on selected products box
function dietCountList2()
{
 if(gEBI('div_listValue2').value==2)
 {
  var wartosc1=0;
  var wartosc2=0;
  var wartosc3=0;
  var wartosc4=0;
  var wartosc5=0;
  var wartosc6=0;
  var wartosc7=0;
  var wartosc8=0;
  for(var i=0; i<lista2.length; i++)
  {
   wartosc1=wartosc1+lista2[i][3];
   wartosc2=wartosc2+lista2[i][4];
   wartosc3=wartosc3+lista2[i][5];
   wartosc4=wartosc4+lista2[i][6];
   wartosc5=wartosc5+lista2[i][7];
   wartosc6=wartosc6+lista2[i][8];
   wartosc7=wartosc7+lista2[i][9];
   wartosc8=wartosc8+lista2[i][10];
  }
  gEBI('div_productWartosc1').innerHTML=Math.round(wartosc1);
  gEBI('div_productWartosc2').innerHTML=Math.round(wartosc2);
  gEBI('div_productWartosc3').innerHTML=Math.round(wartosc3);
  gEBI('div_productWartosc4').innerHTML=Math.round(wartosc4);
  gEBI('div_productWartosc5').innerHTML=Math.round(wartosc5);
  gEBI('div_productWartosc6').innerHTML=Math.round(wartosc6);
  gEBI('div_productWartosc7').innerHTML=Math.round(wartosc7);
  gEBI('div_productWartosc8').innerHTML=Math.round(wartosc8);
  
  gEBI('div_listaValue2Label').innerHTML='pożywność listy (na 100g)';
 }
}

//change add products mode
function dietTab(x)
{
 if(x==1)
 {
  changeImg('img_tab1', 'gr_tabProducts_on');
  changeImg('img_tab2', 'gr_tabSets_of');
  gEBI('div_lista1').style.display='block';
  gEBI('div_lista3').style.display='none';
  if(gEBI('div_lista1').innerHTML=='') dietMakeList1();
  gEBI('div_productRight').style.display='block';
  gEBI('div_productRight2').style.display='none';
  gEBI('select_kategoria').style.display='block';
  gEBI('select_kategoriaz').style.display='none';
  gEBI('div_wyszukiwanieLabel').style.display='block';
  gEBI('txt_wyszukiwanie').style.display='block';
  gEBI('div_dietSort1').style.display='block';
  gEBI('div_dietSort2').style.display='block';
  gEBI('div_dietSort3').style.display='block';
  gEBI('div_dietSort1z').style.display='none';
  gEBI('div_dietSort2z').style.display='none';
  gEBI('div_dietSort3z').style.display='none';
  dietCheckMyProduct();
 }
 else
 {
  changeImg('img_tab1', 'gr_tabProducts_of');
  changeImg('img_tab2', 'gr_tabSets_on');
  gEBI('div_lista1').style.display='none';
  gEBI('div_lista3').style.display='block';
  gEBI('div_productRight').style.display='none';
  gEBI('div_productRight2').style.display='block';
  gEBI('select_kategoria').style.display='none';
  gEBI('select_kategoriaz').style.display='block';
  gEBI('div_wyszukiwanieLabel').style.display='none';
  gEBI('txt_wyszukiwanie').style.display='none';
  gEBI('div_dietSort1').style.display='none';
  gEBI('div_dietSort2').style.display='none';
  gEBI('div_dietSort3').style.display='none';
  gEBI('div_dietSort1z').style.display='block';
  gEBI('div_dietSort2z').style.display='block';
  gEBI('div_dietSort3z').style.display='block';
  gEBI('myProduct_of').style.display='block';
  gEBI('myProduct_of2').style.display='none';
  gEBI('myProduct_on').style.display='none';
 }
}

//make products sets list
function dietMakeList3()
{
 tt='';
 tt=tt+'<div style=width:166px;text-align:center;margin-top:12px;margin-bottom:12px class=dGrey1>';
 tt=tt+'*1*';
 tt=tt+'</div>';
 tt=tt+'<table border=0 cellpadding=0 cellspacing=0>';
 tt=tt+'<tr>';
 tt=tt+'<td width=98 class=dGrey2>';
 tt=tt+'energia (kcal):';
 tt=tt+'</td>';
 tt=tt+'<td width=68 class=dGrey2 align=right>';
 tt=tt+'*2*';
 tt=tt+'</td>';
 tt=tt+'</tr>';
 tt=tt+'<tr>';
 tt=tt+'<td class=dGrey2>';
 tt=tt+'białko (g):';
 tt=tt+'</td>';
 tt=tt+'<td class=dGrey2 align=right>';
 tt=tt+'*3*';
 tt=tt+'</td>';
 tt=tt+'</tr>';
 tt=tt+'<tr>';
 tt=tt+'<td class=dGrey2>';
 tt=tt+'tłuszcz (g):';
 tt=tt+'</td>';
 tt=tt+'<td class=dGrey2 align=right>';
 tt=tt+'*4*';
 tt=tt+'</td>';
 tt=tt+'</tr>';
 tt=tt+'<tr>';
 tt=tt+'<td class=dGrey2>';
 tt=tt+'węglowodany (g):';
 tt=tt+'</td>';
 tt=tt+'<td class=dGrey2 align=right>';
 tt=tt+'*5*';
 tt=tt+'</td>';
 tt=tt+'</tr>';
 tt=tt+'<tr>';
 tt=tt+'<td class=dGrey2>';
 tt=tt+'błonnik (g):';
 tt=tt+'</td>';
 tt=tt+'<td class=dGrey2 align=right>';
 tt=tt+'*6*';
 tt=tt+'</td>';
 tt=tt+'</tr>';
 tt=tt+'<tr>';
 tt=tt+'<td class=dGrey2>';
 tt=tt+'kwas foliowy (&micro;g):';
 tt=tt+'</td>';
 tt=tt+'<td class=dGrey2 align=right>';
 tt=tt+'*7*';
 tt=tt+'</td>';
 tt=tt+'</tr>';
 tt=tt+'<tr>';
 tt=tt+'<td class=dGrey2>';
 tt=tt+'wapń (mg):';
 tt=tt+'</td>';
 tt=tt+'<td class=dGrey2 align=right>';
 tt=tt+'*8*';
 tt=tt+'</td>';
 tt=tt+'</tr>';
 tt=tt+'<tr>';
 tt=tt+'<td class=dGrey2>';
 tt=tt+'żelazo (mg):';
 tt=tt+'</td>';
 tt=tt+'<td class=dGrey2 align=right>';
 tt=tt+'*9*';
 tt=tt+'</td>';
 tt=tt+'</tr>';
 tt=tt+'</table>';
 
 out='';
 out=out+'<tr id=\"tr_dietList3_*1*\" onmouseover=\"this.style.backgroundColor=\'#bceeff\'\" onmouseout=\"if(gEBI(\'div_selectedItem3Id\').value!=*2*){this.style.backgroundColor=\'\'\}else{this.style.backgroundColor=\'#b9daff\'\}">';
 out=out+'<td width=\"23\"></td>';
 out=out+'<td width=\"306\" onclick=\"dietSetItem3(*3*, *4*)\" style="cursor: pointer">';
 
 out=out+'<div style=\"position: absolute; margin-top: 10px; width: 274px; text-align: right\" class=\"standard\">';
 if(gEBI('div_listValue3').value==1) out=out+'*6*';
 if(gEBI('div_listValue3').value==2) out=out+'*7*';
 if(gEBI('div_listValue3').value==3) out=out+'*8*';
 if(gEBI('div_listValue3').value==4) out=out+'*9*';
 if(gEBI('div_listValue3').value==5) out=out+'*10*';
 if(gEBI('div_listValue3').value==6) out=out+'*11*';
 if(gEBI('div_listValue3').value==7) out=out+'*12*';
 if(gEBI('div_listValue3').value==8) out=out+'*13*';
 out=out+'</div>';
 out=out+'<div style=\"position: absolute; margin-left: 288px; margin-top: 8px\" onmouseover=\"ttshow(this, \'*14*\',0,0,3)\" onmouseout=\"tthidePrevent=false; tthide()\"><img src=\"'+root+'graph/ic_info.gif\" alt=\"\" /></div>';
 out=out+'<div style=\"margin-top: 10px; width: 230px; text-align: left\" class=\"standard\">*5*</div>';
 out=out+'<div class=\"standard\"><i>*15*</i></div>';
 out=out+'<div style=\"height: 7px\"><!-- --></div>';
 out=out+'</td>';
 out=out+'<td width=\"38\"></td>';
 out=out+'</tr>';
 out=out+'<tr>';
 out=out+'<td height=\"1\" bgcolor=\"#ffffff\" width=\"367\" colspan=\"3\"></td>';
 out=out+'</tr>';
  
 out2='';
 out2=out2+'<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\">';
 for(var i=0; i<lista3.length; i++)
 {
  tt1=tt.replace('*1*', lista3[i][1].replace(/\"/g, ''));
  tt1=tt1.replace('*2*', Math.round(lista3[i][5]));
  tt1=tt1.replace('*3*', Math.round(lista3[i][6]));
  tt1=tt1.replace('*4*', Math.round(lista3[i][7]));
  tt1=tt1.replace('*5*', Math.round(lista3[i][8]));
  tt1=tt1.replace('*6*', Math.round(lista3[i][9]));
  tt1=tt1.replace('*7*', Math.round(lista3[i][10]));
  tt1=tt1.replace('*8*', Math.round(lista3[i][11]));
  tt1=tt1.replace('*9*', Math.round(lista3[i][12]));
   
  out1=out;
  out1=out1.replace('*1*', lista3[i][0]);
  out1=out1.replace('*2*', lista3[i][0]);
  out1=out1.replace('*3*', lista3[i][0]);
  out1=out1.replace('*4*', i);
  out1=out1.replace('*5*', lista3[i][1]);
  out1=out1.replace('*6*', lista3[i][5].toString().replace('.', ','));
  out1=out1.replace('*7*', lista3[i][6].toString().replace('.', ','));
  out1=out1.replace('*8*', lista3[i][7].toString().replace('.', ','));
  out1=out1.replace('*9*', lista3[i][8].toString().replace('.', ','));
  out1=out1.replace('*10*', lista3[i][9].toString().replace('.', ','));
  out1=out1.replace('*11*', lista3[i][10].toString().replace('.', ','));
  out1=out1.replace('*12*', lista3[i][11].toString().replace('.', ','));
  out1=out1.replace('*13*', lista3[i][12].toString().replace('.', ','));
  out1=out1.replace('*14*', tt1);
  out1=out1.replace('*15*', lista3[i][2]);
  
  out2=out2+out1;
 }
 out2=out2+'</table>';

 gEBI('div_lista3').innerHTML=out2;
}

//checking if product is users product
function dietCheckMyProduct()
{
 if(lista1[gEBI('div_selectedItem1Index').value])
 {
  if(lista1[gEBI('div_selectedItem1Index').value][14]>0)
  {
   gEBI('myProduct_of').style.display='none';
   gEBI('myProduct_of2').style.display='none';
   gEBI('myProduct_on').style.display='block';
  }
  else
  {
   gEBI('myProduct_of').style.display='none';
   gEBI('myProduct_of2').style.display='block';
   gEBI('myProduct_on').style.display='none';
  }
 }
 else
 {
  gEBI('myProduct_of').style.display='none';
  gEBI('myProduct_of2').style.display='block';
  gEBI('myProduct_on').style.display='none';
 }
}

//enter to diet edit mode
function dietEdit(j)
{
 lista2=new Array;
 lista2=dieta[j];
 
 dietMakeList2();
 gEBI('div_addProduct').style.display='block';
 gEBI('div_posilek').value=j;
}

//exit diet edit mode
function dietAdd()
{
 dietMakeList2();
 
 j=gEBI('div_posilek').value;
 dieta[j]=new Array;
 
 for(var i=0; i<lista2.length; i++)
 {
  if(lista2[i][16]==1)
  {
   lista2[i][17]=lista2[i][15];
   lista2[i][18]=0;
  }
  else
  {
   lista2[i][17]=lista2[i][15]*lista2[i][13];
   lista2[i][18]=lista2[i][15];
  }
 }
 
 dieta[j]=lista2;
 refreshDiet();
 gEBI('div_addProduct').style.display='none';
}

//enter add my own product mode
function dietAddMyProduct()
{
 xt.textCreate('txt_myProduct1', 'xMyProduct1', 165);
 xt.textCreate('txt_myProduct2', 'xMyProduct2', 84);
 xt.textCreate('txt_myProduct3', 'xMyProduct3', 83);
 xt.textCreate('txt_myProduct4', 'xMyProduct4', 83);
 xt.textCreate('txt_myProduct5', 'xMyProduct5', 83);
 xt.textCreate('txt_myProduct6', 'xMyProduct6', 83);
 xt.textCreate('txt_myProduct7', 'xMyProduct7', 83);
 xt.textCreate('txt_myProduct8', 'xMyProduct8', 83);
 xt.textCreate('txt_myProduct9', 'xMyProduct9', 83);
 xt.textCreate('txt_myProduct10', 'xMyProduct10', 83);
  
 xs.selectCreate(11, kategorie, 'select_myProduct1', 195);
 xs.selectCreate(12, miary, 'select_myProduct2', 195);
 gEBI('11').value=1;
 gEBI('12').value=1;
 
 gEBI('checkbox_myProduct1').checked='';
 gEBI('hidden_myProduct').value=0;
   
 gEBI('dietMyProduct').style.display='block';
 gEBI('div_usun1').style.display='block';
 gEBI('div_usun2').style.display='none';
}

//enter edit my own product mode
function dietEditMyProduct()
{
 i=gEBI('div_selectedItem1Index').value;
 id=gEBI('div_selectedItem1Id').value;
 
 xt.textCreate('txt_myProduct1', 'xMyProduct1', 165);
 xt.textCreate('txt_myProduct2', 'xMyProduct2', 84);
 xt.textCreate('txt_myProduct3', 'xMyProduct3', 83);
 xt.textCreate('txt_myProduct4', 'xMyProduct4', 83);
 xt.textCreate('txt_myProduct5', 'xMyProduct5', 83);
 xt.textCreate('txt_myProduct6', 'xMyProduct6', 83);
 xt.textCreate('txt_myProduct7', 'xMyProduct7', 83);
 xt.textCreate('txt_myProduct8', 'xMyProduct8', 83);
 xt.textCreate('txt_myProduct9', 'xMyProduct9', 83);
 xt.textCreate('txt_myProduct10', 'xMyProduct10', 83);
  
 xs.selectCreate(11, kategorie, 'select_myProduct1', 195);
 xs.selectCreate(12, miary, 'select_myProduct2', 195);
 
 gEBI('xMyProduct1').value=lista1[i][2];
 gEBI('xMyProduct3').value=lista1[i][3].toString().replace('.',',');
 gEBI('xMyProduct4').value=lista1[i][4].toString().replace('.',',');
 gEBI('xMyProduct5').value=lista1[i][5].toString().replace('.',',');
 gEBI('xMyProduct6').value=lista1[i][6].toString().replace('.',',');
 gEBI('xMyProduct7').value=lista1[i][7].toString().replace('.',',');
 gEBI('xMyProduct8').value=lista1[i][8].toString().replace('.',',');
 gEBI('xMyProduct9').value=lista1[i][9].toString().replace('.',',');
 gEBI('xMyProduct10').value=lista1[i][10].toString().replace('.',',');
 
 gEBI('11').value=lista1[i][12];
 for(var j=1; j<kategorie.length; j++)
 {
  tmp=kategorie[j].split('|');
  if(tmp[1]==lista1[i][12]) gEBI('selectInput11728381').value=tmp[0];
 }
 
 gEBI('12').value=lista1[i][19];
 for(var j=1; j<miary.length; j++)
 {
  tmp=miary[j].split('|');
  if(tmp[1]==lista1[i][19]) gEBI('selectInput12728381').value=tmp[0];
 }
 
 gEBI('checkbox_myProduct1').checked=false;
 
 if(lista1[i][19]>0)
 {
  gEBI('xMyProduct2').value=lista1[i][13];
  gEBI('checkbox_myProduct1').checked=true;
 }
  
 gEBI('hidden_myProduct').value=id;
   
 gEBI('dietMyProduct').style.display='block';
 
 gEBI('div_usun2').style.display='block';
 gEBI('div_usun1').style.display='none';
}

//save my own product
function dietMyProductSave()
{
 id=gEBI('hidden_myProduct').value;
 
 nazwa=gEBI('xMyProduct1').value;
 wartosc1=gEBI('xMyProduct3').value.replace(',', '.');
 wartosc2=gEBI('xMyProduct4').value.replace(',', '.');
 wartosc3=gEBI('xMyProduct5').value.replace(',', '.');
 wartosc4=gEBI('xMyProduct6').value.replace(',', '.');
 wartosc5=gEBI('xMyProduct7').value.replace(',', '.');
 wartosc6=gEBI('xMyProduct8').value.replace(',', '.');
 wartosc7=gEBI('xMyProduct9').value.replace(',', '.');
 wartosc8=gEBI('xMyProduct10').value.replace(',', '.');
 
 if(gEBI('checkbox_myProduct1').checked)
 {
  miara=gEBI('12').value;
  pojemnosc=gEBI('xMyProduct2').value;
 }
 else
 {
  miara=0;
  pojemnosc=0;
 }
 kategoria=gEBI('11').value;
 
 if(nazwa!='' && wartosc1!='' && wartosc2!='' && wartosc3!='' && wartosc4!='' && wartosc5!='' && wartosc6!='' && wartosc7!='' && wartosc8!='' && wartosc1>0 && wartosc2>0 && wartosc3>0 && wartosc4>0 && wartosc5>0 && wartosc6>0 && wartosc7>0 && wartosc8>0)
 {
  if((gEBI('checkbox_myProduct1').checked && pojemnosc!='' && pojemnosc>0) || !gEBI('checkbox_myProduct1').checked)
  {
   data=id+'~*~'+nazwa+'~*~'+kategoria+'~*~'+miara+'~*~'+pojemnosc+'~*~'+wartosc1+'~*~'+wartosc2+'~*~'+wartosc3+'~*~'+wartosc4+'~*~'+wartosc5+'~*~'+wartosc6+'~*~'+wartosc7+'~*~'+wartosc8;
   jsrsPOST=true;
   jsrsExecute(root+'jsremote.php', dietMyProductSaveCont, "dietMyProductSave", data);
  }
 }
}
function dietMyProductSaveCont(id)
{
 nazwa=gEBI('xMyProduct1').value;
 wartosc1=gEBI('xMyProduct3').value.replace(',', '.');
 wartosc2=gEBI('xMyProduct4').value.replace(',', '.');
 wartosc3=gEBI('xMyProduct5').value.replace(',', '.');
 wartosc4=gEBI('xMyProduct6').value.replace(',', '.');
 wartosc5=gEBI('xMyProduct7').value.replace(',', '.');
 wartosc6=gEBI('xMyProduct8').value.replace(',', '.');
 wartosc7=gEBI('xMyProduct9').value.replace(',', '.');
 wartosc8=gEBI('xMyProduct10').value.replace(',', '.');
 
 if(gEBI('checkbox_myProduct1').checked)
 {
  miara=gEBI('12').value;
  pojemnosc=gEBI('xMyProduct2').value;
 }
 else
 {
  miara=0;
  pojemnosc=0;
 }
 kategoria=gEBI('11').value;
 
 miaraN='';
 for(var j=1; j<miary.length; j++)
 {
  tmp=miary[j].split('|');
  if(tmp[1]==miara) miaraN=tmp[0];
 }
 
 newP=new Array;
 newP[0]=id;
 newP[1]=0;
 newP[2]=nazwa;
 newP[3]=wartosc1;
 newP[4]=wartosc2;
 newP[5]=wartosc3;
 newP[6]=wartosc4;
 newP[7]=wartosc5;
 newP[8]=wartosc6;
 newP[9]=wartosc7;
 newP[10]=wartosc8;
 newP[11]=miaraN;
 newP[12]=kategoria;
 newP[13]=pojemnosc;
 newP[14]=1;
 newP[15]=100;
 newP[16]=1;
 newP[17]=100;
 newP[18]=0;
 newP[19]=miara;
 
 if(gEBI('hidden_myProduct').value==0)
 {
  lista.push(newP);
 }
 else
 {
  for(var j=0; j<lista.length; j++)
  {
   if(lista[j][0]==id) lista[j]=newP;
  }
 }
 gEBI('dietMyProduct').style.display='none';
 gEBI('div_category').value=0;
 dietGetCategory(gEBI(5).value);
 dietProductSort(2, 1);
}

//delete my own product
function dietMyProductDel1()
{
 if(gEBI('hidden_myProduct').value>0)
 {
  for(var j=0; j<lista.length; j++)
  {
   if(lista[j][0]==gEBI('hidden_myProduct').value) lista.splice(j, 1);
  }
  jsrsPOST=true;
  jsrsExecute(root+'jsremote.php', emptyF, "dietMyProductDel", gEBI('hidden_myProduct').value.toString());
 }
 gEBI('dietMyProduct').style.display='none';
 gEBI('div_category').value=0;
 dietGetCategory(gEBI(5).value);
 dietProductSort(2, 1);
}
function dietMyProductDel2()
{
 if(gEBI('div_selectedItem1Id').value>0)
 {
  for(var j=0; j<lista.length; j++)
  {
   if(lista[j][0]==gEBI('div_selectedItem1Id').value) lista.splice(j, 1);
  }
  jsrsPOST=true;
  jsrsExecute(root+'jsremote.php', emptyF, "dietMyProductDel", gEBI('div_selectedItem1Id').value.toString());
 }
 gEBI('div_category').value=0;
 dietGetCategory(gEBI(5).value);
 dietProductSort(2, 1);
}

//save user weight & height
function dietSaveUserData()
{
 weight=gEBI('xWaga').value;
 height=gEBI('xWzrost').value;
 if(weight>30 && weight<200 && height>100 && height<250)
 {
  data=weight+'~*~'+height;
  jsrsPOST=true;
  jsrsExecute(root+'jsremote.php', emptyF, "dietSaveUserData", data);
  
  swfClearCache();
 }
}

//empty function
function emptyF()
{}

//
function photo(file)
{
 gEBI('imgPicture').src=root+file;
 gEBI('divPicture').style.display='block';
}

function changeTourTab(x) 
{
 gEBI('tour_tab1').style.display='none';
 gEBI('tour_tab2').style.display='none';
 gEBI('tour_tab3').style.display='none';
 gEBI('tour_tab4').style.display='none';
 gEBI('tour_tab5').style.display='none';
 gEBI('tour_tab6').style.display='none';
 gEBI('tour_tab7').style.display='none';
 gEBI('tour_tab8').style.display='none';
 gEBI('tour_tab9').style.display='none';
 gEBI('tour_tab10').style.display='none';
 gEBI('tour_tab' + x).style.display='block';
}

function register()
{
 try{mainSwf.setRegisterView();}
 catch(e){}
 loadP(17);
}

//clear flash's cache
function swfClearCache() 
{
 //alert('clear cache');
}