//___________________________//
//       JS developer        //
//¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯//
//            ·^·            //
//         /7\øñø©ë®ø        //
//     · Leonardo Alia ·     //
//  .: ©å§7ø®ø £åßø®ïø§ø :.  //
//___________________________//
//                           //
/************************************************************************************
COSTRUZIONE OGGETTO
************************************************************************************/

function txtmove(obj_n,div_n)
{
	/* Proprietà */
	this.obj_n = obj_n;
	this.div_n = div_n;
	this.box_width = 150;
	this.box_height = 200;
	this.speed = -1;
	this.pause = 0;
	this.htmlcode = "";
	this.cont = "";
	this.mvobj= "";
	this.mvtype= "v";
	
	this.ie = document.all?1:0;
	this.ns6 = document.getElementById&&!document.all?1:0;
	
	this.move = move;
	this.ymove = ymove;
	this.xmove = xmove;
	
	this.set_cont = set_cont;
	this.set_speed = set_speed;
	this.pause_move = pause_move;
	this.set_width = set_width;
	this.set_height = set_height;
	this.set_type = set_type;
	
	this.create_div = create_div;
	
	this.write_div = write_div; 

}

/************************************************************************************
METODI
************************************************************************************/
function set_cont(cont){this.cont=cont;}
function set_speed(speed){this.speed=speed*(-1);}
function pause_move(speed){this.speed=speed;}
function set_width(w){this.box_width=w;}
function set_height(h){this.box_height=h;}
function set_type(t){this.mvtype=t;}

function write_div(class1,class2)
{ 
this.create_div(class1,class2)
document.write (this.htmlcode);
	this.move();
} 

function create_div(class1,class2)
{	
	var m_over = this.obj_n+".pause_move("+this.pause+")";
	var m_out = this.obj_n+".pause_move("+this.speed+")";
	var div1="<div class=\""+class1+"\" onmouseover=\""+m_over+"\" onmouseout=\""+m_out+"\">";
	var div2="<div id=\""+this.div_n+"\" class=\""+class2+"\">";
	if(this.mvtype=="h"){div2+="<nobr>";}
	div2+=this.cont;
	if(this.mvtype=="h"){div2+="</nobr>";}
	div2+="</div>";
	var div3="</div>";
	this.htmlcode=div1+div2+div3;
}

function move() {
        if (this.ie) {
        this.mvobj=eval("document.all."+this.div_n);
        }
        if (this.ns6) {
	this.mvobj=document.getElementById(this.div_n);
        }
        if(this.mvtype=="v"){
	this.mvobj.style.top=this.box_height+"px";
	this.mvobj.style.left=0+"px";	
	this.ymove()
	}else{
	this.mvobj.style.left=this.box_width+"px";
	this.mvobj.style.top=0+"px";	
	this.xmove()
	}
}

function xmove() {
	var noww=parseInt(this.mvobj.offsetWidth)*(-1);
	var newxpos=parseInt(this.mvobj.style.left)+this.speed;
	this.mvobj.style.left=newxpos+"px";
	if (newxpos>noww){var timer=setTimeout(this.obj_n+".xmove()",20)}
	else{this.mvobj.style.left=this.box_width+"px";var timer=setTimeout(this.obj_n+".xmove()",20)}
}

function ymove() {
	var nowh=parseInt(this.mvobj.offsetHeight)*(-1);
	var newypos=parseInt(this.mvobj.style.top)+this.speed;
	this.mvobj.style.top=newypos+"px";
	if (newypos>nowh){var timer=setTimeout(this.obj_n+".ymove()",50)}
	else{this.mvobj.style.top=this.box_height+"px";var timer=setTimeout(this.obj_n+".ymove()",50)}
}
