﻿//start image resizing. 

function ShowUp(img, isTrue) 
{
	//doLog("ShowUp");
}

var ImgControl;
var ctrl;
var sTheURL;
var iImgWidth;
var iImgHeight;	
var bDone = false;
var sName = "ctl00_ctl00_ctl00_ContentPlaceHolder1_cp1b_";

function ShowThisPic()
{
    var sURL = document.getElementById(sName + "hdnPic").value;
    
    ImgControl = document.getElementById(sName + "imgClick");
	ImgControl.className = "hide";
    var currentTime = new Date()
    var t = currentTime.getTime();
	if (sURL != "")
	{	
		img = new Image();
		img.id = "imgTest";
		sTheURL = sURL + "?" + t;  //firefox won't show pic on refresh of browser unless new pic has a different scr.
		
		//img.onload Needed for firefox, but not ie:  http://www.codingforums.com/showthread.php?t=76568
		var somethingIsTrue = true;		
		img.onload = (function(bool){
		return function(){ShowUp(this, bool);}
		})(somethingIsTrue);
		
			
		img.src = sTheURL;	
		iImgWidth = img.width;
		iImgHeight = img.height;
		for(var i = 0; i < 10; i++)
		{
		    if (iImgWidth == 0 || iImgHeight == 0)
		    {    
		        setTimeout("unhidePic('" + i + "')", 500);
		    }
		}
	}
}
	
function unhidePic(i)
{    
    iImgWidth = img.width;
    iImgHeight = img.height;
    //document.getElementById('TextBox1').value = document.getElementById('TextBox1').value + "\nwidth Before Done unhidePic: " + iImgWidth + " case: " + i;
    //document.getElementById('TextBox1').value = document.getElementById('TextBox1').value + "\nNotDone";
    if (iImgWidth > 0 && iImgHeight > 0 && bDone == false) 
    {
        //document.getElementById('TextBox1').value = document.getElementById('TextBox1').value + "\n DONE";
        //document.getElementById('TextBox1').value = document.getElementById('TextBox1').value + "\nwidth Done unhidePic: " + iImgWidth + " case: " + i;
        bDone = true;
        imgResize();
        ctrl = document.getElementById(sName + "imgClick");
        ctrl.src = sTheURL;
        ctrl.width = iImgWidth;
        ctrl.height = iImgHeight;	
        //ctrl.className = "show"; 
    
        ImgControl.className = "show";	
    
        ctrl = document.getElementById(sName + "pnlPicCenter");
        ctrl.className = "pnlPicCenter"; 
        ctrl = document.getElementById(sName + "pnlPicBtn");
        ctrl.className = "pnlPicCenter"; 
    }
}    

function imgResize()
{	
    //var iWidest = 110;
    //var iHighest = 125;
    var iHighest = 150;
    var iWidest = 150;
	if(iImgWidth > iWidest)
	{		
		var iProportion = iImgHeight/iImgWidth;
		iImgWidth = iWidest;
		iImgHeight = iProportion * iImgWidth;
	}
	if(iImgHeight > iHighest)
	{		
		var iProportion = iImgHeight/iImgWidth;
		iImgHeight = iHighest;
		iImgWidth = iImgHeight / iProportion;
	}			
}			

//end image resizing. 


//to resize the frame heights
function resizeFrames()
{

    var is_ie = (navigator.userAgent.indexOf("MSIE") >= 0) ? 1 : 0;
    if (window.parent.document.getElementById('showPrice'))
    var h;
    {
//        h = document.body.scrollHeight;           
//        if (is_ie != 1)
//        {
//            h = window.parent.document.body.scrollHeight;
//            if (h > 750) {h = 750;}
//        }
//        window.parent.document.getElementById('showPrice').height = h + "px";       
    }
    
//window.parent.document.getElementById('TextBox1').height = 800 + "px";

if (document.getElementById('TextBox1'))
{
    document.getElementById('TextBox1').value = "window.parent.document.getElementById('showPrice').scrollHeight = " + window.parent.document.getElementById('showPrice').scrollHeight;
}
    
}

function LoadBody()
{  
    ShowThisPic();
}
