var lastPopUpWindow = null;
function pop (sCase)
{
	// close the last pop-up.
	try {
		lastPopUpWindow.close ();
	} catch(e) {
	}
	switch (sCase){
		//DOWNLOADS section
		case "wallpaper" : //wallpaperID number, width
			//lastPopUpWindow = launchPopUpWindow ('wallpaper.html?id=' + pop.arguments [1] + '&width=' + pop.arguments [2] , 'wallpaper', 850, 550, 1, 1);
			launchWallpaper(pop.arguments [1], pop.arguments [2]);
		break;
		case "poster" :
			lastPopUpWindow = launchPopUpWindow ('poster.html', 'poster', 550, 815);
		break;
		case "icons" :
			lastPopUpWindow = launchPopUpWindow ('buddyicons.html', 'buddyicons', 356, 500);
		break;
		
		//partners sections
		case "smoothiePartner" :
			window.open("http://www.tropicalsmoothiecafe.com");
		break;
		case "icePartner" :
			window.open("http://www.ice.com/customer/hollywood_jewels/fools_gold_jewelry.jsp");
		break;
		case "coinstarPartner" :
			window.open("http://www.coinstar.com");
		break;
		case "criscraftPartner" :
			window.open("http://www.chriscraft.com");
		break;
		case "funjetPartner" :
			window.open("http://www.funjet.com/foolsgold");
		break;
		case "redrobinPartner" :
			window.open("http://www.redrobin.com");
		break;
		
		//tickets section
		case "movieticketsdotcomTickets" :
			window.open("http://www.movietickets.com/movie_detail.asp?movie_id=57530 ");
		break;
		case "fandangoTickets" :
			window.open("http://www.fandango.com/foolsgold_44929/movieoverview ");
		break;
		case "moviefoneTickets" :
			window.open("http://movies.aol.com/movie/fools-gold/27065/main ");
		break;
		
		//contests section
		case "facebookContest" :
			window.open("http://www.facebook.com/apps/application.php?id=15250095692");
		break;
		case "moviewebContest" :
			window.open("http://www.movieweb.com/news/18/26118.php");
		break;
		case "atlantisContest" :
			window.open("http://hs.interpolls.com/3FD8C1.html");
		break;
		
		case "matthewmcconaugheyContest" :
			window.open("http://www.matthewmcconaughey.com/fgsweepstakes/index.htm");
		break;
		case "dishdivaContest" :
			window.open("http://dishdiva.spaces.live.com/Blog/cns!5CC5E634036E2F2D!3974.entry");
		break;
		case "acedmagazineContest" :
			window.open("http://acedmagazine.com/content/view/887/1/");
		break;
		case "cinematicalContest":
			window.open("http://www.cinematical.com/2008/02/01/insert-caption-fools-gold/");
		break;
		case "videodetectiveContest" :
			window.open("http://www.videodetective.com/contest.aspx?ID=77");
		break;
		case "latinoreviewContest":
			window.open(" http://www.latinoreview.com/news/contest-fool-s-gold-giveaway-3728");
		break;
		case "teenhollywoodContest":
			window.open("http://www.teenhollywood.com/contests/1317/fools-gold-giveaway.html");
		break;
		case "3blackchicksContest":
			window.open("http://www.3blackchicks.com//index.php?option=com_content&task=view&id=1317&Itemid=51");
		break;
		case "iesbContest":
			window.open("http://www.iesb.net/index.php?option=com_content&task=view&id=4185&Itemid=99");
		break;
		case "starpulseContest":
			window.open("http://www.starpulse.com/Contests/Fools_Gold_Giveaway:_14K_Gold_Necklace_&_More/1769/");
		break;
		case "blackfilmContest":
			window.open("http://www.blackfilm.com/20080118/features/foolsgoldcontest.shtml");
		break;
		case "popculturemadnessContest":
			window.open("http://www.popculturemadness.com/Entertainment/News/Fools-Gold-Contest.html");
		break;
		case "hollywooddotcomContest":
			window.open("http://www.hollywood.com/contest/Fools_Gold_Tropical_Smoothie_Recipe_Contest/5043727");
		break;
		case "extratvContest":
			window.open("http://extratv.warnerbros.com/contests/foolsgoldpackage/");
		break;
		
		//endless radio contests
		case "wnbcContest":
			window.open("http://www.wnbc.com/entertainment/15158312/detail.html");
		break;
		case "knbcContest":
			window.open("http://www.nbc4.tv/entertainment/15158312/detail.html");
		break;
		case "wmaqContest":
			window.open("http://www.nbc5.com/entertainment/15158312/detail.html");
		break;
		case "wcauContest":
			window.open("http://www.nbc10.com/entertainment/15158312/detail.html");
		break;
		case "kntvContest":
			window.open("http://www.nbc11.com/entertainment/15158312/detail.html");
		break;
		case "ktvuContest":
			window.open("http://www.ktvu.com/entertainment/15158312/detail.html");
		break;
		case "wcvbContest":
			window.open("http://www.wcvb.com/entertainment/15158312/detail.html");
		break;
		case "wmurContest":
			window.open("http://www.thewmurchannel.com/entertainment/15158312/detail.html");
		break;
		case "kxasContest":
			window.open("http://www.nbc5i.com/entertainment/15158312/detail.html");
		break;
		case "wrcContest":
			window.open("http://www.nbc4.com/entertainment/15158312/detail.html");
		break;
		case "wgclContest":
			window.open("http://www.cbs46.com/entertainment/15158312/detail.html");
		break;
		case "wsbContest":
			window.open("http://www.wsbtv.com/entertainment/15158312/detail.html");
		break;
		case "kphoContest":
			window.open("http://www.kpho.com/entertainment/15158312/detail.html");
		break;
		case "kptvContest":
			window.open("http://www.kptv.com/entertainment/15158312/detail.html");
		break;
		case "wfsbContest":
			window.open("http://www.wfsb.com/entertainment/15158312/detail.html");
		break;
		case "wvitContest":
			window.open("http://www.nbc30.com/entertainment/15158312/detail.html");
		break;
		case "kvvuContest":
			window.open("http://www.kvvu.com/entertainment/15158312/detail.html");
		break;
		case "wsmvContest":
			window.open("http://www.wsmv.com/entertainment/15158312/detail.html");
		break;
		case "wdivContest":
			window.open("http://www.wdiv.com/entertainment/15158312/detail.html");
		break;
		case "kprcContest":
			window.open("http://www.kprc.com/entertainment/15158312/detail.html");
		break;
		case "kiroContest":
			window.open("http://www.kirotv.com/entertainment/15158312/detail.html");
		break;
		case "wmorContest":
			window.open("http://www.moretv32.com/entertainment/15158312/detail.html");
		break;
		case "wplgContest":
			window.open("http://www.click10.com/entertainment/15158312/detail.html");
		break;
		case "wtvjContest":
			window.open("http://www.nbc6.net/entertainment/15158312/detail.html");
		break;
		case "wewsContest":
			window.open("http://www.newsnet5.com/entertainment/15158312/detail.html");
		break;
		case "kmghContest":
			window.open("http://www.kmgh.com/entertainment/15158312/detail.html");
		break;
		case "kcraContest":
			window.open("http://www.thekcrachannel.com/entertainment/15158312/detail.html");
		break;
		case "weshContest":
			window.open("http://www.wesh.com/entertainment/15158312/detail.html");
		break;
		case "wkmgContest":
			window.open("http://www.wkmg.com/entertainment/15158312/detail.html");
		break;
		case "wftvContest":
			window.open("http://www.wftv.com/entertainment/15158312/detail.html");
		break;
		case "wtaeContest":
			window.open("http://www.wtae.com/entertainment/15158312/detail.html");
		break;
		case "wpxiContest":
			window.open("http://www.wpxi.com/entertainment/15158312/detail.html");
		break;
		case "wbalContest":
			window.open("http://www.thewbalchannel.com/entertainment/15158312/detail.html");
		break;
		case "wrtvContest":
			window.open("http://www.wrtv.com/entertainment/15158312/detail.html");
		break;
		case "kgtvContest":
			window.open("http://www.kgtv.com/entertainment/15158312/detail.html");
		break;
		case "knsdContest":
			window.open("http://www.nbcsandiego.com/entertainment/15158312/detail.html");
		break;
		case "wb58Contest":
			window.open("http://www.wb58tv.com/entertainment/15158312/detail.html");
		break;
		case "wsocContest":
			window.open("http://www.wsoctv.com/entertainment/15158312/detail.html");
		break;
		case "kctvContest":
			window.open("http://www.kctv5.com/entertainment/15158312/detail.html");
		break;
		case "kmbcContest":
			window.open("http://www.kmbc.com/entertainment/15158312/detail.html");
		break;
		case "wlwtContest":
			window.open("http://www.wlwt.com/entertainment/15158312/detail.html");
		break;
		case "wisnContest":
			window.open("http://www.wisn.com/entertainment/15158312/detail.html");
		break;
		case "wyffContest":
			window.open("http://www.wyff.com/entertainment/15158312/detail.html");
		break;
		case "whnsContest":
			window.open("http://www.foxcarolina.com/entertainment/15158312/detail.html");
		break;
		case "ksatContest":
			window.open("http://www.ksat.com/entertainment/15158312/detail.html");
		break;
		case "wpbfContest":
			window.open("http://www.thewpbfchannel.com/entertainment/15158312/detail.html");
		break;
		case "wdsuContest":
			window.open("http://www.wdsu.com/entertainment/15158312/detail.html");
		break;
		case "kocoContest":
			window.open("http://www.koco.com/entertainment/15158312/detail.html");
		break;
		case "koatContest":
			window.open("http://www.koat.com/entertainment/15158312/detail.html");
		break;
		case "wgalContest":
			window.open("http://www.thewgalchannel.com/entertainment/15158312/detail.html");
		break;
		case "wlkyContest":
			window.open("http://www.wlky.com/entertainment/15158312/detail.html");
		break;
		case "wjxtContest":
			window.open("http://www.wjxt.com/entertainment/15158312/detail.html");
		break;
		case "whioContest":
			window.open("http://www.whiotv.com/entertainment/15158312/detail.html");
		break;
		case "kcciContest":
			window.open("http://www.kcci.com/entertainment/15158312/detail.html");
		break;
		case "kitvContest":
			window.open("http://www.kitv.com/entertainment/15158312/detail.html");
		break;
		case "ketvContest":
			window.open("http://www.ketv.com/entertainment/15158312/detail.html");
		break;
		case "wiscContest":
			window.open("http://www.channel3000.com/entertainment/15158312/detail.html");
		break;
		case "waptContest":
			window.open("http://www.thejacksonchannel.com/entertainment/15158312/detail.html");
		break;
		case "wptzContest":
			window.open("http://www.wptz.com/entertainment/15158312/detail.html");
		break;
		case "wmtwContest":
			window.open("http://www.wmtw.com/entertainment/15158312/detail.html");
		break;
		case "wjacContest":
			window.open("http://www.wjactv.com/entertainment/15158312/detail.html");
		break;
		case "kfoxContest":
			window.open("http://www.kfoxtv.com/entertainment/15158312/detail.html");
		break;
		case "wxiiContest":
			window.open("http://www.wxii12.com/entertainment/15158312/detail.html");
		break;
		case "khbsContest":
			window.open("http://www.khbs.com/entertainment/15158312/detail.html");
		break;
		case "wnemContest":
			window.open("http://www.wnem.com/entertainment/15158312/detail.html");
		break;
		case "krxiContest":
			window.open("http://www.krxitv.com/entertainment/15158312/detail.html");
		break;
		case "ksbwContest":
			window.open("http://www.theksbwchannel.com/entertainment/15158312/detail.html");
		break;
		case "keroContest":
			window.open("http://www.kero.com/entertainment/15158312/detail.html");
		break;
		case "wtovContest":
			window.open("http://www.wtov9.com/entertainment/15158312/detail.html");
		break;
		
		
		
		//homepage
		case "sendMeUpdates":
			window.open("http://email-warnerbros.com/registration.jsp?title=foolsgold&source=WBTH");
		break;
		
	   default:
			//alert("troubleshooting a failed popup -- case: " + sCase);
		break;
		
	}
}

function launchWallpaper(id,width){
	if(isNaN(width) && (width!=800) && (width!=1024) && (width!=1280)) { width = 1024; }
	var height = width==1280 ? 1024 : width/4*3;
	var margin = 14;
	var newWidth = Number(width) + (margin * 2) < screen.width ? Number(width) + (margin * 2) : screen.width;
	var newHeight = height + 164 < screen.height ? height + 164 : screen.height;
	lastPopUpWindow = launchPopUpWindow ('wallpaper.html?id=' +id + '&width=' + width +"&height=" + height, 'wallpaper', newWidth, newHeight);
}