var ua =navigator.userAgent;
//check the ie version is bigger than 5 version
var up5browser = qualifyBrowser();
function getIEVersion(){
   var IEOffset =ua.indexOf("MSIE ");
   return parseFloat(ua.substring(IEOffset+5,ua.indexOf(";",IEOffset)));
}
function qualifyBrowser(){
   var qualified = false;
   if(navigator.appName == "Microsoft Internet Explorer")
     if (parseInt(getIEVersion())>=5.5)
      if (ua.indexOf("Windows")!=-1)
        qualified = true;
   return qualified;
}
//window operator
function openMiniWin(url,name,width,height){
  var str = "directories=no," +
            "location=no,menubar=no," +
            "resizable=no,status=no,toolbar=no," +
            "scrollbars=yes,";
      str += "height=" + height;
      str += ",";
      str += "width=" + width;
      str += ",";
  var screenw = screen.width;
  var screenh = screen.height;
  var left = (screenw - width)/2;
  var top = (screenh - height)/2;
      str += "left=" + left;
      str += ",";
      str += "top=" + top;

  var child;
  if(typeof(dialogArguments) == "object"){
    child = dialogArguments.window.open('', name, str);
  }else{
    child = window.open('', name, str);
  }
  child.focus();
  child.opener = self;
  child.location.replace(url);
  return child;
}
function openUnResizableMaxWin(url,name){
  var str = "directories=no," +
            "location=no,menubar=no," +
            "resizable=no,status=no,toolbar=no," +
            "scrollbars=no,";
      str += "left=" + 0;
      str += ",";
      str += "top=" + 0;
      str += ",";
      str += "height=" + screen.availHeight;
      str += ",";
      str += "width=" + screen.availWidth;
  var child;
  if(typeof(dialogArguments) == "object"){
    child = dialogArguments.window.open('', name, str);
  }else{
    child = window.open('', name, str);
  }
  child.focus();
  child.opener = self;
  child.location.replace(url);
//  child.moveTo(0,0);
  child.resizeTo(screen.availWidth,screen.availHeight);
  return child;
}
function openNormalMaxWin(url){
  var str = "directories=no," +
            "location=no,menubar=yes," +
            "resizable=yes,status=yes,toolbar=no," +
            "scrollbars=yes,";
     // str += "height=" + screen.height;
     // str += ",";
     // str += "width=" + screen.width;
     // str += ",";
      str += "left=" + 0;
      str += ",";
      str += "top=" + 0;

  var child;
  if(typeof(dialogArguments) == "object"){
    child = dialogArguments.window.open('', '', str);
  }else{
    child = window.open('', '', str);
  }
  child.focus();
  child.opener = self;
  child.location.replace(url);
  return child;
}


function openMainFullScreenWin(url){
  var str = "directories=no," +
            "location=no,menubar=no," +
            "resizable=yes,status=yes,toolbar=no," +
            "scrollbars=yes,";
      str += "left=" + 0;
      str += ",";
      str += "top=" + 0;
      str += ",fullscreen=yes";

  var child;
  if(typeof(dialogArguments) == "object"){
    child = dialogArguments.window.open('', '', str);
  }else{
    child = window.open('', '', str);
  }
  child.focus();
  child.opener = self;
  child.location.replace(url);
  return child;
}

function openMainMaxWin(url){
  _openMainMaxWin(url,'');
}
function _openMainMaxWin(url,name){
  var str = "directories=no," +
            "location=no,menubar=yes," +
            "resizable=yes,status=yes,toolbar=no," +
            "scrollbars=yes,";
      str += "left=" + 0;
      str += ",";
      str += "top=" + 0;
      str += ",";
      str += "height=" + screen.availHeight;
      str += ",";
      str += "width=" + screen.availWidth;
  var child;
  if(typeof(dialogArguments) == "object"){
    child = dialogArguments.window.open('', name, str);
  }else{
    child = window.open('', name, str);
  }
  child.focus();
  child.opener = self;
  child.location.replace(url);
//  child.moveTo(0,0);
  child.resizeTo(screen.availWidth,screen.availHeight);
  return child;
}


function openResizableMiniWin(url,name,width,height){
  var str = "directories=no," +
            "location=no,menubar=yes," +
            "resizable=yes,status=no,toolbar=no," +
            "scrollbars=yes,";
      str += "height=" + height;
      str += ",";
      str += "width=" + width;
      str += ",";
  var screenw = screen.width;
  var screenh = screen.height;
  var left = (screenw - width)/2;
  var top = (screenh - height)/2;
      str += "left=" + left;
      str += ",";
      str += "top=" + top;

  var child;
  if(typeof(dialogArguments) == "object"){
    child = dialogArguments.window.open('', name, str);
  }else{
    child = window.open('', name, str);
  }
  child.focus();
  child.opener = self;
  child.location.replace(url);
}

function openResizableMiniWin2(url,name,width,height){
  var str = "directories=no," +
            "location=no,menubar=no," +
            "resizable=yes,status=no,toolbar=no," +
            "scrollbars=yes,";
      str += "height=" + height;
      str += ",";
      str += "width=" + width;
      str += ",";
  var screenw = screen.width;
  var screenh = screen.height;
  var left = (screenw - width)/2;
  var top = (screenh - height)/2;
      str += "left=" + left;
      str += ",";
      str += "top=" + top;

  var child;
  if(typeof(dialogArguments) == "object"){
    child = dialogArguments.window.open('', name, str);
  }else{
    child = window.open('', name, str);
  }
  child.focus();
  child.opener = self;
  child.location.replace(url);
  return child;
}

function openSimpleMiniWin(url,name,width,height){
  var str = "directories=no," +
            "location=no,menubar=no," +
            "resizable=no,status=no,toolbar=no," +
            "scrollbars=no,";
      str += "height=" + height;
      str += ",";
      str += "width=" + width;
      str += ",";
  var screenw = screen.width;
  var screenh = screen.height;
  var left = (screenw - width)/2;
  var top = (screenh - height)/2;
      str += "left=" + left;
      str += ",";
      str += "top=" + top;

  var child;
  if(typeof(dialogArguments) == "object"){
    child = dialogArguments.window.open('', name, str);
  }else{
    child = window.open('', name, str);
  }
  child.focus();
  child.opener = self;
  child.location.replace(url);
}
function openModalWin(url,arg,width,height,sbar,help){
  var str = "dialogWidth:" + width + "px; ";
  str += "dialogHeight:" + height + "px; ";
  if(sbar != true)
      str += "status:no; ";
  if(help != true)
      str += "help:no; ";
      
  var args;
  if(arg != null){
    args = new Array();
    args[0] = arg;
    args[1] = window;
  }else{
    args = new Object;
    args.window = window;
  } 
 return window.showModalDialog(url,args,str);
}

//open a modal dialog
function openModelessWin(url,arg,width,height,sbar,help)
{
  var str = "dialogWidth:" + width + "px; ";
  str += "dialogHeight:" + height + "px; ";
  if(sbar != true)
      str += "status:no; ";
  if(help != true)
      str += "help:no; ";
  
  var args;
  if(arg != null){
    args = new Array();
    args[0] = arg;
    args[1] = window;
  }else{
    args = new Object;
    args.window = window;
  } 
  
  dlog = window.showModelessDialog(url,args,str);
  dlog.opener = window;
  return dlog;
}
function openHintWin(url,name,width,height)
{
  var str = "directories=no," +
            "location=no,menubar=no," +
            "resizable=no,status=no,toolbar=no,title=no," +
            "scrollbars=no,";
      str += "height=" + height;
      str += ",";
      str += "width=" + width;
      str += ",";
  var screenw = screen.width;
  var screenh = screen.height;
      str += "left=" + 0;
      str += ",";
      str += "top=" + screenh;
  
  var child;
  if(typeof(dialogArguments) == "object"){
    child = dialogArguments.window.open('', name, str);
  }else{
    child = window.open('', name, str);
  }
  
  child.opener = self;
  child.location.replace(url);
  if(child.window.screenTop>screen.height) for(var i=0;i<155;i++){
    child.window.moveBy(0,-1);
  }
}

function errortrap()
{
  alert(_msg_openeropen);
  window.close();
  return true;
}

function returnmodal(result)
{
  window.returnValue = result;
  window.close();
}

function callFromModalWinFail(){
  alert(_msg_callfrommodalwinerr);
}

function priverror(){
  if(document.all['sub_div'] != null){
    document.getElementById("sub_div").style.visibility="hidden";    
  }
  alert(_msg_priverror);
}

function dberror(){
  if(document.all['sub_div'] != null){
    document.getElementById("sub_div").style.visibility="hidden";    
  }
  alert(_msg_dberror);
}

function maxsizeerror(maxsize){
  if(document.all['sub_div'] != null){
    document.getElementById("sub_div").style.visibility="hidden";    
  }
  alert(_msg_maxsizeerror+maxsize);
}

function compdateerror(){
  if(document.all['sub_div'] != null){
    document.getElementById("sub_div").style.visibility="hidden";    
  }
  alert(_msg_compdateerror);
}
function fileerror(){
  if(document.all['sub_div'] != null){
    document.getElementById("sub_div").style.visibility="hidden";    
  }
  alert(_msg_fileerror);
}

function ioerror(){
  if(document.all['sub_div'] != null){
    document.getElementById("sub_div").style.visibility="hidden";    
  }
  alert(_msg_ioerror);
}
function errorShow(str){
  if(document.all['sub_div'] != null){
    document.getElementById("sub_div").style.visibility="hidden";    
  }
  alert(str);
}
function nowfpending(){
  alert(_msg_nowfpending);
}
function actionerror(){
  if(document.all['sub_div'] != null){
    document.getElementById("sub_div").style.visibility="hidden";    
  }
  alert(_msg_actionerror);
}
function resizeAndCenter(x,y){
   window.moveTo((screen.width-x)/2,(screen.height-y)/2);
   window.resizeTo(x,y);
}

/*
  ExEngineµ¯³ö´°¿Ú
*/

function openDefineWin(url,name,width,height,resizable,scrollbars){
  if(width == 0){
    width = screen.width;    
  }
  if(height == 0){
    height = screen.height;
  }
  var str = "directories=no," +
            "location=no,menubar=no," +
            "resizable="+(resizable?"yes":"no") +
            ",status=no,toolbar=no," +
            "scrollbars="+(scrollbars?"yes":"no");
  if(height != -1){      
      str += ",height=" + height;
  }else{
      height = screen.height/2;
  }
  if(width != -1){    
      str += ",width=" + width;
  }else{
      width = screen.width/2;
  }
  var screenw = screen.width;
  var screenh = screen.height;
  var left = (screenw - width)/2;
  var top = (screenh - height)/2;
      str += ",left=" + left;
      str += ",top=" + top;
  var child;
  if(typeof(dialogArguments) == "object"){
    child = dialogArguments.window.open('', name, str);
  }else{
    child = window.open('', name, str);
  }
  child.focus();
  child.opener = self;
  child.location.replace(url);
  return child;
}

function openDefineModalWin(url,arg,width,height,resizable,scroll)
{
  var str = "dialogWidth:" + width + "px; ";
  str += "dialogHeight:" + height + "px; ";
  if(resizable == true)
      str += "resizable:yes; ";
  if(scroll == false)
      str += "scroll:no;";    
  str += "help:no; status:no ;";
  var args;
  if(arg != null){
    args = new Array();
    args[0] = arg;
    args[1] = window;
  }else{
    args = new Object;
    args.window = window;
  } 
 return window.showModalDialog(url,args,str);
}

function openDefineModelessWin(url,arg,width,height,resizable,scroll)
{
  var str = "dialogWidth:" + width + "px; ";
  str += "dialogHeight:" + height + "px; ";
  if(resizable == true)
      str += "resizable:yes; ";
  if(scroll == false)
      str += "scroll:no;";    
  str += "help:no; status:no ;";
  
  var args;
  if(arg != null){
    args = new Array();
    args[0] = arg;
    args[1] = window;
  }else{
    args = new Object;
    args.window = window;
  } 
  
  dlog = window.showModelessDialog(url,args,str);
  dlog.opener = window;
  return dlog;
}

