
function ShowIt(id)
{
	//alert(document.getElementById(id));
	if(document.getElementById(id).style.display == 'none')
		document.getElementById(id).style.display = 'inline';
	else
		document.getElementById(id).style.display = 'none';	
}

function popup(page, wt, ht)
{
	eval('window.open("popups/'+ page + '.html","","height=' + ht + ',width=' + wt + ',status=yes,toolbar=no,menubar=no,location=no")');
	
}

function SetBgColor(obj,color)
{
	//alert(obj)
	if(color.charAt(0) == '#')
	{
		obj.style.backgroundColor = color;
	}
	else
	{
		
		obj.style.backgroundColor = document.getElementById(color).style.backgroundColor;
	}
	
}


function SetColor(color)
{
	var red,green,blue;
	color = color.toUpperCase();
	var coll,obj,x;
	
	//alert(color);
	
	if(color.charAt(0) != '#' || color.length < 7)
	{
		if(color.length == 6 && color.charAt(0) != '#')
		{
			color = '#' + color;
		}
		else
		{
			alert("feil fargekode. Farge skal skrives i formatet '#FFFFFF', hvor alle tegn etter '#' kan være fra 0-9 og A-F");
			color='#FFFFFF';
		}
	}
	
	red = color.charAt(1)+color.charAt(2);
	green = color.charAt(3)+color.charAt(4);
	blue = color.charAt(5)+color.charAt(2);
	
	//body background color
	document.body.style.backgroundColor = color;
	
	//menu color
	
	obj = document.getElementById('menu1');
	obj.style.backgroundColor = colorshift(red, -1, green, -1, blue, -1);
	
	//news article color
	coll = document.getElementsByName('news1');
	for(x=0;x<coll.length;x++)
		coll.item(x).style.backgroundColor = colorshift(red, +1, green, +1, blue, +1);
	
	//menu buttons 
	
	coll = document.getElementsByName('menu_button1')
	for(x=0;x<coll.length;x++)
		coll.item(x).style.backgroundColor = colorshift(red, -1, green, -1, blue, -1);
	
	
	document.getElementById('menubt_source').style.backgroundColor = colorshift(red, -1, green, -1, blue, -1);
	document.getElementById('menubt_selected_source').style.backgroundColor = colorshift(red, +2, green, +1, blue, +1);
	document.getElementById('menu_button_selected1').style.backgroundColor = colorshift(red, +2, green, +1, blue, +1);
	
	//border
	document.getElementById('headertd').style.backgroundColor = colorshift(red, -3, green, -3, blue, -3);
	document.getElementById('annonsertd').style.backgroundColor = colorshift(red, -3, green, -3, blue, -3);
	document.getElementById('menutd').style.backgroundColor = colorshift(red, -3, green, -3, blue, -3);
	
}

function colorshift(rcode, rshift, gcode, gshift, bcode, bshift)
{
	var codearr = "0123456789ABCDEF";
	var red,green,blue, colorcode;
	
	
	if((rcode.charCodeAt(0) + rshift) < 'F'.charCodeAt(0))
	{
		if((rcode.charCodeAt(0) + rshift) < '0'.charCodeAt(0))
			red = '0';
		else
		{
			red = codearr.charAt(MatchArr(rcode.charAt(0),codearr) + rshift);
		}
	}
	else
		red='F';
	red = red+red;
	
	if((gcode.charCodeAt(0) + gshift) < 'F'.charCodeAt(0))
	{
		if((gcode.charCodeAt(0) + gshift) < '0'.charCodeAt(0))
			green = '0';
		else
		{
			green = codearr.charAt(MatchArr(gcode.charAt(0),codearr) + gshift);
		}
	}
	else
		green='F';
	green = green+green;
	
	if((bcode.charCodeAt(0) + bshift) < 'F'.charCodeAt(0))
	{
		if((bcode.charCodeAt(0) + bshift) < '0'.charCodeAt(0))
			blue = '0';
		else
		{
			blue = codearr.charAt(MatchArr(bcode.charAt(0),codearr) + bshift);
		}
	}
	else
		blue='F';
	blue = blue+blue;
	
	colorcode = '#' +red+green+blue;;
	
	return colorcode;
}

function MatchArr(letter, arr)
{
	
	for(x=0;x<arr.length;x++)
	{
		if(arr.charAt(x) == letter)
			return x;
	}
	return -1;
}


/**** NOT USED CODE
var locked = 0;
var mcolor;

function lock(tolock)
{
	locked = tolock;
	if(tolock == 1)
	{
		mcolor = document.getElementById('menu1').style.backgroundColor;
		document.getElementById('menu1').style.backgroundColor = 'gray';
	}
	else if(tolock == 0)
	{
		document.getElementById('menu1').style.backgroundColor = mcolor;
	}
		
}

function move()
{
	var xvar = event.clientX-2+'px';
	var yvar = event.clientY-2+'px';
	if(locked == 1)
	{
		document.getElementById('menu1').style.top = yvar;
		document.getElementById('menu1').style.left = xvar;
		
	}
	
}

*/



