function getMovieName(movieName) {
	if (navigator.appName.indexOf("Microsoft") != -1) {
		return window[movieName]
	}
	else {
		return document[movieName]
	}
}
/**
 * getPageScroll()
 * Returns array with x,y page scroll values.
 * Core code from - quirksmode.org
 */
function getPageScroll(){
	var yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	// Explorer 6 Strict
	//alert("aaa");
		yScroll = document.documentElement.scrollTop;
	
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
	}

	arrayPageScroll = new Array('',yScroll) 
	return arrayPageScroll;
}

/**
 * getPageSize()
 * Returns array with page width, height and window width, height
 * Core code from - quirksmode.org
 * Edit for Firefox by pHaez
 */
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;
}


/**
 * pause(numberMillis)
 * Pauses code execution for specified time. Uses busy code, not good.
 * Code from http://www.faqts.com/knowledge_base/view.phtml/aid/1602
 */
function pause(numberMillis) {
	var now = new Date();
	var exitTime = now.getTime() + numberMillis;
	while (true) {
		now = new Date();
		if (now.getTime() > exitTime)
		return;
	}
}

var objOverlay;
var isFloating = false;

function showFlash(asVer, path){

	var file = "swf/child_" + asVer + "0.swf";
	if(navigator.appName.indexOf("Microsoft") != -1){
		var br = "ie";
	} else {
		var br = "other";
	}
	//FlashVars
	var fv = "br=" + br;//browser
	fv += "&amp;contentPath=" + path;//

	var arrayPageSize = getPageSize();
	var arrayPageScroll = getPageScroll();	
	var objBody = document.body;

	if(!isFloating){//
		objOverlay = document.createElement("div");
	} else {
		objOverlay = objBody.firstChild;
	}
	
//htmlsource
	var myTag = "<object id='overlayFlash' data='" + file + "' type='application/x-shockwave-flash' width='100%' height='100%'>";
//	var myTag = "<object id='overlayFlash' data='" + file + "' type='application/x-shockwave-flash' width='900' height='509'>";
	myTag += "<param name='movie' value='" + file + "' />";
	myTag += "<param name='allowScriptAccess' value='sameDomain' />";
	myTag += "<param name='menu' value='false' />";
	myTag += "<param name='wmode' value='transparent' />";
	myTag += "<param name='salign' value='lt' />";
	myTag += "<param name='scale' value='noscale' />";
	myTag += "<param name='bgcolor' value='#ffffff' />";
	myTag += "<param name='FlashVars' value='" + fv + "' />";
	myTag += "</object>";

	objOverlay.setAttribute('id','overlay');
//	objOverlay.onclick = function () {hideFlash(); return false;}
	objOverlay.style.display = 'block';
	objOverlay.style.position = 'absolute';
//	objOverlay.style.top = '0';
	objOverlay.style.top = (arrayPageScroll[1] + 'px');
	objOverlay.style.left = '0';
	objOverlay.style.zIndex = '200';
	objOverlay.style.width = '100%';
//	objOverlay.style.height = arrayPageSize[3] + 'px';//表示エリアでつくる
	objOverlay.style.height = arrayPageSize[1] + 'px';//コンテンツ領域（ステージサイズ）でつくる。

	if(isFloating){//あれば
		//objOverlay.innerHTML = myTag;
		objOverlay.innerHTML = myTag;
	} else {//最初
		objOverlay.innerHTML = myTag;
		objBody.insertBefore(objOverlay, objBody.firstChild);
	}

	//window.document.overlayFlash.onclick = function () {hideFlash(); return false;}
	objOverlay.style.display = 'block';
	//alert('onresize');
	isFloating = true;
	return false;
}
/**
 * メッセージ用のフォーム部分のFlashを表示する
 *
 *
 */
function showMessageSwf(path, sw, sh){//
//wとhはステージサイズ
//alert("showMessageSwf " + sw + " sh = " + sh);
	var file = path;
	//FlashVars
        var br = "safari";
	var fv = "br=" + br;//browser
	fv += "&amp;contentPath=" + path;//

	var arrayPageSize = getPageSize();
	var arrayPageScroll = getPageScroll();	

	var objBody = document.body;
//	var objOverlay2 = objBody.firstChild;
	var objOverlay2 = document.createElement("div");

//        alert(objOverlay2);
	
//htmlsource
	var myTag = "<object id='overlayFlashMessage' data='" + file + "' type='application/x-shockwave-flash' width='715' height='140'>";
	myTag += "<param name='movie' value='" + file + "' />";
	myTag += "<param name='allowScriptAccess' value='sameDomain' />";
	myTag += "<param name='menu' value='false' />";
//	myTag += "<param name='wmode' value='transparent' />";
	myTag += "<param name='wmode' value='window' />";
	myTag += "<param name='salign' value='lt' />";
	myTag += "<param name='scale' value='noscale' />";
	myTag += "<param name='bgcolor' value='#000000' />";
	myTag += "<param name='FlashVars' value='" + fv + "' />";
	myTag += "</object>";

//	objOverlay2.setAttribute('id','message_form');


//	objOverlay2.onclick = function () {hideFlash(); return false;}
	objOverlay2.style.display = 'block';
	objOverlay2.style.position = 'absolute';
//	objOverlay2.style.top = '0';
//	objOverlay2.style.top = (arrayPageScroll[1] + 'px');
	objOverlay2.style.top = ((sh / 2) + 97) + 'px';
//	objOverlay2.style.left = '0';
	objOverlay2.style.left = ((sw - 870) / 2) + 78 + 'px';
	objOverlay2.style.zIndex = '300';
	objOverlay2.style.width = '715' + 'px';
//	objOverlay2.style.height = arrayPageSize[1] + 'px';//コンテンツ領域（ステージサイズ）でつくる。
	objOverlay2.style.height = '140' + 'px';//

	objOverlay2.innerHTML = myTag;
//	objBody.insertBefore(objOverlay2, objBody.firstChild);
//	objBody.insertBefore(objOverlay2, objBody.lastChild);

	objOverlay.insertBefore(objOverlay2, document.getElementById('overlayFlash'));

//メインのほうの一個前divid="overlay"の子として追加したい。

	//window.document.overlayFlash.onclick = function () {hideFlash(); return false;}
	objOverlay2.style.display = 'block';
	//alert('onresize');
//	return false;
}
function hideMessageSwf(){
//	var targetObj = document.body.lastChild;
	var targetObj = objOverlay.childNodes[0];
	objOverlay.removeChild(targetObj);
//	alert("hideMessageSwf" + targetObj);
//	alert("hideMessageSwf" + );
	//return false;
}

/**
 *
 *
 *
 */
function hideFlash(){
	var objBody = document.body;
        this.flaDivEl = objBody.firstChild;
	this.flaDivEl.style.display = 'none';
//	objBody.removeChild(this.flaDivEl);
//


//	var flDivEl = objOverlay;
//	this.flDivEl.style.display = ‘none’; 
//	document.body.removeChild(this.flDivEl);
	swfTarget("external10th").hideCircle();
}
function swfTarget(str) {
	if (navigator.appName.indexOf("Microsoft") != -1) {
		return window[str];
	} else {
		return document[str];
	}
}
/**
 *
 *
 *
 */
function estSetLayer(){	
	var arrayPageScroll = getPageScroll();
	var arrayPageSize = getPageSize();
	objOverlay.style.top = (arrayPageScroll[1] + 'px');
	objOverlay.style.height = '100%';
}

/**
 * ウィンドウをリサイズした際
 *
 *
 */
window.onresize = function(){
	var arrayPageSize = getPageSize();
	if(objOverlay){
		objOverlay.style.height = arrayPageSize[3] +'px';
	}
		
};

/**
 * 
 * 
 *
 */
window.onscroll = function(){
	if(objOverlay){
		estSetLayer();
	}
}


function initoverLayFlash(){

	if (!document.getElementsByTagName){ return; }
	
//	var anchors = document.getElementsByTagName("a");

//loop through all anchor tags
//	for (var i=0; i<anchors.length; i++){
//		var anchor = anchors[i];
//		if (anchor.getAttribute("href") && (anchor.getAttribute("rel") == "overLayFlash")){
//			window.onload = function () {
				//showFlash(this); 
//				return false;
//			};
//		}
//	}
}


//
// addLoadEvent()
// Adds event to window.onload without overwriting currently assigned onload functions.
// Function found at Simon Willison's weblog - http://simon.incutio.com/
//

function addLoadEvent(func)
{ 
	var oldonload = window.onload;
	if (typeof window.onload != 'function'){
		window.onload = func;
	} else {
		window.onload = function(){
		oldonload();
		func();
	}
	}

}
//addLoadEvent(initoverLayFlash); 


