﻿////////////////////////////////////////////////////////
// Simple functions for load page,
// Spiderweb Design.

// description of elements; 
var isDOM = (document.getElementById ? true : false);
var isIE4 = ((document.all && !isDOM) ? true : false);
var isNS4 = (document.layers ? true : false);
var isIE = (document.all ? true:false);
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != 1)? true : false;
var isOpera = (navigator.userAgent.indexOf("Opera") != 1)? true : false;

// getting by name; 
function getByName(name)
{
    document.getElementsByName(name);
}
document.getByName=getByName;

if(document.parent==null)
	document.parent=window;

// refturns a refrence of an object;
function getRef(id) 
{
	if (isDOM) return document.getElementById(id);
	if (isIE4) return document.all[id];
	if (isNS4) return document.layers[id];
}
document.getRef=getRef;

// Gets a style of an object, by its id; 
function getSty(id)
{
	var obj=getRef(id);
	if(obj.style==null)
	{
		return obj;
	}
	else return obj.style;
}

// gets a style of an object; 
function getObjSty(obj)
{
	if (obj==null)
		return null;
	if(obj.style==null)
		return obj;
	else return obj.style;
}

document.getSty=getSty;
document.getObjSty=getObjSty;

function Create(tag)
{
    var cur=document.createElement(tag);
    cur.Style=getObjSty(cur);
    return cur;
}

function setOpacity(obj,value)
{
    if(isIE)
    {
        getObjSty(obj).filter = 'alpha(opacity=' + value + ')';
    }
    else
    {
        getObjSty(obj).opacity = value/100;    
    }
}

function GetChildByID(obj,id)
{
	if(obj.childNodes==null)
		return null;
	for(var i=0;i<obj.childNodes.length;i++)
	{
		var c=obj.childNodes[i];
		if(c.id==id)
		{
		    c.Style=getObjSty(c);
			return c;
		}
		else
		{
			var cr=GetChildByID(c,id);
			if(cr!=null)
			{
			    cr.Style=getObjSty(cr);
				return cr;
		    }
		}
	}
	
	return null;
}
    
function hideShow(el,text)
{
    var sty=getObjSty(GetChildByID(el,"hide"));
    var btn=GetChildByID(el,"btn");
    if(sty.display=="none")
    {
        sty.display="";
        btn.innerHTML="▲ ";
    }
    else
    {
        sty.display="none";
        btn.innerHTML="▼ ";
    }
}
