	scrollingFlg = false;

	var searchAction = "/sc-o/paging/";
	var page = -1;

	var scrollControl={
		locking:false,
		isLocked:function(){
			return this.lock;
		},
		lock:function(){
			this.locking = true;
		},
		unlock:function(){
			this.locking = false;
		}
	}
	function autoScroll(){
		if($.browser.mozilla || $.browser.msie || $.browser.opera || $.browser.safari){
			scrollingFlg = true;
			var parms = getPageInfo();
			scrollControl.lock();
			if ($("#mark" + page).size() > 0) {
				$("#mark" + page).css({display:"block"});
			} else {
				return;
			}
			$("#mark" + page).css({display:"block"});
			$.ajax({
				type: "GET",
				url: searchAction,
				data:parms,
				dataType: 'html',
				success: function(html){
					var nextPage=document.createElement("div");
					nextPage.innerHTML=html;
					var con = document.getElementById("autoScroll");
					con.appendChild(nextPage);
					if(document.getElementById("mark" + page) != null){
						$("#mark" + page).css({display:"none"});
					}
					page++;
					scrollControl.unlock();
					scrollingFlg = false;

					addImageLoad();
				}
			});
		}
	}
	function getPageInfo(){
		var parms = "";
		str = "keyword=" + encodeURIComponent($("#preKeyword").val()) + "&category=" + $("#preCategory").val();
		var preSite = $("#preSite");
		if (preSite.size() > 0) {
			str += "&uri=" + encodeURIComponent(preSite.val());
		}
		var type = {0:'word',1:'excel',2:'ppt',3:'pdf'};
		if($("#preMimeType").size() > 0){
			var types = $("#preMimeType").val();
			for(var i = 0;i < types.length;i++){
				if(types.substr(i,1) == '1'){
					str += "&" +  type[i] + "=on";
				}
			}
		}
		if(page == -1){
			if($("#firstPageNum").size() > 0){
				page = parseInt($("#firstPageNum").val());
			}
			else {
			return;
			}
		}
		str += "&page=" + (page + 1) + "&divPage=true";
		return str;
	}

	function Pos(){
		var yScroll;
		if (window.pageYOffset) {
			yScroll = window.pageYOffset;
		}else {
			yScroll = document.documentElement.scrollTop || document.body.scrollTop;
		}
		var sindowHeight;
		if(window.innerHeight){
			windowHeight = window.innerHeight;
		} else {
			windowHeight = document.documentElement.clientHeight || document.body.clientHeight;
		}
		return {scrollY:yScroll,winHeight:windowHeight}
	}

	function lowerThenScroll() {

		var scrollPoint = $(window).height();
		var underPoint = document.body.clientHeight - $(window).scrollTop();

		return underPoint < scrollPoint + 300;

	}

	function checkNextBlog() {
		if($.browser.mozilla || $.browser.msie || $.browser.opera || $.browser.safari){

			if (scrollingFlg) return ;
			if (scrollControl.isLocked() == true){
				return;
			}
			if ($('#emptyText').html()) {
					return;
			}
			if(document.getElementById("endTag")){
				if(document.getElementById("mark" + page) != null){
					var mark = document.getElementById("mark" + page);
					mark.style.display = "none";
					return;
				}
			}
			var getPagePoint = lowerThenScroll();
			if(getPagePoint == false) {
				return;
			} else {
				autoScroll();
			}
		} else {
			return;
		}
	}
	function showBigPic(imgPath){
		var pictFrame = $("#bigpic");
		var pos = Pos();
		var offsetY = (pos.winHeight - parseInt(pictFrame.height()))/2;
		var offsetX = (parseInt($("body").width()) - parseInt(pictFrame.width()))/2;

		var topSet = pos.scrollY + offsetY + "px";
		var leftSet = offsetX + "px";
		pictFrame.css({top: topSet, left: leftSet, display: "block"});

		var img = $("#bigpic > img");
		var image = new Image();
		image.onload = function(){
			var w = (this.naturalWidth)? this.naturalWidth : this.width;
			var h = (this.naturalHeight)? this.naturalHeight : this.height;

			var padding = 40;
			var wrate = w / (pictFrame.width()-padding);
			var hrate = h / (pictFrame.height()-padding);
			
			var width = pictFrame.width() - padding;
			var height = pictFrame.height() - padding;
			
			if (wrate > 1) {
				if (wrate > hrate) {
					img.width(width);
					img.height(Math.round(h / wrate));
				} else {
					img.width(Math.round(w / hrate));
					img.height(height);
				}
			} else {
				if (hrate > 1) {
					img.width(Math.round(w / hrate));
					img.height(height);
				} else {
					img.width(w);
					img.height(h);
				}
			}
			
			pictFrame.html(img.css({'margin-left': 0, 'margin-top': 0}).attr('src', this.src));
			
			if(!$("#bigpic:visible").length){ return; }
			
			var margin_left = width - img.width();
			if(margin_left > 0){
				img.css({'margin-left': margin_left/2});
			}
			var margin_top = height - img.height();
			if(margin_top > 0){
				img.css({'margin-top': margin_top/2});
			}
		};
		image.src=imgPath;
	}

	function fix(){
		$("#bigpic").css("display", "block");
	}

	function hideBigPic(){
		$("#bigpic").css("display", "none");
	}

	function hideBigPicFix(){
		$("#bigpic").css("display", "none");
	}
	$(document).ready(function(){
		setInterval(checkNextBlog,2000);
	});

