function Reference(image, useoriginal)
{
	if(useoriginal)
		subimage=image;
	else
		subimage=image.substring(0,image.length-10)+".jpg";
	document.open();
	document.write("<body bgcolor='#000'>");
	document.write("<p align='center'><a href='/'><img src='/img/TopBar.gif' border='0'></a></p>");
	document.write("<p align='center'><img src="+subimage+">");
	document.write("<br/><br/><font face='Verdana'><a href='javascript:history.back(-1);' style='color:#fff'>Tilbage til oversigten</a>")
	document.write("</font></p>");
	document.write("</body>");
	document.close();
}

function ChangeBgColor(id, cl, cl1, cl2)
{
	if(cl == cl1)
		cl=cl2;
	else
		cl=cl1;
	document.getElementById(id).style.backgroundColor = cl;
	setTimeout("ChangeBgColor('" + id + "','" + cl + "','" + cl1 + "','" + cl2 + "')", 500);
}

function ChangeFontColor(id, cl, cl1, cl2)
{
	if(cl == cl1)
		cl=cl2;
	else
		cl=cl1;
	document.getElementById(id).style.color = cl;
	setTimeout("ChangeFontColor('" + id + "','" + cl + "','" + cl1 + "','" + cl2 + "')", 500);
}

function FlashElementColor(id, cl, cl1, cl2)
{
    var secColor;
	if(cl == cl1)
	{
		cl = cl2;
		secColor = cl1;
    }
	else
	{
		cl = cl1;
		secColor = cl2;
    }
	document.getElementById(id).style.backgroundColor = cl;
	document.getElementById(id).style.color = secColor;
	var seed = new Date().getSeconds();
    var randomPause = Math.floor(Math.random(seed)*500);
	setTimeout("FlashElementColor('" + id + "','" + cl + "','" + cl1 + "','" + cl2 + "')", randomPause);
}

function ChangeColor(classname, cl1, cl2, cl, index)
{
	cl = (cl==cl1)?cl2:cl1;

	var index = addCSSRule(classname, "color:" + cl, index);
	setTimeout("ChangeColor('" + classname + "','" + cl1 + "','" + cl2 + "','" + cl + "'," + index + ")", 1000);
}

/*
var mysheet=document.styleSheets[0];
var myrules=mysheet.cssRules? mysheet.cssRules: mysheet.rules;
for (i=0; i<myrules.length; i++)
{
	alert(myrules[i].selectorText);
	if(myrules[i].selectorText.toLowerCase()==".box1")
	{ //find "box1" rule
		targetrule=myrules[i];
		break;
	}
}
*/

function addCSSRule(selectorText, declarations, ruleindex)
{
	var styleSheet;
	if (document.styleSheets)
	{
		if (document.styleSheets.length === 0)
		{
			var styleElement;
			if (document.createElement && (styleElement = document.createElement('style')))
			{
				styleElement.type = 'text/css';
				document.getElementsByTagName('head')[0].appendChild(styleElement);
				styleSheet = styleElement.sheet;
			}
		}
		
		
		if (document.styleSheets.length > 0)
		{
			styleSheet = document.styleSheets[document.styleSheets.length - 1];
			
			// Clean up rule
			if(ruleindex != null)
			{
				if( styleSheet.deleteRule )
				{
					styleSheet.deleteRule(ruleindex);
				} 
				else if( styleSheet.removeRule )
				{
					styleSheet.removeRule(ruleindex);
				}
			}
			
			var index;
			if (styleSheet.insertRule)
			{
				index = styleSheet.cssRules.length;
				styleSheet.insertRule(selectorText + ' { ' + declarations + ' }', index);
			}
			else if (styleSheet.addRule)
			{
				index = styleSheet.rules.length;
				styleSheet.addRule(selectorText, declarations);
			}
			return index;
		}
	}
}
