var hpanel='';
var x=0;
var pcount=0;
var curpage=1;
for(i=pics.length;i>=0;i--){
	if(pics[i]){
		x++;
		pcount++;
		if(x==1){hpanel+='<div class="ppage">';}
		hpanel+='<div class="pimgs"><img src="'+pics[i].replace(/.jpg/i,'_s.jpg')+'" onclick="slide(0,'+(i)+')"><div class="dpnum" onclick="slide(0,'+(i)+')">'+(i+1)+'</div></div>';
		if(x==15){hpanel+='</div>';x=0;}
	}
}
var ymax=pics.length-1;
var ymin=ymax-pcount+1;
var pages=Math.ceil(pcount/15);
var strPic=ymax;

function slide(pn,ppn){
if(ppn || ppn==0){if(strPic==ppn){return;};strPic=ppn}
else
{
strPic=strPic+pn;
strPic=strPic>ymax?ymin:strPic<ymin?ymax:strPic;
}
$('#vtext').slideUp('fast');
if(strPic==ymax){document.getElementById('arr').style.display='none';}else{document.getElementById('arr').style.display='';}
if(strPic==ymin){document.getElementById('arl').style.display='none';}else{document.getElementById('arl').style.display='';}
$('#vimg').fadeOut('fast',function(){

  $('#vimg')
    .load(function () {
      $(this).fadeIn();
	  $('#vtext').html(strings[strPic]).fadeIn('fast');
	  document.getElementById('ol').innerHTML = strPic+1
    })
    .attr('src', pics[strPic]);
	
});

	gopage(0,Math.ceil((ymax-strPic+1)/15));
}


$(function(){
	$('#mover').width(pages*185).css('left','0px').html(hpanel);
	if(pages>1){$('#panel').append('<div id="more" style="position:absolute;bottom:0px;right:0px;cursor:pointer;" onclick="gopage(1)"><img src="images/design/next.gif" style="border:0px;margin:0px;"><img src="images/design/next.gif" style="border:0px;margin:0px;"></div><div id="pre" style="position:absolute;bottom:0px;left:10px;cursor:pointer;display:none;" onclick="gopage(-1)"><img src="images/design/prev.gif" style="border:0px;margin:0px;"><img src="images/design/prev.gif" style="border:0px;margin:0px;"></div>');}
	$('.dpnum').css('bottom','-17px').css('left','0px');
	$('.pimgs').hover(
		function(){
			$(this).children('.dpnum').animate({bottom:'0'},'fast');
		},
		function(){
			$(this).children('.dpnum').animate({bottom:'-17'},'fast');
		}
	);
	
  document.getElementById('ol').innerHTML = '';
  $('#vtext').hide();
  $('#vimg').hide()
    .load(function () {
      $(this).fadeIn();
	  $('#vtext').html(strings[strPic]).fadeIn('fast');
	  document.getElementById('ol').innerHTML = strPic+1
    })
    .attr('src', pics[strPic]);
	
	
});

function gopage(p,pp){
if(pp){
if(curpage==pp){return;}
curpage=pp;
}
else{curpage=curpage+p};

pageto=-(curpage-1)*185;
$('#mover').animate({
	left: pageto
});

if(curpage>1){$('#pre').fadeIn();}else{$('#pre').fadeOut();}
if(curpage==pages){$('#more').fadeOut();}else{$('#more').fadeIn();}

}
