homeTest = 1; /* indicates homepage for Home link in NavAcct Links header area */

function showMaterial(material, lnk)
{
	document.getElementById('matContentWhite').style.display = 'none';
	document.getElementById('matContentClear').style.display = 'none';
	document.getElementById('matContentColor').style.display = 'none';
	document.getElementById('matContentMetallic').style.display = 'none';
	document.getElementById('matContentWP').style.display = 'none';
	document.getElementById('matContentCardstock').style.display = 'none';



	var div = document.getElementById('matWrapper');

	div.style.left = FindPosX(lnk) + 100 + 'px'; /* sets X pos 8 */

	if (FindPosY(lnk) > FindWindowMiddle()+getScrollY() ) { /* sets Y pos based on scroll POS */
		div.style.top = FindPosY(lnk) - 200 + 'px';
	}
	else {
		div.style.top = FindPosY(lnk) + 25 + 'px';
	}
	

	document.getElementById('matWrapper').style.display = 'block';  //displays material popup
	document.getElementById('matContent' + material).style.display = 'block'; //toggles the actual content of the material popup material parameter
}

function hideMaterial()
{
	document.getElementById('matWrapper').style.display = 'none';  
}

var delay = 250;
var timeoutId;

function ShowSize(product, lnk)
{
    document.getElementById('imgSize').src = 'images/thumbnails/' + product + '.gif';
    
    var div = document.getElementById('sizePopup');
    var divContainer = document.getElementById('divProductContainer');
    
    div.style.left = FindPosX(lnk) + 110 + 'px';
    div.style.top = FindPosY(lnk) - divContainer.scrollTop - 42 + 'px';
    
    timeoutId = setTimeout(ShowSizePopup, delay);
}

function ShowSizePopup()
{
    document.getElementById('sizePopup').style.display = 'block';    
    clearTimeout(timeoutId);
}

function HideSize()
{
    document.getElementById('sizePopup').style.display = 'none';
    clearTimeout(timeoutId);
}


function ShowUses(image, lnk)
{
    document.getElementById('imgUses').src = 'images/browser/' + image;
    
    var div = document.getElementById('usesPopup');
    div.style.left = FindPosX(lnk) - 138 + 'px';
    div.style.top = FindPosY(lnk) - 35 + 'px';
    
    timeoutId = setTimeout(ShowUsesPopup, delay);
}

function ShowUsesPopup()
{
    document.getElementById('usesPopup').style.display = 'block';    
    clearTimeout(timeoutId);
}

function HideUses()
{
    document.getElementById('usesPopup').style.display = 'none';
    clearTimeout(timeoutId);
}


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 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 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;
}

//included here for Price calculator popup
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');
}

//toggles main popup for default v9.2.0
function openPopUpAd(){
	document.getElementById("adPopUpBG").style.display = "block";
}

function closePopUpAd(){
	document.getElementById("adPopUpBG").style.display = "none";
}
