/*@cc_on _d=document;eval('var document=_d')@*/
var db = document.documentElement||document.body,IPosX,IPosY,LoadCnt,BgA = 0,Domain,White = new Image(),BaseBG = new Image(),backButton = new Image(),nextButton = new Image(),backButtonR = new Image(),nextButtonR = new Image(),ImageArr = new Array(),LoactionCheck,cpLoad;

exScriptsLoad = function(){
//	$('leftbox').style.position = ABFX;
	LoactionCheck = new String(window.location);
	LoactionCheck = (LoactionCheck.indexOf("30th.html") === -1)? 0:1;
	if(LoactionCheck == 0){
		var IEF = IE7;
		if(MOSC == 1 && IEF == 0){
			ie6leftboxPosition();
		}else{
			$('leftbox').style.left = 'auto';
			$('leftbox').style.marginLeft = '20px';
			if(IEF == 2){
				correctHeaderPosition(0);
			}else if(undefined !== window.Components){
				correctHeaderPosition(1);
			}
		}

		observe($('bio_head_menu'),'mouseover',function (e){
			shortCutMenuOn('bio')
		},false);
		observe($('bio_head_menu'),'mouseout',function (e){
			shortCutMenuOff('bio')
		},false);

		observe($('gallery_head_menu'),'mouseover',function (e){
			shortCutMenuOn('gallery')
		},false);
		observe($('gallery_head_menu'),'mouseout',function (e){
			shortCutMenuOff('gallery')
		},false);

//		getShortCutIndex();
	}

	var galleryCheck = new String(window.location);
	if(galleryCheck.indexOf("gallery/index") !== -1){
		var ele = document.getElementsByTagName("*"),eleL = ele.length;
		for(var i = 0;i<eleL;i++){
			if(ele[i].id){
				if(ele[i].id.indexOf("hidden_detail_") !== -1){
					ele[i].style.display = 'none';
				}else if(ele[i].id.indexOf("open_detail_") !== -1){
					observe(ele[i],'click',function (e){
						openGalleryDetail(this)
					},false);
				}
			}
		}
	}

	imageViewer();
	makeWaiter();
	if(cpLoad) cpLoad();
}

function openGalleryDetail(obj){
	var arr = new Array('hidden_detail_'),num = obj.id.match(/_(\d+)/),cstyle ;
	arr[1] = RegExp.$1;
	arr = arr.join('');
	cstyle = $(arr).currentStyle || document.defaultView.getComputedStyle($(arr), '')
	if(cstyle.display == 'block'){
		$(arr).style.display = 'none';
		obj.childNodes[1].style.display = 'block'
	}else{
		$(arr).style.display = 'block';
		obj.childNodes[1].style.display = 'none'
	}
	if(IE7 == 2){
		obj.parentNode.parentNode.style.position = 'static';
		obj.parentNode.parentNode.style.position = 'relative';
	}
}

window.onresize = function(){
	if(LoactionCheck == 1) return;
	var IEF = IE7;
	if(MOSC == 1 && IEF == 0){
		ie6leftboxPosition();
	}else{
		fixedTopMenubar();
		if(IEF == 2){
			correctHeaderPosition(0);
		}else if(undefined !== window.Components){
			correctHeaderPosition(1);
		}
	}
}

window.onscroll = function(){
	if(LoactionCheck == 1) return;
	if(MOSC == 1 && IE7 == 0){
		ie6leftboxPosition();
	}else{
		fixedTopMenubar()
	}
}

function correctHeaderPosition(BRS){
	var cw = db.clientWidth,brsA = (BRS == 1)? '1px 0px':'0px 0px',brsB = (BRS == 1)? '0px 0px':'1px 0px';
	if(cw % 2 != 0){
		$('head_menu').style.backgroundPosition = brsA;
		$('head').style.backgroundPosition = brsA;
	}else{
		$('head_menu').style.backgroundPosition = brsB;
		$('head').style.backgroundPosition = brsB;
	}
}

function ie6leftboxPosition(){
	if(db.clientHeight <= 730) return ie6RestPosition();
	var cstyle = $('shadow').currentStyle || document.defaultView.getComputedStyle($('shadow'), ''),arr = new Array(db.scrollTop - 278,'px');
	if(db.scrollTop >= 341){
		$('leftbox').style.top = arr.join('');
		$('head_menu').style.position = ABFX;
		arr = new Array(db.scrollTop,'px');
		$('head_menu').style.top = arr.join('');
		$('head_menu').style.left = '14px';
		$('toplink').style.visibility = 'visible';
	}else{
		$('leftbox').style.top = '30px';
		$('head_menu').style.position = 'static';
		$('toplink').style.visibility = 'hidden';
	}
}

function ie6RestPosition(){
	if(MOSC == 1 && IE7 == 0){
		$('leftbox').style.top = '30px';
		$('head_menu').style.position = 'static';
	}
}

function fixedTopMenubar(){
	var scrollTop  = document.body.scrollTop  || document.documentElement.scrollTop,cstyle = $('shadow').currentStyle || document.defaultView.getComputedStyle($('shadow'), ''),arr;
	if(scrollTop >= 341){

		$('head_menu').style.position = ABFX;
		$('head_menu').style.top = '0px';
		if(IE7 == 1){
			if(db.clientWidth < 778){
				$('head_menu').style.left = '15px';
			}else{
				arr = (db.clientWidth - numberGet(cstyle.width)) / 2 + 14;
				arr = new Array(arr,'px');
				$('head_menu').style.left = arr.join('');
			}
//			window.status = arr[0] + ' ' + db.clientWidth + ' ' + cstyle.width
		}
		$('toplink').style.visibility = 'visible';
		$('leftbox').style.position = ABFX;
		$('leftbox').style.marginTop = '30px';
		if(undefined !== window.Components) $('head_menu').style.backgroundPosition = '1px 0px';
	}else{
		$('head_menu').style.position = 'static';
		$('toplink').style.visibility = 'hidden';
		$('leftbox').style.position = 'absolute';
		$('leftbox').style.marginTop = '0px';
		if(undefined !== window.Components) correctHeaderPosition(1);
	}
/*
	cstyle = $('head_menu').currentStyle || document.defaultView.getComputedStyle($('head_menu'), '')
	window.status = $('head_menu').style.left + ' ' + $('head_menu').style.marginLeft + ' ' + $('head_menu').style.background
*/
}

function shortCutMenuOn(MODE){
	var ID,arr = new Array(MODE,'_shortcut'),hID;
	ID = arr.join('');
	arr = new Array(MODE,'_head_menu');
	hID = arr.join('');
	$(ID).style.visibility = 'visible';
	arr = new Array($(hID).offsetLeft,'px');
	$(ID).style.left = arr.join('')

}

function shortCutMenuOff(MODE){
	var ID,arr = new Array(MODE,'_shortcut'),hID;
	ID = arr.join('');
	arr = new Array(MODE,'_head_menu');
	hID = arr.join('');
	$(ID).style.visibility = 'hidden';
}

function makeWaiter(){
	if(!$('waiter')){
		var d = document,ele = d.createElement('DIV'),eles = ele.style,arr = new Array('<p><img src="',Domain,'/images/default/img_common/waiter.gif" width="58" height="167" /><br /><span class="waitstr1">画像を読み込み中です...</span><br /><span class="waitstr2">Now Loading...</span></p>'),ele2,dw;
		ele.id = 'waiter';
		eles.position = ABFX;
		eles.top = '0px';
		if(MOSC == 1){
			if(IE7 > 0)eles.filter = 'alpha(opacity=80)';
			eles.width = (IE7 == 0)? '100px':eles.width
		}else{
//			if(undefined !== window.opera && "function" === typeof window.opera.version){
				eles.opacity = 0.8
/*			}else{
				eles.backgroundColor = (NN7 == 1)? 'rgb(255,255,255)':'rgba(255,255,255,0.6)';
			}
*/
		}

		eles.visibility = 'hidden';
		ele.innerHTML =arr.join('');
		d.body.appendChild(ele);

		if(MOSC == 1 && IE7 == 0){
			ele = d.createElement('IFRAME');
			eles = ele.style;
			ele.id = 'dwaiter';
			ele.scrolling = 'no';
			eles.position = ABFX;
			eles.width = '200px';
			eles.top = '0px';
			eles.backgroundColor = '#000';
			eles.zIndex = 251;
			eles.visibility = 'hidden';
			d.body.appendChild(ele);
		}
	}else{
		$('waiter').style.visibility = 'visible'
	}
}

window.onunload = function(){
	if($('waiter')) document.body.removeChild($('waiter'));
	if($('dwaiter')) document.body.removeChild($('dwaiter'));
	if($('basefield')) document.body.removeChild($('basefield'));
	if($('menufield')) document.body.removeChild($('menufield'));
	if($('ntimage')) document.body.removeChild($('ntimage'));
	if($('largeimg_title')) document.body.removeChild($('largeimg_title'));
	if($('bio_head_menu')){
		EventRemover($('bio_head_menu'),'mouseover',shortCutMenuOn);
		EventRemover($('bio_head_menu'),'mouseout',shortCutMenuOff);
		EventRemover($('gallery_head_menu'),'mouseover',shortCutMenuOn);
		EventRemover($('gallery_head_menu'),'mouseout',shortCutMenuOff);
	}

	if($('open_detail_1')){
		var ele = document.getElementsByTagName("*"),eleL = ele.length;
		for(var i = 0;i<eleL;i++){
			if(ele[i].id && ele[i].id.match(/(hidden|open)_detail_/)){
				EventRemover(ele[i],'click',openGalleryDetail);
			}
		}
	}

}

function setCenterring(x,y){
	var d = document,IPosX,IPosY,PosArray,ws = $('waiter').style,arr = new Array(x,'px'),clientWidth = d.documentElement.clientWidth||d.body.clientWidth,clientHeight = d.documentElement.clientHeight||d.body.clientHeight,scrollTop = d.documentElement.scrollTop||d.body.scrollTop,scrollLeft = d.documentElement.scrollLeft||d.body.scrollLeft,scrollHeight = d.documentElement.scrollHeight||d.body.scrollHeight;
	ws.width = (x == '100%')? x:arr.join('');
	arr[0] = y;
	ws.height = arr.join('');

	if(MOSC == 1 && IE7 == 0){
		var dw = $('dwaiter').style;
		arr = new Array(x,'px')
		dw.width = (x == '100%')? x:arr.join('');
		arr = new Array(y,'px')
		dw.height = arr.join('');

		IPosX = (x == '100%')? x:scrollLeft + clientWidth / 2 - x / 2;
		IPosY = scrollTop + clientHeight / 2 - y;
		arr[0] = IPosX;
		dw.left = (x == '100%')? '0px':arr.join('');
		arr[0] = IPosY;
		dw.top = arr.join('');
		dw.visibility = 'visible';
//		window.status = IPosY + ' ' + dw.top;

	}else{
		var cstyle = $('waiter').currentStyle || document.defaultView.getComputedStyle($('waiter'), '');
		if(cstyle.position == 'absolute'){
			IPosX = (x == '100%')? x:scrollLeft + clientWidth / 2 - x / 2;
			IPosY = scrollTop + clientHeight / 2 - y;
		}else{
			IPosX = (x == '100%')? 0:scrollLeft + clientWidth / 2 - x / 2;
			IPosY = clientHeight / 2 - y
		}
	}
	arr[0] = IPosX;
	ws.left = (x == '100%')? '0px':arr.join('');
	arr[0] = IPosY;
	ws.top = arr.join('');
	ws.visibility = 'visible';
}

function imageViewer(){
	var LocationStr = new String(window.location),d = document,ele = document.getElementsByTagName("A"),eleL = ele.length,arr = new Array("javascript:displayLargeImage('",
	"",
	"',",
	'',
	")"),j = 0,str;
	for(var i=0;i<eleL;i++){
		if(ele[i].href.match(/\.(jpeg|jpg|gif|png)$/i)){
			arr[1] = new String(ele[i].href);
			arr[1] = arr[1].replace(/http:\/\//,'');
			arr[3] = j;
			ele[i].href = arr.join('');
			ImageArr[j] = i;
			j++;
		}
	}
	Domain = $('rdomainvalue').href;
	arr = new Array(Domain,'/images/default/img_common/');
	arr = arr.join('');
	ImgDir = new Array(arr,'white.png');
	White.src = ImgDir.join('');
	ImgDir[1] = 'largelogo.png';
	BaseBG.src = ImgDir.join('');
	ImgDir[1] = 'backbutton_d.png';
	backButton.src = ImgDir.join('');
	ImgDir[1] = 'nextbutton_d.png';
	nextButton.src = ImgDir.join('')
	ImgDir[1] = 'backButton_r.png';
	backButtonR.src = ImgDir.join('');
	ImgDir[1] = 'nextbutton_r.png';
	nextButtonR.src = ImgDir.join('');
}

function waiterClose(){
	$('waiter').style.visibility = 'hidden';
	if(MOSC == 1 && IE7 == 0) $('dwaiter').style.visibility = 'hidden';
}

function ImageHide(e){
	$('basefield').style.display = 'none';
	$('menufield').style.display = 'none';
	waiterClose();
	document.body.removeChild($('ntimage'));
	if($('largeimg_title')) document.body.removeChild($('largeimg_title'));
}

displayLargeImage = function(iurl,num){
	var d = document,Nimg = d.createElement('DIV'),Ns = Nimg.style,arr,nextImg = num + 1,prevImg = num - 1,ele = d.getElementsByTagName('A'),prevTag,nextTag,str = new Array('http://',iurl),comm,comS,comV;
	str = str.join('');
	if(NN7 == 1){
		window.open(str,"_blank");
	}else{
		IPosX = db.clientWidth / 2 + db.scrollLeft;
		IPosY = db.clientHeight / 2 + db.scrollTop;
		LoadCnt = 150;

		if(ele[ImageArr[prevImg]]){
			prevTag = new String(ele[ImageArr[prevImg]].href);
			prevTag = new Array('<a class="nextlink" href="',prevTag,'"><img src="',backButton.src,'" width="97" height="38" alt="Back" title="一つ前の画像" onmouseover="EzRollOver(this)" onmouseout="EzRollOut(this)" /></span>');
			prevTag = prevTag.join('')
		}

		if(ele[ImageArr[nextImg]]){
			nextTag = new String(ele[ImageArr[nextImg]].href);
			nextTag = new Array('<a class="nextlink" href="',nextTag,'"><img src="',nextButton.src,'" width="94" height="38" alt="Next" title="次の画像" onmouseover="EzRollOver(this)" onmouseout="EzRollOut(this)" /></a>');
			nextTag = nextTag.join('')
		}

		if(!$('basefield')){
			var BaseField = d.createElement('DIV'),BFs = BaseField.style,MenuField = d.createElement('DIV'),MFs = MenuField.style;
			BaseField.id = 'basefield';
			BFs.position = ABFX;
			BFs.zIndex = 100;
			BFs.cursor = 'pointer';
			BFs.top = '0px';
			BFs.left = '0px';
			BFs.backgroundColor = '#000';
			BFs.backgroundRepeat = 'no-repeat';
			var BFsBG = new Array('url(',BaseBG.src,')');
			BFs.backgroundImage = BFsBG.join('');
			BFs.width = '100%';
			d.body.appendChild(BaseField);

			MenuField.id = 'menufield';
			MFs.position = ABFX;
			MFs.zIndex = 101;
			MFs.top = '0px';
			MFs.left = '0px';
			MFs.backgroundColor = 'transparent';
			MFs.width = '100%';
			d.body.appendChild(MenuField);
		}
		if(MOSC == 1 && IE7 == 0 ){
			var ie6bp = db.scrollTop + db.clientHeight * 0.6;
			ie6bp += 'px';
			$('basefield').style.backgroundPosition = 'center ' + ie6bp;
			$('basefield').style.height = db.scrollHeight + 'px'
		}else{
			$('basefield').style.backgroundPosition = 'center 85%';
			$('basefield').style.height = '100%';
		}
		$('basefield').innerHTML = '&nbsp;';
		$('basefield').style.display = 'block';
		arr = new Array(prevTag,nextTag);
		$('menufield').innerHTML = arr.join('');
		$('menufield').style.display = 'block';

		if($('ntimage')) document.body.removeChild($('ntimage'));

		Nimg.id = 'ntimage';
		Ns.position = 'absolute';
		Ns.zIndex = 120;
		Ns.cursor = 'pointer';
		Ns.visibility = 'hidden';
		Ns.clip = 'rect(0px,0px,0px,0px)';
		Ns.border = '10px solid #fff';
		arr = new Array('url(',str,')');
		Ns.backgroundImage = arr.join('');
		Ns.backgroundRepeat = 'no-repeat';
		arr = new Array('<img id="white" src="',str,'" />');
		Nimg.innerHTML = arr.join('');
		d.body.appendChild(Nimg);

		if($('largeimg_title')) document.body.removeChild($('largeimg_title'));
		if(ele[ImageArr[num]].title){
			comm = d.createElement('P');
			comm.id = 'largeimg_title';
			comS = comm.style;
			comS.position = 'absolute';
			comS.zIndex = 119;
			comS.fontSize = '5em';
			arr = new Array(db.clientWidth,'px');
			comS.width = arr.join('');
			comS.left = '0px';
			arr = new Array(db.clientHeight / 2 + db.scrollTop,'px');
			comS.top = arr.join('');
			comV = ele[ImageArr[num]].title.replace(/ {2}/g,'<br />');
			comm.innerHTML = comV;
			d.body.appendChild(comm);
		}

		if(MOSC == 1){
			$('basefield').style.filter = 'alpha(opacity=75)';
			$('basefield').setAttribute("onclick",new Function("ImageHide();"));
			$('white').style.filter = 'alpha(opacity=100)';

			if(typeof db.style.outline != 'undefined'){
				$('basefield').setAttribute('onclick',"ImageHide();");
				$('ntimage').setAttribute('onclick',"ImageHide();");
			}else{
				$('basefield').setAttribute("onclick",new Function("ImageHide();"));
				$('ntimage').setAttribute("onclick",new Function("ImageHide();"));
			}
			if(IE7 == 0){
				arr = new Array(db.scrollTop,'px');
				$('menufield').style.top = arr.join('');
			}
		}else{
			$('basefield').style.opacity = 0;
			$('basefield').setAttribute('onclick',"ImageHide();");
			$('ntimage').setAttribute('onclick',"ImageHide();");
			$('white').style.opacity = 1;
			BgA = 0;
		}

		arr = new Array('<p><img src="',Domain,'/images/default/img_common/waiter.gif" width="58" height="167" /><br /><span class="waitstr1">画像を読み込み中です...</span><br /><span class="waitstr2">Now Loading...</span></p>');
		setCenterring(200,240);

		$('waiter').innerHTML = arr.join('');
		boxAnimation($('basefield'),0,0.7,500,0);
	}
}

function getShortCutIndex(){
		var setPath,arr,filename = '';
		setPath =  new String(window.location);
		setPath = setPath.match(/(http:\/\/[-.!~*'()\w;?:\@&=+\$,%#\/]+)\/[\w\-_]+\/[\w\-_]+\.html/);
		setPath = RegExp.$1;
		arr = new Array(setPath,'/press/index.html');
		sendRequest('GET',arr.join(''),filename,true,makeShortCut);
}

function makeShortCut(XMLhttpObject){
	var txt = new String(XMLhttpObject.responseText),arr = new Array(),arr2 = new Array();
	txt = txt.match(/<\!-- Press List Begin -->/);
	txt = RegExp.rightContext.match(/<\!-- Press List End -->/);
	txt = RegExp.leftContext;
	txt.replace(/href=\"(http:\/\/[-.!~*'()\w;?:\@&=+\$,%#\/]+\/[\w\-_]+\/[\w\-_]+\.html)\"/g,function(whole,s1){
			arr.push(s1);
	});
	txt.replace(/>(.*)<\/a>/g,function(whole,s1){
		arr2.push(s1);
	});
	alert(arr.length + ' ' + arr2.length)
}

/*** Piro氏[http://piro.sakura.ne.jp/]のコードを参考にしています ***/
function boxAnimation(aElement, aStart, aEnd,Dur,MODE){
	var d = document,delta = aEnd - aStart,duration  = Dur,startTime =(new Date()).getTime(),IEalpha = 100,arr,timer;
	timer = setInterval(function() {
		var Nt = (new Date()).getTime(),progress = Math.min(1,(Nt - startTime) / duration),clipping = (progress == 1)? aEnd:aStart + (delta * Math.sin((progress * 90) * Math.PI / 180 )),Clipper;
		if(MODE == 1){
			if(!$('white')) return;
			Wt = $('white').style,Clipper = new Array('rect(0px,',clipping + 20,'px,',clipping + 20,'px,0px)');
				if(MOSC == 1){
					 IEalpha = 100 - progress * 100;
					 arr = new Array('alpha(opacity=',IEalpha,')');
					Wt.filter = arr.join('');
				}else{
					Wt.opacity = 1 - progress;
				}
				try{
					void(0);
					$('ntimage').style.clip = Clipper.join('');
				}catch(e){
					waiterClose();
					clearInterval(timer);
				}
			if(progress == 1){
				waiterClose();
				if($('largeimg_title')){
					var ltbounds,lty;
					ltbounds = $('ntimage').getBoundingClientRect();
					lty = ltbounds.top + $('white').height;
					arr = new Array(lty + 40 + db.scrollTop,'px');
					$('largeimg_title').style.top =arr.join('');
					$('largeimg_title').style.fontSize = '3em';
				}
				clearInterval(timer);
			}
		}else{
			if(!$('white')) return;
			if(progress == 1){
				var Ns = $('ntimage').style,Wt = d.images['white'],NW = Wt.width,NH = Wt.height,ClipSize;
				if(Wt.complete){
					waiterClose();
					arr = (undefined !== window.defaultstatus)? new Array(d.body.scrollTop + 100,'px'):new Array(db.scrollTop + 100,'px');
					Ns.top = arr.join('');
					Ns.left = IPosX - NW / 2 + 'px';
					Wt.width = NW;
					Wt.height = NH;
					Wt.src = White.src;
					Ns.visibility = 'visible';
					ClipSize = (NW > NH)? NW:NH;
					clearInterval(timer);
					boxAnimation($('ntimage'),0,ClipSize,500,1);
				}
			}else{
				if(MOSC == 0){
					aElement.style.opacity = clipping;
				}
			}
		}
	}, 10);
}
