var imageBugs=["200610/cross.gif","200610/circle.gif","200610/square.gif","200610/square_full.gif"]
	var thisX=3
	var thisY=30;
	var radius=100;
	var genX,genY;
	
	var degree=500;
	var speed=1;

	var t
	var theBigCross,theBlog,theBlogHolder


	function loadActions(){
		theBigCross=document.getElementById("bigCross");
		theBigCross.style.top=100;
		theBigCross.style.left=280;
		theBigCross.style.zIndex=100;
		//doBlog();
		timedCount();
e.addEvent(document.getElementById('sbmit'),'mousedown',stopCount,false)
		}

	function doBlog(){
		theBlogHolder=document.getElementById("blogHolder");
		theBlog=document.createElement("div");
		theBlog.innerHTML="[....]"
		theBlogHolder.appendChild(theBlog)	
		//blogLoad("http://www.bloglines.com/blog/saski")
		theBlog.innerHTML="<div>hey, hey. my, my. 1.0 will never die<br/><iframe src='http://www.bloglines.com/blog/saski/rss' width='500px' height='200px' frameborder='0' id='blogFrame'></iframe></div>"
		theBlogHolder.style.display="block"
//	theBlogFrame.getElementsByClassName('blog-main')[0].style.display="none"		

	}
	
	function timedCount(){
		t=setTimeout("timedCount()",20)
		count();
	}
	
	
	
	function stopCount(){
		clearTimeout(t)
		//document.location.href="http://www.saski.com/web2001/index.htm"
document.location.href="http://www.saski.com/wp"
	}
	
	function count(){
//		theBlogFrame=document.getElementById('blogFrame')
//		theBlogFrame.style.zIndex=0;
//		if(theBlogFrame)alert(document.getElementsByClassName('blog-main').length)
		
		var theType=Math.round(3*Math.random());
		
		genX=400+radius*Math.sin(degree*speed*Math.PI/180)+Math.round(10*Math.random())
		genY=200+radius*Math.tan(degree*speed*Math.PI/180)+Math.round(10*Math.random())
		degree++;
		
		//theBlog.innerHTML="genX:"+genX+"<br/>"+"genY:"+genY;
		createBug(t+"c",theType,genX,genY);
		
			var xPos=Math.round(6*Math.random());
				(xPos>3)? thisX+=xPos: thisX-=xPos;
			var yPos=Math.round(6*Math.random());
				(yPos>3)? thisY+=yPos: thisY-=yPos;

			(thisX>1000)? thisX=0: thisX=thisX;
			(thisY>500)? thisY=0: thisY=thisY;
			createBug(t,theType,thisX,thisY);
	}
	
	function createBug(id,type,x,y){
		var theDiv=document.createElement("DIV");
		theDiv.Id=id;
		theDiv.style.position="absolute";
		theDiv.style.zIndex=101;
		theDiv.style.left=parseInt(x);
		theDiv.style.top=parseInt(y);
	
		var theImg=document.createElement("IMG");
		theImg.Id=id;
		theImg.style.className="imageBug";
		
		theImg.src=imageBugs[parseInt(type)];
		document.getElementById("theBody").appendChild(theDiv)	
		theDiv.appendChild(theImg)	
		
		theBigCross.style.width=theBigCross.style.height=6*parseInt(type);

		theBigCross.style.top=100-4*parseInt(type)+"px";
		theBigCross.style.left=280-4*parseInt(type)+"px";

		e.addEvent(theBigCross,'mousedown',stopCount,false)

	}
	
/**/

var W3CDOM = (document.createElement && document.getElementsByTagName);
//Gestion de eventos
var e = {
	addEvent : function(obj, evType, fn, useCapture){
		if (obj.addEventListener){
			obj.addEventListener(evType, fn, useCapture);
			return true;
		}else if (obj.attachEvent){
			var r = obj.attachEvent("on"+evType, fn);
			return r;
		}else {
			return false;
		}
	},
	releaseEvent : function(obj, evType, fn, useCapture){
		if (obj.addEventListener){
			obj.removeEventListener(evType, fn, useCapture);
			return true;
		}else if (obj.attachEvent){
			var r = obj.detachEvent("on"+evType, fn);
			return r;
		}else {
			return false;
		}
	}
}

//Creacion de objetos XmlHttpRequest(ajax)
function ajaxobject(){
	this.a=null;
	try {
		this.a = new ActiveXObject("Msxml2.XMLHTTP");
	}catch (e) {
		try {this. a = new ActiveXObject("Microsoft.XMLHTTP");
		}catch (E) {this.a = false;}
	 } 
	 if (!this.a && typeof XMLHttpRequest!='undefined') this.a = new XMLHttpRequest();
	 return this.a
}

document.getElementsByClassName = function ( className,node){
	var elements = new Array ();
	var children = document.getElementsByTagName("*");
	  for ( var a = 0; a < children.length; a++ ){
	    if ( children[a].className==className) {elements[elements.length]=children[a]}
	  }
	  return elements;
}


function blogLoad(xml){
	instance=this
	this.req=new ajaxobject()
	theBlog.innerHTML="[ajaxobject created]"+xml+"::::::"+this.req
	this.req.open("GET",xml,true);
	theBlog.innerHTML="[////]"
	this.req.onreadystatechange = function(){
		if (instance.req.readyState == 4){
			if (instance.req.status == 200) {
				var sel=instance.req.responseXML.getElementsByClassName("blog-main")
				theBlog.innerHTML = sel[1];
			}
		}else{
			theBlog.innerHTML = "[e.r.r.o.r]";
		}
	}
	this.req.send(null); 
}

