/* 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);

/* get element ....................................................................... */

function getElementEX(id_) {
	var result = null;
	if (document.getElementById) {		//NN6,Mozilla,IE5
		result = document.getElementById(id_);
	} else	if (document.all) {			//IE4
		result = document.all(id_);
	}
	return result;
}

function hidediv(div_id) { var objDiv = document.getElementById(div_id);if(objDiv != null){objDiv.style.display = 'none';}return false;}
function showdiv(div_id) { var objDiv = document.getElementById(div_id);if(objDiv != null){objDiv.style.display = 'block'; }return false;}


function myalert(s_) {
	alert(s_);
}

/* 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 = '#000';
  div.style.color = '#FFF';
}
function neg (div) {
  div.style.background = '#333 url(images/_hover.gif) repeat left top';
  div.style.color = '#FFF';
}

/* popup window....................................................................... */

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);
}

/* 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=yes,close=yes,status=no,location=no,directories=no,menubar=no,scrollbars=yes, 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);
}


