function swapDisplay(oName, oDisp, oFrame) 
{
	var theDiv = searchObj(oName, oFrame);
  if (!theDiv)
  {
    return;
  }
	if (theDiv.style)
	{
    theDiv = theDiv.style;
  }
  if (typeof(oDisp)=='string')
  {
    oDisp = oDisp.toLowerCase();
  }
	theDiv.display = (oDisp == 'none') ? 'none' : (oDisp == 'block') ? 'block' : (oDisp == 'inline') ? 'inline' : '';
}

function searchObj(oName, oFrame, oDoc)
{
	if (!oDoc)
	{
    if (oFrame)
    {
      oDoc = oFrame.document;
    }
    else
    {
      oDoc = window.document;
    }
  }
  if (oDoc[oName])
  {
    return oDoc[oName];
  }
  if (oDoc.all && oDoc.all[oName])
  {
    return oDoc.all[oName];
  }
  if (oDoc.getElementById && oDoc.getElementById(oName))
  {
    return oDoc.getElementById(oName);
  }
  for (var x = 0; x < oDoc.forms.length; x++)
  {
    if (oDoc.forms[x][oName])
    {
      return oDoc.forms[x][oName];
    }
  }
  for (var x = 0; x < oDoc.anchors.length; x++)
  {
    if (oDoc.anchors[x].name == oName)
    {
      return oDoc.anchors[x];
    }
  }
  for (var x = 0; document.layers && x < oDoc.layers.length; x++)
  {
		var theOb = searchObj( oName, null, oDoc.layers[x].document );
    if (theOb)
    {
      return theOb;
    }
  }
  if (!oFrame && window[oName])
  {
    return window[oName];
  }
  if (oFrame && oFrame[oName])
  {
    return oFrame[oName];
  }
  for (var x = 0; oFrame && oFrame.frames && x < oFrame.frames.length; x++)
  {
		var theOb = searchObj(oName, oFrame.frames[x], oFrame.frames[x].document);
    if (theOb)
    {
      return theOb;
    }
  }
	return null;
}

function get_Style(oName, oStyle, oFrame)
{
  if (oName == 'document')
  {
    var theBody = oFrame ? oFrame.document : window.document;
		if (theBody.documentElement && theBody.documentElement.style && theBody.documentElement.style.backgroundColor)
		{
      return theBody.documentElement.style.backgroundColor;
    }
		if (theBody.body && theBody.body.style && theBody.body.style.backgroundColor)
		{
      return theBody.body.style.backgroundColor;
    }
		if (theBody.documentElement && theBody.documentElement.style && theBody.documentElement.style.background)
		{
      return theBody.documentElement.style.background;
    }
		if (theBody.body && theBody.body.style && theBody.body.style.background)
		{
      return theBody.body.style.background;
    }
    if (theBody.bgColor)
    {
      return theBody.bgColor;
    }
		return '#ffffff';
	}
  var theDiv = searchObj(oName, oFrame);
  if (!theDiv)
  {
    return null;
  }
  if (theDiv.style && oStyle != 'clip')
  {
    theDiv = theDiv.style;
  }
	switch (oStyle)
	{
		case 'visibility':
      return ((theDiv.visibility && !(theDiv.visibility.toLowerCase().indexOf('hid')+1)) ? true : false);
		case 'left':
			return (parseInt(theDiv.left) ? parseInt(theDiv.left) : 0);
		case 'top':
			return (parseInt(theDiv.top) ? parseInt(theDiv.top) : 0);
		case 'zIndex':
			return (isNaN(theDiv.zIndex) ? 0 : theDiv.zIndex);
		case 'background':
			return (theDiv.bgColor ? theDiv.bgColor : theDiv.background-color ? theDiv.background-color : theDiv.background);
		case 'display':
      return (theDiv.display ? theDiv.display : '');
		case 'size':
			if (typeof(theDiv.pixelWidth) != 'undefined')
			{
			  return [theDiv.pixelWidth,theDiv.pixelHeight];
			}
			if (typeof(theDiv.width) != 'undefined')
			{
			  return [parseInt(theDiv.width),theDiv.parseInt(height)];
			}
			if (theDiv.clip && typeof(theDiv.clip.bottom) == 'number')
			{
			  return [theDiv.clip.right,theDiv.clip.bottom];
			}
			return [0,0];
		case 'clip':
			if (theDiv.clip)
			{
			  return theDiv.clip;
			}
			theDiv = (theDiv.style && theDiv.style.clip) ? theDiv.style.clip : 'rect()';
			theDiv = theDiv.substr(theDiv.indexOf('(')+1);
			var theClip = new Object();
			for (var x = 0, y = ['top','right','bottom','left']; x < 4; x++)
			{
				theClip[y[x]] = parseInt(theDiv);
				if (isNaN(theClip[y[x]]))
				{
				  theClip[y[x]] = 0;
				}
				theDiv = theDiv.substr(theDiv.indexOf((theDiv.indexOf(' ')+1) ? ' ' : (theDiv.indexOf('	')+1) ? '	' : ',')+1);
			}
			return theClip;
		default:
			return null;
	}
}

function swap_Image(oId, path)
{
  var image = searchObj(oId);
  var imagePath = image.src.slice(0, image.src.lastIndexOf('/')+1);
  var imageName = image.src.slice(image.src.lastIndexOf('/')+1, image.src.length);
  if (imageName == 'mminus.gif')
  {
    image.src = imagePath + 'mplus.gif';
  }
  else
  {
    image.src = imagePath + 'mminus.gif';
  }
}

function get_Cookie(name)
{
  var i=0
  var figovina = name+"="
  while (i<document.cookie.length)
  {
    if (document.cookie.substring(i, i+figovina.length)==figovina)
    {
      var end = document.cookie.indexOf(";", i+figovina.length)
      end = (end>-1) ? end : document.cookie.length
      var cook = document.cookie.substring(i+figovina.length, end)
      return unescape(cook)
    }
    i++
  }
  return null
}

function set_Cookie(name,value)
{
	value = value+'@';
  var lifeTime = 31536000;
	var currentStr = retrive_Cookie(name);
	if (!currentStr)
	{
		set_Cookie_2(name, value, lifeTime);
	}
	else if (currentStr.indexOf(value)+1)
	{
		value = new RegExp(value,'');
		set_Cookie_2(name, currentStr.replace(value,''), lifeTime);
	}
	else
	{
    set_Cookie_2(name, currentStr+value, lifeTime);
	}
}

function set_Cookie_2(cookieName, cookieValue, lifeTime, path, domain, isSecure)
{
	if (!cookieName)
	{
	  return false;
	}
	if (lifeTime == "delete")
	{
	  lifeTime = -10;
	}
	document.cookie = escape(cookieName) + "=" + escape(cookieValue) + (lifeTime ? ";expires=" + (new Date((new Date()).getTime() + (1000 * lifeTime))).toGMTString() : "") + (path ? ";path=" + path : "") + (domain ? ";domain=" + domain : "") + (isSecure ? ";secure" : "");
	if (lifeTime < 0)
	{
	  if (typeof(retrive_Cookie(cookieName)) == "string")
	  {
	    return false;
	  }
	  return true;
	}
	if (typeof(retrive_Cookie(cookieName)) == "string")
	{
	  return true;
	}
	return false;
}

function retrive_Cookie(cookieName)
{
	var cookieJar = document.cookie.split("; ");
	for (var x = 0; x < cookieJar.length; x++)
	{
		var oneCookie = cookieJar[x].split("=");
		if (oneCookie[0] == escape(cookieName))
		{ 
		  return unescape(oneCookie[1]);
		}
	}
	return null;
}
