// array of images that need to be preloaded of rollover
var arImages = new Array('nav_thebride','nav_vernitagreen','nav_elledriver','nav_hattorihanzo','nav_gogoyubari','nav_orenishii');

// array of possible states for each image in arImages - 0 for off, 1 for on
var arStates = new Array('0','1');

// path to rollover images
var strImagePath = "images/common/";

// the rollover image that is in its active state when the page is first loaded (it is currently hard coded into the htm file)
var activeImage;

// called with body onload event to preload images and set value for activeImage
function initImages(){
  if(document.images){
    for(var i=0;i<arImages.length;i++){
      for(var j=0;j<arStates.length;j++){
        self[arImages[i] + '_' + arStates[j]] = new Image();
        self[arImages[i] + '_' + arStates[j]].src = strImagePath + arImages[i] + '_' + arStates[j] + '.gif';
      }
      var strSrc = document.images[arImages[i]].src;
      var rExp = /_1\.gif$/;
      // sets activeImage to current image if current image's src ends with _1.gif
      if(rExp.test(strSrc)){
        activeImage = arImages[i];
      }
    }
  }
}

function rollImage(imgName,state){
  if(document.images && self[imgName + '_' + state] && imgName!=activeImage){
    document.images[imgName].src = self[imgName + '_' + state].src;
  }
}

// where roomName = 'gal', 'wal' or 'ecard'
// uses the activeImage variable to choose the correct character of the destination area (ie. elledriver)
function switchArea(roomName){
  var targetPage = activeImage.replace(/nav_/,roomName + '_') + '_01.htm';
  window.location = targetPage;
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}


// charName = the character's fullname in lowercase without spaces or non-alphabetic characters
// type = 'gal' (gallery), 'wal' (wallpapers) or 'ecard'
// opens center on screen
function popupWindow(charName,type)
{
  var targetPage = '' + type + '_' + charName + '_01.htm';
  var popw = 599; // popup width
  var poph = 332; // popup height
  var w = screen.width;
  var h = screen.height;
  var leftPos = (w - popw > 0) ? parseInt((w - popw) / 2) : 0;
  var topPos = (h - poph > 0) ? parseInt((h - poph) / 2) : 0;
  popup = window.open(targetPage,'popup','width='+popw+',height='+poph+',left='+leftPos+',top='+topPos+',scrollbars=0,resizable=0');
}

function openWallpaper(size){
  var targetPage = activeImage.replace(/nav_/,'') + '_' + size + '.htm';
  var popw = 800; // popup width
  var poph = 660; // popup height
  var w = screen.width;
  var h = screen.height;
  var leftPos = (w - popw > 0) ? parseInt((w - popw) / 2) : 0;
  var topPos = (h - poph > 0) ? parseInt((h - poph) / 2) : 0;
  var hWin = window.open('images/wallpaper/'+targetPage,'wallpaper','width='+popw+',height='+poph+',left='+leftPos+',top='+topPos+',resizable=1,scrollbars=1');
}

function openDlWallpaper(roomName,size){
  var targetPage = roomName + '_' + size + '.htm';
  var popw = 800; // popup width
  var poph = 660; // popup height
  var w = screen.width;
  var h = screen.height;
  var leftPos = (w - popw > 0) ? parseInt((w - popw) / 2) : 0;
  var topPos = (h - poph > 0) ? parseInt((h - poph) / 2) : 0;
  var hWin = window.open('images/wallpaper/'+targetPage,'wallpaper','width='+popw+',height='+poph+',left='+leftPos+',top='+topPos+',resizable=1,scrollbars=1');
}

function openComingSoon () {
  var targetPage = 'coming_soon.html';
  var popw = 300; // popup width
  var poph = 120; // popup height
  var w = screen.width;
  var h = screen.height;
  var leftPos = (w - popw > 0) ? parseInt((w - popw) / 2) : 0;
  var topPos = (h - poph > 0) ? parseInt((h - poph) / 2) : 0;
  var hWin = window.open(targetPage,'coming_soon','width='+popw+',height='+poph+',left='+leftPos+',top='+topPos+',resizable=0,scrollbars=0');
}

function openTrailer () {
  var targetPage = 'trailer.html';
  var popw = 500; // popup width
  var poph = 300; // popup height
  var w = screen.width;
  var h = screen.height;
  var leftPos = (w - popw > 0) ? parseInt((w - popw) / 2) : 0;
  var topPos = (h - poph > 0) ? parseInt((h - poph) / 2) : 0;
  var hWin = window.open(targetPage,'trailer','width='+popw+',height='+poph+',left='+leftPos+',top='+topPos+',resizable=0,scrollbars=0');
}

function openFlash6Required () {
  var targetPage = '/got_flash.html';
  var popw = 300; // popup width
  var poph = 120; // popup height
  var w = screen.width;
  var h = screen.height;
  var leftPos = (w - popw > 0) ? parseInt((w - popw) / 2) : 0;
  var topPos = (h - poph > 0) ? parseInt((h - poph) / 2) : 0;
  var hWin = window.open(targetPage,'got_flash','width='+popw+',height='+poph+',left='+leftPos+',top='+topPos+',resizable=0,scrollbars=0');
}

function openVideo () {
  var targetPage = 'video/chinaShow.html';
  var popw = 350; // popup width
  var poph = 250; // popup height
  var w = screen.width;
  var h = screen.height;
  var leftPos = (w - popw > 0) ? parseInt((w - popw) / 2) : 0;
  var topPos = (h - poph > 0) ? parseInt((h - poph) / 2) : 0;
  var hWin = window.open(targetPage,'trailer','width='+popw+',height='+poph+',left='+leftPos+',top='+topPos+',resizable=0,scrollbars=0');
}
