function $(e){if(typeof e=="string")e=document.getElementById(e);return e};
function hide(o){ o.style.display = 'none'; }
function show(o, withFade ){
	if ( typeof(withFade) != 'undefined' && withFade == true ){
		o.style.zoom = 1; //to make layout ( alpha filter don't work without layout in IE)
		setOpacity(o.id, 0 ); //initial opacity to transparrent
	   	o.style.display = 'block';
	   	appear(o.id);
   	} else{
		o.style.display = 'block';
		o.style.visibility = '';
	}
}



//
// getPageScroll()
// Returns array with x,y page scroll values.
// Core code from - quirksmode.org
//
function getPageScroll(){

	var yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
	}

	arrayPageScroll = new Array('',yScroll)
	return arrayPageScroll;
}



//
// getPageSize()
// Returns array with page width, height and window width, height
// Core code from - quirksmode.org
// Edit for Firefox by pHaez
//
function getPageSize(){

	var xScroll, yScroll;

	if (window.innerHeight && window.scrollMaxY) {
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}

	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}

	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else {
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}


	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight)
	return arrayPageSize;
}


function showLightBoxWithSize( contentID, width,height )
{
	if ( $("lightbox-content") == null )
	{
	    var newElement = document.createElement('div');	
	    newElement.id = "lightbox-content";
	    document.body.appendChild( newElement );
        }
	if ( $("lightbox-overlay") == null )
	{
	     var newElement1 = document.createElement('div');
	     newElement1.id = "lightbox-overlay";
	     newElement1['class'] = "iePNG";
	     document.body.appendChild( newElement1 );
        }
/* <div id="login-form-lbox">
</div>
<div id="overlay" class="iePNG">
</div>*/

	var objOverlay = document.getElementById('lightbox-overlay');
	var arrayPageSize = getPageSize();
	var arrayPageScroll = getPageScroll();

	// set height of Overlay to take up whole page and show
	objOverlay.style.height = (arrayPageSize[1] + 'px');
        show($('lightbox-overlay'),false);
        //objOverlay.style.display = 'block';
        var boxSizeWidth = width;
        var boxSizeHeight = height;
	var lightboxTop = arrayPageScroll[1] + ((arrayPageSize[3] - 35 - boxSizeHeight) / 2);
	var lightboxLeft = ((arrayPageSize[0] - 20 - boxSizeWidth) / 2);

	var objLightbox = document.getElementById('lightbox-content');
        objLightbox.innerHTML = $(contentID).innerHTML;
        $(contentID).innerHTML = '';
	objLightbox.style.top = (lightboxTop < 0) ? "0px" : lightboxTop + "px";
	objLightbox.style.left = (lightboxLeft < 0) ? "0px" : lightboxLeft + "px";
	objLightbox.style.width = boxSizeWidth + 'px' ;
        show($('lightbox-content'),false);
}




function hideLoginBox()
{
        hide($('lightbox-overlay'));
        hide($('lightbox-content'));
}
function hideLightBox( contentID )
{
        hide($('lightbox-overlay'));
        hide($('lightbox-content'));
        $(contentID).innerHTML = $('lightbox-content').innerHTML;
}

function fixPNG(element)
{
  if (/MSIE (5\.5|6).+Win/.test(navigator.userAgent))
  {
    var src;
    if (element.tagName=='IMG')
    {
      if (/\.png$/.test(element.src))
      {
        src = element.src;
        element.src = "/blank.gif";
      }
    }
    else
    {
      src = element.currentStyle.backgroundImage.match(/url\("(.+\.png)"\)/i);
      if (src)
      {
        src = src[1];
        element.runtimeStyle.backgroundImage="none";
      }
    }
    if (src)
    {
        element.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "',sizingMethod='scale')";
    }


  }

}
