function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v3.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function tracker(trackerurl,trackersite,trackerpage,trackerdata){
    document.write("<img style='float: left; width: 1px; height: 1px;' src='" + trackerurl + "/site.asp?site=" + trackersite + "&amp;page=" + trackerpage + "&amp;data=" + trackerdata + "&amp;img=no&amp;ref="+escape(document.referrer)+"' alt='' />");
}

function expand (element1, element2) {
    
    if (document.getElementById(element2).value == 'HIDE advanced search')
    {
        document.getElementById(element1).style.display = "none";
        document.getElementById(element2).value = 'SHOW advanced search';
    }
    else
    {
        document.getElementById(element1).style.display = "block";
        document.getElementById(element2).value = 'HIDE advanced search';
    }
}

function articleadmin(action,ref,popup) {
	if (popup == 'Y')
		{window.open('articleadmin.asp?action='+action+'&reference='+ref,'adminwindow','width=870,height=550,left=20,top=10,resize=no,scrollbars=yes,toolbar=no');}
	else
		{location.href='articleadmin.asp?action='+action+'&reference='+ref;}
}

function viewarticle(ref) {
	window.location.href='http://notrenet.ndhs.org.uk/article.asp?reference=' + ref;
}

function articlepicture(picture,title) {
	window.open('articlepicture.asp?picture='+picture+'&desc='+title,'imagewindow','width=817,height=520,left=20,top=10,resizable=1,scrollbars=yes,toolbar=no');
}

function resetbasic() {
	document.searchform.type[0].selected = true;
	document.searchform.audience[0].selected = true;
	document.searchform.subject[0].selected = true;
	document.searchform.title.value = '';
	document.searchform.keywords.value = '';
	setcolours();
	return false;
}

function resetadv() {
	document.searchform.author.value = '';
	document.searchform.reference.value = '';
	document.searchform.publishdated[0].selected = true;
	document.searchform.publishdatem[0].selected = true;
	document.searchform.publishdatey[0].selected = true;
	document.searchform.publishdatexd[0].selected = true;
	document.searchform.publishdatexm[0].selected = true;
	document.searchform.publishdatexy[0].selected = true;
	document.searchform.expirydated[0].selected = true;
	document.searchform.expirydatem[0].selected = true;
	document.searchform.expirydatey[0].selected = true;
	document.searchform.expirydatexd[0].selected = true;
	document.searchform.expirydatexm[0].selected = true;
	document.searchform.expirydatexy[0].selected = true;
	document.searchform.searcharchive.checked = false;
	resetbasic();
	setcolours('on');
	return false;
}

function setcolours(advanced) {
	selcolour = "#e3e289";
	emptycolour = "#f1f1c5";
	if (document.searchform.keywords.value != '') 
		{document.searchform.keywords.style.backgroundColor=selcolour;}
	else
		{document.searchform.keywords.style.backgroundColor=emptycolour;}
	
	if (advanced == 'on')
	{
	    if (!document.searchform.type[0].selected) 
	        {document.searchform.type.style.backgroundColor=selcolour;}
	    else
		    {document.searchform.type.style.backgroundColor=emptycolour;}
	    if (!document.searchform.audience[0].selected) 
		    {document.searchform.audience.style.backgroundColor=selcolour;}
	    else
		    {document.searchform.audience.style.backgroundColor=emptycolour;}
	    if (!document.searchform.subject[0].selected) 
		    {document.searchform.subject.style.backgroundColor=selcolour;}
	    else
		    {document.searchform.subject.style.backgroundColor=emptycolour;}
	    if (document.searchform.title.value != '') 
		    {document.searchform.title.style.backgroundColor=selcolour;}
	    else
		{document.searchform.title.style.backgroundColor=emptycolour;}
		if (document.searchform.author.value != '') 
			{document.searchform.author.style.backgroundColor=selcolour;}
		else
			{document.searchform.author.style.backgroundColor=emptycolour;}
		if (document.searchform.reference.value != '')
			{document.searchform.reference.style.backgroundColor=selcolour;}
		else
			{document.searchform.reference.style.backgroundColor=emptycolour;}

		if (document.searchform.publishdated[0].selected && document.searchform.publishdatem[0].selected && document.searchform.publishdatey[0].selected) 
		{
			document.searchform.publishdated.style.backgroundColor=emptycolour;
			document.searchform.publishdatem.style.backgroundColor=emptycolour;
			document.searchform.publishdatey.style.backgroundColor=emptycolour;
		}
		else
		{
			document.searchform.publishdated.style.backgroundColor=selcolour;
			document.searchform.publishdatem.style.backgroundColor=selcolour;
			document.searchform.publishdatey.style.backgroundColor=selcolour;
		}

		if (document.searchform.publishdatexd[0].selected && document.searchform.publishdatexm[0].selected && document.searchform.publishdatexy[0].selected) 
		{
			document.searchform.publishdatexd.style.backgroundColor=emptycolour;
			document.searchform.publishdatexm.style.backgroundColor=emptycolour;
			document.searchform.publishdatexy.style.backgroundColor=emptycolour;
		}
		else
		{
			document.searchform.publishdatexd.style.backgroundColor=selcolour;
			document.searchform.publishdatexm.style.backgroundColor=selcolour;
			document.searchform.publishdatexy.style.backgroundColor=selcolour;
		}

		if (document.searchform.expirydated[0].selected && document.searchform.expirydatem[0].selected && document.searchform.expirydatey[0].selected) 
		{
			document.searchform.expirydated.style.backgroundColor=emptycolour;
			document.searchform.expirydatem.style.backgroundColor=emptycolour;
			document.searchform.expirydatey.style.backgroundColor=emptycolour;
		}
		else
		{
			document.searchform.expirydated.style.backgroundColor=selcolour;
			document.searchform.expirydatem.style.backgroundColor=selcolour;
			document.searchform.expirydatey.style.backgroundColor=selcolour;
		}

		if (document.searchform.expirydatexd[0].selected && document.searchform.expirydatexm[0].selected && document.searchform.expirydatexy[0].selected) 
		{
			document.searchform.expirydatexd.style.backgroundColor=emptycolour;
			document.searchform.expirydatexm.style.backgroundColor=emptycolour;
			document.searchform.expirydatexy.style.backgroundColor=emptycolour;
		}
		else
		{
			document.searchform.expirydatexd.style.backgroundColor=selcolour;
			document.searchform.expirydatexm.style.backgroundColor=selcolour;
			document.searchform.expirydatexy.style.backgroundColor=selcolour;
		}

		if (document.searchform.searcharchive.checked) 
			{document.searchform.searcharchive.style.backgroundColor=selcolour;}
		else
			{document.searchform.searcharchive.style.backgroundColor='';}
	}
}