// preview ajax. start 

var previewLoadConfirm = 0;
var maxWidth = 0; 

function setLoadConfirm() {
	previewLoadConfirm = 1;
}

function getContents(url, params, e, t, width) {
	maxWidth = width; 
	if (!t) t = 0;
	if (previewLoadConfirm==0) {
		document.getElementById("contentsBox").innerHTML = "";
		try {
			request_ajax_01('Get', url, params, true, response_ajax_01, 'contentsBox'); 
		} catch(exception) {
			alert("connection failed");
		}
	}
	setTimeout("showContents("+e.x+","+e.y+", "+t+");");
	return;
}

function showContents(x, y, t) {
	var realWidth = document.body.clientWidth - 148;
	var meanWidth = realWidth / 2;
	var boxWidth = document.getElementById("contentsBox").scrollWidth;
					
	if (previewLoadConfirm) {
		if (boxWidth < maxWidth) 
			boxWidth = maxWidth;
		
		if (x < meanWidth) {
			document.getElementById("contentsBox").style.left = x + document.body.scrollLeft;
		} else {
			document.getElementById("contentsBox").style.left = x + document.body.scrollLeft - boxWidth;
		} 

		if (y+document.getElementById("contentsBox").clientHeight <= document.body.clientHeight) { 
			document.getElementById("contentsBox").style.top = y + document.body.scrollTop 	;
		} else { 
			document.getElementById("contentsBox").style.top = document.body.clientHeight - document.getElementById("contentsBox").clientHeight + document.body.scrollTop;
		}
		 
	} else {	
		setTimeout("showContents("+x+","+y+", "+t+");");
	}
	return;
}

function moveContents(e) {
	var realWidth = document.body.clientWidth - 160;
	var meanWidth = realWidth / 2;
	var boxWidth = document.getElementById("contentsBox").scrollWidth;

	if (boxWidth < maxWidth)
		boxWidth = maxWidth;

	if (e.x < meanWidth) { 
		document.getElementById("contentsBox").style.left = e.x + document.body.scrollLeft;
	} else { 
		document.getElementById("contentsBox").style.left = e.x + document.body.scrollLeft - boxWidth;
	} 

	if (previewLoadConfirm)
		document.getElementById("contentsBox").style.visibility = "visible";

	if (e.y+document.getElementById("contentsBox").clientHeight <= document.body.clientHeight) { 
		document.getElementById("contentsBox").style.top = e.y + document.body.scrollTop 	;
	} else { 
		document.getElementById("contentsBox").style.top = document.body.clientHeight - document.getElementById("contentsBox").clientHeight + document.body.scrollTop;
	} 		
	return;
}

function hideContents() {
	document.getElementById("contentsBox").style.visibility = "hidden";
	previewLoadConfirm = 0;
	return;
}

// preview ajax. end 
