var lastPopUpWindow = null;

function pop(sCase) {
// close the last pop-up.
	try {
		lastPopUpWindow.close();
	}catch(e){
	}

	switch(sCase) {

//CHARACTER pages
		case "charactericons":
			lastPopUpWindow = launchPopUpWindow('charactericons.html', 'charactericons', 340, 520);
			doTracking(pop.arguments[1]);
			break;

//HOME section
		case "getMobile":
			window.open('http://www.wildhogsmobile.com/');
			doTracking("MOBILE");
			break;			
		case "text2win":
			window.open('http://www.wildhogstext2win.com/');
			doTracking("text2win");
			break;
		case "orderDVD":			
			window.open('http://www.bestbuy.com/site/olspage.jsp?skuId=8371451&st=wild+hogs&type=product&id=1644457');
			doTracking("orderDVD");
			break;
		case "orderBluRay":
			window.open('http://www.bestbuy.com/site/olspage.jsp?skuId=8371255&st=wild+hogs&type=product&id=1644459');
			doTracking("orderBluRay");
			break;
		case "orderDVDBluRay":
			window.open('http://www.bestbuy.com/site/olspage.jsp?skuId=8371255&st=wild+hogs&type=product&id=1644459');
			doTracking("orderBluRay");
			break;
		case "homeimprovement":
			window.open('http://video.movies.go.com/products/5435503.html');
			doTracking("homeimprovement");
			break;
	/*	case "sweeps":
			window.open('');
			doTracking("SWEEPSTAKES");
			break;*/

//GALLERY section

//DOWNLOADS section
		case "wallpapers":
			var width = Number(pop.arguments[2]);
			var height = (width==1280 ? 1024 : width/4*3)+140;
			lastPopUpWindow = launchPopUpWindow('wallpaper.html?id='+pop.arguments[1]+'&width='+width, 'wallpaper_'+width, width+20, height, 1, true);
			break;
		case "buddyicons":
			lastPopUpWindow = launchPopUpWindow('buddyicons.html', 'buddyicons', 340, 525);
			doTracking("Icon"+pop.arguments[2]);
			break;
		case "screensaver":
			switch(pop.arguments[1]) {
				case "macx":
					filePath = "assets/downloads/screensavers/wh_ss_osx.sit.hqx"
					trackingCase="ss_macx";
					break;
				case "mac9":
					filePath = "assets/downloads/screensavers/wh_ss_os9.sit.hqx"
					trackingCase="ss_mac9";
					break;
				case "win":
				default:
					trackingCase="ss_win";
					filePath = "assets/downloads/screensavers/wh_ss.zip"
					break;
			}
			lastPopUpWindow = launchPopUpWindow('download.html?theFile='+filePath, 'download', 770, 335);
			doTracking(trackingCase);
			break;

//GAMES & ACTIVITIES section
		case "burnrubber":
		case "burn_rubber_game":
			lastPopUpWindow = launchPopUpWindow('burnrubber.html', 'burnrubber', 700, 666);
			break;	
		case "hogs_run_game":
			lastPopUpWindow = launchPopUpWindow('delfuego.html', 'hogsrun', 785, 608);
			break;
		case "which_hog_game":
			lastPopUpWindow = launchPopUpWindow('hogru.html', 'whichhog', 700, 665);
			break;
		case "build_hog_game":
			lastPopUpWindow = launchPopUpWindow('buildahog.html', 'buildhog', 700, 684);
			break;
		case "hogs_swoop_game":
			lastPopUpWindow = launchPopUpWindow('http://www.wildhogsgame.com', 'hogs_swoop_game', 700, 684);
			break;
// SWEEPSTAKES
		case "sweeps":
		 	lastPopUpWindow = launchPopUpWindow('sweepstakes.html', 'sweepstakes', 826, 700, 1, true);
		 	doTracking("sweepstakes");
			break;
		case "sweepstakes_rules":
			lastPopUpWindow = launchPopUpWindow('sweepstakes_popup.html', 'sweepstakes_rules', 600, 700, 1, true);
			break;
		case "sweepstakes_winners":
			lastPopUpWindow = launchPopUpWindow('sweepstakes_winners.html', 'sweepstakes_winners', 790, 527);
			break;
		default:
			alert('Unimplemented pop call: '+sCase);
		break;
	}
}