﻿/*
##################################################
#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, pram ) {
	var imageList = new Array();

	if (document.images) {
		//preload images
		imageList[0] = "";
		//home-item
		imageList[imageList.length++] = newImage(imgpath+"");

		preloadFlag = true;
	}
}


/*
###################################################################
#open window method
#The value of the argument of windowSize is 'width=***,height=***'
#features is  [ true | false | Array ]
###################################################################
*/
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 openWin( theUrl, windowName, features, windowSize, x, y ){
	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 H = parseInt( windowSize.substring(17,20)) + adjusth;
	var winSize = new String( windowSize.substring(0,17) + H ); //String constructor is set up.
	
	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 );
	}

	// It arranges it at the center.
	//var x = parseInt((window.screen.width - parseInt( windowSize.substring(6,9) )) / 2);
	var y = parseInt((window.screen.height - H) / 2);

	var windowPosition = ( ",top=" + x + ",left=" + y );
	wfeatures += ( "," + winSize + windowPosition );
	//alert( wfeatures );

	new_window = window.open( theUrl, windowName, wfeatures ); //window open method.
	new_window.focus();
	//new_window.moveTo( x, y );
}

function openResizeWin(w,h,x,y) {
	window.resizeTo(w,h);
	window.moveTo(x,y);
}

function ShowLargeImgWin( path, imgName, imgW, imgH, features, x, y, 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 newfeatures = '"'+ wfeatures +',width='+ imgW +',height='+ imgH + windowPosition +'"';
	//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=Shift_JIS" />\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('<img src="'+ path + imgName +'" width="'+ imgW +'" height="'+ imgH +'" alt="'+ altTitle +'" title="'+ altTitle +'" />\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(theUrl, windowName, 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( theUrl, windowName, features, 'width='+size.width+',height='+size.height, 0, 0 );
}

/*
##################################################
#The main window is operated. method
##################################################
*/
function dispWin(theUrl, windowName, features, w, h){
	if(window.opener || !window.opener.closed){
		window.opener.location.href = theUrl;
	}else{
		openWin( theUrl, windowName, features, 'width='+w+',height='+h, 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/prototype.js"></script>');
	document.write('<script type="text/javascript" src="'+path+'js/scriptaculous.js?load=effects"></script>');
	document.write('<script type="text/javascript" src="'+path+'js/effects.js"></script>');
	document.write('<script type="text/javascript" src="'+path+'js/lightwindow.js"></script>');
	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);
	}
}

/*
###################################################################
#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');
}
*/
