﻿var ssImage = null;

function ShowSuperSizeImage()
{
   window.open('/images/super_size/' + ssImage,'SuperSizeImage','toolbar=no,menubar=no,location=no,height=480,width=640,left=100,top=150');
}

function ShowMatInfo(matCode, productName, lnk)
{
    if (typeof (matInfo) == 'undefined') {
        return;
    }

    document.getElementById('MatInfo_Title').innerHTML = matInfo[matCode].title;
    document.getElementById('MatInfo_PopUses').innerHTML = matInfo[matCode].desc;
   
    var divMatInfo = document.getElementById('divMatInfo');

	if (FindPosY(lnk) > FindWindowVertMiddle()+getScrollY() ) {
		divMatInfo.style.top = FindPosY(lnk) - 200 + 'px';
	}
	else {
		divMatInfo.style.top = FindPosY(lnk) + 25 + 'px';
	}

    divMatInfo.style.left = '120px';
    divMatInfo.style.display = 'block';

    ssImage = matInfo[matCode].ssImg;
                            
    document.getElementById('MatInfo_Image').src = '/images/materials/thumb_smaller/' + matInfo[matCode].img;
    document.getElementById('MatInfoArea').onclick = ShowSuperSizeImage;
    document.getElementById('selectMaterial').href = productName;
    
    if (navigator.appName.indexOf('Microsoft') >= 0) {
        var iframeMatInfo = document.getElementById('iframeMatInfo');
        iframeMatInfo.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)';
        iframeMatInfo.style.display = 'block'
        iframeMatInfo.style.height = divMatInfo.offsetHeight;
    }
}

function HideMatInfo()
{
    document.getElementById('divMatInfo').style.display = 'none';
}

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 FindWindowVertMiddle()
{
	var winH = 0;
	if (parseInt(navigator.appVersion)>3) {
		if (navigator.appName=="Netscape") {
			winH = window.innerHeight;
		 }
		if (navigator.appName.indexOf("Microsoft")!=-1) {
			winH = document.documentElement.clientHeight;
		}
	}
	return winH /2;
}


function FindWindowHorizMiddle()
{
	var winH = 0;
	if (parseInt(navigator.appVersion)>3) {
		if (navigator.appName=="Netscape") {
			winH = window.innerWidth;
		 }
		if (navigator.appName.indexOf("Microsoft")!=-1) {
			winH = document.body.clientWidth;
		}
	}
	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;
}

