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 '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 "poster1" :
			lastPopUpWindow = window.open('download.html?theFile=assets/downloads/poster/gt_poster1.zip','_blank','width=380,height=450');
		break;
		case "poster2" :
			lastPopUpWindow = window.open('download.html?theFile=assets/downloads/poster/gt_poster2.zip','_blank','width=380,height=450');
		break;
	
		//VIDEOS
		case "more_options" :
		case "moreOptions" :
			window.open('more_options.html', '_self');
		break;		
					
		case "external" :
			var url = pop.arguments[1];
			window.open(url,"_blank")
		break;
		
		default:
		//	alert("troubleshooting a failed popup -- case: " + sCase);
		break;
	}
}


