var lastPopUpWindow = null;
function pop (sCase)
{
	// close the last pop-up.
	try {
		lastPopUpWindow.close ();
	} catch(e) {
	}
	
	switch (sCase) {
		
		case "wallpaper" : //wallpaperID, width
			var id = pop.arguments [1];
			if(id < 10) id = '0' + id;
			var width = pop.arguments [2];
			var height = 0;
			var url = 'assets/de/wallpapers/' + id + '_' + width + '.html';
			popup(url, 1024, 900, 'wallpaper', 1, 0, 1, 0, 0, 0);	
		break;
		
		case "buddyicons":
			var iconURL = 'assets/downloads/buddyicons/buddyicons.html';
			popup(iconURL, 362, 502);
		break;
		
		default:
			alert("troubleshooting a failed popup -- case: " + sCase);
		break;
		
	}
}

function popup( url, w, h, windowName, r, st, s, l, m, t) {
  try {
    win.close();
  } catch(e) {
  }
  var winl = (screen.width-w)/2;
  var wint = (screen.height-h)/2;
  win = window.open(url, windowName, 'height=' +h+ ', width=' +w+ ', resizable=' +r+ ', status= ' +st+ ', scrollbars=' +s+ ', location=' +l+ ', menubar=' +m+  ', toolbar= ' +t+ ', left='+winl+', top='+wint);
  win.focus();  
}


function openEcards(){
      var screenWidth = screen.availWidth;
   var screenHeight = screen.availHeight;

   var popTargetUrl = "eCard.html";
   var popName = "popupWindow";
      var popWidth = "800";
   var popHeight = "660";
      var popPositionX = (screenWidth-popWidth)/2;
   var popPositionY = (screenHeight-popHeight)/2;
      var popLocation = "no";
   var popMenubar = "no";
   var popScrollbars = "no";
   var popStatus = "no";
   var popToolbar = "no";     var popResize = "no";        var popProperties;
   popProperties  = "width="+popWidth+",height="+popHeight;
   popProperties += ",left="+popPositionX+",top="+popPositionY;
   popProperties += ",location="+popLocation+",menubar="+popMenubar+",scrollbars="+popScrollbars+",status="+popStatus+",toolbar="+popToolbar+",resize="+popResize;
      var popupWin = window.open(popTargetUrl, popName, popProperties);
} 