function winload(left,top,name)
{
  var Obj = eval(name);
      Obj.style.top=top;
      Obj.style.left=left;
}

function initAbsolute(left,top,name,content,link){	
	if(link =="")
		{
		document.write('<div id=\"'+ name + '\" style=\"position: absolute;visibility:visible;z-index:1\">'+ content + '</div>');
		}
	if(link !="") 
		{
		document.write('<div id=\"'+ name + '\" style=\"position: absolute;visibility:visible;z-index:1\"><a href=\"' +link +'\" target=\"_blank\">' + content + '</a></div>');
		}
	winload(left,top,name);
}

function setCookie() 
{ 
  var FromUrl=window.location.toString();
      FromUrl=FromUrl.replace("http://","");
  	  FromUrl=FromUrl.replace("www.","");
	    FromUrl=FromUrl.substring(0,FromUrl.indexOf("/"));
  var now=new Date();
//set cookie  expires date 1000ms*60*60
  now.setTime( now.getTime() + 1000 * 60 * 60 );
  var the_cookie = "FromUrl="+FromUrl+";expires="+now.toGMTString()+";path=/";
  document.cookie = the_cookie;//write Cookie
} 

function readCookie()
{
  var the_cookie = document.cookie; 
  return the_cookie;
}
  setCookie();
  //end of init cookie
  var brOK=false;
  var mie=false;
  var vmin=2;
  var vmax=5;
  var timer1;
  var nowads;
  var ad_width=0;
  var ad_height=0;


function movechip(chipname)
{
	if(brOK)
	{
		eval("chip="+chipname);
		if(!mie)
		{
			pageX=window.pageXOffset;
			pageW=window.innerWidth;
			pageY=window.pageYOffset;
			pageH=window.innerHeight;
		} 
		else
		{
			pageX=window.document.body.scrollLeft;
			pageW=window.document.body.offsetWidth-8;
			pageY=window.document.body.scrollTop;
			pageH=window.document.body.offsetHeight;
		}
		chip.xx=chip.xx+chip.vx;
		chip.yy=chip.yy+chip.vy;
		chip.vx+=vr*(Math.random()-0.5);
		chip.vy+=vr*(Math.random()-0.5);
		if(chip.vx>(vmax+vmin))  chip.vx=(vmax+vmin)*2-chip.vx;
		if(chip.vx<(-vmax-vmin)) chip.vx=(-vmax-vmin)*2-chip.vx;
		if(chip.vy>(vmax+vmin))  chip.vy=(vmax+vmin)*2-chip.vy;
		if(chip.vy<(-vmax-vmin)) chip.vy=(-vmax-vmin)*2-chip.vy;
		if(chip.xx<=pageX)
		{
			chip.xx=pageX;
			chip.vx=vmin+vmax*Math.random();
		}
		if(chip.xx>=pageX+pageW-chip.w)
		{
			chip.xx=pageX+pageW-chip.w;
			chip.vx=-vmin-vmax*Math.random();
		}
		if(chip.xx>=pageW-ad_width)
		{
			chip.xx=chip.xx-20;
			chip.vx=-vmin-vmax*Math.random();
		}
		if(chip.yy<=pageY)
		{
			chip.yy=pageY;
			chip.vy=vmin+vmax*Math.random();
		}
		if(chip.yy>=pageY+pageH-ad_height)
		{
			chip.yy=pageY+pageH-ad_height;
			chip.vy=-vmin-vmax*Math.random();
		}
		if(!mie)
		{
			eval('document.'+chipname+'.top ='+chip.yy);
			eval('document.'+chipname+'.left='+chip.xx);
		}
		else
		{
			eval('document.all.'+chipname+'.style.pixelLeft='+chip.xx);
			eval('document.all.'+chipname+'.style.pixelTop ='+chip.yy);
		}
		chip.timer1=setTimeout("movechip('"+chipname+"')",80);
	}
}

function stopme(chipname)
{
	if(brOK)
	{
		eval("chip="+chipname);
		if(chip.timer1!=null)
		{
			clearTimeout(chip.timer1);
		}
	}
}

function nowads(left,top,name,imgid)
{
	if(navigator.appName.indexOf("Internet Explorer")!=-1)
	{
		if(parseInt(navigator.appVersion.substring(0,1))>=4) brOK=navigator.javaEnabled();mie=true;
	}
	if(navigator.appName.indexOf("Netscape")!=-1)
	{
		if(parseInt(navigator.appVersion.substring(0,1))>=4) brOK=navigator.javaEnabled();
	}
	//nowads.named="nowads";
	var LayerID = eval(name);
	LayerID.vx=vmin+vmax*Math.random();
	LayerID.vy=vmin+vmax*Math.random();
	LayerID.w=1;
	LayerID.h=1;
	LayerID.xx=left;
	LayerID.yy=top;
	var objimg=eval(imgid);	
	ad_width=objimg.width;
	ad_height=objimg.height;
	LayerID.timer1=null;
	movechip(name);
}

function getClientSize()
{
   pageW=window.document.body.offsetWidth-8;
   pageH=window.document.body.offsetHeight;    
}



function initAdfloat(left,top,name,link,src,imgid)
{
	if(link !="") 
	{	
  	document.write('<div id='+ name +' style="height:0px;left:0px;position:absolute;top:0px;width:0px; z-index:100000">');
  	document.write('<a style=\"cursor:hand\" href=\"' +link +'\" target="_blank" onmouseover=stopme(\"' + name + '\"); onmouseout=movechip(\"'+ name +'\");>');
  	document.write(src);
  	document.write('</a></div>');
	}
	if(link =="") 
	{	
  	document.write('<div id='+ name +' style="height:0px;left:0px;position:absolute;top:0px;width:0px; z-index:100000">');
  	document.write('<a  target="_blank" onmouseover=stopme(\"' + name + '\"); onmouseout=movechip(\"'+ name +'\");>');
  	document.write(src);
  	document.write('</a></div>');
  	}
  	nowads(left,top,name,imgid);
  	window.onresize=getClientSize;
}
function initAdfloatText(left,top,name,link,src,imgid)
{
  
	if(link !="") {
  	document.write('<div id='+ name +'_text style="height:0px;left:0px;position:absolute;top:0px;width:0px; z-index:100000">');
  	document.write('<table id=' + name  + ' width="150" height="20"><tr><td>');
  	document.write('<a style=\"cursor:hand\" href=\"' +link +'\" target="_blank" onmouseover=stopme(\"' + name + '_text\"); onmouseout=movechip(\"'+ name +'_text\");>');
  	document.write(src);
  	document.write('</a></td></tr></table></div>');
	}
	if(link ==""){
	document.write('<div id='+ name +'_text style="height:0px;left:0px;position:absolute;top:0px;width:0px; z-index:100000">');
  	document.write('<table id=' + name  + ' width="150" height="20"><tr><td>');
  	document.write('<a target="_blank" onmouseover=stopme(\"' + name + '_text\"); onmouseout=movechip(\"'+ name +'_text\");>');
  	document.write(src);
  	document.write('</a></td></tr></table></div>');
	}
  	nowads(left,top,name +'_text',imgid);
  	window.onresize=getClientSize;
}



function myload(imgheight,imgleft,name)
{
	var Obj = eval(name);
	if((imgheight>document.body.offsetHeight)&&(document.body.scrollTop==0))
 	{
 		Obj.style.top = 8;
 	}
 	else
 	{ 		
		Obj.style.top=document.body.scrollTop+document.body.offsetHeight-imgheight+8;
	}
		
 	if((imgheight>document.body.offsetHeight)&&(document.body.scrollTop>0))
 	{
 		Obj.style.top = document.body.scrollTop+8;
 	}
 	else
 	{ 		
		Obj.style.top=document.body.scrollTop+document.body.offsetHeight-imgheight+8;
	} 	
	
	
		
	/*if((imgleft>document.body.offsetWidth)&&(document.body.scrollLeft==0))
 	{
 		Obj.style.left = 8;
 	}
 	else
 	{ 		
		Obj.style.left=document.body.scrollLeft+document.body.offsetWidth-imgleft+8;
	}
		
 	if((imgleft>document.body.offsetWidth)&&(document.body.scrollLeft>0))
 	{
 		Obj.style.left = document.body.scrollLeft+8;
 	}
 	else
 	{ 		
		Obj.style.left=document.body.scrollLeft+document.body.offsetWidth-imgleft+8;
	} 	
	*/
 	
	Obj.style.left=imgleft;
	leftmove(imgheight,imgleft,name);
}

function leftmove(imgheight,imgleft,name)
 {
 	var Obj = eval(name);
 	var strObj = Obj.id;
 			
 	if((imgheight>document.body.offsetHeight)&&(document.body.scrollTop>=0))
 	{
 		Obj.style.top = document.body.scrollTop+8;
 	}
 	else
 	{ 		
		Obj.style.top=document.body.scrollTop+document.body.offsetHeight-imgheight+8;
	}
	
	
	/*if((imgleft>document.body.offsetWidth)&&(document.body.scrollLeft>=0))
 	{
 		Obj.style.left=document.body.scrollLeft+document.body.offsetWidth-imgleft+8;
 	}
 	else
 	{ 		
		Obj.style.left=document.body.scrollLeft+imgleft;
	}
 	 */	
 	 
 	//Obj.style.top=document.body.scrollTop+imgheight; 	
	Obj.style.left=document.body.scrollLeft+imgleft;
	
	setTimeout('leftmove('+imgheight+','+imgleft+','+strObj+');',80);
	
}

function initRelative(imgheight,imgleft,name,content,link){
	if(link ==""){
	document.write('<div id=\"' +name+ '\" style=\"position:absolute;width:120;top:300;visibility: visible;z-index: 1\">' +content+'</div>');
	}
	if(link !="") {
	document.write('<div id=\"' +name+ '\" style=\"position:absolute;width:120;top:300;visibility: visible;z-index: 1\"><a href=\"'+link +'\" target=_blank>' +content+'</a></div>');
	}
		
	
	myload(imgheight,imgleft,name);
}
