var dateObj = new Date();

var noCash = "?" + dateObj.getMonth() + dateObj.getDate() + dateObj.getSeconds();

//var host = "http://www.megatenonline.com/parts/003/";
var host = "http://www.megatenonline.com/parts/003/";

var partsSwf_path = host + "blogparts.swf" + noCash;
var floatSwf_path = host + "float";

var browser = navigator.appName;
var agent = navigator.userAgent;

var nowPix;
var main;

var charaID;

function blogFloat( charaNum ) {
	charaID = charaNum + ".swf";
	
	if( browser == "Microsoft Internet Explorer" ) {
		window.attachEvent( 'onscroll', scrollEvent );
		nowPix = document.body.scrollTop  || document.documentElement.scrollTop;
		
//		nowPix = document.body.scrollTop;
//		nowPix = document.documentElement.scrollTop;
		createForIE();
	}
	else if( browser == "Netscape" ) {
		window.addEventListener( 'scroll', scrollEvent, false );
		nowPix = scrollY;
		createForMozilla();
	}
}

function createForIE() {
	main = document.createElement( 'div' );
	initialCSS();
	main.id = 'flash';
	
	var flaObj1 = document.createElement( 'object' );
	flaObj1.id = 'imagine_fla';
	
	var flaObj2 = document.createElement( 'param' );
	flaObj2.name = 'allowScriptAccess';
	flaObj2.value = 'always';
	
	var flaObj3 = document.createElement( 'param' );
	flaObj3.name = 'movie';
	flaObj3.value = floatSwf_path + charaID + noCash;
	
	var flaObj4 = document.createElement( 'param' );
	flaObj4.name = 'quality';
	flaObj4.value = 'high';
	
	var flaObj5 = document.createElement( 'param' );
	flaObj5.name = 'wmode';
	flaObj5.value = 'transparent';
	
	document.body.appendChild( main );
	document.getElementById( 'flash' ).appendChild( flaObj1 );
	document.getElementById( 'imagine_fla' ).appendChild( flaObj2 );
	document.getElementById( 'imagine_fla' ).appendChild( flaObj3 );
	document.getElementById( 'imagine_fla' ).appendChild( flaObj4 );
	document.getElementById( 'imagine_fla' ).appendChild( flaObj5 );
	document.getElementById( 'imagine_fla' ).setAttribute( "classid","clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" );
	document.getElementById( 'imagine_fla' ).setAttribute( "codebase","http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" );
	document.getElementById( 'imagine_fla' ).width = '100%';
	document.getElementById( 'imagine_fla' ).height = '100%';
//	document.getElementById( 'imagine_fla' ).width = document.body.clientWidth + 17;
//	document.getElementById( 'imagine_fla' ).height = document.body.clientHeight;
}

function createForMozilla() {
	main = document.createElement( 'div' );
	
	var flaObj = document.createElement( 'embed' );
	flaObj.src = floatSwf_path + charaID + noCash;
	flaObj.id = 'imagine_fla';
	flaObj.quality = 'high';
	flaObj.setAttribute('wmode','transparent');
	flaObj.width = '100%';
	flaObj.height = '100%';
	flaObj.setAttribute('allowScriptAccess','always');
	flaObj.type = 'application/x-shockwave-flash';
	flaObj.pluginspage = 'http://www.macromedia.com/go/getflashplayer';
	
	main.id = 'flash';
	document.body.appendChild( main );
	initialCSS();
	document.getElementById( 'flash' ).appendChild( flaObj );
}


function hideFloat() {
	if( ( agent.indexOf( "Safari" ) != -1 ) || ( agent.indexOf( "Firefox" ) != -1 ) ) {
		document.getElementById( 'flash' ).style.display = "none";
		document.getElementById( 'flash' ).removeAttribute( "id" );
		window.removeEventListener( 'scroll', scrollEvent, false );
	}
	else {
		document.body.removeChild( document.getElementById( 'flash' ) );
		window.detachEvent( 'onscroll', scrollEvent );
	}
}

function scrollEvent() {
	if( browser == "Microsoft Internet Explorer" ) {
		nowPix = document.body.scrollTop  || document.documentElement.scrollTop;
//		nowPix = document.body.scrollTop;
//		nowPix = document.documentElement.scrollTop;
	}
	else if( browser == "Netscape" ) {
		nowPix = scrollY + "px";
	}
	document.getElementById( 'flash' ).style.top = nowPix;
}

function initialCSS() {
	main.style.position = "absolute";
	main.style.zIndex = "1";
	main.style.top = nowPix + "px";
	main.style.left = "0";
	main.style.height = "100%";
	main.style.width = "100%";
}


//----
var movePix;
var moveDistance;

function browserShakesInit() {
	moveDistance = 10;
	browserShakes();
}

function browserShakes() {

	if( moveDistance > 0 ) {
		if( ( moveDistance % 2 ) == 0 ) {
			movePix = moveDistance;
		}
		else {
			movePix = ( moveDistance * -1 );
		}
		window.setTimeout( 'browserMove()', 100 );
	
		moveDistance--;
	}
	else {
		return;
	}
	
}

function browserMove() {
	window.moveBy( 0, movePix );
	browserShakes();
}
//----

document.writeln("<div>");
document.writeln("<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='160' height='340' id='blogparts' align='middle'>");
document.writeln("<param name='allowScriptAccess' value='always'>");
document.writeln("<param name='movie' value='"+ partsSwf_path +"'>");
document.writeln("<param name='quality' value='high'>");
document.writeln("<param name='bgcolor' value='#3d637b'>");

document.writeln("<embed src='"+ partsSwf_path +"' allowScriptAccess='always'  quality='high' bgcolor='#3d637b' width='160' height='340' name='blogparts' align='middle' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer'>");
document.writeln("</object>");
document.writeln("</div>");