function SetStyleSheetSub(print, highres, medres, lowres) {
	if (document.getElementsByTagName)
		{x = document.getElementsByTagName('link');}
	else if (document.all)
		{x = document.all.tags('link');}
	else {alert("Your browser has only partial support for Javascript. This page may not render correctly");}
	x[0].disabled=print;
	x[1].disabled=highres;
	x[2].disabled=medres;
	x[3].disabled=lowres;
}

function SetStyleSheet() {
	if (screen.width) {
		if (screen.width >=800 && screen.width < 1024) {SetStyleSheetSub(true, true, true, false);}
		if (screen.width >= 1024 && screen.width < 1280) {SetStyleSheetSub(true, true, false, true);}
		if (screen.width >= 1280) {SetStyleSheetSub(true, false, true, true);}
		if (screen.width < 800) {SetStyleSheetSub(false, true, true, true);}
	}
	else {SetStyleSheetSub(false, true, true, true);}
}

function InsertLogo() {
	var headtopDiv = document.getElementById("headtop");
	document.getElementsByTagName("h1")[0].style.marginLeft = "-5000px";
	document.getElementsByTagName("h2")[0].style.marginLeft = "-5000px";
	
	if (screen.width < 1024) {
		headtopDiv.style.backgroundImage = "url('images/cgcslogo1.gif')";
		headtopDiv.style.backgroundPosition = "40px";
	}
	
	if (screen.width >= 1024 && screen.width < 1280) {
		headtopDiv.style.backgroundImage = "url('images/cgcslogo2.gif')";
		headtopDiv.style.backgroundPosition = "55px";
	}
	
	if (screen.width >= 1280) {
		headtopDiv.style.backgroundImage = "url('images/cgcslogo3.gif')";
		headtopDiv.style.backgroundPosition = "80px";
	}
}

function DisplayPrinterFriendly() {
	SetStyleSheetSub(false, true, true, true);
	document.getElementById("headtop").style.backgroundImage = "none";
	document.getElementsByTagName("h1")[0].style.marginLeft=0;
	document.getElementsByTagName("h2")[0].style.marginLeft=0;
	document.getElementById("navholder").style.display="none";
}

function ResizeImages() {
	
	if (document.getElementById("content"))
	{
		var classElements = new Array();
		classElements = GetContentImages(document.getElementById("content"));
		for (i = 0; i < classElements.length; i++)
			{
				var thisImage = classElements[i];
				if (screen.width >= 1024 && screen.width < 1280) 
				{
					thisImage.src = thisImage.src.replace(new RegExp("&screenwidth=800"), "&screenwidth=1024");
				}
				if (screen.width >= 1280) 
				{
					thisImage.src = thisImage.src.replace(new RegExp("&screenwidth=800"), "&screenwidth=1280");
				}
			} 
	}
}


function GetContentImages(node) {
	var classElements = new Array();
	var els = new Array();
	var searchClass = "autosize";
	els = node.getElementsByTagName("img");
	var elsLen = els.length;
	var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
	for (i = 0, j = 0; i < elsLen; i++) {
		if ( pattern.test(els[i].className) ) {
			classElements[j] = els[i];
			j++;
		}
	}
	return classElements;
}

	
function InitialisePage()
{
	ResizeImages();
}

SetStyleSheet(); 
window.onload = InitialisePage;
