/**
* @brief 화면내에서 상위 영역보다 이미지가 크면 리사이즈를 하고 클릭시 원본을 보여줄수 있도록 변경
**/
var imageGalleryIndex = new Array();
function resizeImageContents() {
// 이미지 태그 정규 표현식
var img_regx = new RegExp("
parent_width - 2) {
obj.style.cursor = "pointer";
var new_w = parent_width - 2;
var new_h = Math.round(obj_height * new_w/obj_width);
xWidth(obj, new_w);
xHeight(obj, new_h);
}
obj.style.cursor = "pointer";
// 만약 대상 이미지에 링크가 설정되어 있거나 onclick 이벤트가 부여되어 있으면 원본 보기를 하지 않음
if(obj.parentNode.nodeName.toLowerCase()!='a' && !obj.getAttribute('onclick')) xAddEventListener(obj,"click", showOriginalImage);
imageGalleryIndex[j][i] = obj.src;
obj.setAttribute("rel", j+','+i);
}
}
}
}
xAddEventListener(window, "load", resizeImageContents);
/**
* @brief 본문내에서 컨텐츠 영역보다 큰 이미지의 경우 원본 크기를 보여줌
**/
function showOriginalImage(evt) {
var e = new xEvent(evt);
var obj = e.target;
var src = obj.src;
var rel = obj.getAttribute('rel');
displayOriginalImage(src, rel);
}
function displayOriginalImage(src, rel) {
// 투명 배경을 지정
var bgObj = xGetElementById("forOriginalImageBGArea");
if(!bgObj) {
bgObj = xCreateElement("div");
bgObj.id = "forOriginalImageBGArea";
bgObj.style.visibility = "hidden";
bgObj.style.backgroundColor = "#000000";
bgObj.style.zIndex = 500;
bgObj.style.position = "absolute";
document.body.appendChild(bgObj);
}
xWidth(bgObj, xClientWidth());
xHeight(bgObj, xClientHeight());
xLeft(bgObj, xScrollLeft());
xTop(bgObj, xScrollTop());
bgObj.style.opacity = .5;
bgObj.style.filter = "alpha(opacity=50);";
bgObj.style.visibility = "visible";
// 원본 이미지 노출을 위한 준비
var foreObj = xGetElementById("forOriginalImageArea");
if(!foreObj) {
foreObj = xCreateElement("div");
foreObj.id = "forOriginalImageArea";
foreObj.style.visibility = "hidden";
foreObj.style.overflow = "hidden";
foreObj.style.position = "absolute";
foreObj.style.zIndex = 510;
document.body.appendChild(foreObj);
}
xWidth(foreObj, xClientWidth());
xHeight(foreObj, xClientHeight());
xLeft(foreObj, xScrollLeft());
xTop(foreObj, xScrollTop());
foreObj.style.visibility = "visible";
var foreWidth = xWidth(foreObj);
var foreHeight = xHeight(foreObj);
// 버튼
var iconClose = xGetElementById("forOriginalImageIconClose");
if(!iconClose) {
iconClose = xCreateElement("img");
iconClose.id = "forOriginalImageIconClose";
iconClose.style.position = "absolute";
iconClose.src = request_uri+"addons/resize_image/iconClose.png";
iconClose.style.width = iconClose.style.height = "60px";
iconClose.className = 'iePngFix';
iconClose.style.zIndex = 530;
iconClose.style.cursor = "pointer";
foreObj.appendChild(iconClose);
}
iconClose.style.visibility = 'visible';
xLeft(iconClose, (foreWidth-60)/2);
xTop(iconClose, 10);
var iconLeft = xGetElementById("forOriginalImageIconLeft");
if(!iconLeft) {
iconLeft = xCreateElement("img");
iconLeft.id = "forOriginalImageIconLeft";
iconLeft.style.position = "absolute";
iconLeft.src = request_uri+"addons/resize_image/iconLeft.png";
iconLeft.style.width = iconLeft.style.height = "60px";
iconLeft.style.zIndex = 530;
iconLeft.className = 'iePngFix';
iconLeft.style.cursor = "pointer";
foreObj.appendChild(iconLeft);
}
iconLeft.onclick = null;
xLeft(iconLeft, 10);
xTop(iconLeft, (foreHeight-60)/2);
iconLeft.style.visibility = 'hidden';
var iconRight = xGetElementById("forOriginalImageIconRight");
if(!iconRight) {
iconRight = xCreateElement("img");
iconRight.id = "forOriginalImageIconRight";
iconRight.style.position = "absolute";
iconRight.src = request_uri+"addons/resize_image/iconRight.png";
iconRight.style.width = iconRight.style.height = "60px";
iconRight.className = 'iePngFix';
iconRight.style.zIndex = 530;
iconRight.style.cursor = "pointer";
foreObj.appendChild(iconRight);
}
iconRight.onclick = null;
xLeft(iconRight, foreWidth - 10 - 60);
xTop(iconRight, (foreHeight-60)/2);
iconRight.style.visibility = 'hidden';
if(rel) {
var tmp = rel.split(',');
var j = parseInt(tmp[0],10);
var i = parseInt(tmp[1],10);
var length = imageGalleryIndex[j].length;
if(length>1) {
var prev = i-1;
var next = i+1;
if(prev>=0) {
iconLeft.style.visibility = 'visible';
iconLeft.onclick = function() { displayOriginalImage(imageGalleryIndex[j][prev], j+','+prev); }
} else {
iconLeft.style.visibility = 'hidden';
}
if(next