


var yhReInitForm=null, yhReInitTarget, yhReInitRefrField=null;
    yhReInitButtonField=null;
    yhReUrl=""; yhReCard=""; SrvLocalUrl="";

function yhRefreshAnimationObj ()
{
   this.modal=0;
   this.cancel = function () {};
   this.onsend = function () {};
   this.onrfStart = function () {};
   this.onrfFinish = function () {};
   this.showModal = function () {};
   this.cancelModal = function () {};

   this.setModal = function () {
      this.modal++;
      if (this.modal==1) { this.showModal();}
   };
   this.resetModal = function () {
      this.modal--;
      if (this.modal==0) { this.cancelModal(); }
   };
   this.set = function (a) { this.cancel(); yhRefreshAnimation = a; }
   this.reset = function () { this.cancel(); yhRefreshAnimation = yhNoRefreshAnimation; }
}

yhRefreshAnimation = yhNoRefreshAnimation = new yhRefreshAnimationObj ();

function yhTestRefreshAnimation ()
{
   a = new yhRefreshAnimationObj ();
   a.redraw = function () {
      var bs=this.saved_bodystyle; var ms="";
     
      if (this.refreshstate) { bs+= this.rfBodyStyle;     ms += this.rfMaskStyle;}
      if (this.modal>0)      { bs+= this.modalBodyStyle;  ms += this.modalMaskStyle;}
 
      document.body.style.cssText = bs;

      var el=document.getElementById ("yhFullPagediv");
      if (ms && ms!="") {
         if (el) {
            el.style.cssText = "position:fixed; left:0px; top:0px; z-index:1;  width:100%; height:100%;" + ms;
         } else {
            var ph = document.createElement ("div");
            ph.style.cssText = "position:fixed; left:0px; top:0px; z-index:1;  width:100%; height:100%;" + ms;
            ph.id = "yhFullPagediv";
            document.body.insertBefore(ph,document.body.firstChild);
         }
      } else {
         if (el) document.body.removeChild (el);
      }
               }
   a.onsend = function () {
      if (this.modal==0) this.saved_bodystyle=document.body.style.cssText;
      this.refreshstate=true;
      this.redraw();
   }
   a.showModal = function () {
      if (!this.refreshstate) this.saved_bodystyle=document.body.style.cssText;
      this.redraw();
   }
   a.cancelModal = function () {
      this.redraw();
   }
   a.cancel = function () {
            this.refreshstate=false;
      this.redraw();
   }
   a.onrfFinish = function () {
      this.cancel();
   }

   a.rfBodyStyle= " cursor:wait";   a.modalBodyStyle = null;
   a.modalMaskStyle = 
      "opacity:0.5; background-color:black;  filter:Alpha(opacity=50);";
   a.rfMaskStyle= a.modalMaskStyle+"cursor:wait";

   return a;
}




function yhshowobj(o){
   var s; var i;
   s = ""; i=0;
   for (props in o) {
     s+= "   "+props + ": " + o[props];
     if (i==5) {s+="\n"; i=0};
     i=i+1;
   }
   alert(s);
}




function yhRefreshLink(l)
{
    var x=l.href; var s="";
                    for (i=0; i<x.length; i++) {
       var c= x.charCodeAt(i);
       if (c>127) {
           var hex="0123456789ABCDEF";
           s += "%" + hex.charAt(Math.floor(c/16)) + hex.charAt(c%16);
       } else 
	 s +=  x.charAt(i);
    }
        if (s.lastIndexOf("?") <0) s+="?";
    if (s.substr(s.length-8,8)!="&_refr=t") s+="&_refr=t";
    l.href = s;
    yhRefreshAnimation.onsend();
}


function yhClickLinkInside (el,ev){


   if (el.tagName=="A") {


     if (ev.srcElement) {          if (el.sourceIndex==ev.srcElement.sourceIndex 
                       && window.event.type=="click") {
         return;
        }
     } else {
	if (el==ev.target){
         return;
        }
     }

     if (el.onclick) el.onclick(ev);

     var t = el.target;
     if (t) f = window.frames[t]; else f=window;
     if (f) f.document.location = el.href;
   } else {
     var i;
     if (el.children) {
        for (i=0; i<el.children.length; i++) {
	   yhClickLinkInside (el.children[i],ev);
        }
     }
   }
}



function yhRefreshButton (b){
   var r;
   yhReInitForm=b.form;
   yhReInitTarget=b.form.target;
   b.form.target = "refrframe";
   r=document.createElement('input');
   r.setAttribute ('type','hidden');  r.setAttribute ('value','t');  r.setAttribute ('name','_refr');
   r.setAttribute ('id','yhReInitRefrField');
   b.parentNode.insertBefore(r,b);
   yhReInitRefrField=document.getElementById('yhReInitRefrField');
   return false;
}

function yhReinitializeRefresh()
{
    yhRefreshAnimation . onrfStart();
   if (yhReInitForm) yhReInitForm.target=yhReInitTarget;
   if (yhReInitRefrField) yhReInitRefrField.parentNode.removeChild(yhReInitRefrField);
   yhReInitForm=null;
   yhReInitRefrField=null;
   if (yhReInitButtonField) yhReInitButtonField.value="";
       
}


function yhEndRefresh()
{
    if (window.yhAdjust) yhAdjust();
    yhRefreshAnimation . onrfFinish();
}


function yhrfNameVal (name,val)
{
   if (parent.document.getElementsByName(name)[0])
	      parent.document.getElementsByName(name)[0].value=val;
}


function yhobjspace(){};

var 
     yhobj = new yhobjspace();
			     yhcurobj = yhobj;

function yhRegisterObj (name, obj)
{
   yhcurobj[name]=obj;
}

var yhdorefreshforcereload = false;

function yhDoRefreshForceReload ()
{
   yhdorefreshforcereload = true;
}

function yhDoRefresh (urlpar)
{    if (yhdorefreshforcereload) {
      var l = document.location + "?&" + "card=" + yhReCard + "&" + urlpar;
      setTimeout ("document.location = '"+l+"'",10);      
   } else {
      var l = yhReUrl + "?" + "card=" + yhReCard + "&_refr=t&" + urlpar;
                        setTimeout ("refrframe.document.location = '"+l+"'",10);
   }
}

function yhrfObj_client_show ()
{
   var el;
   el = this.element();
   el.style.display="";
   this.oncshow();
}
function yhrfObj_client_toggle ()
{
   var el;
   el=this.element();
   if (el.style.display=="none") this.client_show(); else this.client_hide();
}
function yhrfObj_client_hide ()
{
   var el;
   el = this.element();
   el.style.display="none";
   this.onchide();
}
function yhrfObj_show ()
{
   var el;
   this.client_show();
   yhDoRefresh (this.bid + ".show=t");
}
function yhrfObj_hide ()
{
   var el;
   this.client_hide();
   yhDoRefresh (this.bid + ".hide=t");
}
function yhrfObj_toggle ()
{
   var el;
   el=this.element();
   if (el.style.display=="none") this.show(); else this.hide();
}
function yhObj_element ()
{
   return document.getElementById(this.bid);
}

function yhrfObj(bid,onshow,oncshow,onhide,onchide)
{
   this.bid=bid;
   this.show = yhrfObj_show;
   this.hide = yhrfObj_hide;
   this.client_show = yhrfObj_client_show;
   this.client_toggle = yhrfObj_client_toggle;
   this.client_hide = yhrfObj_client_hide;
   this.toggle = yhrfObj_toggle;
   this.element = yhObj_element;
   this.onshow= onshow;
   this.oncshow= oncshow;
   this.onhide= onhide;
   this.onchide=onchide;
}

var yhcurpanel=null;

function yhprototype_panel ()
{
   this. control = function (name)
   {
      return document.getElementsByName(this.bid+"."+name)[0];
   }
   this. element = function ()
   {
      return getElementByName (this.bid)[0];
   }
   this. control_name = function (name)
   {
      return this.bid+"."+name;
   }
}

function yhnewpanel(bid,parent)
{
   this.bid=bid; this.parent=parent;
}
yhnewpanel.prototype = new yhprototype_panel;

function yhprototype_sesform()
{
   this.baseproto=yhprototype_panel; this.baseproto();
}
function yhnewsesform(bid,parent)
{
   this.bid=bid; this.parent=parent;
}
yhnewsesform.prototype = new yhprototype_sesform;


var x = 0;
var url = ""
function yhRewriteSpan(t){
    try{
        if(url==""){
          url = parent.frames['refrframe'].location.href;
        }
        if ((parent.frames['refrframe'].document.readyState == "complete" && x > 0) || ((navigator.userAgent.indexOf("MSIE") <0 )&&(url != parent.frames['refrframe'].location.href)))
        {
            for(y=0;y<parent.document.getElementsByTagName("span").length;y++){
              parent.document.getElementsByTagName("span")[y].innerHTML = parent.frames['refrframe'].document.getElementsByTagName("span")[y].innerHTML;
            }
            x=0;
            url = parent.frames['refrframe'].location.href;
            return;
        }
        else{
            x=x+1
            setTimeout('yhRewriteSpan(\''+t+'\')',100);
        }
 }catch(ex){
        if(parent.document.getElementsByTagName("span")[y]==undefined || parent.frames['refrframe'].document.getElementsByTagName("span")[y]==undefined){
            x=x+1;
            setTimeout('yhRewriteSpan(\''+t+'\')',100);
        }else{
            alert("Error--- "+ex.message);
        }
    }
}
