//		********************************************
//		**	Millennium Schools General Functions  **
//	   ****										 ****
//		**	      1999 - Moonshine Design         **
//		********************************************

//																			//J's Handy Comment Column

//** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **> Jump to the help Screen
function help()
{
	window.open("/static_help.html","help","fullscreen=yes,location=yes,scrollbars=yes,toolbar=yes,resizable=yes");	// open a help window
}

function launchhelp(mode) {
	help = window.open("/_help/quick.html?" + mode + ",0","quickhelp","alwaysRaised,scrollbars,resizable");
}

//** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **> Shunt the news articles down
function news_shunt()
{

	for(var article = 14;article >0;article--)									// shunt articles down
	{
		eval("document.mainform.f_paragraph" + (article+1) + ".value=document.mainform.f_paragraph" + article + ".value;");
		eval("document.mainform.f_date" + (article+1) + ".value=document.mainform.f_date" + article + ".value;");
		eval("document.mainform.f_author" + (article+1) + ".value=document.mainform.f_author" + article + ".value;");
		eval("document.mainform.f_subtitle" + (article+1) + ".value=document.mainform.f_subtitle" + article + ".value;");
		eval("document.mainform.f_image" + (article+1) + ".value=document.mainform.image" + article + ".value;");
		eval("document.mainform.image" + (article+1) + ".value=document.mainform.image" + article + ".value;");
		eval("document.mainform.f_caption" + (article+1) + ".value=document.mainform.f_caption" + article + ".value;");
		eval("document.srcimage" + (article+1) + ".src = document.srcimage" + article +".src;");							// swap images
		eval("document.mainform.f_image" + (article+1) + "_forceconstrain.value=document.mainform.f_image" + article + "_forceconstrain.value;");
		eval("document.mainform.f_image" + (article+1) + "_constrain.value=document.mainform.f_image" + article + "_constrain.value;");
	}

	document.mainform.f_paragraph1.value="";	// then clear article 1
	document.mainform.f_date1.value="";
	document.mainform.f_author1.value="";
	document.mainform.f_subtitle1.value="";
	document.mainform.f_image1.value="";
	document.mainform.image1.value="";
	document.mainform.f_caption1.value="";
	document.srcimage1.src="/images/fig.gif";
}

function file_shunt()
{

	for(var article = 14;article >0;article--)									// shunt articles down
	{
		eval("document.mainform.f_paragraph" + (article+1) + ".value=document.mainform.f_paragraph" + article + ".value;");
		eval("document.mainform.f_date" + (article+1) + ".value=document.mainform.f_date" + article + ".value;");
		eval("document.mainform.f_author" + (article+1) + ".value=document.mainform.f_author" + article + ".value;");
		eval("document.mainform.f_subtitle" + (article+1) + ".value=document.mainform.f_subtitle" + article + ".value;");
		eval("document.mainform.f_file" + (article+1) + ".value=document.mainform.f_file" + article + ".value;");
		eval("document.mainform.f_file" + (article+1) + "_h.value=document.mainform.f_file" + article + "_h.value;");
		eval("document.mainform.f_file" + (article+1) + "_v.value=document.mainform.f_file" + article + "_v.value;");
		eval("document.mainform.f_file" + (article+1) + "_embed.value=document.mainform.f_file" + article + "_embed.value;");
	}

	document.mainform.f_paragraph1.value="";	// then clear article 1
	document.mainform.f_date1.value="";
	document.mainform.f_author1.value="";
	document.mainform.f_subtitle1.value="";
	document.mainform.f_file1.value="";
	document.mainform.f_file1_h.value="";
	document.mainform.f_file1_v.value="";
	document.mainform.f_file1_embed.value="";
}





function calender_shunt()
{

for(var article = 2 ;article <13 ;article++)									// shunt articles up
	{
		eval("self.document.mainform.f_paragraph" + (article-1) + ".value=self.document.mainform.f_paragraph" + article + ".value;");
		eval("self.document.mainform.f_author" + (article-1) + ".value=self.document.mainform.f_author" + article + ".value;");
		eval("self.document.mainform.f_subtitle" + (article-1) + ".value=self.document.mainform.f_subtitle" + article + ".value;");
		eval("self.document.mainform.f_image" + (article-1) + ".value=self.document.mainform.f_image" + article + ".value;");
		eval("self.document.mainform.f_caption" + (article-1) + ".value=self.document.mainform.f_caption" + article + ".value;");
		
	}

self.document.mainform.f_paragraph12.value="";	// then clear article 12
self.document.mainform.f_author12.value="";
self.document.mainform.f_subtitle12.value="";
self.document.mainform.f_image12.value="";
self.document.mainform.f_caption12.value="";
}

function checklink(url) {
	if(url != "") {
		if(url.indexOf('@') != -1) {
			if(url.indexOf("mailto:") == -1) {
				url = "mailto:" + url;
			}
		} else {
			if(url.indexOf("http://") == -1) {
				url = "http://" + url;
			}
		}
		return url;
	} else {
		return "";
	}
}

function whosyourdaddy() {
	var daddy = self.parent.frames.length;
	if(daddy == 0) {
		loc=self.location.pathname;
		self.location = "http://www.millenniumschools.co.uk/index.html?" + loc;
	}
}

function shade(oldcolour) {
	refstr="0123456789ABCDEF";
	attrib = new Array();
	attrib[0] = oldcolour.slice(1,3);
	attrib[1] = oldcolour.slice(3,5);
	attrib[2] = oldcolour.slice(5,7);
	for(at = 0; at < 3; at++) {
		fv = attrib[at].slice(0,1);
		fv = fv.toUpperCase();
		var ps = refstr.indexOf(fv);
		if(ps > 7) {
			fv = refstr.slice(ps-1,ps);
		} else {
			fv = refstr.slice(ps+1,ps+2);
		}
		sv = attrib[at].slice(1);
		sv = sv.toUpperCase();
		var ps = refstr.indexOf(sv);
		if(ps > 7) {
			sv = refstr.slice(ps-1,ps);
		} else {
			sv = refstr.slice(ps+1,ps+2);
		}
		attrib[at] = fv + sv;
	}
	var newcolour = "#" + attrib[0] + attrib[1] + attrib[2];
	return newcolour;
}

function imageinfo(a,b,c,d,e,f) {
	var command = a + "," + b + "," + c + "," + d + "," + e + "," + f;
	c = (c-0) + 20;
	d = (d-0) + 100;
	var left = (800 - c)/2;
	var top = (600 - d)/2;
	alert("c:" + c + " d:" + d);
	window.open("/image_inspector.html?" + command,"imageinspector","WIDTH=" + c + ",HEIGHT=" + d + ",TOP=" + top +",LEFT=" + left + ",SCREENX=" + left + ",SCREENY=" + top,false);
}
