<!-- start scripting
// popupads.js - Draw pop-up ads.
var gAdServer = "http://ads.live365.com";
//gAdServer = "http://fc02.corp.nanocosm.com";

var	gLive365PopUpAdWin = null;
var gLive365PopCounter = 1;
var cLive365MaxPops = 5;

function NoPopsForYou()
{
	return (displayPreferredAds() || isNewbieListener() || AdCookieExists("popups"));
}

	
function GenericPopUpAdBox(url, width, height, args, noblur)
{
	if (NoPopsForYou())
		return null;

    if (GenericPopUpAdBox.arguments.length < 5)
		noblur = 0;
                    
	gLive365PopUpAdWin = window.open(url,"Live365_Sponsor_" + gLive365PopCounter , "width=" + width + ",height=" + height + args);

	SetAdCookie("popups", 24*3600);
	
    // RESET POPUP COUNTER IF GREATER THAN MAX LIMIT
    if (++gLive365PopCounter > cLive365MaxPops)
        gLive365PopCounter = 1;
    
	if (gLive365PopUpAdWin != null && gLive365PopUpAdWin.blur && !noblur)
	    gLive365PopUpAdWin.blur();
    else if (gLive365PopUpAdWin != null)        
	    gLive365PopUpAdWin.focus();
        	
    return gLive365PopUpAdWin;
}


function AdCookieExists(campaign)
{
	var cookieName = 'ad_' + campaign;
	return (document.cookie.indexOf(cookieName) != -1);
}


function SetAdCookie(campaign, rotationPeriod)
{
	var cookieName = 'ad_' + campaign;
	var set_it = true;

	if (AdCookieExists(campaign)) {
		var oldRotation = GetCookie(cookieName);
		set_it = (oldRotation < rotationPeriod);
	}

	if (set_it) {
		var expireDate = new Date(); 
		var tm = expireDate.getTime();
		expireDate.setTime(tm + (rotationPeriod*1000));
		SetCookie(cookieName, rotationPeriod, expireDate);
	}
}


function DrawPopUpBannerAd(when)
{
	if (NoPopsForYou())
		return;
	
	var expireDate = new Date(); 
	var tm = expireDate.getTime();
	var pop_id = "ZedoAd";

	if (when == "body") {
		document.write('<IFRAME name="' + pop_id + '" class="' + pop_id + '" width=1 height=1 SRC="/images/dot.gif"></IFRAME>');
		document.write('<LAYER  name="' + pop_id + '"  width=1 height=1 SRC="/images/dot.gif"></LAYER>');
	}
	else if (when == "onload") {
		if (document.layers) {
			if (document.layers[pop_id])
				document.layers[pop_id].src = "/zedo.html?tm=" + tm;
		}
		else 
			document.frames[pop_id].location.href = "/zedo.html?tm=" + tm;
	}
}


function PopUpBannerAd(genre, waitPeriod, rotationPeriod)
{
	if (NoPopsForYou())
		return;
	
	var popup_shares = new Array(
		"All",			1.00
	);

	if (PopUpBannerAd.arguments.length < 1)
		waitPeriod = 0;
	
	if (PopUpBannerAd.arguments.length < 2)
		rotationPeriod = 600;

	var campaign = GetCampaignFromGenre(genre);
	var popup_pct = CalcSharesByCampaign(popup_shares, campaign);

	var cookieName = "AdComPopUp";
	var url = "/mini/popupad.live?width=300&height=250&genre=" + genre;	
	var width = 300;
	var height = 250;
	var args = ',status=0,location=0';

	if (!waitPeriod) {
		if (!AdCookieExists(cookieName)) {
			if (Math.random() <= popup_pct)
				GenericPopUpAdBox(url, width, height, args);
		}

		SetAdCookie(cookieName, rotationPeriod);
		waitPeriod = rotationPeriod;
	}

	window.setTimeout('PopUpBannerAd("' + genre + '" , 0, ' + rotationPeriod + ')', waitPeriod*1000);
}


function Pop3rdPartyCampaign(campaign_ratio)
{
	if (NoPopsForYou())
		return;
	
	var i;
	var doc = document;  
	var total = 0;
	var now = new Date();
	var tm = now.getSeconds();

	for (i = 0; i < campaign_ratio.length; i += 2) {
		total += campaign_ratio[i + 1];
	}

	var rand = total * Math.random();
	var camp = '';
	total = 0;

	for (i = 0; i < campaign_ratio.length; i += 2) {
		total += campaign_ratio[i + 1];

		if (rand <= total) {
			camp = campaign_ratio[i];

			if (camp != "rock" || !AdCookieExists("rock"))
				break;
		}
	}

    if (camp.indexOf("playerpop") != -1){
		DrawZedoPopAd(camp);
	}
}


function DrawZedoPopAd(zone, genre)
{
	if (NoPopsForYou())
		return;

	var campaign = zone;
	
	if (DrawZedoPopAd.arguments.length > 1 && genre != '')
		campaign = GetCampaignFromGenre(genre);
		
	DrawZedoAd(campaign, 1, 1);
}

// end scripting -->


