﻿/*
##################################################
#This javascript was made on January 31, 2003.
#It is responsible for a MEDAL Co,Ltd.
#Responsibility is not taken although use is free.
##################################################
#nn4 reload & window resize bugfix
#reloads the window if Netscape4x resized.
#copyright macromedia.Co, Ltd.
##################################################
*/

function MM_reloadPage(init){
	if( init==true ){
		with( navigator ){
			if(( appName.charAt(0)=="N" )&&( parseInt(appVersion)<=4 )){
				document.MM_pgW=innerWidth;
				document.MM_pgH=innerHeight;
				window.onresize = MM_reloadPage; 
			}
		}
	}else if((innerWidth!=document.MM_pgW)||(innerHeight!=document.MM_pgH)) location.reload();
}

MM_reloadPage(true);


function MM_showHideLayers(){ //v6.0
	var i, p, v, obj;
	var args = MM_showHideLayers.arguments;

	for (i=0; i<(args.length-2); i+=3){
		if(( obj = MM_findObj(args[i])) != null){
			v = args[i+2];
			if( obj.style ){
				obj = obj.style;
				v = (v == 'show')?'visible':(v == 'hide')?'hidden':v;
			}
			obj.visibility = v;
		}
	}

}

function MM_findObj( n, d ){ //v4.01
	var p, i, x;
	if(!d) d = document;

	if((p = n.indexOf("?")) >0 && parent.frames.length){
		d = parent.frames[n.substring(p+1)].document;
		n = n.substring( 0, p );
	}

	if(!(x = d[n]) && d.all){ //ie4 lower or ie5up
		x = d.all[n];
		for(i=0; !x&&i<d.forms.length; i++){
			x=d.forms[i][n];
		}
	}

	for(i=0; !x&&d.layers&&i<d.layers.length; i++){
		x = MM_findObj( n, d.layers[i].document ); //ns4 lower
	}

	if(!x && d.getElementById) x=d.getElementById(n); //ie5up or ns6up

	return x;
}


/*
###################################
#menu pushbutton script
###################################
*/
function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;

		return rslt;
	}
}

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
			//alert(changeImages.arguments[i+1]);
		}
	}
}

var preloadFlag = false;

function preloadImages( imgpath ) {
	var imageList = new Array();

	if (document.images) {
		//preload images
		imageList[0] = "";
		//home-item
		imageList[imageList.length++] = newImage(imgpath+"");

		preloadFlag = true;
	}
}


/*
###################################################################
#open window method
#features is  [ true | false | Array ]
#position is "CT: center", "TL: top left", "TR: top right",
"BL: botttom left", "BR: bottom right", "x,y Number"
###################################################################
*/
function WindowFeaturesItem( foption ){ //features option.
	var wf = "";
	wf = "toolbar=" + (foption[0] ? "yes" : "no");
	wf += ",location=" + (foption[1] ? "yes" : "no");
	wf += ",directories=" + (foption[2] ? "yes" : "no");
	wf += ",status=" + (foption[3] ? "yes" : "no");
	wf += ",menubar=" + (foption[4] ? "yes" : "no");
	wf += ",scrollbars=" + (foption[5] ? "yes" : "no");
	wf += ",resizable=" + (foption[6] ? "yes" : "no");

	return wf;
}

function windowPosition(pram, w, h){
	var positionObj = new Object();

	if(pram=="CT"){
		positionObj.x = parseInt((window.screen.height - Number(h))/2);
		positionObj.y = parseInt((window.screen.width - Number(w))/2);
	}else if(pram=="TL"){
		positionObj.x = Number(0);
		positionObj.y = Number(0);
	}else if(pram=="TR"){
		var s_width = Number(window.screen.availWidth);
		var win_width= Number(s_width / 2);
		positionObj.x = Number(0);
		positionObj.y = Number(s_width - win_width);
	}else if(pram=="BL"){
		var s_height = Number(window.screen.availHeight);
		var win_height = Number(s_height / 2);
		positionObj.x = Number(s_height - win_height);
		positionObj.y = Number(0);
	}else if(pram=="BR"){
		var s_width = Number(window.screen.availWidth);
		var win_width= Number(s_width / 2);
		var s_height = Number(window.screen.availHeight);
		var win_height = Number(s_height / 2);
		positionObj.x = Number(s_height - win_height);
		positionObj.y = Number(s_width - win_width);
	}else{
		positionObj.x = Number(pram[0]);
		positionObj.y = Number(pram[1]);
	}

	return positionObj;
}

function openWin( theUrl, windowName, features, w, h, position ){
	var is = new Is_env();

	// windowhight is adjusted at the time of Mac ie4.5.
	if( is.MAC && is.IE && is.IE45 ) var adjusth = 2;
	else var adjusth = 0;

	var winSize = "width="+w+",height="+parseInt(h+adjusth);

	if((features==true)||(features==false)){
		var f = new Array();
		for(var i=0; i<7; i++){
			f[i] = features;
		}
		var wfeatures = WindowFeaturesItem(f);
	}else{
		var wfeatures = WindowFeaturesItem(features); //window features setting.
	}

	// position settings
	if((position == "undefined") || (position==null) || (position=="")) position="TL";
	var postionVal = windowPosition(position, w, h);
	var positions = ( ",top=" + postionVal.x + ",left=" + postionVal.y );
	wfeatures += ( "," + winSize + positions );
	//alert( wfeatures );

	new_window = window.open( theUrl, windowName, wfeatures ); //window open method.
	new_window.focus();
}

function openResizeWin(w,h,x,y) {
	window.resizeTo(w,h);
	window.moveTo(x,y);
}

function ShowLargeImgWin( path, imgpath, imgName, imgW, imgH, features, pram, altTitle ){
	if((features==true)||(features==false)){
		var f = new Array();
		for(i=0; i<7; i++){
			f[i] = features;
		}
		var wfeatures = WindowFeaturesItem(f);
	}else{
		var wfeatures = WindowFeaturesItem( features ); //window features setting.
		//alert( wfeatures );
	}

	//var x = parseInt((screen.width - imgW) / 2);
	//var y = parseInt((screen.height - imgH) / 2);
	//var windowPosition = ( ",top=" + x + ",left=" + y );
	var position = windowPosition(pram, imgW, imgH);
	var wPositions = ( ",top=" + position.x + ",left=" + position.y );
	var newfeatures = '"'+ wfeatures +',width='+ imgW +',height='+ imgH + wPositions +'"';
	//alert(newfeatures);

	//var windowSize = 'width='+imgW+',height='+imgH;
	//newWindow = openWin( "", "newSubWindow", false, windowSize, 0, 0 );

	newSubWindow = window.open( "", "SUB_WIN", newfeatures );
	newSubWindow.document.open("text/html");
	newSubWindow.document.write('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">\n');
	newSubWindow.document.write('<html lang="ja" dir="ltr">\n');
	newSubWindow.document.write('<head>\n');
	newSubWindow.document.write('<meta http-equiv="Content-Language" content="ja" />\n');
	newSubWindow.document.write('<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />\n');
	newSubWindow.document.write('<meta http-equiv="Content-Style-Type" content="text/css" />\n');
	newSubWindow.document.write('<meta http-equiv="Content-Script-Type" content="text/javascript" />\n');
	newSubWindow.document.write('<meta http-equiv="imagetoolbar" content="no" />\n');
	newSubWindow.document.write('<title>'+ altTitle +'</title>\n');
	newSubWindow.document.write('<script type="text/javascript" src="'+path+'js/default.js"></script>\n');
	newSubWindow.document.write('<script type="text/javascript" src="'+path+'js/base.js"></script>\n');
	newSubWindow.document.write('</head>\n');
	newSubWindow.document.write('<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginheight="0" marginwidth="0" onBlur="self.closeWin();" onClick="self.closeWin(); return false;">\n');
	newSubWindow.document.write('<div id="Largeimage">\n');
	newSubWindow.document.write('<p><img src="'+ imgpath + imgName +'" width="'+ imgW +'" height="'+ imgH +'" alt="'+ altTitle +'" title="'+ altTitle +'" /></p>\n');
	newSubWindow.document.write('</div>\n');
	newSubWindow.document.write('</body>\n');
	newSubWindow.document.write('</html>');
	newSubWindow.document.close();
	newSubWindow.focus();
}

/*
#################################
#closed window method
#################################
*/
function onErrMacWinClose(){
	closeWin();
	return true;
}

function closeWin(){
	var is = new Is_env();

	if( is.MAC && is.IE4X ) window.onerror = onErrMacWinClose;
	if( !this.closed ) this.close();
}

/*
##################################################
#The size of the parents window is acquired and
#it reflects it in the child window.
##################################################
*/
/* GET WINDOW SIZE METHOD */
function getWindowWidth(){
	if(window.innerWidth){
		return window.innerWidth;
	}else if(document.documentElement && document.documentElement.clientWidth){
		return document.documentElement.clientWidth;
	}else if ( document.body && document.body.clientWidth){
		return document.body.clientWidth;
	}
}

function getWindowHeight(){
	if(window.innerHeight){
		return window.innerHeight;
	}else if(document.documentElement && document.documentElement.clientHeight){
		return document.documentElement.clientHeight;
	}else if ( document.body && document.body.clientHeight){
		return document.body.clientHeight;
	}
}

/* RESIZE WINDOW METHOD */
function checkWindowSize(pram, w, h) {
	var sizeObj = new Object();
	if(pram=="WH"){
		sizeObj.width = getWindowWidth();
		sizeObj.height = getWindowHeight();
	}else if(pram=="W"){
		sizeObj.width = w;
		sizeObj.height = getWindowHeight();
	}else if(pram=="H"){
		sizeObj.width = getWindowWidth();
		sizeObj.height = h;
	}

	//alert(sizeObj.width+', '+sizeObj.height);
	return sizeObj;
}

function focusWin(file, target, pram, w, h, features) {
	if((w == null) || (w == "undefined") || (w == '')) w = 640;
	if((h == null) || (h == "undefined") || (h == '')) h = 480;
	var size = checkWindowSize(pram, w, h);
	openWin( file, target, features, size.width, size.height, 0, 0 );
}


/*
##################################################
#The script for branching Windows IE..
#In this case, the file of VBScript.
##################################################
*/
function check_vbscript( path ){
	var is = new Is_env();
	document.open("text/html");
	if(is.WIN && document.all && !is.OPERA){
		document.write('<script language="VBScript" type="text/VBScript" src="'+path+'js/flashCheck.vbs"></scr'+'ipt>');
	}
	document.close();
}

function load_lightWindow( path ) {
	document.open("text/html");
	document.write('<script type="text/javascript" src="'+path+'js/lightwindow/prototype.js"></script>');
	document.write('<script type="text/javascript" src="'+path+'js/lightwindow/scriptaculous.js?load=effects"></script>');
	document.write('<script type="text/javascript" src="'+path+'js/lightwindow/effects.js"></script>');
	document.write('<script type="text/javascript" src="'+path+'js/lightwindow/lightwindow.js"></script>');
	document.close();
}

function load_spry( path ) {
	document.open("text/html");
	document.write('<script type="text/javascript" src="'+path+'js/includes/SpryDOMUtils.js"></script>');
	document.write('<script type="text/javascript" src="'+path+'js/includes/SpryEffects.js"></script>');
	document.write('<script type="text/javascript" src="'+path+'js/widgets/slidingpanels/SprySlidingPanels.js"></script>');
	document.write('<script type="text/javascript" src="'+path+'js/spry_home.js"></script>');
	document.close();
}

/*
###################################
#writing footer method
###################################
*/
function writefooter(path){
	var is = new Is_env(); 
	var target = new Date();
	var year = new Array();

	if(!is.NN40X_LOW){
		var _year = target.getFullYear();

		for(i=0; i<4; i++){
			year[i] = (_year.toString()).substring(i, i+1);
		}
	}else{
		if( target.getYear() >= 2000 ) var _year = target.getYear();
		else var _year = target.getYear()+1900;

		for(i=0; i<4; i++){
			year[i] = (_year.toString()).substring(i, i+1);
		}
	}

	if( _year > 2009 ) var start_year='2009-';
	else var start_year='';

	document.open("text/html");
	document.write('<address title="All rights reserved / Copyright(c) Japan Center for Asian Historical Records '+ start_year + _year +'.">');
	document.write('<img src="'+path+'images/common/footer_top.gif" width="333" height="12" border="0" class="mr2">');
	if( _year > 2009 ){
		document.write('<img src="'+path+'images/common/c2.gif" width="6" height="12" border="0">');
		document.write('<img src="'+path+'images/common/c0.gif" width="6" height="12" border="0">');
		document.write('<img src="'+path+'images/common/c0.gif" width="6" height="12" border="0">');
		document.write('<img src="'+path+'images/common/c9.gif" width="6" height="12" border="0">');
		document.write('<img src="'+path+'images/common/hifun.gif" width="6" height="12" border="0">');
	}
	document.write('<img src="'+path+'images/common/c'+year[0]+'.gif" width="6" height="12" border="0">');
	document.write('<img src="'+path+'images/common/c'+year[1]+'.gif" width="6" height="12" border="0">');
	document.write('<img src="'+path+'images/common/c'+year[2]+'.gif" width="6" height="12" border="0">');
	document.write('<img src="'+path+'images/common/c'+year[3]+'.gif" width="6" height="12" border="0">');
	document.write('<img src="'+path+'images/common/footer_last.gif" width="3" height="12" border="0">\n');
	document.write('</address>');
	document.close();

}

/*
#########################################################################
#scroll potion method.
#ex.JavaScript:doPageScroll('up', -100) or doPageScroll('down', 500)
#########################################################################
*/
function doScroller( action, pram ){
	if (action == 'up'){ //scroll up action
		if (pram == screen.availHeight) var y = 0;
		else var y = 1000;

		y = y +(pram - y)*.1;
		while(y != pram){
			window.scroll(0, y);
			y = y + (pram - y)*.1;
			//window.status = "pram is : " +pram+ ", Y is : " +y;
			if (((pram - y) <= .5)&&((pram - y) >= -.5)) y = pram;
		}
	}else if (action == 'down'){ //scroll down action1
		y = 1;
		boundary = pram*.5;

		while(y <= boundary){
			window.scroll(0, y);
			y = y +(y*.3);
			if (((boundary - y) <= .5)&&((boundary - y) >= -.5)) y = boundary;
		}

		while(y != pram){
			window.scroll(0, y);
			y = y +(pram - y)*.1;
			if (((pram - y) <= .5)&&((pram - y) >= -.5)) y = pram;
		}
	}else{ //scroll down action2
		y = 0;
		y = y +(pram - y)*.1;

		while(y != pram){
			window.scroll(0, y);
			y = y +(pram-y)*.1;
			if (((pram - y) <= .5)&&((pram - y) >= -.5)) y = pram;
		}
	}
}

/*
######################################################################
#Side Scroll Page method
#<a href="javascript: slidePageTo(500)">x座標=500の位置へ移動</a>
#<a href="javascript: slidePageBy(300)">右に300ピクセル移動</a>
#<a href="javascript: slidePageBy(-300)">左に300ピクセル移動</a>
######################################################################
*/
var moveID = false;
var pos = 0;

function slideMe_left(n) {
	pos += Math.ceil((n-pos)*0.07);
	self.scroll(pos,0);
	if ((n-pos) <= 1) {
		pos = n;
		self.scroll(n,0);
		clearTimeout(moveID);
		moveID = false;
		return;
	}
	moveID = setTimeout("slideMe_left(" + n + ")",0);
}

function slideMe_right(n) {
	pos -= Math.ceil((pos-n)*0.07);
	self.scroll(pos,0);
	if (Math.abs(n-pos) <= 1) {
		pos = n;
		self.scroll(n,0);
		clearTimeout(moveID);
		moveID = false;
		return;
	}
	moveID = setTimeout("slideMe_right(" + n + ")",0);
}

function slidePageTo(n) {
	if(!moveID) {
		var d = (n>pos)? "left" : "right";
		var f ="slideMe_"+ d +"(" + n + ")";
		moveID = setTimeout(f,0);
	}
}

function slidePageBy(n) {
	if(!moveID) {
		var d = (n>0)? "left" : "right";
		var f ="slideMe_"+ d +"(" + (pos+n) + ")";
		moveID = setTimeout(f,0);
	}
}


function pageTopScroll() {
	var scrj = 1;
	var scdist = document.body.parentNode.scrollTop;
	if(scrj<50 && scdist) {
		scdist = (scdist>2) ? Math.ceil(scdist*.2) : 1;
		scrj++;
		scrollBy(0,-scdist);
		setTimeout("pageTopScroll()",20);
	} else {
		scrollTo(0,0);
	scrj = 1;
	}
} 

/*
###################################################################
#CRLF check method
###################################################################
# Escape Codec Library: ecl.js (Ver.041208)
# Copyright (C) http://nurucom-archives.hp.infoseek.co.jp/digital/
###################################################################
*/
/*
EscapeSJIS=function(str){
	return str.replace(/[^*+.-9A-Z_a-z-]/g,function(s){
		var c=s.charCodeAt(0),m;
		return c<128?(c<16?"%0":"%")+c.toString(16).toUpperCase():65376<c&&c<65440?"%"+(c-65216).toString(16).toUpperCase():(c=JCT11280.indexOf(s))<0?"%81E":"%"+((m=((c<8272?c:(c=JCT11280.lastIndexOf(s)))-(c%=188))/188)<31?m+129:m+193).toString(16).toUpperCase()+(64<(c+=c<63?64:65)&&c<91||95==c||96<c&&c<123?String.fromCharCode(c):"%"+c.toString(16).toUpperCase())
	})
};

UnescapeSJIS=function(str){
	return str.replace(/%(8[1-9A-F]|[9E][0-9A-F]|F[0-9A-C])(%[4-689A-F][0-9A-F]|%7[0-9A-E]|[@-~])|%([0-7][0-9A-F]|A[1-9A-F]|[B-D][0-9A-F])/ig,function(s){
		var c=parseInt(s.substring(1,3),16),l=s.length;
		return 3==l?String.fromCharCode(c<160?c:c+65216):JCT11280.charAt((c<160?c-129:c-193)*188+(4==l?s.charCodeAt(3)-64:(c=parseInt(s.substring(4),16))<127?c-64:c-65))
	})
};

EscapeUTF8=function(str){
	return str.replace(/[^*+.-9A-Z_a-z-]/g,function(s){
		var c=s.charCodeAt(0);
		return (c<16?"%0"+c.toString(16):c<128?"%"+c.toString(16):c<2048?"%"+(c>>6|192).toString(16)+"%"+(c&63|128).toString(16):"%"+(c>>12|224).toString(16)+"%"+(c>>6&63|128).toString(16)+"%"+(c&63|128).toString(16)).toUpperCase()
	})
};

UnescapeUTF8=function(str){
	return str.replace(/%(E(0%[AB]|[1-CEF]%[89AB]|D%[89])[0-9A-F]|C[2-9A-F]|D[0-9A-F])%[89AB][0-9A-F]|%[0-7][0-9A-F]/ig,function(s){
		var c=parseInt(s.substring(1),16);
		return String.fromCharCode(c<128?c:c<224?(c&31)<<6|parseInt(s.substring(4),16)&63:((c&15)<<6|parseInt(s.substring(4),16)&63)<<6|parseInt(s.substring(7),16)&63)
	})
};

function getCRLF(){
	var is = new Is_env();
	if(is.WIN){ //Windowsの改行コードは「CRLF=%0D%0A」
		return ("%0D%0A");
	}else if((is.OSX)||(is.UNIX)){ //UNIXの改行コードは「LF=%0A」
		return ("%0A");
	}else { //Macの改行コードは「CR=%0D」
		return ("%0D");
	}
}

function SetSubject( pram ){
	var is = new Is_env();
	if(pram == 'jp'){
		var str="岩合光昭ギャラリートーク＆サイン会 お申し込み・お問い合わせ";
		//Shift_JIS( URL encode )
		if(is.FIREFOX || is.NN8X || is.MOZILLA) return "?Subject="+EscapeSJIS(str);
		//UTF-8
		else if(is.OPERA) return "?Subject="+EscapeUTF8(str);
		//Shift_JIS
		else return "?Subject="+str;
	}
}

function SetBody( pram ){
	var is = new Is_env();
	if(pram == 'jp'){ //japanese
		var strTitle   = "・ ギャラリートーク＆サイン会お申し込み";
		var strName    = "・ 【お名前、またはハンドルネーム】";
		var strAddress = "・ 【返信用メールアドレス】";
		var strDetails = "・ 【ご希望日時】※6月28日（土） 16:30～ ／ 6月29日（日） 14:00～ のいずれか";
		var body = "";

		if(is.FIREFOX || is.NN8X || is.MOZILLA){ //Shift_JIS(URL encode)
			body += "&body="+EscapeSJIS(strTitle);
			body += getCRLF();
			body += EscapeSJIS(strName);
			body += getCRLF();
			body += EscapeSJIS(strAddress);
			body += getCRLF();
			body += EscapeSJIS(strDetails);
			return body;
		}else if(is.OPERA){ //UTF-8
			body += "&body="+EscapeUTF8(strTitle);
			body += getCRLF();
			body += EscapeUTF8(strName);
			body += getCRLF();
			body += EscapeUTF8(strAddress);
			body += getCRLF();
			body += EscapeUTF8(strDetails);
			return body;
		}else{ //Shift_JIS
			body += "&body="+strTitle;
			body += getCRLF();
			body += strName;
			body += getCRLF();
			body += strAddress;
			body += getCRLF();
			body += strDetails;
			return body;
		}
	}
}

function goEmail( pram ){
	//link path
	if (pram=='e-mail') top.location.href="mailto:info@gww-photocon.com"+SetSubject('jp')+SetBody('jp');
}
*/
