//---------------------------------begin class moving()-------------------------------//
function moving()
{
//------------------------------------begin public variable
//---------------begin about
this.au = {}
this.init ={}
this.init.y = 50;
this.init.x = 50;
this.init.width = 120;
this.init.height = 120;
this.delay = cnet_floatdelay;
this.span = {};
this.span.xstep = 1;
this.span.ystep = 2;
this.span.ystepcount = 0;
this.main = {};
this.main.id = "sqmovingad";
this.main.classname = "sqmovingad";
var sstr = '
[关闭]
';
this.main.innerhtml = ''+cnet_floatcode+sstr+"
";
//------------------------------------end public variable
//------------------------------------begin private variable
var tl = this;
var pmain = null;
var movetime = null;
//------------------------------------end private variable
//------------------------------------begin public method
this.go = fgo;
//------------------------------------end public method
//------------------------------------begin private method
function fgo()
{
var elediv = document.createelement("div");
var height = 0;
var width = 0;
with(elediv)
{
id = tl.main.id;
classname = tl.main.classname;
innerhtml = tl.main.innerhtml;
/******************加入鼠标事件 start***********************/
onmouseover=function(){
clearinterval(movetime);
}
onmouseout = function(){
movetime = setinterval(startgo , tl.delay);
}
/******************加入鼠标事件 end***********************/
style.width = tl.init.width+"px";
style.height = tl.init.height+"px";
style.top = tl.init.y+"px";
style.left = tl.init.x+"px";
if(fckbrs()==1)
{
style.position = "absolute";
}
else
{
style.position = "fixed";
}
} // end with
document.body.appendchild(elediv);
elediv = null;
pmain = document.getelementbyid(tl.main.id);
if(true) //fckbrs()==2
{
movetime = setinterval(startgo , tl.delay );
} // end if
} // end function fgo
function startgo(){
var itemp = 0;
if(fckbrs()==2)
{
itemp = 18;
}
else if (fckbrs()==1)
{
itemp = 1;
}
else
{
itemp = 0;
}
var itop = parseint(pmain.style.top);
var ileft = parseint(pmain.style.left);
var width = document.body.clientwidth-tl.init.width-itemp;
// begin top
if(fckbrs()==1)
{
var scrolltop = document.documentelement.scrolltop;
itop = scrolltop;
if((fgetviewportsize()[1]-tl.init.height)height)
{
tl.span.ystep = -tl.span.ystep;
}
if(itop<0)
{
tl.span.ystep = math.abs(tl.span.ystep);
}
pmain.style.top = (itop+tl.span.ystep)+"px";
}
// end top
if(ileft>width)
{
tl.span.xstep = -tl.span.xstep;
}
if(ileft<0)
{
tl.span.xstep = math.abs(tl.span.xstep);
}
pmain.style.left = (ileft+tl.span.xstep)+"px";
}
function fckbrs()
{// shawl.qiu script
switch (navigator.appname)
{
case 'opera': return 2;
case 'netscape': return 3;
default: return 1;
}
} // end function fckbrs
function fgetviewportsize()
{// shawl.qiu script
var mywidth = 0, myheight = 0;
if(typeof(window.innerwidth ) == 'number' )
{//non-ie
mywidth = window.innerwidth;
myheight = window.innerheight;
}
else if
(
document.documentelement &&
( document.documentelement.clientwidth || document.documentelement.clientheight )
)
{//ie 6
mywidth = document.documentelement.clientwidth;
myheight = document.documentelement.clientheight;
}
else if( document.body && ( document.body.clientwidth || document.body.clientheight ) )
{ //ie 4
mywidth = document.body.clientwidth;
myheight = document.body.clientheight;
}
return [mywidth, myheight];
} // end function fgetviewportsize
//------------------------------------end private method
} // shawl.qiu code
//---------------------------------end class moving()---------------------------------//
//关闭
function closediv(obj)
{
document.getelementbyid(obj).style.display="none";
}
function dodo()
{
var moving = new moving();
moving.go();
moving = null;
}
if ( typeof window.onload!='function')
{
window.onload=function()
{
dodo(); //页面加载完成时调用的函数
}
}
else
{
var oldonload=window.onload;
window.onload=function()
{
dodo(); //页面加载完成时调用的函数
oldonload();
}
}