﻿
//float
function InitFloat(img1url,href1,bt1,img2url,href2,bt2)
{
var pophtml = "<div id=\"popdiv01\" class=\"floatdl1\" style=\"float:left;width:120px;height:380px;\"><a href=\""+href1+"\" target=_blank ><a style=\"padding:3 0;display:inline;float:right;position:relative;color:red;\" href=\"javascript:hidepopdiv()\">关闭</a><img src=\""+img1url+"\" width=\"120px\" border=\"0\" alt=\""+bt1+"\" /></a><br /></div>";
pophtml += "<div id=\"popdiv02\" class=\"floatdl1\" style=\"float:right;width:120px;height:380px;\"><a href=\""+href2+"\" target=_blank ><a style=\"padding:3 0;display:inline;float:right;position:relative;color:red;\" href=\"javascript:hidepopdiv()\">关闭</a><img src=\""+img2url+"\" width=\"120px\" border=\"0\" alt=\""+bt2+"\"  /></a><br /></div>";
document.write(pophtml);
var popdiv01 = document.getElementById("popdiv01");
var popdiv02 = document.getElementById("popdiv02");
popdiv01.style.position = "absolute";
popdiv02.style.position = "absolute";
popdiv01.style.left = 0;
popdiv02.style.right = 0;

inp = setInterval("intpopx()",1);

}
function intpopx()
{
 popdiv01.style.top = document.body.scrollTop + 180;
 popdiv02.style.top = document.body.scrollTop + 180;
}
function hidepopdiv()
{
 popdiv01.style.display = "none";
 popdiv02.style.display = "none";
 clearInterval(inp);
 SetCookie("dlgg","gbpb",600);
}

//cookie
function GetCookieVal(offset)
//获得Cookie解码后的值
{
var endstr = document.cookie.indexOf (";", offset);
if (endstr == -1)
endstr = document.cookie.length;
return unescape(document.cookie.substring(offset, endstr));
}
function SetCookie(name, value)
//设定Cookie值
{
var expdate = new Date();
var argv = SetCookie.arguments;
var argc = SetCookie.arguments.length;
var expires = (argc > 2) ? argv[2] : null;
var path = (argc > 3) ? argv[3] : null;
var domain = (argc > 4) ? argv[4] : null;
var secure = (argc > 5) ? argv[5] : false;
if(expires!=null) expdate.setTime(expdate.getTime() + ( expires * 1000 ));
document.cookie = name + "=" + escape (value) +((expires == null) ? "" : ("; expires="+ expdate.toGMTString()))
+((path == null) ? "" : ("; path=" + path)) +((domain == null) ? "" : ("; domain=" + domain))
+((secure == true) ? "; secure" : "");
}
function DelCookie(name)
//删除Cookie
{
var exp = new Date();
exp.setTime (exp.getTime() - 1);
var cval = GetCookie (name);
document.cookie = name + "=" + cval + "; expires="+ exp.toGMTString();
}
function GetCookie(name)
//获得Cookie的原始值
{
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while (i < clen)
{
var j = i + alen;
if (document.cookie.substring(i, j) == arg)
return GetCookieVal (j);
i = document.cookie.indexOf(" ", i) + 1;
if (i == 0) break;
}
return null;
}

function IsNumber(s){ //适于校验非负整数
   var reg = /^[01233456789]{1,}$/;
	if(reg.test(s))
		return true;
	else
		return false;
}



var Rimifon = {
	"Ads" : new Object,
	"NewFloatAd" : function(imgUrl, strLink)
	{
		var ad = document.createElement("a");
		ad.DirV = true;
		ad.DirH = true;
		ad.AutoMove = true;
		ad.Image = new Image;
		ad.Seed = Math.random();
		ad.Timer = setInterval("Rimifon.Float(" + ad.Seed + ")", 50);
		this.Ads[ad.Seed] = ad;
		ad.Image.Parent = ad;
		ad.style.position = "absolute";
		ad.style.left = 0;
		ad.style.top = 0;
		ad.Image.src = imgUrl;
		ad.Image.onmouseover = function(){this.Parent.AutoMove = false;}
		ad.Image.onmouseout = function(){this.Parent.AutoMove = true;}
		if(strLink)
		{
			ad.href = strLink;
			ad.Image.border = 0;
			ad.target = "_blank";
		}
		ad.appendChild(ad.Image);
		document.body.appendChild(ad);
		return ad;
	},
	"Float" : function(floatId)
	{
		var ad = this.Ads[floatId];
		if(ad.AutoMove)
		{
			var curLeft = parseInt(ad.style.left);
			var curTop = parseInt(ad.style.top);
			if(ad.offsetWidth + curLeft > document.body.clientWidth + document.body.scrollLeft - 1)
			{
				curLeft = document.body.scrollLeft + document.body.clientWidth - ad.offsetWidth;
				ad.DirH = false;
			}
			if(ad.offsetHeight + curTop > document.body.clientHeight + document.body.scrollTop - 1)
			{
				curTop = document.body.scrollTop + document.body.clientHeight - ad.offsetHeight;
				ad.DirV = false;
			}
			if(curLeft < document.body.scrollLeft)
			{
				curLeft = document.body.scrollLeft;
				ad.DirH = true;
			}
			if(curTop < document.body.scrollTop)
			{
				curTop = document.body.scrollTop;
				ad.DirV = true;
			}
			ad.style.left = curLeft + (ad.DirH ? 1 : -1) + "px";
			ad.style.top = curTop + (ad.DirV ? 1 : -1) + "px";
		}
	}
}
