/* functions for overlay and lightwindow*/

var lightWindow = null;
var overlay = null;
var height = null;
var width = null;

function showLightWindow(id,wHeight,wWidth)
{
	//overlay
	overlay = document.getElementById('overlay');
	overlay.style.display = "block";
	opacity('overlay', 0, 40, 100);	
	
	height = wHeight;
	width = wWidth;
	
	//window
	if (document.getElementById(id) != null)
	{
		lightWindow = document.getElementById(id);
	}
	else
	{
		lightWindow = document.getElementById('adviceFields');
		height = 200;
		width = 400;
	}
		
	lightWindow.style.position = "absolute";
	lightWindow.style.height = height+"px";
	lightWindow.style.width = width+"px";
	
	if(centering != 'no')
	{	
		lightWindow.style.top = (595/2 - height/2)+"px";	
		lightWindow.style.left = (1000/2 - width/2)+"px";
	}
	else
	{
		lightWindow.style.top = (595/2 - height/2)+"px";	
		lightWindow.style.left = (780/2 - width/2)+"px";
		
	}
	setTimeout("lightWindow.style.display = 'block'",600);	
	
	
}

function hideLightWindow()
{			
	lightWindow.style.display = "none";
	if (document.getElementById('lwBigger') != null)
	{
		document.getElementById('lwBigger').value = '';
	}
	opacity('overlay', 70, 0, 100);
	setTimeout("overlay.style.display = 'none'",600);
}


function setLightWindowItems(submitId) 
{
	document.getElementById('submitId').value=submitId;	
	document.getElementById('lwHeight').value=height;	
	document.getElementById('lwWidth').value=width;		
}

function getSubmitId() 
{
	return document.getElementById('submitId').value;	
}

function getLightWindowHeight() 
{		
	if (document.getElementById('lwBigger').value != '')
	{		
		return document.getElementById('lwHeight').value;
	}
	else
	{		
		document.getElementById('lwBigger').value = 'yes';
		return parseInt(document.getElementById('lwHeight').value) + 40;		
	}
			
}

function getLightWindowWidth() 
{
	return document.getElementById('lwWidth').value;	
}


function opacity(id, opacStart, opacEnd, millisec) {
    //speed for each frame
    var speed = Math.round(millisec / 100);
    var timer = 0;   

    //determine the direction for the blending, if start and end are the same nothing happens
    if(opacStart > opacEnd) {
        for(i = opacStart; i >= opacEnd; i--) {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    } else if(opacStart < opacEnd) {
        for(i = opacStart; i <= opacEnd; i++)
            {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    }
}

//change the opacity for different browsers
function changeOpac(opacity, id) {
    var object = document.getElementById(id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
} 







