var lastPopUpWindow = null;
function pop (sCase)
{
	// close the last pop-up.
	try {
		lastPopUpWindow.close ();
	} catch(e) {
	}
	switch (sCase){
		//HOME PAGE
		case "ecard" :
			window.open("http://fourchristmasessweeps.com/greetings/",'_blank')
		break;
				
		//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=1200; 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;
			window.open('wallpaper.html?id=' +id + '&width=' + width +"&height=" + height,'_blank','scrollbars=1,resizable=1,width='+ newWidth + ',height=' +newHeight + '');	
		break;
		case "poster" :
			window.open('download.html?theFile=assets/downloads/poster/fc_poster.zip','_blank','width=380,height=450');
			return false;
		break;
		case "buddyicons":
		case "icons" :  //iconID
			var iconURL = 'icons.html?id='+pop.arguments [1];
			window.open(iconURL, '_blank','width=380,height=450');
			return false;
		break;
	
		//VIDEOS
		case "more_options" :
		case "moreOptions" :
			window.open('more_options.html', '_self');
		break;
		
		case "tickets" :
			switch (pop.arguments [1]){
				case "movietickets":
					window.open('http://www.movietickets.com/movie_detail.asp?movie_id=60860', '_blank');
				break;
				case "fandango":
					window.open('http://www.fandango.com/fourchristmases_111154/movieoverview', '_blank');
				break;
				case "moviefone":
					window.open('http://www.moviefone.com/search/four%20christmases', '_blank');
				break;
			}
		break;			
					
		case "external" :
			var url = pop.arguments[1];
			window.open(url,"_blank")
		break;
		
		default:
		//	alert("troubleshooting a failed popup -- case: " + sCase);
		break;
	}
}


