/* --  File Paths  -- */
var ssFile = 'downloads/screensaver/screensaver.html';
var wpFile = 'downloads/wallpapers/wallpapers.html';
var biFile = 'downloads/buddyicons/buddyicons.html';

/* --  PopUp  -- */
function pop (sCase) {
  // Argument Test
  //alert (sCase + '  ' +  pop.arguments[1]+ '  ' +  pop.arguments[2]);
  
  switch(sCase) {
  /* --  ORDER DVD   -- */
  // Order DVD
  case 'order' :
    var platform = pop.arguments[1];
		var url;
    switch (platform) {
        case 'dvd':
				  setExitLink ('ordernow', 0);	
					url = 'http://switch.atdmt.com/action/POTC3_buynow';
					break;
        case  'br':
				  setExitLink ('ordernow', 1);
					url = 'http://switch.atdmt.com/action/POTC3_bluray_buy_now';
          break;
      }
    //alert (url);
    window.open (url, 'p3order', '');
    break;
	
	/* --  Downloads   -- */
  // Buddy Icon
  case 'buddyicon' :
    var iconId = pop.arguments[1];
    var rel = pop.arguments[2];
    switch(iconId) {
        case 1:
          setHBX('downloads', 8);
          break;
        case  2:
          setHBX('downloads', 9);
          break;
        case  3:
          setHBX('downloads', 10);
          break;
        case  4:
          setHBX('downloads', 11);
          break ;
        case 5:
          setHBX('downloads', 12);
          break;
        case  6:
          setHBX('downloads', 13);
          break;
      }
    popup(biFile+'?iconId='+iconId+'&rel='+rel, 600, 450, 'win', 'yes', 'no', 'auto', 'no', 'no', 'no');
    break;
  
  // Screensaver   
  case 'ss':
    var os = pop.arguments[1];
    var file;
    switch (os) {
      case 'osx':
        setHBX ('downloads', 16);
        file = 'potc3dvd_ss_osx.zip';
        break;
      case 'pc':
        setHBX ('downloads', 15);
        file = 'potc3dvd_ss_pc.zip';
        break;
      }
      popup(ssFile+'?os='+os+'&file='+file, 600, 400, 'win', 'yes', 'no', 'auto', 'no', 'no', 'no');
      break;
  
  // Wallpaper
  case 'wallpaper':
      // Get Image Width And Image Number
      var iNum   = pop.arguments[1];
      var iWidth = pop.arguments[2];
      var rel    = pop.arguments[3];
      switch(iNum) {
        case 1:
          setHBX('downloads', 1);
          break;
        case  2:
          setHBX('downloads', 2);
          break;
        case  3:
          setHBX('downloads', 3);
          break;
        case  4:
          setHBX('downloads', 4);
          break ;
        case 5:
          setHBX('downloads', 5);
          break;
        case  6:
          setHBX('downloads', 6);
          break;
      }
      // Get Accompaning Height
      if (iWidth == 1920) iHeight = 1200;
      if (iWidth == 1680) iHeight = 1050;
      if (iWidth == 1280) iHeight = 1024;
      if (iWidth == 1024) iHeight = 768;
      if (iWidth == 800)  iHeight = 600;
      // Force New Window
      window.open (wpFile+'?iNum='+iNum+'&width='+iWidth+'&height='+iHeight+'&rel='+rel, 'wallpaper', '');
      break;
      
  /* --  GAMES   -- */
  case 'games':
    var gameID = pop.arguments[1];
    // Switch GAME Via GAMEID
    switch (gameID) {
      case 1: // Rock The Boat
        setHBX ('games', 0);
        popup ('games/rocktheboat/index.html', 700, 500, 'games', 'no', 'no', 'auto', 'no', 'no', 'no');
        break;
      case 2: // Jack-A-pult
        setHBX ('games', 1);
        popup ('games/pitchapirate/index.html', 700, 500, 'games', 'no', 'no', 'auto', 'no', 'no', 'no');
        break;   
      case 3: // Ships Ahoy
        setHBX ('games', 2);
        popup ('games/shipmate/index.html', 700, 500, 'games', 'no', 'no', 'auto', 'no', 'no', 'no');
        break;   
    }
		// close games
    break;
	
	/* --  Trailers   -- */
	case 'textonly_trailer':	
	  // Launch Trailer
		popup ('http://www.totaleclips.com/player/splash.aspx?custid=3&playerid=2&clipid=e32839', 360, 480 , 'p3dvdTrialer', 'no', 'no', 'auto', 'no', 'no', 'no');		
    // close trailer
	  break;
  } 
}

// Make Popup Windows
function popup (url, w, h, windowName, r, st, s, l, m, t) {
  //alert (url);
  try {
    win.close();
  } catch(e) {    
  }
  //w = 5;
  h += 15;
  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();    
}