var dir_url    = "http://www.0101.co.jp/bp/07winter/";
var swf_url    = dir_url + '07xmas_blogparts_movie.swf';
var banner_url = dir_url + '07xmas_blogparts.swf';

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;
}


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 showFlash(objLink,int){
	var file = objLink.href;
	var ver = objLink.ver;

	var file = swf_url;
	var br = int;

	var arrayPageSize = getPageSize();
	var arrayPageScroll = getPageScroll();	
	var objBody = document.body;
	var objOverlay = document.createElement("div");
	var myTag= '<embed src="'+file+'?br=' + br + '" quality="high" salign="lt" swLiveConnect=true wmode="transparent" bgcolor="#ffffff" width="100%" height="100%" name="overlayFlash" id="overlayFlash" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" allowScriptAccess="always" />';
	
	var myTag= '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="100%" height="100%" id="overlayFlash" align="middle"><param name="allowScriptAccess" value="always" /><param name="movie" value="' + file + '?br=' + br + '" /><param name="quality" value="high" /><param name="salign" value="lt" /><param name="wmode" value="transparent" /><param name="bgcolor" value="#ffffff" /><embed src="'+file+'?br=' + br + '" quality="high" salign="lt" swLiveConnect=true wmode="transparent" bgcolor="#ffffff" width="100%" height="100%" name="overlayFlash" id="overlayFlash" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></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.left = '0';
	objOverlay.style.zIndex = '200';
 	objOverlay.style.width = '100%';
	objOverlay.style.height = (arrayPageSize[1] + 'px');
	objOverlay.innerHTML = myTag;
	objBody.insertBefore(objOverlay, objBody.firstChild);
	//window.document.overlayFlash.onclick = function () {hideFlash(); return false;}
	objOverlay.style.display = 'block';
	
	//Y------
	//setScrInt();
}


function hideFlash(){
	var objBody = document.body;
	objBody.removeChild(objBody.firstChild);
	
	//Y-----
	//clearInterval( init_id );
}


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")){
			anchor.onclick = function () {
				showFlash(this); 
				return false;
			}
		}
		
	}
	
}

//BannerSwfWriten
function writeBanner(){
	var html = "";
	html += "<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0' width='170' height='162' align='middle' VIEWASTEXT>";
	html += "<param name='allowScriptAccess' value='always' />";
	html += "<param name='movie' value='" + banner_url + "' />";
	html += "<param name='scale' value='noscale' />";
	html += "<param name='salign' value='lt' />";
	html += "<param name='quality' value='high' />";
	html += "<param name='wmode' value='transparent' />"
	html += "<embed src='" + banner_url + "' quality='high' scale='noscale' salign='lt' wmode='transparent' width='170' height='162' swLiveConnect=true align='middle' allowScriptAccess='always' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />";
	html += "</object>";

	
	
	
	document.write(html);

	var url  = 'http://www02.tracer.jp/VL/Trace';
	var p    = 'bpbtn001';
	var c    = 'c=' + '189';
	var tp   = 'tp=' + '1';
	var fl   = 'fl=' + '1';
	var para = 'p=' + p + '&' + c + '&' + tp + '&' + fl;
	document.write('<SCRIPT type="text/javascript" src="' + url + '?' + para + '"></SCRIPT>');
}

/*
function setScrTop(){

	var n1 = document.body.scrollTop;
	var n2 = document.documentElement.scrollTop;
	var scrtop;
	if(n1){
		scrtop = n1;
	}else{
		scrtop = n2;
	}

	document.overlayFlash.SetVariable("scrtop",scrtop);
}

//Y----------
function setScrInt(){
	init_id = setInterval(setScrTop,50);
}
*/


writeBanner();

//autoPlay
//showFlash(this);