function setInputValue(name,value)
{
  document.getElementById(name).value = value;
}


function openWin(wName, wWidth, wHeight, wResize) 
{
  features = 'scrollbars=1,status=1,resizable=' + ((wResize) ? 1 : 0) + ((wWidth) ? ',width=' + wWidth : '') + ((wHeight) ? ',height=' + wHeight : '');
  popWin = window.open('', wName, features);
  if(popWin.focus) 
  { 
    popWin.focus(); 
  }
  return true;
}
	

function navigate(dir) 
{
  np = document.getElementById("navpath");
  np.value=np.value+"/"+dir;
  getbody("main","filebw","navigate");
}

function downloadfile(file) 
{
  np = document.getElementById("file");
  np.value=file;
  np = document.getElementById("clink");
  np.value=0;
  getbody("null","filebw","dwfile");
}
				  
function createlink(file) 
{
  np = document.getElementById("file");
  np.value=file;
  np = document.getElementById("clink");
  np.value=1;
  getbody("crtlink","filebw","dwfile");
}

var tmp = {};

function getbody(id,from,senddata,execondone,txt,txttarget) 
{
  var send=null;
  if (id.indexOf('_')==0) 
  {
    f=document.getElementById(senddata);
    f.action='index.php?action='+from;
    f.target=id;
    openWin(id, 500, 400, true);
    f.method="post";
    f.submit();
    return true;
  }
  else 
  {
    var target = document.getElementById(id);
  }
  var xmlHttpReq = xoad.getXmlHttp();
  if ((target!=null) & (xmlHttpReq!=null)) 
  {
    form = document.getElementById(senddata);
    if (form!=null) 
    {
      send=xoad.html.exportForm(senddata);
      send=xoad.serialize(send);
    }
    url = 'index.php?action='+from;
    if (send!=null) {url=url+'&xoadCall=true';}
    xmlHttpReq.open('POST', url, true);
/***********************************************************/
    xmlHttpReq.onreadystatechange = function() 
    {
      if (xmlHttpReq.readyState == 4) 
      {
        res = xmlHttpReq.responseText;
        if (res[0]=='%') 
	{
          refreshpage(res);
        }
        else if (res=='!close!')
        {
          document.write('<script>self.close()</script>');
        }
        else 
	{
	  bg=res.indexOf("<jscript>");
	  if (bg>0) 
	  {
	    bg=bg+9;
	    be=res.indexOf("</jscript>")-bg-1;
	    cc=res.substr(bg,be);
	    eval(cc);
	    res=res.replace(cc,'');
	  }
          target.innerHTML=res;
	  FB.XFBML.parse();
        }
        if (execondone!=null) 
	{
          execondone();
        }
        setInputfocus();
      }
      else 
      {
      }
    }
/*--------------------------------------*/
    if (send!=null) 
    {
      xmlHttpReq.setRequestHeader('Content-Length', send.length);
    }
    else 
    {   
      xmlHttpReq.setRequestHeader('Content-Length', 1);
      send = "a";
    }
    xmlHttpReq.setRequestHeader('Content-Type', 'text/plain; charset=UTF-8');
    xmlHttpReq.setRequestHeader('Accept-Charset', 'UTF-8');
    xmlHttpReq.send(send);
    if (txt!=null)
    {
      if (txttarget!=null)
      {
        t1 = document.getElementById(txttarget);
      }
      else {t1 = target;}
      t1.innerHTML=txt;
      FB.XFBML.parse();
    }
  }
  else 
  {
//    document.write('target not found: '+id);
  }
}

function setInputfocus() 
{
  var myfrm = document.getElementById('frm@_setfocus');
  if (myfrm!=null) 
  {
    myinp = document.getElementById(myfrm.value);
    myinp.focus();
  }
}

function rfmenu()
{
  getbody('menu','menu');
}

var secs
var timerID = null
var timerRunning = false
var delay = 1000

function InitializeTimer()
{
    // Set the length of the timer, in seconds
  secs = 60
  StopTheClock()
  StartTheTimer()
}
		
function StopTheClock()
{
  if(timerRunning)
  clearTimeout(timerID)
  timerRunning = false
}
				
function StartTheTimer()
{
  if (secs==0)
  {
    getbody("banner","banner");
    InitializeTimer();
  }
  else
  {
    secs = secs - 1
    timerRunning = true
    timerID = self.setTimeout("StartTheTimer()", delay)
  }
}

function initportal() 
{
  getbody('menu','menu');  
  getbody('main','info');  
  getbody('banner','banner');  
  InitializeTimer();
}
	       
function openerGetBody(id,from,senddata,execondone,txt,txttarget) 
{
  var send=null;
  if (id.indexOf('_')==0) {
    f=window.opener.document.getElementById(senddata);
    f.action='index.php?action='+from;
    f.target=id;
    openWin(id, 500, 400, true);
    f.method="post";
    f.submit();
    return true;
  }
  else 
  {
    var target = window.opener.document.getElementById(id);
  }
  var xmlHttpReq = xoad.getXmlHttp();
  if ((target!=null) & (xmlHttpReq!=null)) 
  {
    form = window.opener.document.getElementById(senddata);
    if (form!=null) 
    {
      send=xoad.html.exportForm(senddata);
      send=xoad.serialize(send);
    }
    url = 'index.php?action='+from;
    if (send!=null) {url=url+'&xoadCall=true';}
    xmlHttpReq.open('POST', url, true);
/***********************************************************/
    xmlHttpReq.onreadystatechange = function() 
    {
      if (xmlHttpReq.readyState == 4) 
      {
        res = xmlHttpReq.responseText;
        if (res[0]=='%') 
	{
          refreshpage(res);
        }
        else if (res=='!close!')
        {
          window.opener.document.write('<script>self.close()</script>');
        }
        else 
	{
	  bg=res.indexOf("<jscript>");
	  if (bg>0) 
	  {
	    bg=bg+9;
	    be=res.indexOf("</jscript>")-bg-1;
	    cc=res.substr(bg,be);
	    eval(cc);
	    res=res.replace(cc,'');
	  }
          target.innerHTML=res;
          FB.XFBML.parse();
        }
        if (execondone!=null) 
	{
          execondone();
        }
        setInputfocus();
      }
      else 
      {
      }
    }
/*--------------------------------------*/
    if (send!=null) 
    {
      xmlHttpReq.setRequestHeader('Content-Length', send.length);
    }
    else 
    {   
      xmlHttpReq.setRequestHeader('Content-Length', 1);
      send = "a";
    }
    xmlHttpReq.setRequestHeader('Content-Type', 'text/plain; charset=UTF-8');
    xmlHttpReq.setRequestHeader('Accept-Charset', 'UTF-8');
    xmlHttpReq.send(send);
    if (txt!=null)
    {
      if (txttarget!=null)
      {
        t1 = window.opener.document.getElementById(txttarget);
      }
      else {t1 = target;}
      t1.innerHTML=txt;
      FB.XFBML.parse();	
    }
  }
  else 
  {
//    window.opener.document.write('target not found: '+id);
  }
}
	       

