//common DOM fuctions

function fGD(el)
{
 return document.getElementById(el);
}
function fGDs(el)
{
 return fGD(el).style;
}
fGDsiv=function(el,i,v)
{
 try
 {
  if(v != null)
   document.getElementById(el).style[i]=v;
  return document.getElementById(el).style[i];
 }
 catch(e){return "";}
}
function fToggle(eid,fonopen,fonclose,opening)
{
 try
 {
  var el=fGD(eid);
  var group=el.getAttribute("group");
  if(group)
  {
   var aGroup=group.split(",");
   for(var a=0;a<aGroup.length;a++)
   {
    try
    {
     if(eid!=aGroup[a] && fGDs(aGroup[a]).display=="")
     {
      fGDs(aGroup[a]).display="none";
      if(fGD(aGroup[a]).getAttribute("fonClose"))
       eval(fGD(aGroup[a]).getAttribute("fonClose"));
     }
    }
    catch(e){}
   }
  }
  if(el.style.display=="none")
  {
   el.style.display="";
   if(fonopen)
    fonopen(fonclose);
  }
  else
  {
   if(opening == null || opening == eid)
   {
    el.style.display="none";
    if(fonclose)
     fonclose();
   }
   else
   {
    if(fonopen)
    fonopen(fonclose);
   } 
  }
 }
 catch(e){}
 return false;
}
fGDv=function(el,v)
{
 try
 {
  if(v != null)
   document.getElementById(el).value=v;
  return document.getElementById(el).value;
 }
 catch(e){return 0;}
}
function fSerialize(obj)
{
 try{if(obj.getTime) return 'new Date("'+obj+'")';}catch(e){}
 if(typeof(obj) == "string")
  return '"'+(String(obj).replace(/(\'|\")/g,"\\$1"))+'"';
 if(typeof(obj) == "date")
  return '"'+obj+'"';
 if(typeof(obj) == "number")
  return obj;
 if(typeof(obj) == "undefined")
  return "null";
 if(typeof(obj) == "function")
  return null;
 var atxt=[];
 if(typeof(obj) == "object")
 {
  try
  {
   if(obj.fToString)
    return obj.fToString();
  }catch(fSerializeE){return null;}
  if(String(obj) == "null")
   return null;
  if(obj == true)
   return "true";
  if(obj == false)
   return "false";
  try
  {
   if(String(obj.valueOf()).charAt(0) == "/")
	   return "new RegExp('"+String(obj.valueOf()).replace(/\/(.*)\/(.*)/,"$1','$2'")+")";
   else if(obj.length != null)
   {
    var aobj = [];
    for(var o=0;o<obj.length;o++)
    {
     if(typeof(obj[o]) == "function")
      continue;
     if(typeof(obj[o]) == "object" && obj[o].length==0)
     {
      aobj[aobj.length]=[];
      continue;
     }
     aobj[aobj.length]=fSerialize(obj[o]);
    }
    atxt[atxt.length]="[ "+aobj.join(", ")+" ]";
   }
   else
   {
    var aobj = [];
    for(var o in obj)
    {
     if(o.charAt(0)=="$" || o.charAt(0)=="_" || o.charAt(0)=="f" || typeof(obj[o]) == "function")
     {
      continue;
     }
     aobj[aobj.length]='"'+o+'":'+fSerialize(obj[o]);
    }
    atxt[atxt.length]="{ "+aobj.join(", ")+" }";
   }
  }
  catch(e)
  {
   atxt[atxt.length]="Error:\""+String(e.description)+"\"";
  }
 }
 return(atxt.join(", "));
}
function fGetCookie(c_name)
{
if (document.cookie.length>0)
  {
   var scookie=unescape(document.cookie);
  c_start=scookie.indexOf(c_name + "=");
  if (c_start!=-1)
    {
    c_start=c_start + c_name.length+1;
    c_end=scookie.indexOf(";",c_start);
    if (c_end==-1) c_end=scookie.length;
    return scookie.substring(c_start,c_end);
    }
  }
return "";
}
function fSetCookie(c_name,value,expiredays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ "=" +escape(value)+
((expiredays==null) ? "" : ";expires="+exdate.toUTCString());
}

