// JavaScript Document

<!--GLOBAL VARIABLES-->
var thename;
var theobj;
var allObjs;
var centerAligned=true;
var winHeight;
var winPositionFromTop;
var winWidth;
var startH=1;
var openTimer;
var stopTimer;
var filter=0;
<!--END GLOBAL VARIABLES-->

<!--GLOBAL FUNCTIONS-->

function ietruebody()
{
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;
}

function getIntDimension( strDim )
{
	m_dim = parseInt( strDim.substr(0,strDim.length-2) );
	return m_dim;
}


function putAdDivContainerBox( sHTML )
{
	var divElement = document.createElement("DIV");
	divElement.id = "adViewerDiv";
	divElement.style.position = "absolute";
	divElement.style.width = "0px";
	divElement.style.height = "0px";
	divElement.style.top = "0px";
	divElement.style.left = "0px";
	divElement.style.zIndex = '9999999';
	divElement.style.backgroundColor = '#FFFFFF';
	divElement.style.visibility = 'hidden';
	divElement.style.overflow = "hidden";
	divElement.style.border = '1px solid #000000';
	divElement.innerHTML = sHTML;
	document.body.appendChild(divElement);
}
function setAdObj(inwidth,inheight) 
{
	if(!document.body)
		return;
	else
		clearInterval(intVal);
	adHtml = '<table width="310" border="0" cellspacing="0" cellpadding="4">' + 
				'<tr>' + 
					'<td height="65">' + 
					  '<table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">' + 
						'<tr>' + 
							'<td width="20%" rowspan="2"><div align="center"><img src="http://www.webstarts.com/images/tiny_logo.gif" /></div></td>' + 
							'<!--<td width="80%">&nbsp;</td>-->' + 
						'</tr>' + 
						'<tr>' + 
							'<td><div align="center"><span style="font-family:Arial, Helvetica, sans-serif; font-size:12px;">This site built for free with WebStarts</span><br />' +
							  '<span style="font-family:Arial, Helvetica, sans-serif; font-size:12px;"><a href="http://www.webstarts.com" target="_blank"><img src="http://www.webstarts.com/images/slider_btn.gif" border="0" /></a></span></div></td>' + 
						'</tr>' + 
						'<tr>' + 
							'<td colspan="2" style="height:4px;"><span style="cursor:pointer;font-family:Arial, Helvetica, sans-serif; font-size:10px; color:#0000FF; text-decoration:underline;" onclick="showLogin()">Is this your site? Click here to upgrade and remove this tag.</span>&nbsp;&nbsp;<div align="right" style="display:inline;"><span style="cursor:pointer;font-family:Arial, Helvetica, sans-serif; font-size:12px;" onclick="clearTimeout(openTimer);filter=100;stopIt();"><strong>x</strong></span>&nbsp;&nbsp;</div></td>' + 
						'</tr>' + 
					'</table></td>' + 
				'</tr>' + 
			'</table>';

	putAdDivContainerBox( adHtml );

	thename = "adViewerDiv";
	theobj=document.getElementById? document.getElementById(thename):document.all.thename;
	winHeight=100;
	if(document.all) 
	{
		winPositionFromTop=!window.opera? ietruebody().clientHeight : document.body.clientHeight;
		//winWidth=(ietruebody().clientWidth-ietruebody().leftMargin)
	}
	else
	{
		winPositionFromTop=window.innerHeight;
		//winWidth=(window.innerWidth-(ietruebody().offsetLeft+30))
	}
	winWidth=inwidth;
	winHeight=inheight;

	theobj.style.width=winWidth+"px";
	theobj.style.height=startH+"px";
	if(document.all) 
		theobj.style.top=ietruebody().scrollTop+winPositionFromTop+"px";
	else
		theobj.style.top=window.pageYOffset+winPositionFromTop+"px";

	winPositionFromTop=-winHeight;
	filter=20;
	viewIt();
}

function viewIt() 
{
	if(startH<=winHeight) 
	{
		theobj.style.visibility="visible";
		filter += 1;
		if(document.all) 
		{
			theobj.style.top=(ietruebody().scrollTop+winPositionFromTop)+startH+"px";
			theobj.style.filter = "alpha(opacity="+filter+")";
			//alert(theobj.style.top);
		}
		else
		{
			theobj.style.top=(window.pageYOffset+winPositionFromTop)+startH+"px";
			theobj.style.MozOpacity = (filter/100);
		}
		theobj.style.height=startH+"px";
		startH += 1;
		openTimer=setTimeout("viewIt()",20);
	}
	else
	{
		clearTimeout(openTimer);
		if (theobj.style.MozOpacity)
			theobj.style.MozOpacity = 100;
		else if (theobj.filters)
			theobj.style.filter = "alpha(opacity=100)";
		
	}
}

function stopIt()
{
	if(startH >= 0) 
	{
		theobj.style.visibility="visible";
		theobj.style.top = (getIntDimension(theobj.style.top)-1)+"px";
		//alert(theobj.style.pixelTop);

		theobj.style.height=startH+"px";
		filter -= 2;
		if (theobj.style.MozOpacity)
			theobj.style.MozOpacity = (filter/100);
		else if (theobj.filters)
			theobj.style.filter = "alpha(opacity="+filter+")";
		startH -= 1;
		stopTimer=setTimeout("stopIt()",20);
	}
	else
	{
		clearTimeout(stopTimer);
	}
}


function showLogin()
{
	//consoleRef=window.open("http://www.webstarts.com/google16e42076680c0631.html","LoginWindow","menubar=1,resizable=1,width=350,height=250");
	// Google bgcolor #e8eefa
	// style="border: #C3D9FF 1px solid;"
	consoleRef=window.open("about:blank","LoginWindow","menubar=0,resizable=1,width=300,height=270");
	try
	{
		consoleRef.document.write( '<scr'+'ipt>var sHTML=window.opener.getLoginHTML();document.write(sHTML);</scr'+'ipt>' );
	}
	catch(e)
	{}
	consoleRef.focus();
	consoleRef.document.close();
}
function getLoginHTML()
{
	var sHTML = '<table width="100%" border="0" cellspacing="0" cellpadding="4">' + 
				  '<tr>' + 
					'<td><table width="100%" border="0" cellspacing="0" cellpadding="3" style="border: #C3D9FF 1px solid;">' + 
					  '<tr>' + 
						'<td>' + 
						'<table width="100%" border="0" align="center" cellpadding="2" cellspacing="2" bgcolor="#e8eefa">' + 
						'<form name="form1" method="post" action="http://www.webstarts.com/login.php" target="_blank" onsubmit="self.close()">' + 
						  '<tr>' + 
							'<td colspan="2"><strong><font size="2" face="Arial, Helvetica, sans-serif">&nbsp;&nbsp;&nbsp;Sign in to your WebStarts Account</font></strong></td>' + 
						  '</tr>' + 
						  '<tr>' + 
							'<td colspan="2" height="7"></td>' + 
						  '</tr>' + 
						  '<tr>' + 
							'<td width="9%" align="right"><font size="2" face="Arial, Helvetica, sans-serif">Email</font>:&nbsp;</td>' + 
							'<td width="92%"><input name="username" type="text" id="username" tabindex="1" /></td>' + 
						  '</tr>' + 
						  '<tr>' + 
							'<td align="right"><font size="2" face="Arial, Helvetica, sans-serif">Password</font>:&nbsp;</td>' + 
							'<td><input name="password" type="password" id="password" tabindex="2" /></td>' + 
						  '</tr>' + 
						  '<tr>' + 
							'<td>&nbsp;</td>' + 
							'<td><input type="submit" name="Submit" value="Sign in" tabindex="3" /></td>' + 
						  '</tr>' + 
						  '<input type="hidden" name="wasSubmitted" value="true">' + 
						  '</form>' + 
						'</table>' + 
						'</td>' + 
					  '</tr>' + 
					'</table></td>' + 
				  '</tr>' + 
				  '<tr>' + 
					'<td>&nbsp;</td>' + 
				  '</tr>' + 
				  '<tr>' + 
					'<td><table width="100%" border="0" cellspacing="0" cellpadding="3" style="border: #C3D9FF 1px solid;">' + 
					  '<tr>' + 
						'<td><table width="100%" border="0" align="center" cellpadding="2" cellspacing="2" bgcolor="#e8eefa">' + 
						  '<tr>' + 
							'<td><strong><font size="2" face="Arial, Helvetica, sans-serif">&nbsp;&nbsp;&nbsp;&nbsp;Don\'t have a WebStarts Account?</font></strong></td>' + 
						  '</tr>' + 
						  '<tr>' + 
							'<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="http://www.webstarts.com" target="_blank" onclick="self.close();"><font size="2" face="Arial, Helvetica, sans-serif">Create an account now</font></a></td>' + 
						  '</tr>' + 
						'</table></td>' + 
					  '</tr>' + 
					'</table></td>' + 
				  '</tr>' + 
				'</table>';
		return sHTML;
}
function getViralLinkHTML(_W, _H, _T, _L){
	var sHTML = '<div id="d_u0c0" align="center" style="padding:4px; Z-INDEX: 99999999999; LEFT: '+_L+'px; WIDTH: '+_W+'px; POSITION: absolute; TOP: '+_T+'px; HEIGHT: '+_H+'px; BACKGROUND-COLOR: #ffffff">' +
					 '<table width="100%" border="0" cellspacing="0" cellpadding="0">' +
						'<tr>' +
							'<td width="0%">' +
								'<!--<div align="center"><img src="http://www.webstarts.com/images/tiny-logo.jpg" width="16" height="16" /></div>--></td>' +
							'<td width="100%" align="center">' +
								'<span style="FONT-SIZE: 10pt; FONT-FAMILY: Arial; color: #000000;">' +
								'Create A <a id="a_u0c0" href="http://www.webstarts.com" title="Free Website">Free Website</a> With <a id="a_u0c0" href="http://www.webstarts.com" title="Webstarts">WebStarts</a>' +
								'</span></td>' +
						'</tr>' +
					'</table>' +
				'</div>';
	return sHTML;
}

function getAllObjects(doc){
	return ( doc.all || doc.getElementsByTagName("*") );
}

function getDimension( strDim ){
	m_dim = parseInt( strDim.substr(0,strDim.length-2) );
	return m_dim;
}

function getLayoutWidthHeight(){
	allObjs = getAllObjects(document.body);
	maxLayoutWidth 	= 0;
	maxLayoutHeight = 0;
	sHeight = 0;
	for(i=0;i<allObjs.length;i++)
	{
		if(allObjs[i].id != "d_u0c0_linkAd"){
			sWidth = getDimension(allObjs[i].style.left) + getDimension(allObjs[i].style.width);
			sHeight = getDimension(allObjs[i].style.top) + getDimension(allObjs[i].style.height);
		
			// objtype 14 is for blog only
			if(allObjs[i].getAttribute("objtype") == "14"){
				blogPadding = (window.ie)?50:65;
				sHeight = allObjs[i].offsetTop + allObjs[i].offsetHeight+blogPadding;
				//alert(allObjs[i].id+"\n"+ allObjs[i].offsetTop +"+"+ allObjs[i].offsetHeight +"+"+blogPadding);
			}
			if( sWidth > maxLayoutWidth ){
				maxLayoutWidth = sWidth;
			}
			if( sHeight > maxLayoutHeight )
				maxLayoutHeight = sHeight;
		}
	}
	//alert("maxLayoutHeight: "+maxLayoutHeight);
	return [maxLayoutWidth,maxLayoutHeight];
}
function setLinkAd(objWidth, objHeight){
	if(!document.body)
		return;
	else if(!document.getElementById("d_u0c0_linkAd"))
		return;
	else{
		adLinkDiv = document.getElementById("d_u0c0_linkAd")
		clearInterval(intVal);
	}
	
	// Detect browser type
	window.xpath = !!(document.evaluate);
	if (window.ActiveXObject) window.ie = window[window.XMLHttpRequest ? 'ie7' : 'ie6'] = true;
	else if (document.childNodes && !document.all && !navigator.taintEnabled) window.webkit = window[window.xpath ? 'webkit420' : 'webkit419'] = true;
	else if (document.getBoxObjectFor != null) window.gecko = true;
	else if (window.opera) window.opera = true;
	
	if(document.all){
		winPositionFromTop=!window.opera? ietruebody().clientHeight : document.body.clientHeight;
		winWidth=(ietruebody().clientWidth-ietruebody().leftMargin+40);
	}
	else{
		winPositionFromTop=window.innerHeight;
		winWidth=(window.innerWidth-(ietruebody().offsetLeft));
	}
	layoutWidthHeight = getLayoutWidthHeight();
	
	if(document.body.firstChild)
		centerAlignTAG=document.body.firstChild;
	if(centerAlignTAG.nodeName == "CENTER"){
		for(i=0; i<centerAlignTAG.childNodes.length; i++){
			if(centerAlignTAG.childNodes[i] && (centerAlignTAG.childNodes[i].nodeType == 1) ){
				firstElement = centerAlignTAG.childNodes[i];
				break;
			}
		}
		centerAligned = true;
	}
	else{
		firstElement = document.body;
		centerAligned = false;
	}
	
	//alert("layoutHeight: "+layoutWidthHeight[1]);
	chkValue = layoutWidthHeight[1]+(objHeight+10);
	//alert("ObjectHeight:"+objHeight);
	//alert(chkValue +"<"+ winPositionFromTop);
	padValue = 8;
	if(chkValue < winPositionFromTop){
		if(window.ie)
			padValue = 15;
		else if(window.gecko)
			padValue = 8;
		objTop = winPositionFromTop-objHeight-padValue;
	}
	else
		objTop = layoutWidthHeight[1]+10; //Put TextLink Ad 10-pixels below the content

	if(!centerAligned){	
		centerpoint = Math.floor(layoutWidthHeight[0]/2);	
		objLeft = centerpoint - Math.floor(objWidth/2);
	}
	else{
		objLeft = Math.floor(getDimension(firstElement.style.width)/2) - Math.floor(objWidth/2);
	}
	
	adLinkDiv.style.visibility 	= "visible";
	adLinkDiv.style.width		= objWidth+"px";
	adLinkDiv.style.height		= objHeight+"px";
	adLinkDiv.style.top			= objTop+"px";
	adLinkDiv.style.left		= objLeft+"px";
	// OLD CODE
	//alert(objLeft);
	//sHTML=getViralLinkHTML(objWidth, objHeight, objTop, objLeft);
	//firstElement.innerHTML = firstElement.innerHTML + sHTML;
}
//var intVal = setInterval("setAdObj(303,75);", 500);
adHeight = (window.ie)?40:28;
var intVal = setInterval("setLinkAd(290,"+adHeight+");", 1000);
<!--END GLOBAL FUNCTIONS-->
