// 
//
// prefix by leh_
//
// functions:
// getHtmlDataFromText(strTheHtml)
// displayContents()

function leh_getHtmlDataFromText(strTheHtml)
{
    var e;
    
    try
    {
        strTheHtml = strTheHtml.replace(/&quot;/g,'"');
        strTheHtml = strTheHtml.replace(/&lt;/g,'<');
        strTheHtml = strTheHtml.replace(/&gt;/g,'>');
        
    }
    catch (e)
    {
        alert(e.message);
    }
    
    return strTheHtml;
}

function leh_rescaleImagesForCorrectResolution(strTheHtml)
{
	var dblResChange = screen.height/1024;	

	if (dblResChange == 1) {return strTheHtml;}

	var arrHeightWidth = new Array("height:","width:");
	var dblHeightOrWidth;

	for (var i=0; i<arrHeightWidth.length; ++i)
	{
		var intIndex = strTheHtml.indexOf(arrHeightWidth[i]);
	
		if (intIndex !=-1)
		{		
			var intLen = arrHeightWidth[i].length;

			intSemiColonStop = (strTheHtml.substring(intIndex+intLen)).indexOf(";");
			if (intSemiColonStop > 0)
			{
				dblHeightOrWidth = strTheHtml.substring(intIndex+intLen, intIndex+intSemiColonStop + intLen);
				dblHeightOrWidth = dblHeightOrWidth * dblResChange;

				if (i==0)
				{
					strTheHtml = strTheHtml.substring(0, intIndex + intLen) + dblHeightOrWidth + strTheHtml.substring(intIndex+intSemiColonStop+intLen);
				}
				else //check now for other heights and widths later:
				{
					strTheHtml = strTheHtml.substring(0, intIndex + intLen) + dblHeightOrWidth + leh_rescaleImagesForCorrectResolution(strTheHtml.substring(intIndex+intSemiColonStop+intLen));
				}
			}
		}
	}

	return strTheHtml;
}

function leh_insertHtml(strDivName, strTaHolder)
{
	var strTheHtml = frames["frameTextHolder"].document.getElementById(strTaHolder).innerHTML;
	var strHtmlToUse = leh_rescaleImagesForCorrectResolution(leh_getHtmlDataFromText(strTheHtml));
	document.getElementById(strDivName).innerHTML = strHtmlToUse;
}

function leh_displayContents()
{
    var e;    

    //leh_insertHtml("divCornerImage", "taHtmlCornerImageContainer");
    leh_insertHtml("divText", "taHtmlTextContainer"); 

    gIntCurrentFrame = 2;	
    gIntervalFadeIn = window.setInterval("fadeIn_timer()",30); 
	
 //   gIntervalFadeInText = window.setInterval("fadeInTextTimer()", 200);
           
}            
