// Code to display window every time broser opens this page language="JavaScript1.2"

var ie=document.all
var dom=document.getElementById
var ns4=document.layers
var ns6=document.getElementById&&!document.all
var calunits=document.layers? "" : "px"
var finalsheight=0

var bouncelimit=32 //(must be divisible by 8)
var direction="up"
var lpos
var tpos
//var swidth=parseInt(screen.width)
//var sheight=parseInt(screen.height)
var swidth
var sheight
var hwidth
var hheight
var dropstep=30
var dropunit
var moveunit
var expDays = 999; // number of days the cookie should last
var	chkshow=false;
var hoverborder

function initbox(){
if (!dom&&!ie&&!ns4)
return
crossobj=(dom)?document.getElementById("dropin").style : ie? document.all.dropin : document.dropin
scroll_top=(ie)? truebody().scrollTop : window.pageYOffset

//alert(document.getElementById("dropin").offsetHeight+" "+document.getElementById("dropin").offsetWidth)
if (hheight<document.getElementById("dropin").offsetHeight)
{
	hheight=document.getElementById("dropin").offsetHeight
}
else
{
	document.getElementById("tbl").style.height=hheight
	document.getElementById("tbl_inn").style.height=hheight
	document.getElementById("dropin").style.height=hheight +'px'
}
if (hwidth<document.getElementById("dropin").offsetWidth)
{
	hwidth=document.getElementById("dropin").offsetWidth
}
else
{
	document.getElementById("tbl").style.width=hwidth
	document.getElementById("tbl_inn").style.width=hwidth
	document.getElementById("dropin").style.width=hwidth +'px'
}

crossobj.top=scroll_top-hheight+calunits
//alert(document.getElementById("dropin").offsetHeight+" "+document.getElementById("dropin").offsetWidth)
scroll_right=(ie)? truebody().scrollLeft : window.pageXOffset
crossobj.left=scroll_right+tpos+calunits

swidth=(document.body.clientWidth-(hoverborder*2))
sheight=(document.body.clientHeight-(hoverborder*2))
crossobj.visibility=(dom||ie)? "visible" : "show"
dropunit=sheight
dropunit=dropunit-hheight
dropunit=dropunit/dropstep
dropunit=dropunit.toFixed()
if(dropunit<=0 )
{
	dropunit=1
}

moveunit=parseInt(hwidth)+parseInt(crossobj.left)
moveunit=(parseInt(swidth)-moveunit)
moveunit=moveunit/dropstep
moveunit=moveunit.toFixed()

dropstart=setInterval("dropin()",10)
}

function dropin(){
scroll_top=(ie)? truebody().scrollTop : window.pageYOffset

hoverheight=parseInt(crossobj.top)
hoverheight=hoverheight+parseInt(hheight)
//alert("sheight="+sheight+" hoverheight="+hoverheight)

//if (hoverheight<parseInt(sheight))
//{

if(document.body.clientHeight<hheight)
{
	finalsheight=hheight-document.body.clientHeight
}
//	alert(hoverheight+"+"+parseInt(dropunit)+" > "+parseInt(sheight)+"+"+finalsheight)
	if ((hoverheight+parseInt(dropunit))>(parseInt(sheight)+finalsheight))
	{
		clearInterval(dropstart)
		topstart=setInterval("movetop()",50)
	}
	else
	{
		crossobj.top=parseInt(crossobj.top)+parseInt(dropunit)+calunits
	}
//}
//else
//{
//	clearInterval(dropstart)
//	topstart=setInterval("movetop()",50)
//}
}

function movetop(){
scroll_right=(ie)? truebody().scrollLeft : window.pageXOffset

hoverposright=parseInt(crossobj.left)
//alert("hoverposright="+hoverposright)
hoverposright=hoverposright+parseInt(hwidth)
//alert("hoverposright="+hoverposright)
if (hoverposright<parseInt(swidth))
{
//	alert(parseInt(crossobj.top))
	if (parseInt(crossobj.top)>0)
	{
		posright=0
		posright=parseInt(hoverposright)+parseInt(moveunit)
		//alert(posright+"<"+swidth)
		if (posright<swidth)
		{
			crossobj.left=parseInt(crossobj.left)+parseInt(moveunit)+calunits
//			alert(hoverposright+"<>"+parseInt(swidth))
			if(parseInt(crossobj.top)<parseInt(dropunit))
			{
//				alert("last")
				clearInterval(topstart)
			}
			else
			{
				crossobj.top=parseInt(crossobj.top)-parseInt(dropunit)+calunits
			}
//			alert("inner "+parseInt(crossobj.top))
		}
		else
		{
			clearInterval(topstart)
		}
	}
	else
	{
		clearInterval(topstart)
	}
}
else
{
	clearInterval(topstart)
}
}

function winresize()
{
crossobj.left=((document.body.clientWidth-hwidth)-10)
}

function bouncein(){
crossobj.top=parseInt(crossobj.top)-bouncelimit+calunits
if (bouncelimit<0)
bouncelimit+=8
bouncelimit=bouncelimit*-1
if (bouncelimit==0){
clearInterval(bouncestart)
}
}

function dismissbox(){
if (window.bouncestart) clearInterval(bouncestart)
crossobj.visibility="hidden"
document.getElementById("dropin").innerHTML=''
}

function truebody(){
return (document.compatMode!="BackCompat")? document.documentElement : document.body
}
function delay(x)
{
	var d=new Date()
	d=d.getSeconds()+x
	if (d>=60) d=d-60
	while (true)
	{
		var d1=new Date()
		if(d==d1.getSeconds())
			break;
	}	
}
// funciton to set the browser cookie

function GetCookie (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 getCookieVal (j);    
i = document.cookie.indexOf(" ", i) + 1;    
if (i == 0) break;   
}  
return null;
}

function SetCookie (name, value) {  
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;  
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 = GetCookie (name);  
	document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}

var exp = new Date(); 
exp.setTime(exp.getTime() + (expDays*24*60*60*1000));

function amt(name)
{
var count = GetCookie(name)
	if(count == null)
	{
		SetCookie(name,'1')
		return 1
	}
	else
	{
		var newcount = parseInt(count) + 1;
		DeleteCookie(name)
		SetCookie(name,newcount,exp)
		return count
	}
}

function getCookieVal(offset) {
var endstr = document.cookie.indexOf (";", offset);
if (endstr == -1)
endstr = document.cookie.length;
return unescape(document.cookie.substring(offset, endstr));
}

function checkCount(name) {
var count = GetCookie(name);
if (count == null) {
count=1;
SetCookie(name, count, exp);
}
else {
count++;
SetCookie(name, count, exp);
chkshow=true;
   }
}


function DropIn(main_bgcolor,main_texttype,main_textsize,main_textcolor,textbar,height,width,top,left,bordercolor,borderstyle,borderwidth,sec,showeverytime)
{
	lpos = top
	tpos = left
	hheight=height
	hwidth=width
	hoverborder=borderwidth
	ans="no"
	//delay(sec)
	chkshow=false;
	if (!showeverytime)
	{
		checkCount("popmotion")
	}
	else
	{
		DeleteCookie("popmotion")
	}
	if(!chkshow)
	{ 
		if (ns4)
		{
			templayer=document.layers[0]				
			templayer.left=left				
			templayer.top=top
			templayer.width=width
			templayer.height=height
		}
		else if (ns6)
		{
			if(borderstyle=="double" && borderwidth==1)
			{
				borderwidth=2
			}
			document.getElementById("tbl").style.border = bordercolor+' '+borderwidth+'px '+borderstyle
	//		document.getElementById("dragtext").innerHTML=textbar
			
//			document.getElementById("dropin").style.height=height +'px'
//			document.getElementById("dropin").style.width =width +'px'
			document.getElementById("dropin").style.left =left +'px'
			document.getElementById("dropin").style.top =top +'px'
			document.getElementById("dragtext").style.backgroundColor=main_bgcolor
			document.getElementById("dragtext").style.color = main_textcolor
			document.getElementById("dragtext").style.fontFamily = main_texttype
			document.getElementById("dragtext").style.fontSize = main_textsize+'px'
		}
		else 
		{
			document.getElementById("tbl").style.border = bordercolor+' '+borderwidth+'px '+borderstyle
	//		document.getElementById("dragtext").innerHTML=textbar
				
//			document.getElementById("dropin").style.height=height +'px'
//			document.getElementById("dropin").style.width =width +'px'
			document.getElementById("dropin").style.left =left +'px'
			document.getElementById("dropin").style.top =top +'px'
			document.getElementById("dragtext").style.backgroundColor=main_bgcolor
			document.getElementById("dragtext").style.color = main_textcolor
			document.getElementById("dragtext").style.fontFamily = main_texttype
			document.getElementById("dragtext").style.fontSize = main_textsize+'px'
		}
		setTimeout("initbox();",(sec*1000));	
	}
	if(chkshow)
	{ 
		document.getElementById("dropin").innerHTML=''
	}
}
//}

window.onresize=winresize;
//window.onload=initbox




