function third_party(url)
{
	var popup = "third_party_popup.html?location=" + url;
	var swidth = ( ((parseInt(screen.width) / 2)) - 190)
	var sheight = (((parseInt(screen.height) / 2)) - 165)
	window.open(popup, '', "toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=380,height=330,top=" + sheight + ",left=" + swidth );
}

function mapWindow(url)
{
	
	window.open(url, '', 'toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=480,height=460');
}

function Helper (debug)
{
	this.debug = false;
	if (debug && debug == true)
	{
		this.dw = document.getElementById('debug');
		this.dh = document.getElementById('debug_hover');
		if (this.dw != null && this.dh != null)
		{
			this.dh.style.display = 'block';
			this.dh.onmouseover = function () { var h_temp = new Helper(); h_temp.hideObject('debug_hover'); h_temp.showObject('debug'); }
			this.dw.onmouseout = function () { var h_temp = new Helper(); h_temp.hideObject('debug'); h_temp.showObject('debug_hover'); }
			this.debug = true;
		}
	}
}

Helper.prototype.getObject = function (o)
{
	var obj = o;

	if (typeof o == "string")
	{
		obj = document.getElementById(o);
	}

	return obj;
}

Helper.prototype.showObject = function (oid)
{
	if (!oid) { return; }

	var o = this.getObject(oid);

	if (o && o.style)
	{
		o.style.display = '';
	}
}

Helper.prototype.hideObject = function (oid)
{
	if (!oid) { return; }

	var o = this.getObject(oid);

	if (o && o.style)
	{
		o.style.display = 'none';
	}
}

Helper.prototype.selectObject = function (oid)
{
	if (!oid) { return; }

	var o = this.getObject(oid);

	if (o && o.className != null)
	{
		o.className += " selected";
	}
}

Helper.prototype.deselectObject = function (oid)
{
	if (!oid) { return; }

	var o = this.getObject(oid);

	if (o && o.className != null)
	{
		o.className = o.className.replace(/selected/g, '');
	}
}

Helper.prototype.objectSelected = function (oid)
{
	if (!oid) { return; }

	var o = this.getObject(oid);

	if (o.className && o.className.indexOf('selected') >= 0)
	{
		return true;
	}
	else
	{
		return false;
	}
}

Helper.prototype.swapOption = function (oid)
{
	if (this.objectSelected(oid))
	{
		this.deselectObject(oid);
		this.hideObject(oid + "_content");
	}
	else
	{
		this.selectObject(oid);
		this.showObject(oid + "_content");
	}
}

Helper.prototype.drawOption = function (oid)
{
	this.deselectAllSiblings(oid);
	this.selectObject(oid);
	this.showObject(oid + "_content");

  // hack
  this.setNextTo(oid);
}

Helper.prototype.clearOption = function (oid)
{
	this.deselectObject(oid);
	this.hideObject(oid + "_content");

  // hack
  this.unsetNextTo(oid);
}

Helper.prototype.sections = ['consulting_practice', 'software_solutions', 'professionals', 'seminars_publications', 'corporate_equality'];
Helper.prototype.setNextTo = function (oid)
{
	if (typeof oid != "string")
	{
    if (oid.id) { oid = oid.id; }
    else { oid = ''; }
	}

  for (var i = 0; i < this.sections.length; i++)
  {
    if (i + 1 == this.sections.length) { break; }
    else if (this.sections[i] == oid)
    {
      var o = this.getObject(this.sections[i + 1]);
      if (o && o.className != null)
      {
        o.className += " next_to";
      }
    }
  }
}

Helper.prototype.unsetNextTo = function (oid)
{
	if (typeof oid != "string")
	{
    if (oid.id) { oid = oid.id; }
    else { oid = ''; }
	}

  for (var i = 0; i < this.sections.length; i++)
  {
    if (i + 1 == this.sections.length) { break; }
    else if (this.sections[i] == oid)
    {
      var o = this.getObject(this.sections[i + 1]);
      if (o && o.className != null)
      {
        o.className = o.className.replace(/next_to/g, '');
      }
    }
  }
}

Helper.prototype.trace = function (msg)
{
	if (this.debug)
	{
		this.dw.innerHTML += "<div class=\"debug_message\">" + msg + "</div>\n";
	}
}

Helper.prototype.deselectAllSiblings = function (oid)
{
	var o = this.getObject(oid);
	var siblings = o.parentNode.childNodes; 
	for (var i = 0; i < siblings.length; i++)
	{
		var s = siblings[i];
		this.deselectObject(s);
	}
}

Helper.prototype.getElementsByStyleClass = function (className)
{
	var all = document.all ? document.all : document.getElementsByTagName('*');
	var elements = [];
	for (var i = 0; i < all.length; i++)
	{
		var tagClass = all[i].className;
		var index = tagClass.indexOf(className, 0);
		if (index != -1)
		{
			if (index > 0)  // className isn't the first part of the string
			{
				if (tagClass.charAt(index - 1) == ' ')
				{
					elements.push(all[i]);
				}
			}
			else if (tagClass.length > className.length)  // there's more to the string
			{
				if (tagClass.charAt(className.length) == ' ')
				{
					elements.push(all[i]);
				}
			}
			else  // exact match
			{
				elements.push(all[i]);
			}
		}
	}

	return elements;
}

var h;

// cleans up some of the HTML by automating the onmouseover and onmouseout events for the main menu
window.onload = function ()
{
	h = new Helper(true);

	// set up event handling on all sub navigational options
	var sub_navs = h.getElementsByStyleClass('sub_nav');
	for (var i = 0; i < sub_navs.length; i++)
	{
		var sub_nav_options = sub_navs[i].childNodes;

		for (var j = 0; j < sub_nav_options.length; j++)
		{
			var sub_nav_option = sub_nav_options[j];

			if (sub_nav_option.className != "separator")
			{
				sub_nav_option.onmouseover = function () { h.deselectAllSiblings(this); h.selectObject(this); };
				sub_nav_option.onmouseout = function () { h.deselectObject(this); };
			}
		}
	}
}


