﻿var smallWidth = 47;
var largeWidth = 107;

var smallHeight = 65;
var largeHeight = 147;

var product;
var timeoutId;
var loaded = false;

function Expand(obj, productName)
{
    if (!loaded) return;
    
    product = productName;
    
    document.getElementById('tblExpand').style.height = largeHeight;
    document.getElementById('lnkExpand').href = obj.parentNode.href;
    
    var divExpand = document.getElementById('divExpand');
    divExpand.style.left = FindPosX(obj);
    divExpand.style.top = FindPosY(obj) - largeHeight + smallHeight;
 
    divExpand.style.display = 'block';
    
    var imgExpand = document.getElementById('imgExpand');
 
    // First set it to the current image because we know it's been loaded
    imgExpand.src = obj.src;
    imgExpand.width = smallWidth;
    imgExpand.height = smallHeight;
    
    if (timeoutId)
		clearTimeout(timeoutId);
    
    timeoutId = setTimeout(StartExpand, 300);
}

function StartExpand()
{
    var imgExpand = document.getElementById('imgExpand');
    imgExpand.src = 'proicon/' + product + '_middle.gif';
    imgExpand.width = smallWidth;
    imgExpand.height = smallHeight;
    
    if (timeoutId)
		clearTimeout(timeoutId);
    
    timeoutId = setTimeout(ContinueExpand, 50);
}
 
function ContinueExpand()
{
    var imgExpand = document.getElementById('imgExpand');
    
    if (imgExpand.width < largeWidth)
    {
        imgExpand.width += (largeWidth - smallWidth) * .25;
        imgExpand.height += (largeHeight - smallHeight) * .25;
        
        if (timeoutId)
			clearTimeout(timeoutId);
                
        timeoutId = setTimeout(ContinueExpand, 50);
    }
}
 
function Collapse()
{
    document.getElementById('divExpand').style.display = 'none';
    
    clearTimeout(timeoutId);
}

function FindPosX(obj)
{
    var curleft = 0;
   
    if (obj.offsetParent) {
        while(true) {
            curleft += obj.offsetLeft;
     
            if(!obj.offsetParent)
                break;
               
            obj = obj.offsetParent;
        }
    }
    else if(obj.x) {
        curleft += obj.x;
    }
   
    return curleft;
}

function FindPosY(obj)
{
    var curtop = 0;
   
    if (obj.offsetParent) {
        while(true) {
            curtop += obj.offsetTop;
           
            if (!obj.offsetParent)
                break;
               
            obj = obj.offsetParent;
        }
    }
    else if(obj.y) {
        curtop += obj.y;
    }
   
    return curtop;
}
function FindWindowMiddle()
{
	var winH = 0;
	if (parseInt(navigator.appVersion)>3) {
		if (navigator.appName=="Netscape") {
			winH = window.innerHeight;
		 }
		if (navigator.appName.indexOf("Microsoft")!=-1) {
			winH = document.body.clientHeight;
		}
	}
	return winH /2;
}

function getScrollY()
{
	var scrOfY = 0;
	if( typeof( window.pageYOffset ) == 'number' ) {
		//NS
		scrOfY = window.pageYOffset;
	} 
	else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
		//DOM compliant
		scrOfY = document.body.scrollTop;
	} 
	else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
		//IE6 standards compliant mode
		scrOfY = document.documentElement.scrollTop;
	}
	return scrOfY;
}

function openDetail(page)
{		
	window.open(page,"thisName", "directories=0,height=300,width=325");
}

function displayWindow(url,width,height) 
{
   window.Win = window.open(url,"displayWindow",'width=' + width + ',height=' + height + ',screenX=0,screenY=0,top=0,left=0,resizable,scrollbars,location=0,status=1');
}