var lastPopUpWindow = null;
function pop (sCase)
{
	// close the last pop-up.
	try {
		lastPopUpWindow.close ();
	} catch(e) {
	}
	switch (sCase){
		//HOME PAGE
				
		//DOWNLOADS section
		case "wallpaper" : //wallpaperID number, width
			var id = pop.arguments [1];
			var width = pop.arguments [2];
			var height=0;
			var margin = 14;
			switch (width){
				case '800' : height=600; break;
				case '1024' : height=768; break;
				case '1280' : height=1024; break;
				case '1600' : height=1200; break;
				case '1680' : height=1050; break;
				case '1920' : height=1080; break;
				default : width=1024; height=768; break;
			}
			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 = window.open('wallpaper.html?id=' +id + '&width=' + width +"&height=" + height,'_blank','scrollbars=1,resizable=1,width='+ newWidth + ',height=' +newHeight + '');	
		break;
		case "poster" :
			lastPopUpWindow = window.open('download.html?theFile=assets/downloads/poster/gf_poster1.zip','_blank','width=380,height=450');
		break;
		case "icons" :
			lastPopUpWindow = window.open('icons.html','_blank','width=360,height=500');
		break;
		case "screensaver_mac" :
			lastPopUpWindow = window.open('download.html?theFile=assets/downloads/screensaver/GForce_ScreenSaver_mac.zip','_blank','width=380,height=450');
		break;
		case "screensaver_pc":
			lastPopUpWindow = window.open('download.html?theFile=assets/downloads/screensaver/GForce_ScreenSaver_pc.zip','_blank','width=380,height=450');
		break;
	
		//VIDEOS
	  	case "more_options" :
  		case "moreOptions" :
  			lastPopUpWindow = window.open('more_options.html','_blank','width=700,height=524');
  		break;
		
		case "more_options_teaser" :
    	case "moreOptionsTeaser" :
    	lastPopUpWindow = window.open('more_options_teaser.html','_blank','width=700,height=524');
    	break;

		case "more_options_story" :
    	case "moreOptionsStory" :
    	lastPopUpWindow = window.open('more_options_story.html','_blank','width=700,height=524');
    	break;
		
		//GAMES
		case "game_blaster" :
		case "blaster_game" :
			lastPopUpWindow = window.open('games/blaster/index.html','_blank','scrollbars=1,resizable=1,width=620,height=512');
		break;

		case "game_darwin" :
		case "darwin_game" :
			lastPopUpWindow = window.open('games/darwin/index.html','_blank','scrollbars=1,resizable=1,width=620,height=512');
		break;

		case "game_juarez" :
		case "juarez_game" :
			lastPopUpWindow = window.open('games/juarez/index.html','_blank','scrollbars=1,resizable=1,width=620,height=512');
		break;
		
		case "game_mooch":
		case "mooch_game":
			lastPopUpWindow = window.open('games/mooch/index.html','_blank','scrollbars=1,resizable=1,width=620,height=512');
		break;

		case "game_speckles":
		case "speckles_game":
			lastPopUpWindow = window.open('games/speckles/index.html','_blank','scrollbars=1,resizable=1,width=620,height=512');
		break;

		case "game_hurley":
		case "hurley_game":
			lastPopUpWindow = window.open('games/hurley/index.html','_blank','scrollbars=1,resizable=1,width=620,height=512');
		break;

		case "game_team":
		case "team_game":
			lastPopUpWindow = window.open('http://disney.go.com/disneypictures/gforce/games/teamtactics/','_blank','scrollbars=1,resizable=1,width=620,height=512');
		break;
		
		case "game_gadget":
		case "gadget_game":
			lastPopUpWindow = window.open('games/gadgets/index.html','_blank','scrollbars=1,resizable=1,width=620,height=512');
		break;
			
		case "external" :
			var url = pop.arguments[1];
			window.open(url,"_blank");
		break;
		
		default:
			alert("troubleshooting a failed popup -- case: " + sCase);
		break;
	}
}


