/**
* MM_swapImgRestore
* MM_preloadImages
* MM_findObj
* MM_swapImage
* myOpenWin
* mySetFocusOnForm
* AlertError
* myGetMicroTime
*/

//========

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i>a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i>d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

//========

var myWin;
function myOpenWin(arg1, arg2, arg3, arg4)
{
	if(myWin != null){
		myWin.close();
	}
	if(!arg4){
		arg4 = document.title;
	}

	myWin=window.open('','new_window','width='+arg2+',height='+arg3+',resizable=1,location=0,menubar=0,status=0,scrollbars=0');
	myWin.document.open();
	myWin.document.write('<html><head>');
	myWin.document.write('<style>body{background:#FFFFFF; margin:0px 0px 0px 0px; padding:0px 0px 0px 0px;}</style>');
	myWin.document.write('<title>' + arg4 + '</title>');
	myWin.document.write('</head>');
	myWin.document.write('<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">');
	myWin.document.write('<img src="' + arg1 + '" hspace="0" vspace="0">');
	myWin.document.write('</body></html>');
	myWin.document.close();
	myWin.focus();
}

//========

//var ExactElems = new Array('text', 'select-one');
var ExactElems = new Array('text');
function mySetFocusOnForm(){
  SkipFrm = arguments[0];
  CntFrms = document.forms.length;

  for(i=1; i<=CntFrms; i++){
    if(document.forms[i-1].name == 'Authentication'){
    	continue;
    }else if(SkipFrm && SkipFrm != undefined){
      var tContinue = false;
      for(var a=0; a < SkipFrm.length; a++){
        if(document.forms[i-1].name == SkipFrm[a]){
          tContinue = true;
          break;
        }
      }
      if(tContinue){
        continue;
      }
    }
    CntElms = document.forms[i-1].elements.length;

    for(j=1; j<=CntElms; j++){
      ElmsType = document.forms[i-1].elements[j-1].type;

      for(k=0; k<ExactElems.length; k++){
        if(ElmsType == ExactElems[k]){
          document.forms[i-1].elements[j-1].focus();
          return;
        }
      }
    }
  }
}

//========

function AlertError() {
	var mess = arguments[0];
	var actn = arguments[1];
	/**
	* Action
	* Alert;  [0-{Always}; 1-{ModeDebug active}; 2-{Always}; 3-{ModeDebug active}; 4-{ModeDebug active};]
	* Logout; [2-{Always}; 3-{ModeDebug active}; 4-{Always};]
	*/

	if(actn == null){
	  actn = 0;
	}
	if(actn == 0 || actn == 2 || (iModeDebug && (actn == 1 || actn == 3 || actn == 4))){
	  alert(mess);
	}
	if(actn == 2 || actn == 4 || (iModeDebug && (actn == 3))){
	  //Logout & Redirect
	  document.location = sErrorRedirectUrl;
	}
}

//========

function myGetMicroTime(){
  var Time, Today;

  Today = new Date();
  Time = Today.getTime();
  Time = Time / 1000;

  if(arguments[0]){
    Time = Math.round(Time);
  }

  return Time;
}

//========

function myMenuCatShowHide(){
  var mCatName = arguments[0];
  var mCatNum  = arguments[1];

  if(giCntMenuCat && document.getElementById){
    for(var i=1; i <= giCntMenuCat; i++){
      if(mCatNum == i){
        if(document.getElementById(mCatName + mCatNum).style.display == 'none'){
          document.getElementById(mCatName + mCatNum).style.display = 'block';
        }else{
          document.getElementById(mCatName + mCatNum).style.display = 'none';
        }
      }else{
        document.getElementById(mCatName + i).style.display = 'none';
      }
    }
  }

  return;
}

//========
