function closewindow()
{
	if( window.opener )
	{
		window.opener.focus();
		window.close();
	}
}

function openwindow( url, wleft, wtop, wwidth, wheight, wname, wprop )
{
	if( wheight > screen.availHeight-75 || wheight == 0 )
		wheight = screen.availHeight-75;
	if( wwidth > screen.availWidth || wwidth == 0 )
		wwidth = screen.availWidth;
	
	if( wleft < 0 )
		wleft = screen.availWidth - wwidth + wleft + 1;
	if( wtop < 0 )
		wtop = screen.availHeight - 75 - wheight + wtop + 1;
	
	wprop = wprop + (wprop.length>0?',':'')
				+'width='+wwidth+',height='+wheight+',left='+wleft+',top='+wtop+',screenX='+wleft+',screenY='+wtop+'';
	wnd = open(url, wname, wprop);
	return wnd;
}

// Accepts a variable number of arguments, in triplets as follows:
// arg 1: object ( use findObj for get it )
// arg 2: 'hide' or 'show'
// repeat...
//
// Example: showHideLayers(Layer1,'show',Layer2,'hide');
function showhideLayers()
{ 
	var i, visStr, obj, args = showhideLayers.arguments;
	for (i=0; i<(args.length-1); i+=2)
	{
		obj = args[i];
		visStr = args[i+1];
		if (obj.style)
		{
			obj = obj.style;
			if(visStr == 'show') visStr = 'visible';
			else if(visStr == 'hide') visStr = 'hidden';
		}
		obj.visibility = visStr;
	}
}

// Example: obj = findObj("image1");
function findObj(theObj, theDoc)
{
  var p, i, foundObj;
  
  if(!theDoc) theDoc = document;
  if( (p = theObj.indexOf("?")) > 0 && parent.frames.length)
  {
    theDoc = parent.frames[theObj.substring(p+1)].document;
    theObj = theObj.substring(0,p);
  }
  if(!(foundObj = theDoc[theObj]) && theDoc.all) foundObj = theDoc.all[theObj];
  for (i=0; !foundObj && i < theDoc.forms.length; i++) 
    foundObj = theDoc.forms[i][theObj];
  for(i=0; !foundObj && theDoc.layers && i < theDoc.layers.length; i++) 
    foundObj = findObj(theObj,theDoc.layers[i].document);
  if(!foundObj && document.getElementById) foundObj = document.getElementById(theObj);
  
  return foundObj;
}


// arg 1: object ( use findObj for get it )
// arg 2: X coord - use null for don't change X
// arg 3: Y coord - use null for don't change Y
//
// Example: moveLayerTo( Layer1, 50, 200);
function moveLayerTo( obj, x, y )
{

  if (document.all)//IE
  {
		if( x != null )
      obj.style.pixelLeft = x;
		if( y != null )
      obj.style.pixelTop = y;
	}
	else if (document.layers)  //NS
	{
		if( x != null )
      obj.left = x;
		if( y != null )
      obj.top = y;
	}
	else if ( document.getElementById )
	{
		if( x != null )
      obj.style.left = x + 'px';
		if( y != null )
      obj.style.top = y + 'px';
  }

}

function getObjPos( obj )
{
	if ( document.layers )  //NS
	{
		x = obj.pageX;
		y = obj.pageY;
  }
  else
  { //other browsers
    x=0; y=0; var temp;

    if(obj.offsetParent)
    {
      temp = obj;
      while(temp.offsetParent)
      { //Looping parent elements to get the offset of them as well
        temp=temp.offsetParent; 
        x+=temp.offsetLeft;
        y+=temp.offsetTop;
      }
    }
    x+=obj.offsetLeft;
    y+=obj.offsetTop;
  }
  //Returning the x and y as an array
  return [x,y];
}

function dispEMAddr(user, host)
{
	var symb = '@';
	document.write('<a href="mail'+''+'to:'+user+symb+host+'">'+user+symb+host+'</a>');
}

// xOpacity r1, Copyright 2006-2007 Michael Foster (Cross-Browser.com)
// Part of X, a Cross-Browser Javascript Library, Distributed under the terms of the GNU LGPL

function xOpacity(e, o)
{
  var set = typeof(o)==='undefined' ? false : true;
  //  if (set && o == 1) o = .9999; // FF1.0.2 but not needed in 1.5
  if (typeof(e)==='string')
  {
	  if(!(e=document.getElementById(e))) return 2; // error
	}
  if (typeof(e.style.opacity)==='string') { // CSS3
    if (set) e.style.opacity = o + '';
    else o = parseFloat(e.style.opacity);
  }
	else if (typeof(e.style.filter)==='string') { // IE5.5+
    if (set)
    {
			e.style.zoom = '1';
			e.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(Opacity=' + (100 * o) + ')';
			e.style["-ms-filter"] = 'progid:DXImageTransform.Microsoft.Alpha(Opacity=' + (100 * o) + ')';
			e.style.filter = 'alpha(opacity=' + (100 * o) + ')';
    }
    else if (e.filters && e.filters.alpha) { o = e.filters.alpha.opacity / 100; }
  }
  else if (typeof(e.style.MozOpacity)==='string') { // Gecko before CSS3 support
    if (set) e.style.MozOpacity = o + '';
    else o = parseFloat(e.style.MozOpacity);
  }
  else if (typeof(e.style.KhtmlOpacity)==='string') { // Konquerer and Safari
    if (set) e.style.KhtmlOpacity = o + '';
    else o = parseFloat(e.style.KhtmlOpacity);
  }
  return isNaN(o) ? 1 : o; // if NaN, should this return an error instead of 1?
}
