var ptown_ad_interval = 0;function ptown_animate_ads(){	if (! ptown_ad_interval) ptown_animate_ads_preload();	else	{		var spot;		var index;		var lastIndex;		var ad;		var picture;		for (var k in ptown_ads)		{			spot = ptown_ads[k];			lastIndex = spot.index;			index = lastIndex + 1;			if (index >= spot.ads.length) index = 0;						spot.index = index;						if (picture = xGetElementById('ptown_ad_' + spot.id))			{				picture.src = spot.ads[index].image.src;			}			/*			else if (picture = xGetElementById('ptown_ad_' + spot.id + '_' + spot.ads[index]))			{				xVisibility('ptown_ad_' + spot.id + '_' + spot.ads[lastIndex], 0);				xVisibility('ptown_ad_' + spot.id + '_' + spot.ads[index], 1);			}			*/		}	}}function ptown_ad_click(id) {		var spot = ptown_ads['db_' + id];	if (spot) 	{		var ad = spot.ads[spot.index];		if (ad && ad.url) open(ad.url);	}	return false;}function ptown_ad_over(id) {		var spot = ptown_ads['db_' + id];	if (spot) 	{		var ad = spot.ads[spot.index];		if (ad && ad.url) window.status = 'Visit ' + ad.url;	}	return true;}function ptown_animate_ads_preload(){	var spot;	var ad;	var z;	var foundPic = false;		for (var k in ptown_ads)	{		spot = ptown_ads[k];		if (spot.width)		{			foundPic = true;			spot.index = 0;			z = spot.ads.length;			for (var i = 0; i < z; i++)			{				ad = spot.ads[i];				if (i) ad.image = new Image(spot.width, spot.height);				else 				{					ad.image = new Object();					ad.image.loaded = true;				}				ad.image.src = ad.picture;			}		}		else // it's an html ad		{			var index = readCookie('html' + spot.id);			if (! index) index = 0;			if (index >= spot.ads.length) index = 0;			xVisibility('ptown_ad_' + spot.id + '_' + spot.ads[index], 1);					index ++;						createCookie('html' + spot.id, index);		}				//spot.index = spot.ads.length - 1;	}	if (foundPic) ptown_ad_interval = setInterval('ptown_animate_ads()', 5000);		}// cross platform functionsfunction xGetElementById(e){  if(typeof(e)!='string') return e;  if(document.getElementById) e=document.getElementById(e);  else if(document.all) e=document.all[e];  else e=null;  return e;}	function xVisibility(e, bShow){  if(!(e=xGetElementById(e))) return null;  if(e.style && xDef(e.style.visibility)) {    if (xDef(bShow)) e.style.visibility = bShow ? 'visible' : 'hidden';    return e.style.visibility;  }  return null;}function xDef(){  for(var i=0; i<arguments.length; ++i){if(typeof(arguments[i])=='undefined') return false;}  return true;}// cookie handling funcitonsfunction createCookie(name,value,days){	if (days)	{		var date = new Date();		date.setTime(date.getTime()+(days*24*60*60*1000));		var expires = "; expires="+date.toGMTString();	}	else var expires = "";	document.cookie = name+"="+value+expires+"; path=/";}function readCookie(name){	var nameEQ = name + "=";	var ca = document.cookie.split(';');	for(var i=0;i < ca.length;i++)	{		var c = ca[i];		while (c.charAt(0)==' ') c = c.substring(1,c.length);		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);	}	return null;}function eraseCookie(name){	createCookie(name,"",-1);}
