var o_o;
var o_o1;
var o_o2;
var o_oTimer = -1;
var scrnW;
var scrnH;

function o_o(objName,initWsin) {
	this.obj = document.getElementById(objName);
	this.mx = rander(scrnW);
	this.my = rander(scrnH);
	this.x = 500;
	this.y = 500;
	this.w = 200;
	this.wsin = initWsin;
}

o_o.prototype = {
	mv: function() {
		if (rander(100)<2) {
			this.mx = rander(scrnW);
			this.my = rander(scrnH)+document.body.scrollTop;
		}
		var sx = Math.round((this.mx-this.x)/10.0);
		var sy = Math.round((this.my-this.y)/10.0);
		this.x += sx;
		this.y += sy;
		this.wsin += 0.1;
		
		var ww = 300 + (Math.sin(this.wsin)*200);
		
		if (document.layers) {
			this.obj.moveTo(this.x - (ww/2),this.y - (ww/2));
		} else {
			this.obj.style.left = this.x - (ww/2);
			this.obj.style.top = this.y - (ww/2);
		}
		this.obj.style.width = ww; // + " px";
		this.obj.style.height = ww; // + " px";
	}
}

/////

function o_o_ini() {
	scrnW = getInnerWidth();
	scrnH = getInnerHeight();
	o_o1 = new o_o("o_o1",0);
	o_o2 = new o_o("o_o2",3);
	o_o_foc();
}

function o_o_bl() {
	if (o_oTimer != -1) {
		clearInterval(o_oTimer);
		o_oTimer = -1;
	}
}
function o_o_foc() {
	if (o_oTimer == -1) {
		o_oTimer = setInterval('o_o_mv()',20);
	}
}
function o_o_mv() {
	o_o1.mv();
	o_o2.mv();
}

function getInnerHeight(){
	if(window.opera) {
		return window.innerHeight;        //o6,o7用
	} else if(document.all) {
		return document.body.clientHeight; //e4,e5,e6用
	} else if(document.layers) {
		return  window.innerHeight;        //n4用
	} else if(document.getElementById) {
		return window.innerHeight ;
	        //n6,n7,m1,s1用
	}
	return null;
}
function getInnerWidth(){
	if(window.opera) {
		return window.innerWidth;         //o6,o7用
	} else if(document.all) {
		return document.body.clientWidth; //e4,e5,e6用
	} else if(document.layers) {
		return  window.innerWidth       //n4用
	} else if(document.getElementById) {
		return window.innerWidth;
		         //n6,n7,m1,s1用
	}
	return null
}
function rander(r) {
	return Math.random()* r;
}
	
//////////////////////////////////////

	var g;

function gra() {
		window.moveBy(-10,0);
		window.moveBy(10,0);
}
function startGra() {
	g = setInterval("gra()",2);
}
function stopGra() {
	clearInterval(g);
}



