var overtime=false;
var imageurl="http://ui.sina.com/rm/yp/091104/yp_top3_120x60_091104.gif";
var imagewidth=120;
var imageheight=60;
var imageurl2 = "http://ui.sina.com/rm/yp/091104/yp_top3_120x60_091104.gif";
var imageheight2 =120;
var imagewidth2 =60;
var floatadlink="http://food.sina.com/top3";
var duration=24;
function wmadobj( n , w , h , x , y , px , py , mx , my )
{
this.name = n;
this.W = w ; 
this.H = h ; 
this.X = x ; 
this.Y = y ; 
this.posX = px ; 
this.posY = py ; 
this.my = my;
this.mx = mx;
this.mytmp = my;
this.mxtmp = mx;
}
function getMaxHeight( NS )
{
var ih;
if ( NS ) ih = innerHeight;
else ih = document.body.clientHeight;
return ih;
}
function getMaxWidth( NS )
{
var iw;
if ( NS ) iw = innerWidth;
else iw = document.body.clientWidth;
return iw;
}
function setPosXY( NS , wm ) 
{
var i;
var ih,iw;
var barW = 0;
var barH = 0;
var ih = getMaxHeight( NS );
var iw = getMaxWidth( NS );
if ( NS ) 
{	
if (document.height > innerHeight) barW = 20;
if (document.width > innerWidth) barH = 20;
}
wm.posX = ((iw - wm.W)-barW) * (wm.X/100);
wm.posY = ((ih - wm.H)-barH) * (wm.Y/100);
}
function set_xy( wMark , x , y )
{
wMark.left = x;
wMark.top = y;
}
function N6_set_xy( wMark, x, y) {
wMark.style.left = x;
wMark.style.top = y;
}
function wRefreshs2() 
{
var NS, i;
if( navigator.appName == 'Netscape' ) NS = true;
else NS = false;
for( i = 0 ; i<arguments.length ; i++ )
{
if( check_exist( arguments[i].name ) == true )
wRefresh( NS , arguments[i] );
}
}
function wRefreshs() 
{
wRefreshs2( wmadobj1 ) 
}
function getUserObject( name )
{
if( wmadobj1 && name == wmadobj1.name ) return wmadobj1;
return null;
}
function getWmadObject( name )
{
var xb,wMark,NS;
if( navigator.appName == 'Netscape' ) NS = true;
else NS = false;
if( NS )
{ 
xb = name;
if (document.getElementById) {
wMark = document.getElementById( xb );
wMark = wMark.style;
} else {
wMark = document.layers[ xb ] ;
}
}
else
{ 
xb = 'document.all.' + name + '.style';
wMark = eval( xb );
}
return wMark;
}
function wRefresh( NS , wm ) 
{
var i;
var xb;
var x,y;
var wMark;
var ih = getMaxHeight( NS );
var iw = getMaxWidth( NS );
wMark = getWmadObject( wm.name );
wMark.width = wm.W;
wMark.height = wm.H;
x = wm.posX + (NS?pageXOffset:document.body.scrollLeft);
y = wm.posY + (NS?pageYOffset:document.body.scrollTop);
if( wm.my == 1 ) wm.posY++;
else if( wm.my == -1 ) wm.posY--;
if( wm.posY > ih ){
wm.posY = -wm.H;
}
else if( wm.posY < -wm.H ) wm.posY = ih;
if( wm.mx == 1 ) wm.posX++;
else if( wm.mx == -1 ) wm.posX--;
set_xy( wMark , x, y );
}
function setPosXYs2()
{
var NS, i;
if( navigator.appName == 'Netscape' ) NS = true;
else NS = false;
for( i=0; i < arguments.length ; i++ )
{
if( check_exist( arguments[i].name ) == true )
setPosXY( NS , arguments[i] );
}
}
function setPosXYs()
{
setPosXYs2( wmadobj1 );
}
function markMe()
{
var NS;								
var markRefresh = 50; 
if( navigator.appName == 'Netscape' ) NS = true;
else NS = false;
setPosXYs();
window.onresize=setPosXYs;
markID = setInterval ("wRefreshs()",markRefresh);
}
function check_exist( nn )
{
if ( document.getElementById && document.getElementById(nn)) return true;
else if( navigator.appName == 'Netscape' && document.layers[nn] ) return true;
else if( navigator.appName != 'Netscape' && document.all[nn] ) return true;
else 
return false;
}
function domouseover(o)
{
if( !o.name )  o.name = o.id;
if( (o.name == 'KFE') || (o.name == 'KFW') )
{
var w1 = getUserObject( o.name );
w1.mxtmp = w1.mx;
w1.mx = 0;
w1.mytmp = w1.my;
w1.my = 0;
}
show_big();
}
function domouseout(o)
{
if( !o.name )  o.name = o.id;
if( (o.name == 'KFE') || (o.name == 'KFW'))
{
var w1 = getUserObject( o.name );
w1.mx = w1.mxtmp;
w1.my = w1.mytmp;
}
hide_big();
}
function show_big(){
//show the big picture 
if (navigator.appName == 'Netscape' && ! document.getElementById){
	var bigx = document.KFE.left;
	var bigy = document.KFE.top;
	bigx = parseInt(bigx)-90;
	bigy = parseInt(bigy)-10;
}
else if( document.getElementById && !document.all ){
	//document.getElementById("KFE").style.visibility="visible";
}
else{
	var bigx = document.all.KFE.style.left;
	var bigy = document.all.KFE.style.top;
	bigx = parseInt(bigx)-90;
	bigy = parseInt(bigy)-10;
}
}
function hide_big(){
//hide the big picture
if (navigator.appName == 'Netscape' && ! document.getElementById){
	//document.POP.visibility = "hide";
	//document.KFE.visibility = "show";
}
else if(document.getElementById&&!document.all){
	//document.getElementById("KFE").style.visibility="visible";
}
else{
	var bigx = document.all.KFE.style.left;
	var bigy = document.all.KFE.style.top;
	//bigx = parseInt(bigx)+90;
	//bigy = parseInt(bigy)+10;
	document.all.KFE.style.left = bigx;
	document.all.KFE.style.top = bigy;	
	//document.all.POP.style.visibility = "hidden"; //hide the big picture
	//document.all.KFE.style.visibility = "visible";
}
}

function close_float()
{
    KFE.style.visibility = "hidden";
}
function do_wmad()
{
   if (!overtime) {
      var w1 = getWmadObject( wmadobj1.name );
      markMe();
   }
}
if (!overtime) {
var wmadobj1 = new wmadobj( 'KFE',80,80,97,0,0,0,0,1 );
}
if (!overtime)  {
var x1 = "<a href='"+floatadlink+"' target=_blank><img src='"+imageurl+"' border=0 width='" + imagewidth + "' height='" + imageheight + "'></a><br><a href='javascript:close_float();'>CLOSE</a>";
var x2 = "<a href='"+floatadlink+"' target=_blank><img src='" + imageurl2 + "' border=0 width='" + imagewidth2 + "' height='" + imageheight2 + "'></a><br><a href='javascript:close_float();'>CLOSE</a>";
if( navigator.appName == 'Netscape' && !document.getElementById)
{ // netscape
document.writeln( "<LAYER name='KFE' id='KFE' onMouseOver='domouseover(this)' onMouseOut='domouseout(this)'>");
document.writeln( x1 );
document.writeln( "</LAYER>");
}
else if(document.getElementById&&!document.all){ //ns6 
	document.writeln( "<div id='KFE' style='top:-150px; left:0px; position:absolute;visibility:visible' onMouseOver='domouseover(this)' onMouseOut='domouseout(this)'>");
	document.writeln( x1 );
	document.writeln( "</div>" );
}
else{ //ie //onMouseOut='domouseout(this)'
	document.writeln( "<div id='KFE' style='top:-150px; left:0px; position:absolute;visibility:visible' onMouseOver='domouseover(this)' onMouseOut='domouseout(this)'>");
	document.writeln( x1 );
	document.writeln( "</div>" );
}
}
window.onload=do_wmad;