// correctly handle PNG transparency in Win IE 5.5 & 6.
function correctPNG()
{
   var arVersion = navigator.appVersion.split("MSIE")
   var version = parseFloat(arVersion[1])
   if ((version >= 5.5) && (version < 7.0) && (document.body.filters))
   {
      for(var i=0; i<document.images.length; i++)
      {
         var img = document.images[i]
         var imgName = img.src.toUpperCase()
         if (imgName.substring(imgName.length-3, imgName.length) == "PNG" && img.className && img.className.indexOf("png-image") != -1)
         {
            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
            var strNewHTML = "<span " + imgID + imgClass + imgTitle
            + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
            + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
            + "(src=\'" + img.src + "\', sizingMethod='scale');\"></span>"
            img.outerHTML = strNewHTML
            i = i-1
         }
      }
   }
}

function selectValue(invForm,selectName,setValue,optionProperty)
{
  var options = document.forms[invForm][selectName].options;
  for(var i = 0; i < options.length; i++)
  {
    var optionValue = options[i][optionProperty];
    if(optionValue == setValue)
    {
      document.forms[invForm][selectName].selectedIndex = i;
      return true;
    }
  }
  return false;
}

/**
 * Returns an object for current page dimension, that includes height and width of the page.
 */
function getPageDimensions()
{
    var pageHeight;
    var pageWidth;

	if (window.innerHeight && window.scrollMaxY) // For Firefox
	{
		pageHeight = window.innerHeight + window.scrollMaxY;
		pageWidth = window.innerWidth + window.scrollMaxX;
	}
	else if (document.body.scrollHeight > document.body.offsetHeight) // For all but Explorer Mac
	{
		pageHeight = document.body.scrollHeight;
		pageWidth = document.body.scrollWidth;
	}  // For Explorer 6 Strict, Mozilla (not FF) and Safari
	else
	{
		pageHeight = document.body.offsetHeight;
		pageWidth = document.body.offsetWidth;
  	}

	return { height: pageHeight, width: pageWidth };
}

/** 
 * To change the class of iframe container div(page-core-container) to custom-html-page-core-container(of width 966px), if the included iFrame is of width 966px;. 
 */
function setCustomHTMLContainerWidth(){
  var customPageContainer = document.getElementById('page-core-container');
  for(var i=0; i<customPageContainer.childNodes.length;i++){
    if(customPageContainer.childNodes[i].tagName=='IFRAME' & customPageContainer.childNodes[i].offsetWidth=="966"){
      customPageContainer.className = "custom-html-page-core-container";
      break;
    }
  }
}
