var strGif = "transparentpixel.gif"
var strFilter = "progid:DXImageTransform.Microsoft.AlphaImageLoader"
var arVersion = navigator.appVersion.split("MSIE")
var version = parseFloat(arVersion[1])

function makeTransparentPNG(oDiv)
{
	if ((version >= 5.5) && (document.body.filters)) 
	{
		var arrImages = oDiv.getElementsByTagName("img");
		for(var i=0; i<arrImages.length; i++)
		{
		   var img = arrImages[i]
		   var imgName = img.src.toUpperCase()
		   if (imgName.substring(imgName.length-3, imgName.length) == "PNG")
		   {
			  var imgID = (img.id) ? "id='" + img.id + "' " : ""
			  var imgClass = (img.className) ? "class='" + img.className + "' " : ""
			  var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
			  var imgStyle = "display:inline-block;" + img.style.cssText 
			  if (img.align == "left") imgStyle = "float:left;" + imgStyle
			  if (img.align == "right") imgStyle = "float:right;" + imgStyle
			  if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
			  if (img.useMap)
			  {  
				 strAddMap = "<img style=\"position:relative; left:-" + img.width + "px;"
				 + "height:" + img.height + "px;width:" + img.width +"\" "
				 + "src=\"" + strGif + "\" usemap=\"" + img.useMap 
				 + "\" border=\"" + img.border + "\">"
			  }
			  var strNewHTML = "<span " + imgID + imgClass + imgTitle
			  + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
			  + "filter:" + strFilter
			  + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>" 
			  if (img.useMap) strNewHTML += strAddMap
			  img.outerHTML = strNewHTML
			  i = i-1
		   }
		}
	
	}
}


//
// 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 initSplash()
{	
	var oDivSplashWrap = document.getElementById("splashOuterWrap");
	makeTransparentPNG(oDivSplashWrap)

	var oDivTransparent = document.getElementById("transparent");
	if (oDivTransparent)
	{
		var arrPageSize = getPageSize();
		oDivTransparent.style.height = arrayPageSize[1] +"px";
		//Now do workaround for selects in IE
		if (oDivTransparent.insertAdjacentHTML )
		{
			oDivTransparent.insertAdjacentHTML("beforeBegin","<iframe id=\"ifrmShim\"  src=\"javascript:void(0);\"  scrolling=\"no\" frameborder=\"0\"  style=\"position:absolute; border: 1px solid black; top:0px; left:0px; display:none;\"> </iframe>")
			var ifrmShim = document.getElementById("ifrmShim");
			ifrmShim.style.width = oDivTransparent.offsetWidth;
			ifrmShim.style.height = oDivTransparent.offsetHeight;
			//ifrmShim.style.top = oDivTransparent.style.top;
			//ifrmShim.style.left = oDivTransparent.style.left;
			ifrmShim.style.zIndex = 79;
			//ifrmShim.style.zIndex = oDivTransparent.style.zIndex - 1;
			//alert(ifrmShim.style.zIndex );
			ifrmShim.style.display = "block";
			ifrmShim.style.filter='progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)';
			
		}
	}
	
	if (fnOldOnload!=null)fnOldOnload();
}

function closeSplash()
{
	var oDivSplashWrap = document.getElementById("splashOuterWrap");
	oDivSplashWrap.style.display = "none";
			
}

var fnOldOnload;
if (window.attachEvent)
	{
		window.attachEvent('onload', initSplash);
   }
else if (window.addEventListener)
	{
		window.addEventListener('load', initSplash, false);
	}
else
	{
		fnOldOnload = window.onload;
		window.onload = initSplash;		
	}