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;
	}
}

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);
}
