// JavaScript Document

function oModule(){
  
 //potc pc screens
    this.POTCPC_PATH = "http://static.zenimax.com/pirates/images/pcscreens/";
    this.POTCPC_PREFIX = "piratespc_";
    this.POTCPC_BIG_SUFFIX = "B.jpg";
    this.POTCPC_TOTAL = 9;
	

 //potc ps2 screens
    this.POTCPS2_PATH = "http://static.zenimax.com/pirates/images/ps2screens/";
    this.POTCPS2_PREFIX = "piratesps2_";
    this.POTCPS2_BIG_SUFFIX = "B.jpg";
    this.POTCPS2_TOTAL = 8;
	
//variable properties
  this.randArray = new Array();
  this.currentShot;
  this.conceptType;
  
  //public methods
  this.drawScreenShots = oModule_drawScreenShots;
  this.showConcepts = oModule_showConcepts;
  this.openWindow = oModule_openWindow;
  
  //private methods
  this.init = oModule_init;
  this.init();
	
}

function oModule_openWindow(arg_theUrl, arg_name, arg_width, arg_heigth, arg_scroll){
  window.open(arg_theUrl,arg_name,'width=' + arg_width + ',height=' + arg_heigth + ',leftmargin="10",topmargin="10",marginwidth="0",marginheight="0",scrollbars='+ arg_scroll +',menubar=no,status=no,resizable=yes')
}

function oModule_drawScreenShots(){

  var randNumber;
  var randImage;
  var theString = "";
    
  for(var i=1;i<=this.SSHOTS_IN_PAGE;i++){
   
    randNumber = Math.round(Math.random() * (this.randArray.length - 1));     
    randImage = parseInt(this.randArray.splice(randNumber,1));        
       
    theString += '<tr>'; 
    theString += '<td align="center"><a href="javascript:module.showScreenShot(\''+ randImage + '\')"><img src="' + this.SSHOTS_PATH + this.SSHOTS_PREFIX + ((randImage < 10) ? "0" + randImage : randImage) + this.SSHOTS_SUFIX + '" width="137" height="137" border="0"></td>';
    theString += '</tr>'
        
    theString += '<tr> ';
    theString += '<td><img src="http://static.zenimax.com/pirates/images/other/pxl_transparent.gif" width="1" height="5"></td>';
    theString += '</tr>';

  }

  document.open();
  document.write(theString);
  document.close();

}

function oModule_showConcepts(arg_type, arg_shot){
  this.conceptType = arg_type;
  this.currentShot = arg_shot;
  if ((screen.width < 1085) || (screen.height < 800))
	 this.openWindow("popup_screenshots.html", "screenshot", screen.width, screen.height, "yes");
	 else this.openWindow("popup_screenshots.html", "screenshot", 1085, 800, "yes") ;
}

function oModule_init(){
  //construct array
  for(var i=1;i<=this.SSHOTS_TOTAL;i++){
    this.randArray[i-1] = i;
  }
}

var module = new oModule();