/* where r u from..................................................................... */

//IE NN6 NN4
var fIE = false;
var fIE5 = false;
var fNN4 = false;
var fNN6 = false;
var bCode = 0;
function getBVer(){
  if(document.all){fIE = true; bCode = 1;}
    if(document.getElementById){
    if(fIE){
      fIE5 = true;
    }
    else{
      fNN6 = true; bCode = 2;
    }
  }
  if(document.layers){fNN4 = true; bCode = 3;}
}
//Auto Browser Version Check
//IE4 NN6
getBVer();


//Browser Language Check
//IE NN6 NN4
FoceEnglish = false;
function getBLang(){
  if(fIE){
    return navigator.browserLanguage;
  }else{
    if(fNN4 || fNN6)
    {
      return navigator.language;
    }else{
      return "";
    }
  }
}
lang = getBLang();
langJa = ((lang.indexOf("ja") != -1) || (lang == "undefined") || (lang == "")) && (FoceEnglish != true);

/* diplay control..................................................................... */

function getStyleElement(id_) {
  var stylObj = null;
  if (document.getElementById) {
    stylObj = document.getElementById(id_).style;
  } else if (document.layers) {
    stylObj = document.layers[id_];
  } else if (document.all) {
    stylObj = document.all(id_).style;
  }
  return stylObj;
}


function dispToggle(id_) {
  var stylObj = getStyleElement(id_);
  if (stylObj.display == "none") {
    stylObj.display = "block";
  } else {
    stylObj.display = "none";
  }
}

/* onMouseover(style)................................................................. */

function submitForm (button) {
  button.className = button.className.replace('submitForm','submitFormOver');
  button.onmouseout = function() {
    this.className = this.className.replace('submitFormOver','submitForm');
	}
}

function pos (div) {
  div.style.background = '#7799AA';
  div.style.color = '#FFF';
}
function neg (div) {
  div.style.background = '#FFFFF6';
  div.style.color = '#000';
}

/* random image viewer................................................................ */

function TRandomImageFilename(){
  if(this.imageNames.length > 0){
    return this.imageNames[Math.floor(Math.random() *this.imageNames.length)];
  }
}

function randomImageSelect(){
  this.imageNames = new Array();
  this.get = TRandomImageFilename;
  if(randomImageSelect.arguments.length > 0){
    for(var i = 0; i < randomImageSelect.arguments.length; i++){
      this.imageNames[i] = randomImageSelect.arguments[i];
    }
  }
}

riList = new randomImageSelect();
riList.imageNames[0] = 'purchase.asp"><img src="/triglav/images/_b01';
riList.imageNames[1] = 'purchase.asp"><img src="/triglav/images/_b02';
riList.imageNames[2] = 'purchase.asp"><img src="/triglav/images/_b03';

/* game window open................................................................... */

function openWindow(w,h)
{
openParam="toolbar=no,resizable=no,close=yes,status=no,location=no,directories=no,menubar=no,scrollbars=no,width="+w+",height="+h;
window.open("","launch",openParam);
}

fCareerMode = false;
gameWindow = null;
function openGame(w_, h_){
 var url_ = "";
 if(openGame.arguments.length > 2){
    url_ = openGame.arguments[2];
  }
  openParam="toolbar=no,resizable=no,close=yes,status=yes,location=no,directories=no,menubar=no,scrollbars=no,width="+w_+",height="+h_;
  var wo = window.open(url_, "game", openParam);
  wo.focus();
  return wo;
}


/* make a new window and fit to image................................................. */

windowList = new Array();
function tWindowObj(_hWindow, _imgName){
  this.hWindow = _hWindow;
  this.imgName = _imgName;
}

var popWin = window;
var fOpenMode = 1;
function newWindowOpen(popImageUrl, title, fOpenMode, beforeSizeX, beforeSizeY){
  if(beforeSizeX == null) beforeSizeX = 420;
  if(beforeSizeY == null) beforeSizeY = 420;

  var htmlData = '<html><head><title>' +title +'</title>'
                +'<link rel="stylesheet" type="text/css" href="main.css">'
                +'<script type="text/javascript">'
                +'function winAutoResize(){resizeWin(document.images["img"].width, document.images["img"].height)}'
                +'</scr' +'ipt></head><body>'
                +'<a href="javascript:close()"><img src="' +popImageUrl +'" name="img" title="Click to Close"></a>'
                +'</body></html>';

  var j = 0;
  if((fOpenMode == 1) && (windowList.length != 0)){
    popWin = window;
    workList = new Array();
    for(i=0;i<windowList.length;i++){
      if(!windowList[i].hWindow.closed){
        workList[j] = windowList[i];
        j++;
      }
    }
    windowList = workList;

    var fMatch = false;
    for(i=0;i<windowList.length;i++){
      if(windowList[i].imgName == popImageUrl){
        popWin = windowList[i].hWindow;
        fMatch = true;
        break;
      }
    }
  }

  if((popWin == window) || popWin.closed || (fOpenMode == 3)) {
    popWin = window.open("" , "_blank", "toolbar=no,resizable=no,close=yes,status=no,location=no,directories=no,menubar=no,scrollbars=no, width=" +beforeSizeX +", height=" +beforeSizeY)
    if(fOpenMode == 1){
      windowList[windowList.length] = new tWindowObj();
      windowList[windowList.length -1].hWindow = popWin;
      windowList[windowList.length -1].imgName = popImageUrl;
    }
  }else{
    popWin.focus();
  }
  if(((fOpenMode == 1) && !fMatch) || (fOpenMode == 2) || (fOpenMode == 3)){
    popWin.document.open();
    popWin.document.write(htmlData);
    popWin.document.close();
  }
  return(false);
}
