function n()
		{
			chimg(parseInt($('#imageholder').attr('ipos'))+1);
		}
		
		function p(){
			chimg(parseInt($('#imageholder').attr('ipos'))-1);
		}
		
		function chimg(nip){
			var e=$('#imageholder');
			var pos = nip*810;
			if($('#img'+nip,e).length==1)
			{
				$(e).animate({left:"-"+pos+"px"},500)
				e.attr('ipos',nip);
			}
			else
			{
				//fade out to index ..
				$('#back,#next').hide();
				$('#img'+(nip-1)).fadeOut(200,function(){
					self.location.href="index.php";
				});
			}
			
			
			if(nip==1)
			{
				$('#back').show().fadeIn(500);
			}
			else if(nip == 0)
			{
				$('#back').hide();
			}
			
			
			if($('#img'+(nip+1),e).length!=1)
			{
				//$('#next').hide();
				
				$('#imageholder').css('cursor','pointer');
				//$('#imageholder').attr('title','back to index');
			}
			else
			{
				//$('#next').show();
				//$('#imageholder img').click(null);
				$('#imageholder').css('cursor','');
			}
			
		}
		
		
		
		
		function initSlideshows(){
		
			$('.slideshow').attr('inum',0);
							$('.slideshow').attr('thumbs',$('.slideshow li').length);
							$('.slideshow').each(function(n,e)
							{
								$(e).attr('id','slides'+n);
								$('li',e).each(function(n,e)
									{
										$(e).addClass('th'+n);
									});	
							});
			
							
			$('.slideshow').hover(
				function(){
					overslides($(this).attr('id'));
					
					var iv = setInterval(overslideshow,1500,$(this).attr('id'));
					//alert('over '+iv);
					
					$(this).attr('interv',iv);
				},
				function(){			
					var ivk = $(this).attr('interv');		
					//alert('out '+ivk);
					clearInterval(ivk);			
				}
			);
			
			$('.slideshow .th0').show();
		}
		
		
		function overslideshow(eid){
			var e = $("#"+eid);
			var ri = parseInt($(e).attr('inum'))+1;
			var prev = $(e).attr('inum');
			if($('.th'+ri,e).length !=1)ri =0

			$('li:visible',e).fadeOut();

			$('.th'+ri,e).fadeIn();
			$(e).attr('inum',ri)
		}
		
		
		var lastover = "";
		var lastint = 0;
		function indexList(){
		$(".indeximage").each(function(n,e){
			$('.th0',e).fadeIn(100+n*70);
			//$('.th0',e).show();
			$('.thumblist',e).attr('inum','0')
			$('.thumblist',e).hover(
				function(){
					//$(this).attr('num')+" &nbsp"
					clearInterval(lastint);
					$('#rolloverinfo').html($("a",this).attr('alt'));
					
					overslides($(this).attr('id'),true);
					var interv = setInterval(overslides,1000,[$(this).attr('id')]);
					lastover = $(this).attr('id');
					lastint = interv;
					//alert(interv);
					$(this).attr('interv',interv);
					//alert("over "+interv);
				},
				function(){			
					var kiv = $(this).attr('interv');
					lastover = "";
					//alert(kiv);		
					clearInterval(kiv);
					clearInterval(lastint);
					//$('li:visible',e).hide();
					//$('.th0',e).show();
					$('#rolloverinfo').html('&nbsp;&nbsp;');
					//alert("out "+kiv);
					
				}
			);
		});

		
		}
		
		
		function loadImages(){
			$("img.preload[loadsrc]").each(function(n,e){
				$(e).attr('src',$(e).attr('loadsrc'));
				$(e).attr('loadsrc','');
			});
		}
		
		function overslides(eid){
			
			
			if(!eid){
				//alert(" ERROR NO EID ");
				//alert();
				eid= lastover;
				
			}
			
			var e = $("#"+eid);
			
			//alert("initial inum read: "+parseInt($(e).attr('inum')));
			
			var ri = parseInt($(e).attr('inum'))+1;
			if(!ri || ri == NaN){
				ri = '0';
				$(e).attr('inum','0');
			}
			
			//var ri = 1+Math.floor(Math.random()*e.attr('thumbs'));
			//if(!first)alert("overslides "+ri);
			if($('.th'+ri,e).length !=1)
			{
				ri ='0';
				//alert('reached last');
			}
			
			$('li:visible',e).fadeOut(500);
			$('.th'+ri,e).fadeIn(400);
			$(e).attr('inum',ri);
			
			//alert("end inum read: "+parseInt($(e).attr('inum')));
		}

		$(document).ready(function(){
				checkCenter();
				if($.browser.msie){
					$("body").addClass("ie");
				}
		})
		
		function checkCenter(){
			if($(document).height()>=750)
			{
				$(".page").removeClass("smallwindow");
			}
			else
			{
				$(".page").removeClass("smallwindow");
			}
		}
		window.onresize = function(){
		
			//checkCenter();
		};
