/* call init */


/* extra part */
function getPageScroll(){

	var yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
	}

	arrayPageScroll = new Array('',yScroll) 
	//return arrayPageScroll;
	return yScroll;
}

function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}


	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

function pause(numberMillis) {
	var now = new Date();
	var exitTime = now.getTime() + numberMillis;
	while (true) {
		now = new Date();
		if (now.getTime() > exitTime)
			return;
	}
}


function gimic(req){
	
	if(navigator.userAgent.indexOf("Firefox") != -1){ // 文字列に「Firefox」が含まれている場合

		var wmode = "normal";

	}else{
		var wmode = "transparent";
	}

	var bb = setbg();
	var arrayPageSize = getPageSize();
	var arrayPageScroll = getPageScroll();
	
	var ph = arrayPageSize[3];
	var pw = arrayPageSize[2];
	
	var aheight = arrayPageSize[1];
	
	ph = ph -650;
	pw = pw - 1024;
	
	if(ph < 0){
		ph = 0;
	}
	
	if(pw < 0){
		pw = 0;
	}
	
	var objBody = document.body;
	
	
	if(document.getElementById('gabitotool')){
		objBody.removeChild(document.getElementById('gabitotool'));
	}

	var objOverlay = document.createElement("div");
	var myTag="<object id='gabitoobj' style='height:650px;width:1024px;' classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0' width='1024' height='650'align='middle'><param name='allowScriptAccess' value='always' /><param name='movie' value='http://www.gabito.jp/exec/UploadEx.swf' /><param name='quality' value='high' /><param name='scale' value='noscale' /><param name='salign' value='cm' /><param id='wa' name='wmode' value='normal' /><param name='bgcolor' value='#000000' /><param name='FlashVars' value='btnmode=on&req="+req+"' /><embed id='gabitoembed' wmode='"+wmode+"'  src='http://www.gabito.jp/exec/UploadEx.swf' FlashVars='req="+req+"&btnmode=on' quality='high' scale='noscale' salign='cm'  bgcolor='#000000' width='1024' height='650' name='gimic' align='middle' allowScriptAccess='always' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' /></object>";
	objOverlay.setAttribute('id','gabitotool');
	objOverlay.style.display = 'block';
	objOverlay.style.position = 'absolute';
	objOverlay.style.top = '0px';
	objOverlay.style.left = '0px';
	objOverlay.style.zIndex = '1000';
	objOverlay.style.width = '100%';
	objOverlay.style.height = '100%';
	objOverlay.style.textAlign = 'center';
	objOverlay.style.padding = (getPageScroll()+(ph/2))+'px 0px 0px 0px';
	
	objOverlay.innerHTML = myTag;
	
	objBody.insertBefore(objOverlay, objBody.firstChild);
	
	
	
    
	
	
}

function setbg(){
	
	var objBody = document.body;
	
	
	var arrayPageSize = getPageSize();
	var arrayPageScroll = getPageScroll();
	
	var ph = arrayPageSize[3];
	var pw = arrayPageSize[2];
	
	var aheight = arrayPageSize[1];
	
	ph = ph -650;
	pw = pw - 1024;
	
	if(ph < 0){
		ph = 0;
	}
	
	if(pw < 0){
		pw = 0;
	}
	var tag = "<div id='gabitobgcore' style='padding-top:"+(getPageScroll()+(ph/2)) +"px;background-color:#000000;width:100%;height:100%;filter: alpha(opacity=80);-moz-opacity:0.8;opacity:0.8;'></div>";
	
	
	var objOverlay = document.createElement("div");
	var myTag= tag;
	objOverlay.setAttribute('id','gabitobg');
	objOverlay.style.display = 'block';
	objOverlay.style.position = 'absolute';
	objOverlay.style.top = '0px';
	objOverlay.style.left = '0px';
	objOverlay.style.zIndex = '99';
	objOverlay.style.width = '100%';
	if(getPageScroll() == 0){
		objOverlay.style.height = aheight+'px';
	}else{
		objOverlay.style.height = (aheight-(getPageScroll()+(ph/2)))+'px';
	}
	objOverlay.innerHTML = myTag;
	objBody.insertBefore(objOverlay, objBody.firstChild);
	objOverlay.style.display = 'block';
	
	return true;
}

/* kill extra part */
function killMe(){
	
	var objBody = document.body;
	
	document.getElementById('gabitotool').style.display = "none";
	
	if(document.getElementById('gabitobg')){
		objBody.removeChild(document.getElementById('gabitobg'));
		
	}
	
}

// 透明度をセットする処理
function setOpacity (value_opacity) {
	if(navigator.userAgent.indexOf("Firefox") != -1){
		return;
	
	}
	
    document.getElementById('gabitotool').style.filter = 'alpha(opacity=' + (value_opacity * 10) + ')';
    document.getElementById('gabitotool').style.MozOpacity = value_opacity / 10;
    document.getElementById('gabitotool').style.opacity = value_opacity / 10;
	
	/*
	if(value_opacity <= 8){
		document.getElementById('gabitobgcore').style.filter = 'alpha(opacity=' + (value_opacity * 10) + ')';
    	document.getElementById('gabitobgcore').style.MozOpacity = value_opacity / 10;
    	document.getElementById('gabitobgcore').style.opacity = value_opacity / 10;
	}
	
	if(navigator.userAgent.indexOf("Firefox") != -1 && value_opacity >= 10){
		document.getElementById('gabitobgcore').setAttribute("wmode","normal");
	}
	*/
}

