//Changes background color of the element passed as obj argument
function bgCC(obj, color) { //v1.1 by Project VII
	var b;
	if(!obj.style)
	{
		obj = findObj(obj);
	}
	b=(document.layers)?obj:obj.style;
	b.backgroundColor=color
}

//Changes css class
function cCSS(obj, cssClass) { //v1.1 by Project VII
	if(!obj.className)
	{
		obj = findObj(obj);
	}
	obj.className = cssClass;
}

//Locates an object within a page, based on it's ID
function findObj(n, d) 
{
  var p,i,x;  
  if(!d) d=document; 
  if((p=n.indexOf("?"))>0 && parent.frames.length) 
  {
    d=parent.frames[n.substring(p+1)].document; 
    n=n.substring(0,p);
  }
  if(!(x=d[n])&&d.all) x = d.all[n]; 
  for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); 
  return x;
}

//Controls appearance of the flyout menu elements, basically only leaves elements that have been included as arguments visible 
//and hides all other elements previously loaded that have been stored in p7c array.
function autoL() 
{ 
	var g,b,k,f,parent,orientation,args=autoL.arguments;

	if(!document.p7setc) 
	{
		p7c=new Array();
		document.p7setc=true;
	}
	
	for(k = 0; k < p7c.length; k++) 
	{
		if((g=findObj(p7c[k]))!=null) 
		{
			b=(document.layers)?g:g.style;
			b.visibility="hidden";
		}
	}
	
	for(k=0; k<args.length; k++) 
	{
		if((g=findObj(args[k])) != null) 
		{
			b=(document.layers)?g:g.style;
			b.visibility="visible";
			
			f=false;
			for(j=0;j<p7c.length;j++) 
			{
				if(args[k]==p7c[j]) 
				{
					f=true;
				}
			}
			if(!f) 
			{
				p7c[p7c.length++]=args[k];
			}
		}
	}
}

// this function sets a position of an child element related to parent.
function setPosition(parentID, childID, Orientation, offsetVert, offsetHoriz, borderW)
{
	
	//if browser is safari compensate for margins that seem to be ignored
	var mh = (navigator.appVersion.indexOf('Safari')!=-1 ? document.body.marginHeight : 0);
	var mw = (navigator.appVersion.indexOf('Safari')!=-1 ? document.body.marginWidth : 0);
	
	
	var g, h, b;
	if((g=findObj(childID))!=null && (h=findObj(parentID))!=null) 
	{
		b=(document.layers)?g:g.style;
		switch(Orientation)
		{
			//bassed on orientation to the parent set appropriate position for an element
			case 'bottom':
				b.top = DL_GetElementTop(h) + h.offsetHeight - borderW + offsetVert - mh;
				b.left = DL_GetElementLeft(h) - borderW + offsetHoriz - mw;
				break;
			case 'right' :
				b.top = DL_GetElementTop(h) - borderW + offsetVert - mh;
				b.left = DL_GetElementLeft(h) + h.offsetWidth - offsetHoriz - borderW - mw;
				break;
			case 'left' :
				b.top = DL_GetElementTop(h) - borderW + offsetVert - mh;
				b.left = DL_GetElementLeft(h) - h.offsetWidth + offsetHoriz - borderW - mw;
				break;				
		}
	}
}

//Gets position of an element from the left
function DL_GetElementLeft(eElement)
{
	var nLeftPos = eElement.offsetLeft; // initialize var to store calculations
	var eParElement = eElement.offsetParent; // identify first offset parent element
	while (eParElement != null)
	{ // move up through element hierarchy
	nLeftPos += eParElement.offsetLeft; // appending left offset of each parent
	eParElement = eParElement.offsetParent; // until no more offset parents exist
	}
	return nLeftPos; // return the number calculated
}

//Gets position of an element from the top
function DL_GetElementTop(eElement)
{
	var nTopPos = eElement.offsetTop; // initialize var to store calculations
	var eParElement = eElement.offsetParent; // identify first offset parent element
	while (eParElement != null)
	{ // move up through element hierarchy
	nTopPos += eParElement.offsetTop; // appending top offset of each parent
	eParElement = eParElement.offsetParent; // until no more offset parents exist
	}
	return nTopPos; // return the number calculated
}

//Makes elemenent visible
function MakeVisible(elemID)
{
		var g, b;
		if((g=findObj(elemID))!=null) 
		{
			b=(document.layers)?g:g.style;
			b.visibility="visible";
		}
}

//Preloads an array of immages passed trough (usualy hover images)
function preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

//Restores an image that was changed on mouse over
function swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

//Changes an image on mouse over
function swapImage() { //v3.0
  var i,j=0,x,a=swapImage.arguments; 
  document.MM_sr=new Array; 
  for(i=0;i<(a.length-2);i+=3)
   if ((x=findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}