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('popUps/wallpaper.html?id=' +id + '&width=' + width +"&height=" + height,'_blank','scrollbars=1,resizable=1,width='+ newWidth + ',height=' +newHeight + '');	
		break;
		
		case "sized" :			
			var url = pop.arguments [1];
			var width = pop.arguments [2];
			var height = pop.arguments [3];
			lastPopUpWindow = window.open(url,'_blank','width='+width+',height='+height);
		break;			
		
		case "external" :
			var url = pop.arguments[1];
			window.open(url,"_blank");
		break;
		
		default:
		break;
	}
}



