/**
 * @author User
 */

var minPageWidth = 940;
var minPageHeight = 550;
//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 + ")";
}


function opacity( id, opacStart, opacEnd, millisec)
{
	//alert('hej')
	
	//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++;
        }
    }
}



function centerElement(elementID, elementHeight, elementWidth, addTop, addLeft)
{
	var winH, winW;
	var object = document.getElementById(elementID).style;
	
	if (parseInt(navigator.appVersion)>3) 
	{
		if (navigator.appName=="Netscape") 
		{
			winH = window.innerHeight;
			winW = window.innerWidth;
		}
		if (navigator.appName.indexOf("Microsoft")!=-1) 
		{
			winH = document.documentElement.clientHeight;
			winW = document.documentElement.clientWidth;
		}
	}

	if (elementHeight)
	{
		if( winH < minPageHeight )
			winH = minPageHeight;
		var topValue = ( (winH-elementHeight)/2 ) + addTop +'px';
		
		object.top = topValue;
	}
	
	if (elementWidth)
	{
		if( winW < minPageWidth )
			winW = minPageWidth;

		object.left= ( (winW-elementWidth)/2 ) + addLeft +'px';
	}
	
}

function scalePagewrapper()
{
	var winH, winW;
		
	if (parseInt(navigator.appVersion)>3) 
	{
		if (navigator.appName=="Netscape") 
		{
			winH = window.innerHeight;
			winW = window.innerWidth;
		}
		if (navigator.appName.indexOf("Microsoft")!=-1) 
		{
			winH = document.documentElement.clientHeight;
			winW = document.documentElement.clientWidth;
		}
	}
	
	
	if (winH < minPageHeight)
		{
			var numH = (minPageHeight/winH)*100;
			document.getElementById('pagewrapper').style.height = numH + '%'
		}
	else document.getElementById('pagewrapper').style.height = '100%'
	
	if (winW < minPageWidth)
		{
			var numW = (minPageWidth/winW)*100;
			document.getElementById('pagewrapper').style.width = numW + '%'
		}
	else document.getElementById('pagewrapper').style.width = '100%'
}

function gradient(gradientHeight, gradientDirection, gradientColor)
{
	var opacityChangePerLine = (100/gradientHeight);
	
	for(i = 0; i < gradientHeight; i++)
	{
		var opacityThisLine = opacityChangePerLine*i;
		
		document.write("<div style='position:absolute;" + gradientDirection + ":" + i + "px;height:1px; width:100%;background-color:#" + gradientColor + ";opacity:" + opacityThisLine/100 + ";filter:alpha(opacity=" + opacityThisLine + ");'> </div>");
		
			
	}
	
	
}
