var isDownUp		= 1;
var styleWidth		= 0;
var styleHeight		= 0;
var styleTop		= 0;
var tmpStyleTop		= 0;
var styleLeft		= 0;
var clipTop			= 0;
var tmpClipTop		= 0;
var clipRight		= 0;
var clipBottom		= 0;
var tmpClipBottom	= 0;
var clipLeft		= 0;
var motionSpeed		= 0;
var pauseLength		= 0;
var linkHeight      = 0;

function DivGetCookieVal (offset)
{
	var endstr = document.cookie.indexOf (";", offset);  
	if (endstr == -1)    
		endstr = document.cookie.length;  
	return unescape(document.cookie.substring(offset, endstr));
}

function DivGetCookie (name)
{
	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 DivGetCookieVal (j);    
		i = document.cookie.indexOf(" ", i) + 1;    
		if (i == 0) break;   
	}  
	return null;
}

function DivSetCookie (name, value)
{
	var argv = DivSetCookie.arguments;  
	var argc = DivSetCookie.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;  
	document.cookie = name + "=" + escape (value) + 
	((expires == null) ? "" : ("; expires=" + expires.toGMTString())) + 
	((path == null) ? "" : ("; path=" + path)) +  
	((domain == null) ? "" : ("; domain=" + domain)) +    
	((secure == true) ? "; secure" : "");
}

function DeleteCookie (name)
{
	var exp = new Date();  
	exp.setTime (exp.getTime() - 1);  
	var cval = DivGetCookie (name);  
	document.cookie = name + "=" + cval + "; ";
}

function AnimateDivTag(divID, linkOffset, motionType, speed, pause)
{
cookiestring = "test=1;EXPIRES=Sunday, 03-Apr-11 23:59:59 GMT;" 
document.cookie = cookiestring;
 

if (document.cookie) {
	cookiestring = "test=1;EXPIRES=Wednesday, 04-Apr-01 03:09:32 GMT;path=;" 
	document.cookie = cookiestring;
 motionType=motionType; 
} else {
 motionType=3;
}


		if (navigator.appName != "Netscape") {
			var divObj  = document.getElementById(divID);
			styleWidth  = ParsePixelSize(divObj.style.width);
			styleHeight = ParsePixelSize(divObj.style.height) + 8;
			styleTop    = ParsePixelSize(divObj.style.top);
			styleLeft   = ParsePixelSize(divObj.style.left);
			clipTop		= styleHeight;
			clipRight	= styleWidth;
			clipBottom	= styleHeight;
			clipLeft	= 0;
			motionSpeed = speed;
			pauseLength = pause;
			linkHeight  = linkOffset;
		
			var DivAdView = DivGetCookie("DivAdView");
				
			if (DivAdView != 1)
			{
				var exp = new Date()
				//exp.setTime(exp.getTime() + (1*3600*1000));
				DivSetCookie("DivAdView",1);
			}
			else
			{
				divObj.style.top = styleTop - (styleHeight - linkHeight);
				divObj.style.clip = "rect(" + (styleHeight - linkHeight) + "," + styleWidth + "," + styleHeight + ",0)";
				divObj.style.display = "";
				return;
			}
			
			divObj.style.height = styleHeight;
			
			if (motionType == 1)
			{
				tmpStyleTop	= styleTop - styleHeight;
				tmpClipTop	= clipTop;
				isDownUp    = 1;
				MotionDownUp(divID);
			}
			else if (motionType == 2)
			{
				tmpStyleTop = styleTop + styleHeight;
				tmpClipBottom = 0;
				isDownUp = 2;
				MotionUpDown(divID);
			}
		}
	}

function MotionDownUp(divID)
{
	var divObj  = document.getElementById(divID);
	
	if (tmpStyleTop != styleTop)
	{
		if (isDownUp == 1)
		{
			tmpStyleTop += 2;
			tmpClipTop -= 2;
		}
		else
		{
			tmpStyleTop -= 2;
			tmpClipTop += 2;
		}
		divObj.style.display = "";
		divObj.style.clip = "rect(" + tmpClipTop + "," + clipRight + "," + clipBottom + "," + clipLeft + ")";
		divObj.style.top = tmpStyleTop;
		setTimeout("MotionDownUp('" + divID + "')", motionSpeed);
		
		if ((tmpStyleTop - styleTop) == linkHeight)
			tmpStyleTop = styleTop;
	}
	else
	{
		if (isDownUp != 2)
		{
			styleTop = tmpStyleTop - styleHeight;
			isDownUp = 2;
			setTimeout("MotionDownUp('" + divID + "')", pauseLength);
		}
	}
	
}

function MotionUpDown(divID)
{
	var divObj  = document.getElementById(divID);
	if (tmpStyleTop != styleTop)
	{	
		if (isDownUp == 1)
		{
			tmpStyleTop += 1;
			tmpClipBottom -= 1;
		}
		else
		{
			tmpStyleTop -= 1;
			tmpClipBottom += 1;	
		}
		divObj.style.display = "";
		divObj.style.clip = "rect(" + tmpClipTop + "," + clipRight + "," + tmpClipBottom + "," + clipLeft + ")";
		divObj.style.top = tmpStyleTop;
		setTimeout("MotionUpDown('" + divID + "')", motionSpeed);		
	}
	else
	{
		if (isDownUp != 1)
		{
			styleTop = parseInt(tmpStyleTop) + parseInt(styleHeight);
			isDownUp = 1;
			setTimeout("MotionUpDown('" + divID + "')", pauseLength);
		}
	}	
}

function ParsePixelSize(size)
{
	return parseInt(size.substr(0,size.length - 2));
}			
