/* * modalWindow.js *  * Copyright (C) 2011 GLIDE ARTS STUDIO. * @ version 0.13 * @ 2011-10-22 * @ Athor GLIDE ARTS STUDIO. *  */var G_indicator = new Image();var G_indicatorSrc = "http://www.glide.co.jp/common/images/indicator.gif";var G_indicatorTutorialSrc = "http://www.glide.co.jp/images/tutorial2.gif";/* ---------------------------------------------------------------------------------------------- */var doc = document;var G_ModalWindowOverlay     = doc.createElement("div");var G_ModalWindowBody        = doc.createElement("div");var G_ModalWindowImage       = doc.createElement("img");var G_ModalWindowTitle       = doc.createElement("h1");var G_ModalWindowTitleText   = doc.createTextNode("");var G_ModalWindowDiscription = doc.createElement("p");var G_ModalWindowDiscriptionText = doc.createTextNode("");var G_ModalWindowDate        = doc.createElement("p");var G_ModalWindowDateText    = doc.createTextNode("");var G_ModalWindowLink        = doc.createElement("a");var G_ModalWindowLinkText    = "";var G_ModalWindowCloseButton = "";var G_ModalWindowNextButton  = doc.createElement("p");var G_ModalWindowPrevButton  = doc.createElement("p");var G_ModalWindowNextIcon    = doc.createElement("img");var G_ModalWindowPrevIcon    = doc.createElement("img");var G_ModalWindowIndicatorContainer = doc.createElement("div");var G_ModalWindowCurrentImageNumber = "";var G_ModalWindowCurrentImageText   = "";var G_ModalWindowIsImageLoading = false;var G_ModalWindowIsInfomationLoading = false;var G_MWTween              = new Tween();var G_MWBodyPadding        = 30;var G_MWPrevCaption        = "";var G_MWPrevURL            = "";var G_MWPrevId             = "";var G_MWNextCaption        = "";var G_MWNextURL            = "";var G_MWNextId             = "";var G_MWCurrentGroup       = "";var G_MWImageDefaultWidth  = 0;var G_MWImageDefaultHeight = 0;var G_MWScrollbarWidth     = 0;var G_ModalWindowCurrentMaxImages = 0;if (UA.os === "windows") {	switch(UA.browser) {		case "msie"    : G_MWScrollbarWidth = 0;  break;		case "firefox" : G_MWScrollbarWidth = 17; break;		case "safari"  : G_MWScrollbarWidth = 17; break;		case "chrome"  : G_MWScrollbarWidth = 17; break;		case "opera"   : G_MWScrollbarWidth = 18; break;		default        : G_MWScrollbarWidth = 17;	}} else {	switch(UA.browser) {		case "firefox" : G_MWScrollbarWidth = 15; break;		case "safari"  : G_MWScrollbarWidth = 15; break;		case "chrome"  : G_MWScrollbarWidth = 15; break;		default        : G_MWScrollbarWidth = 15;	}}function G_ModalWindowInit(target) {		var centerPosition = (G_ModalWindowGetPageSize()[2] / 2) + (G_ModalWindowIndicatorContainer.offsetWidth / 2);		if (G_ModalWindowCurrentImageNumber == "") {		G_indicator.src = G_indicatorTutorialSrc;	} else {		G_indicator.src = G_indicatorSrc;	}		if (document.addEventListener) {		window.addEventListener("resize", G_ModalWindowResize, false);			} else if (document.attachEvent) {		window.onresize = G_ModalWindowResize;	}}function G_ModalWindowOpen(caption, url, imageGroup, photoId) {		var doc = document;	var html = doc.getElementsByTagName("html")[0];	var body = doc.getElementsByTagName("body")[0];	var overlay = G_ModalWindowOverlay;	var modalBody = G_ModalWindowBody;	var dev = UA.device;	var photolog = doc.getElementById("photolog");	var currentFunction = arguments.callee.caller;		modalBody.style.webkitTransitionDuration = "0s";	modalBody.style.transitionDuration = "0s";	G_ModalWindowCurrentMaxImages = photolog.getElementsByTagName("li").length;				try {		//if IE 6		if (UA.browser === "msie" && UA.version === 6) {						body.style.height = "100%";			body.style.width = "100%";			html.style.height = "100%";			html.style.width = "100%";			html.style.overflow = "hidden";		}				if (document.getElementById("G_ModalWindowOverlay") === null) {			body.appendChild(overlay);			overlay.setAttribute("id", "G_ModalWindowOverlay");			overlay.setAttribute("class", "ModalOverlayBG");			modalBody.setAttribute("id", "G_ModalWindowBody");						if (String(currentFunction).indexOf("onImageClickHandler", 0) >= 1) {				overlay.setAttribute("class", "ModalOverlayBG ModalOverlayBGFadein");			}						if (UA.browser === "msie" && UA.version <= 8) {				overlay.setAttribute("class", "ModalOverlayBGUnderIE8");				overlay.style.height = G_ModalWindowGetPageSize()[1] + 60 + "px";							} else if (UA.device === "iphone" || UA.device === "ipod" || UA.device === "ipad") {				overlay.style.height = document.documentElement.scrollHeight + "px";			}						// Add Events(for the Flick)			G_ModalWindowAddMouseEvent();					}								modalBody.style.opacity = 1;		G_MW_xp = 0;		G_MWCurrentGroup = imageGroup;		G_ModalWindowImage.setAttribute("id", "image");		G_ModalWindowShow(caption, url, imageGroup, photoId);		} catch(event) {		// Do nothing	}}var imgPreloader;function G_ModalWindowShow(caption, url, imageGroup, photoId) {		var body = document.getElementsByTagName("body")[0];	var img = document.createElement("img");	var baseURL = "";	var padding = G_MWBodyPadding;	var pagesize = G_ModalWindowGetPageSize();	var windowWidth = pagesize[2];	var windowHeight = pagesize[3];	var centerPosition = (windowWidth / 2) + (G_ModalWindowIndicatorContainer.offsetWidth / 2);		G_ModalWindowIndicatorContainer.setAttribute("id", "G_ModalWindowIndicatorContainer");	G_ModalWindowIndicatorContainer.setAttribute("class", "");	try {				if (caption === null) caption = "";				if (UA.browser === "msie" && UA.version === 6) {			G_ModalWindowIndicatorContainer.style.position = "absolute";		}				if (url.indexOf("?") !== -1) {			baseURL = url.substr(0, url.indexOf("?"));					} else { 			baseURL = url;		}				var TempArray = new Array();		var groupLength = 0;				G_ModalWindowIndicatorContainer.style.position = "fixed";		G_ModalWindowIndicatorContainer.style.left = (centerPosition - G_MWBodyPadding) + "px";		G_ModalWindowIndicatorContainer.style.top = parseInt((windowHeight / 2) - (G_indicator.height / 2)) + "px";		G_ModalWindowIndicatorContainer.appendChild(img);		G_ModalWindowIndicatorContainer.setAttribute("class", "fadein");				body.appendChild(G_ModalWindowIndicatorContainer);		img.setAttribute("src", G_indicator.src);		img.setAttribute("id", "G_indicator");				G_ModalWindowBody.setAttribute("class", "");				if (imageGroup) {						TempArray = getElementsByRelationName(imageGroup, document.getElementsByTagName("body")[0]);			groupLength = TempArray.length;						if (groupLength > 1) {				for (var i = 0; i < groupLength; i++) {					if (TempArray[i].getAttribute("data-href") === url) {												// between						if (i > 0 && i < groupLength - 1) {							G_ModalWindowAddPageNavigation("next");							G_ModalWindowAddPageNavigation("prev");							G_MWPrevCaption = TempArray[i - 1].getAttribute("title") || null;							G_MWNextCaption = TempArray[i + 1].getAttribute("title") || null;							G_MWPrevURL = TempArray[i - 1].getAttribute("data-href") || "";							G_MWNextURL = TempArray[i + 1].getAttribute("data-href") || "";							G_MWPrevId = TempArray[i - 1].getAttribute("data-id") || "";							G_MWNextId = TempArray[i + 1].getAttribute("data-id") || "";													// last						} else if (i === groupLength - 1) {							G_ModalWindowAddPageNavigation("prev");							G_MWPrevCaption = TempArray[i - 1].getAttribute("title") || null;							G_MWPrevURL = TempArray[i - 1].getAttribute("data-href") || "";							G_MWPrevId = TempArray[i - 1].getAttribute("data-id") || "";													// first						} else if (i === 0) {							G_ModalWindowAddPageNavigation("next");							G_MWNextCaption = TempArray[i + 1].getAttribute("title") || null;							G_MWNextURL = TempArray[i + 1].getAttribute("data-href") || "";							G_MWNextId = TempArray[i + 1].getAttribute("data-id") || "";						}												G_ModalWindowCurrentImageNumber = i;						G_ModalWindowCurrentImageText = groupLength + " of " + (i + 1) + " Images";						break;					}				}			}		}				G_ModalWindowIsImageLoading = true;		G_ModalWindowIsInfomationLoading = true;				imgPreloader = new Image();		imgPreloader.onload = function () {			imgPreloader.onload = null;			G_ModalWindowImage.setAttribute("src", imgPreloader.src);			G_ModalWindowIsImageLoading = false;			getPhotoInfomation(photoId, "G_ModalWindowSetInformation");			if (UA.browser === "msie" && UA.version === 6) G_ModalWindowBody.style.position = "absolute";		}				imgPreloader.src = url;				document.onkeyup = null;		document.onkeyup = function (event) {			var keycode;			if (event === null) {				keycode = event.keyCode;			} else {				keycode = event.which;			}			// Esc key			if (keycode === 27) {				G_ModalWindowRemove();							} else if (keycode === 37 && G_ModalWindowCurrentImageNumber !== G_ModalWindowCurrentMaxImages - 1) {// Left key				G_MWTween.play(G_ModalWindowBody, {left:-G_MW_limit - (padding * 2) + "px"}, 0.2, easeOutExpo, G_ModalWindowGotoNext);				G_ModalWindowIndicatorContainerInitPosition = G_ModalWindowGetPageSize()[2] + 50;							} else if (keycode === 39 && G_ModalWindowCurrentImageNumber !== 0) {// Right key				G_MWTween.play(G_ModalWindowBody, {left:G_ModalWindowGetPageSize()[2] + "px"}, 0.2, easeOutExpo, G_ModalWindowGotoPrev);				G_ModalWindowIndicatorContainerInitPosition = -50;			}		}		} catch(event) {		// Do nothing	}}function G_ModalWindowAddPageNavigation (type) {		var body = document.getElementsByTagName("body")[0];	var pagesize = G_ModalWindowGetPageSize();	var windowWidth = pagesize[2];	var windowHeight = pagesize[3];		if (type == "next") {				G_ModalWindowNextButton.setAttribute("id","G_ModalWindowNext")		G_ModalWindowNextButton.style.top = parseInt((windowHeight / 2) - 100 / 2) + "px";		body.appendChild(G_ModalWindowNextButton);				G_ModalWindowNextIcon.setAttribute("id","G_ModalWindowNextIcon");		G_ModalWindowNextIcon.setAttribute("src","images/modalwindow_side_next.png");		G_ModalWindowNextIcon.style.top = parseInt((windowHeight / 2) - 30/2) + "px";		G_ModalWindowNextIcon.style.display = "none";		body.appendChild(G_ModalWindowNextIcon);				//G_ModalWindowNextButton.onclick = G_ModalWindowGotoNext;	}		if (type == "prev") {				G_ModalWindowPrevButton.setAttribute("id","G_ModalWindowPrev")		G_ModalWindowPrevButton.style.top = parseInt((windowHeight / 2) - 100 / 2) + "px";		body.appendChild(G_ModalWindowPrevButton);				G_ModalWindowPrevIcon.setAttribute("id","G_ModalWindowPrevIcon");		G_ModalWindowPrevIcon.setAttribute("src","images/modalwindow_side_prev.png");		G_ModalWindowPrevIcon.style.top = parseInt((windowHeight / 2) - 30/2) + "px";		G_ModalWindowPrevIcon.style.display = "none";		body.appendChild(G_ModalWindowPrevIcon);				//G_ModalWindowPrevButton.onclick = G_ModalWindowGotoPrev;	}}function G_ModalWindowGotoNext() {	G_MW_adjustX = 0;	G_ModalWindowRemove();	G_ModalWindowOpen(G_MWNextCaption, G_MWNextURL, G_MWCurrentGroup, G_MWNextId);	}function G_ModalWindowGotoPrev() {	G_MW_adjustX = 0;	G_ModalWindowRemove();	G_ModalWindowOpen(G_MWPrevCaption, G_MWPrevURL, G_MWCurrentGroup, G_MWPrevId);}function G_ModalWindowRemove() {		var doc = document;	var html = doc.getElementsByTagName("html")[0];	var body = doc.getElementsByTagName("body")[0];		imgPreloader.onload = null;		if (G_ModalWindowIsInfomationLoading) {		if (document.getElementById("FlickrPhotoInfomation")) {			body.removeChild(document.getElementById("FlickrPhotoInfomation"));		}	} else {		G_ModalWindowLink.removeChild(G_ModalWindowIconFlickr);		G_ModalWindowBody.removeChild(G_ModalWindowTitle);		G_ModalWindowBody.removeChild(G_ModalWindowDiscription);		G_ModalWindowBody.removeChild(G_ModalWindowDate);		G_ModalWindowBody.removeChild(G_ModalWindowLink);		G_ModalWindowBody.removeChild(G_ModalWindowImage);	}		if (!G_ModalWindowIsImageLoading) {						G_ModalWindowBody.style.width = 0;		G_ModalWindowBody.style.height = 0;				G_ModalWindowCloseButton.onclick = null;		G_ModalWindowImage.setAttribute("src","");				if (doc.getElementById("G_ModalWindowNext")) {			body.removeChild(G_ModalWindowNextButton);			body.removeChild(G_ModalWindowNextIcon);		}		if (doc.getElementById("G_ModalWindowPrev")) {			body.removeChild(G_ModalWindowPrevButton);			body.removeChild(G_ModalWindowPrevIcon);		}	}		G_ModalWindowIsImageLoading = false;		if (G_ModalWindowOverlay) {		body.removeChild(G_ModalWindowOverlay);	}		if (document.getElementById("FlickrPhotoInfomation")) {		body.removeChild(document.getElementById("FlickrPhotoInfomation"));	}		if (document.getElementById("G_ModalWindowBody")) {		body.removeChild(G_ModalWindowBody);	}		if (doc.getElementById("G_indicator")) {		G_ModalWindowIndicatorContainer.removeChild(document.getElementById("G_indicator"));		body.removeChild(G_ModalWindowIndicatorContainer);	}		doc.onkeydown = null;	doc.onkeyup = null;		// Remove Events	G_ModalWindowRemoveMouseEvent();		//IE6 only	if (UA.browser === "msie" && UA.version === 6) {		body.style.height = "auto";		body.style.width = "auto";		html.style.height = "auto";		html.style.width = "auto";		html.style.overflow = "auto";	}		return false;}var G_ModalWindowIconFlickr = document.createElement("img");G_ModalWindowIconFlickr.setAttribute("id","G_ModalWindowIconFlickr")function G_ModalWindowSetInformation(data) {		var list = data.photo;	var title = list.title._content;	var discription = list.description._content;	var date = list.dates.taken;	var url = list.urls.url[0]._content;	var partision = discription ? " / " : "";		var body = document.getElementsByTagName("body")[0];	var padding = G_MWBodyPadding;		if (doc.getElementById("G_indicator")) {		G_ModalWindowIndicatorContainer.removeChild(document.getElementById("G_indicator"));		body.removeChild(G_ModalWindowIndicatorContainer);	}		G_ModalWindowIsInfomationLoading = false;	G_ModalWindowImageIsLoading = false;			if (document.getElementById("FlickrPhotoInfomation")) {				body.appendChild(G_ModalWindowBody);				G_ModalWindowImage.setAttribute("class", "fadeIn");				G_MWImageDefaultWidth = imgPreloader.width;		G_MWImageDefaultHeight = imgPreloader.height;				G_ModalWindowBody.appendChild(G_ModalWindowImage);		G_ModalWindowBody.style.paddingTop = padding + "px";		G_ModalWindowCloseButton.onclick = G_ModalWindowRemove;		G_ModalWindowResize();				G_ModalWindowIconFlickr.src = "./images/modalwindow_flickr.png";				G_ModalWindowTitleText.nodeValue = "";		G_ModalWindowDiscriptionText.nodeValue = "";		G_ModalWindowDateText.nodeValue = "";				G_ModalWindowTitleText.nodeValue = title + partision + discription;		G_ModalWindowTitle.appendChild(G_ModalWindowTitleText);		G_ModalWindowTitle.setAttribute("id", "G_MW_title");				G_ModalWindowDiscriptionText.nodeValue = discription;		G_ModalWindowDiscription.appendChild(G_ModalWindowDiscriptionText);		G_ModalWindowDiscription.setAttribute("id", "G_MW_discription");		G_ModalWindowDiscription.style.display = "none";				G_ModalWindowDateText.nodeValue = date;		G_ModalWindowDate.appendChild(G_ModalWindowDateText);		G_ModalWindowDate.setAttribute("id", "G_MW_date");		G_ModalWindowDate.style.display = "none";				//G_ModalWindowLinkText = document.createTextNode("Flickr");		//G_ModalWindowLink.appendChild(G_ModalWindowLinkText);		G_ModalWindowLink.appendChild(G_ModalWindowIconFlickr);		G_ModalWindowLink.setAttribute("id", "toFlickr");		G_ModalWindowLink.setAttribute("href", url);		G_ModalWindowLink.setAttribute("title", "Flickr");		G_ModalWindowLink.setAttribute("target", "_blank");				G_ModalWindowBody.appendChild(G_ModalWindowTitle);		G_ModalWindowBody.appendChild(G_ModalWindowDiscription);		G_ModalWindowBody.appendChild(G_ModalWindowDate);		G_ModalWindowBody.appendChild(G_ModalWindowLink);				body.removeChild(document.getElementById("FlickrPhotoInfomation"));	}}function G_ModalWindowResize() {		var pagesize;	var windowWidth;	var windowHeight;	var adjustW;	var adjustH;	var bodyWidth;	var bodyHeight;	var padding;	var imageWidth;	var imageHeight;	var dev = UA.device;		if (document.getElementById("G_ModalWindowBody")) {				pagesize     = G_ModalWindowGetPageSize();		windowWidth  = pagesize[0] - G_MWScrollbarWidth;		windowHeight = pagesize[3];		adjustW      = pagesize[0] - G_MWScrollbarWidth;		adjustH      = pagesize[3] - 200;		bodyWidth    = 0;		bodyHeight   = 0;		padding      = G_MWBodyPadding;		imageWidth   = G_MWImageDefaultWidth;		imageHeight  = G_MWImageDefaultHeight;				if (imageWidth > adjustW) {						imageHeight = imageHeight * (adjustW / imageWidth); 			imageWidth = adjustW; 						if (imageHeight > adjustH) { 				imageWidth = imageWidth * (adjustH / imageHeight); 				imageHeight = adjustH; 			}					} else if (imageHeight > adjustH) { 						imageWidth = imageWidth * (adjustH / imageHeight); 			imageHeight = adjustH; 						if (imageWidth > adjustW) { 				imageHeight = imageHeight * (adjustW / imageWidth); 				imageWidth = adjustW;			}		}				bodyWidth  = imageWidth + (padding * 2);		bodyHeight = imageHeight + (padding * 2);		G_MW_limit = imageWidth;		G_MW_centerPos = parseInt((windowWidth / 2) - (bodyWidth / 2));				if (dev === "iphone" || dev === "ipod" || dev === "ipad") {			G_ModalWindowBody.style.webkitTransform = "translate3d(" + parseInt((windowWidth / 2) - (bodyWidth / 2)) + "px, 0px, 0px)";		} else {			G_ModalWindowBody.style.left = parseInt((windowWidth / 2) - (bodyWidth / 2)) + "px";		}				G_ModalWindowBody.style.top     = parseInt((windowHeight / 2) - (bodyHeight / 2) - (padding / 2)) + "px";		G_ModalWindowBody.style.width   = bodyWidth + "px";		G_ModalWindowBody.style.height  = bodyHeight + "px";		G_ModalWindowImage.style.width  = imageWidth + "px";		G_ModalWindowImage.style.height = imageHeight + "px";						if (document.getElementById("G_ModalWindowNext")) {			G_ModalWindowNextButton.style.top = parseInt((windowHeight / 2) - (120 / 2)) + "px";		}		if (document.getElementById("G_ModalWindowPrev")) {			G_ModalWindowPrevButton.style.top = parseInt((windowHeight / 2) - (120 / 2)) + "px";		}	}}function G_ModalWindowAddMouseEvent() {		var doc = document;	var con = G_ModalWindowBody;	var dev = UA.device;	var overlay = G_ModalWindowOverlay;		if (dev === "iphone" || dev === "ipod" || dev === "ipad") {				con.addEventListener("touchstart", G_ModalWindowOnTouchEvent, false);		con.addEventListener("touchmove",  G_ModalWindowOnTouchEvent, false);		con.addEventListener("touchend",   G_ModalWindowOnTouchEvent, false);		overlay.addEventListener("touchend",   G_ModalWindowRemove, true);			} else if (UA.browser === "msie") {				doc.attachEvent("onmousemove", G_ModalWindowOnMouseEvent);		doc.attachEvent("onmouseup",   G_ModalWindowOnMouseEvent);		doc.attachEvent("onmouseout",  G_ModalWindowOnMouseEvent);		con.attachEvent("onmousedown", G_ModalWindowOnMouseEvent);		con.attachEvent("onmouseout",  G_ModalWindowOnMouseEvent);		overlay.attachEvent("onclick",  G_ModalWindowRemove);			} else {				doc.addEventListener("mousemove", G_ModalWindowOnMouseEvent, false);		doc.addEventListener("mouseup",   G_ModalWindowOnMouseEvent, false);		con.addEventListener("mousedown", G_ModalWindowOnMouseEvent, false);		con.addEventListener("mouseout",  G_ModalWindowOnMouseEvent, false);		overlay.addEventListener("click",  G_ModalWindowRemove, true);			}}function G_ModalWindowRemoveMouseEvent() {		var doc = document;	var con = G_ModalWindowBody;	var dev = UA.device;	var overlay = G_ModalWindowOverlay;		if (dev === "iphone" || dev === "ipod" || dev === "ipad") {				con.removeEventListener("touchstart", G_ModalWindowOnTouchEvent, false);		con.removeEventListener("touchmove",  G_ModalWindowOnTouchEvent, false);		con.removeEventListener("touchend",   G_ModalWindowOnTouchEvent, false);		overlay.removeEventListener("touchend",   G_ModalWindowRemove, true);			} else if (UA.browser === "msie") {				doc.detachEvent("onmousemove", G_ModalWindowOnMouseEvent);		doc.detachEvent("onmouseup",   G_ModalWindowOnMouseEvent);		doc.detachEvent("onmouseout",  G_ModalWindowOnMouseEvent);		con.detachEvent("onmousedown", G_ModalWindowOnMouseEvent);		con.detachEvent("onmouseout",  G_ModalWindowOnMouseEvent);		overlay.detachEvent("onclick",  G_ModalWindowRemove);			} else {				doc.removeEventListener("mousemove", G_ModalWindowOnMouseEvent, false);		doc.removeEventListener("mouseup",   G_ModalWindowOnMouseEvent, false);		con.removeEventListener("mousedown", G_ModalWindowOnMouseEvent, false);		con.removeEventListener("mouseout",  G_ModalWindowOnMouseEvent, false);		overlay.removeEventListener("click",  G_ModalWindowRemove, true);			}}var G_MW_date_time;var G_MW_date_time_old;var G_MW_newX = 0;var G_MW_oldX = 0;var G_MW_curX = 0;var G_MW_newDeffX = 0;var G_MW_oldDeffX = 0;var G_MW_adjustX = 0;var G_MW_xp = 0;var G_MW_centerPos = 0;var G_MW_limit = 500;var G_ModalWindowIsMouseDown = false;var G_ModalWindowIndicatorContainerInitPosition = 0;var leftButtonWidth = 0;var rightButtonWidth = 0;var G_flickingDeffX = 5;var G_ModalWindowPageIndicatorIntervalId;function G_ModalWindowOnMouseEvent(event) {		var date = new Date();	var pagesize;	var windowWidth;	var bodyWidth;	var doc = document;	var windowWidth = window.innerWidth || doc.documentElement.clientWidth || doc.body.clientWidth;	var css;		windowWidth -= G_MWScrollbarWidth;		if (browser !== "msie") {		css = document.defaultView.getComputedStyle(G_ModalWindowBody, "");		event.preventDefault();			} else {		css = G_ModalWindowBody.currentStyle	}		if ((event.type === "mousemove" || event.type === "mousedown") && G_ModalWindowIsMouseDown === true) {				G_MWTween.removeTweens();		G_MW_oldDeffX = G_MW_newDeffX;		G_MW_oldX = G_MW_newX;		G_MW_newX = G_ModalWindowGetPageX(event);		G_MW_xp = G_MW_newX - G_MW_adjustX;		G_ModalWindowBody.style.left = G_MW_xp + "px";		G_MW_newDeffX = G_MW_newX - G_MW_oldX;				G_ModalWindowMovePageIndicator.move();				G_MW_date_time_old = G_MW_date_time;		G_MW_date_time = date.getTime();			} else if (event.type === "mousedown") {				G_ModalWindowMovePageIndicator.reset();		G_ModalWindowIsMouseDown = true;		G_MW_newX = G_ModalWindowGetPageX(event);		G_MW_curX = G_ModalWindowGetElementPosition(G_ModalWindowBody)[0];		G_MW_adjustX = G_MW_newX - G_MW_curX;		G_ModalWindowBody.setAttribute("class","drag handHoldCursor");			} else if (event.type === "mouseup") {				//clearInterval(G_ModalWindowPageIndicatorIntervalId);		G_ModalWindowBody.setAttribute("class","drag");		G_ModalWindowIsMouseDown = false;		G_MW_xp = G_MW_newX - G_MW_adjustX;		G_ModalWindowBody.style.left = (parseInt(css.left)) + "px";				// Flicking		if (date.getTime() - G_MW_date_time_old < 180) {			if (G_MW_oldDeffX > G_flickingDeffX && G_ModalWindowCurrentImageNumber !== 0) {				toPrev(easeOutExpo);							} else if (G_MW_oldDeffX < -G_flickingDeffX && G_ModalWindowCurrentImageNumber !== G_ModalWindowCurrentMaxImages - 1) {				toNext(easeOutExpo);							} else {				toCenter();			}					// Swiping		} else {			if (G_MW_xp > G_MW_centerPos + G_MW_limit && G_ModalWindowCurrentImageNumber !== 0) {				toPrev(easeInOutExpo);							} else if (G_MW_xp < G_MW_centerPos - G_MW_limit && G_ModalWindowCurrentImageNumber !== G_ModalWindowCurrentMaxImages - 1) {				toNext(easeInOutExpo);							} else {				toCenter();			}		}				G_MW_newX = G_MW_centerPos;				leftButtonWidth = 0;		rightButtonWidth = 0;				G_ModalWindowNextButton.setAttribute("class", "transition");		G_ModalWindowPrevButton.setAttribute("class", "transition");		G_ModalWindowPrevButton.style.width = leftButtonWidth + "px";		G_ModalWindowNextButton.style.width = rightButtonWidth + "px";		G_ModalWindowPrevIcon.style.display = "none";		G_ModalWindowNextIcon.style.display = "none";	}		function toCenter() {		G_MWTween.play(G_ModalWindowBody, {left:G_MW_centerPos + "px"}, 0.2, easeOutExpo, tweenComplete);	}		function toNext(easing) {		G_MWTween.play(G_ModalWindowBody, {left:-G_MW_limit - (G_MWBodyPadding * 2) + "px"}, 0.2, easing, G_ModalWindowGotoNext);		G_ModalWindowIndicatorContainerInitPosition = G_ModalWindowGetPageSize()[2] + 50;	}		function toPrev(easing) {		G_MWTween.play(G_ModalWindowBody, {left:G_ModalWindowGetPageSize()[2] + "px"}, 0.2, easing, G_ModalWindowGotoPrev);		G_ModalWindowIndicatorContainerInitPosition = -50;	}		function tweenComplete() {		G_ModalWindowBody.setAttribute("class","");	}		return false;}function G_ModalWindowOnTouchEvent(event) {		var date = new Date();	var pagesize;	var windowWidth;	var bodyWidth;	var doc = document;	var windowWidth = doc.body.clientWidth;	var css = document.defaultView.getComputedStyle(G_ModalWindowBody, "");		event.preventDefault();		if ((event.type === "touchstart" || event.type === "touchmove") && G_ModalWindowIsMouseDown === true) {				G_MW_oldDeffX = G_MW_newDeffX;		G_MW_oldX = G_MW_newX;		G_MW_newX = event.touches[0].pageX;		G_MW_xp = G_MW_newX - G_MW_adjustX;		G_ModalWindowBody.style.webkitTransform = "translate3d(" + G_MW_xp + "px, 0px, 0px)";		G_MW_newDeffX = G_MW_newX - G_MW_oldX;				G_ModalWindowMovePageIndicator.move();				G_MW_date_time_old = G_MW_date_time;		G_MW_date_time = date.getTime();					} else if (event.type === "touchstart") {				G_ModalWindowMovePageIndicator.reset();		G_ModalWindowIsMouseDown = true;		G_MW_newX = event.touches[0].pageX;		G_MW_curX = getWebKitCSSMatrix().e;		G_MW_adjustX = G_MW_newX - G_MW_curX;		G_ModalWindowBody.style.webkitTransitionProperty = "-webkit-transform";		G_ModalWindowBody.style.webkitTransitionDuration = "0ms";		G_ModalWindowBody.style.webkitTransitionTimingFunction = "linear";				G_ModalWindowBody.setAttribute("class", "noshadow");			} else if (event.type === "touchend") {				G_ModalWindowIsMouseDown = false;		G_MW_xp = G_MW_newX - G_MW_adjustX;				G_ModalWindowBody.style.webkitTransitionTimingFunction = "cubic-bezier(0, 0.5, 0.5, 1.0)";		G_ModalWindowBody.style.webkitTransitionDuration = "200ms";		G_ModalWindowBody.style.webkitTransitionProperty = "-webkit-transform";		G_ModalWindowBody.style.webkitTransform = "translate3d(" + getWebKitCSSMatrix().e + "px, 0px, 0px)";						// Flicking 一定の時間差と移動量でマウスが離された場合フリック		if (date.getTime() - G_MW_date_time_old < 180) {			if (G_MW_oldDeffX > G_flickingDeffX && G_ModalWindowCurrentImageNumber !== 0) {				toPrev("ease-out");							} else if (G_MW_oldDeffX < -G_flickingDeffX && G_ModalWindowCurrentImageNumber !== G_ModalWindowCurrentMaxImages - 1) {				toNext("ease-out");							} else {				toCenter();			}					// Swiping		} else {			if (G_MW_xp > G_MW_centerPos + G_MW_limit && G_ModalWindowCurrentImageNumber !== 0) {				toPrev("ease-in-out");							} else if (G_MW_xp < G_MW_centerPos - G_MW_limit && G_ModalWindowCurrentImageNumber !== G_ModalWindowCurrentMaxImages - 1) {				toNext("ease-in-out");							} else {				toCenter();			}		}				leftButtonWidth = 0;		rightButtonWidth = 0;				G_ModalWindowNextButton.setAttribute("class", "transition");		G_ModalWindowPrevButton.setAttribute("class", "transition");		G_ModalWindowPrevButton.style.width = leftButtonWidth + "px";		G_ModalWindowNextButton.style.width = rightButtonWidth + "px";		G_ModalWindowPrevIcon.style.display = "none";		G_ModalWindowNextIcon.style.display = "none";	}		function toCenter() {				G_ModalWindowBody.style.webkitTransitionTimingFunction = "ease-in-out";		G_ModalWindowBody.style.webkitTransitionDuration = "200ms";		G_ModalWindowBody.style.webkitTransform = "translate3d(" + G_MW_centerPos + "px, 0px, 0px)";		G_ModalWindowBody.setAttribute("class", "noshadow");		setTimeout(tweenComplete, 200);	}		function toNext(easing) {		G_ModalWindowBody.style.webkitTransitionTimingFunction = easing;		G_ModalWindowBody.style.webkitTransform = "translate3d(" + (-G_MW_limit - (G_MWBodyPadding * 2) - 10) + "px, 0px, 0px)";				G_ModalWindowIndicatorContainerInitPosition = G_ModalWindowGetPageSize()[2] + 50;		setTimeout(G_ModalWindowGotoNext, 200);		setTimeout(tweenComplete, 200);	}		function toPrev(easing) {		G_ModalWindowBody.style.webkitTransitionTimingFunction = easing;		G_ModalWindowBody.style.webkitTransform = "translate3d(" + (G_ModalWindowGetPageSize()[2] + 10) + "px, 0px, 0px)";				G_ModalWindowIndicatorContainerInitPosition = -50;		setTimeout(G_ModalWindowGotoPrev, 200);		setTimeout(tweenComplete, 200);	}		function tweenComplete() {		G_ModalWindowBody.setAttribute("class", "");	}		function getWebKitCSSMatrix() {		var matrix = new WebKitCSSMatrix(window.getComputedStyle(G_ModalWindowBody).webkitTransform);		return matrix;	}		return false;}var G_ModalWindowMovePageIndicatorObject = function () {		var padding = G_MWBodyPadding;	var distanceRatio = 0;	var buttonMaxWidth = 30;	var buttonDefaultWidth = 15;		this.reset = function () {		G_ModalWindowNextButton.setAttribute("class", "transition");		G_ModalWindowPrevButton.setAttribute("class", "transition");		distanceRatio = (G_MW_centerPos - G_MW_xp + G_MWBodyPadding * 2) / G_MW_limit;				rightButtonWidth = buttonDefaultWidth;		leftButtonWidth = buttonDefaultWidth;				G_ModalWindowPrevButton.style.width = leftButtonWidth + "px";		G_ModalWindowNextButton.style.width = rightButtonWidth + "px";	}		this.move = function () {		G_ModalWindowNextButton.setAttribute("class", "");		G_ModalWindowPrevButton.setAttribute("class", "");		distanceRatio = (G_MW_centerPos - G_MW_xp + G_MWBodyPadding * 2) / G_MW_limit;				// prev		if (G_MW_oldDeffX > 0) {			rightButtonWidth = Math.round(distanceRatio * buttonMaxWidth) + buttonDefaultWidth;			leftButtonWidth = Math.round(distanceRatio * -buttonMaxWidth) + buttonDefaultWidth;					// next		} else {			rightButtonWidth = Math.round(distanceRatio * buttonMaxWidth) + buttonDefaultWidth - 3;			leftButtonWidth = Math.round(distanceRatio * -buttonMaxWidth) + buttonDefaultWidth;		}				if (rightButtonWidth < 0) rightButtonWidth = 0;		if (leftButtonWidth < 0) leftButtonWidth = 0;				reflesh();	}		function reflesh() {				if (G_MW_xp > G_MW_centerPos + G_MW_limit + padding * 2) {			G_ModalWindowNextButton.style.width = 0 + "px";			G_ModalWindowNextIcon.style.display = "none";						G_ModalWindowPrevButton.style.width = buttonMaxWidth + buttonDefaultWidth + "px";			G_ModalWindowPrevIcon.style.display = "block";					} else if (G_MW_xp < G_MW_centerPos - G_MW_limit) {			G_ModalWindowNextButton.style.width = buttonMaxWidth + buttonDefaultWidth + "px";			G_ModalWindowNextIcon.style.display = "block";						G_ModalWindowPrevButton.style.width = 0 + "px";			G_ModalWindowPrevIcon.style.display = "none";					} else {			G_ModalWindowPrevButton.style.width = leftButtonWidth + "px";			G_ModalWindowNextButton.style.width = rightButtonWidth + "px";			G_ModalWindowPrevIcon.style.display = "none";			G_ModalWindowNextIcon.style.display = "none";		}	}}var G_ModalWindowMovePageIndicator = new G_ModalWindowMovePageIndicatorObject();/* ---------------------------------------------------------------------------------------------- */// IE onlyfunction msieGetElementsByClassName(classNameString, targetObject){		var element = targetObject;	var array = new Array();	var target;		if (element === undefined || element === "") element = document;		target = element.all;		if (document.all) {		for (i = 0, j = 0; i < target.length; i++) {			if (target[i].className === classNameString) {				array[j] = target[i];				j++;			}		}	}	return array;}function getElementsByRelationName(relNameString, targetObject){		var array = new Array();	var tags = new Array();	var len = 0;		// IE only	document.all ? tags = targetObject.all : tags = targetObject.getElementsByTagName("*");		len = tags.length;		for (i = 0, j = 0; i < len; i++) {		if (tags[i].getAttribute("rel") == relNameString) {			array[j] = tags[i];			j++;		}	}	return array;}function G_ModalWindowGetPageSize() {		var xScroll;	var yScroll;	var windowWidth;	var windowHeight;	var pageWidth;	var pageHeight;	var arraySizes;		// Gecko	if (window.innerHeight && window.scrollMaxY) {		xScroll = window.innerWidth + window.scrollMaxX;		yScroll = window.innerHeight + window.scrollMaxY;			// Webkit, IE(Standards mode)	} else if (document.body.scrollHeight > document.body.offsetHeight) {		xScroll = document.body.scrollWidth;		yScroll = document.body.scrollHeight;			// Other IE	} else {		xScroll = document.body.offsetWidth;		yScroll = document.body.offsetHeight;	}		// not IE	if (window.innerHeight) {		windowWidth  = window.innerWidth;		windowHeight = window.innerHeight;			// IE(Standards mode)	} else if (document.documentElement.clientHeight && document.documentElement) {		windowWidth  = document.documentElement.clientWidth;		windowHeight = document.documentElement.clientHeight;			// Other IE	} else if (document.body) {		windowWidth  = document.body.clientWidth;		windowHeight = document.body.clientHeight;	}		yScroll < windowHeight ? pageHeight = windowHeight : pageHeight = yScroll;	xScroll < windowWidth  ? pageWidth  = windowWidth  : pageWidth  = xScroll;		arraySizes = new Array(pageWidth, pageHeight, windowWidth, windowHeight);		return arraySizes;}function G_ModalWindowGetElementPosition(element) {		var target = typeof element == "string" ? document.getElementById(element) : element;	var left   = 0;	var top    = 0;		while (target) {		left  += target.offsetLeft;		top   += target.offsetTop;		target = target.offsetParent;	}		return new Array(left, top);}function G_ModalWindowGetPageX(event) {		var pageX = 0;	var doc = document;		if (UA.browser === "msie") {		pageX = doc.body.scrollLeft + window.event.clientX;			} else {		pageX = event.pageX;	}		return pageX;}
