

	this.timer = 0;
	this.maxPhotos = 14;
	var ps = new Array(maxPhotos);

	function photo(id, initY,fn, w, h) {
		this.Y = initY;
		this.goY = initY;
		this.speed = 25;
		this.obj = document.getElementById(id);
		this.obj.style.top = initY + "px";
		this.fn = fn;
		this.w = w;
		this.h = h;

		this.move = function () {
			this.Y += (this.goY - this.Y) / this.speed;
			this.obj.style.top = this.Y + "px";
		}
		
		this.test = function () { 
			return Math.abs(this.goY - this.Y);
			
		}
	}

	function init() {		
		timer = 0;
		maxY = (this.maxPhotos - 1) * 130;
		p = new Array(3);
		for (a=0;a<maxPhotos;a++) {
			p[a] = new photo("p" + (a+1), (a-1) * 130, "",0,0);
		}
	}

	
	
	this.slideup = function() {
		for (a=0;a<this.maxPhotos;a++) {
			if (this.p[a].goY == -130) {
				this.p[a].Y = maxY;
				this.p[a].goY = maxY;
			}			
			this.p[a].goY -= 130;
		}		
		clearTimeout(timer);
		movePics();
	}
	
	this.slidedown = function () {
		for (a=0;a<this.maxPhotos;a++) {
			if (this.p[a].goY == maxY) {
				this.p[a].Y = -130;
				this.p[a].goY = -130;
			}
			this.p[a].goY += 130;		
			
		}		
		clearTimeout(this.timer);
		movePics();
	}
	
	
	this.movePics = function() {
		for (a=0;a<this.maxPhotos;a++) {
			this.p[a].move();
		}
//		document.title = new Date();
		if (this.p[0].test() < 1) { 
			clearTimeout(this.timer);
			this.timer = setTimeout("slidedown()",5000);
		} else {
			clearTimeout(this.timer);
			this.timer = setTimeout("movePics()",50);
		}
	}

	init();
	slidedown();
	var ow = 0;
	var oh = 0;

function r_pic() {
	$(".bigpic").remove();
}	

function show_big_photo(fn) {		
		//set prev and next button
		var next = parseInt(fn) + 1;
		var prev = parseInt(fn) - 1;
		if (next > this.maxPhotos-1) next = 0;
		if (prev < 0) prev = this.maxPhotos - 1;
		$("#pic_next").attr("alt", next);
		$("#pic_prev").attr("alt", prev);
			
		//Get the screen height and width
		var maskHeight = $(document).height();
		var maskWidth = $(window).width();
	
		//Set height and width to mask to fill up the whole screen
		$('#mask').css({'width':maskWidth,'height':maskHeight});
		
		//transition effect		
		//$('#mask').fadeIn(1000);	
		$('#mask').fadeTo(400,0.8);	
		$("#mask").css({
			"background-image":"url('images/img_loader.gif')",
			"background-repeat":"no-repeat",
			"background-position":"center"
			});
	
		//Get the window height and width
		var winH = $(window).height();
		var winW = $(window).width();
		var w = 0;
		var h = 0;
		var p = 0;
        var id = "#dialog";		
		//var img = document.getElementById("pic");				
			//var img = new Image();
			//$("#pic").append(this.img);
			//$(img).attr("class","bigpic");			
			//filename = this.p[fn].fn;
			img = new Image();
			$("#pic").append(this.img);
			$(img).attr("class","bigpic");			
					
			$(img).show();
			$(img).attr("src", "");
			
			$(img).load(function() {
						$("#mask").css("background-image","none");						
						w = $(this).attr('width');
						h = $(this).attr('height');						
						if (w > h) {
							p = 500 / w;
						} else {
							p = 500 / h;
						}								
						w = ow = w * p;
						h = oh = h * p;						
						$(this).attr("width", w);
						$(this).attr("height", h);								
						//Set the popup window to center
						var adjust = getScrollXY();	//kunin natin amount ng scrolled vertically in pixels
						$(id).css('top', adjust + winH/2-$(id).height()/2);
						$(id).css('left', winW/2-$(id).width()/2);
						
						nh = parseInt(adjust) + (winH/2)-($(id).height()/2);
						nw = (winW/2)-($(id).width()/2);
											
						//transition effect
						//$(id).animate({top: nh+"px", left: nw+"px"}, 500);						
						//$(this).animate({width: w+"px", height: h+"px"}, 500);
						$(id).fadeIn(400); 						
					}).attr('src', this.p[fn].fn);	
				
			
												
	

	//if close button is clicked
	$('.window .close').click(function (e) {
		//Cancel the link behavior
		e.preventDefault();
		$('#mask, .window').hide();
		$(".bigpic").remove();
	});		
	
	//if mask is clicked
	$('#mask').click(function () {
		$(this).hide();
		$('.window').hide();
		$(".bigpic").remove();
	});	
}


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

